1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 09:46:22 +00:00

Merge pull request #291 from kostaldavid8/image-drag-fix

Image drag fix
This commit is contained in:
SuenagaRyota
2017-02-18 21:06:16 +09:00
committed by GitHub

View File

@@ -168,13 +168,13 @@ export default class CodeEditor extends React.Component {
e.preventDefault()
let imagePath = e.dataTransfer.files[0].path
let filename = path.basename(imagePath)
let imageMd = `![${filename}](${imagePath})`
let imageMd = `![${encodeURI(filename)}](${encodeURI(imagePath)})`
this.insertImage(imageMd)
}
insertImage (imageMd) {
const textarea = this.editor.getInputField()
textarea.value = textarea.value.substr(0, textarea.selectionStart) + imageMd + textarea.value.substr(textarea.selectionEnd)
const cm = this.editor
cm.setValue(cm.getValue() + imageMd)
}
render () {