mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-14 02:06:29 +00:00
Add image dropper
This commit is contained in:
@@ -163,6 +163,18 @@ export default class CodeEditor extends React.Component {
|
|||||||
this.editor.setCursor(cursor)
|
this.editor.setCursor(cursor)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleDrop (e) {
|
||||||
|
e.preventDefault()
|
||||||
|
let path = e.dataTransfer.files[0].path
|
||||||
|
let filename = path.match(".+/(.+?)\.[a-z]+([\?#;].*)?$")[1]
|
||||||
|
let imageMd = ""
|
||||||
|
this.insertImage(this.editor.getInputField(), imageMd)
|
||||||
|
}
|
||||||
|
|
||||||
|
insertImage (textarea, imageMd) {
|
||||||
|
textarea.value = textarea.value.substr(0, textarea.selectionStart) + imageMd + textarea.value.substr(textarea.selectionEnd)
|
||||||
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
let { className, fontFamily, fontSize } = this.props
|
let { className, fontFamily, fontSize } = this.props
|
||||||
fontFamily = _.isString(fontFamily) && fontFamily.length > 0
|
fontFamily = _.isString(fontFamily) && fontFamily.length > 0
|
||||||
@@ -180,6 +192,7 @@ export default class CodeEditor extends React.Component {
|
|||||||
fontFamily: fontFamily.join(', '),
|
fontFamily: fontFamily.join(', '),
|
||||||
fontSize: fontSize
|
fontSize: fontSize
|
||||||
}}
|
}}
|
||||||
|
onDrop={(e) => this.handleDrop(e)}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user