mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 17:56:25 +00:00
Add dataApi.copyImage for copying image to boostnote storage on an image to boostnote storage on an image doropped into CodeEditor
This commit is contained in:
@@ -2,6 +2,7 @@ import React, { PropTypes } from 'react'
|
||||
import _ from 'lodash'
|
||||
import CodeMirror from 'codemirror'
|
||||
import path from 'path'
|
||||
import copyImage from 'browser/main/lib/dataApi/copyImage'
|
||||
|
||||
CodeMirror.modeURL = '../node_modules/codemirror/mode/%N/%N.js'
|
||||
|
||||
@@ -166,9 +167,13 @@ export default class CodeEditor extends React.Component {
|
||||
|
||||
handleDropImage (e) {
|
||||
e.preventDefault()
|
||||
const imagePath = e.dataTransfer.files[0].path
|
||||
const filename = path.basename(imagePath)
|
||||
const imageMd = `})`
|
||||
let imagePath = e.dataTransfer.files[0].path
|
||||
let filename = path.basename(imagePath)
|
||||
const cachedStorageList = JSON.parse(localStorage.getItem('storages'))
|
||||
const storagePath = _.find(cachedStorageList, {key: this.props.storageKey})
|
||||
|
||||
copyImage(imagePath, this.props.storageKey)
|
||||
const imageMd = `})`
|
||||
this.insertImage(imageMd)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user