mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 17:56:25 +00:00
@@ -277,11 +277,16 @@ export default class CodeEditor extends React.Component {
|
|||||||
|
|
||||||
handleDropImage (e) {
|
handleDropImage (e) {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
const imagePath = e.dataTransfer.files[0].path
|
const ValidImageTypes = ['image/gif', 'image/jpeg', 'image/png']
|
||||||
const filename = path.basename(imagePath)
|
|
||||||
|
|
||||||
copyImage(imagePath, this.props.storageKey).then((imagePath) => {
|
const file = e.dataTransfer.files[0]
|
||||||
const imageMd = `})`
|
const filePath = file.path
|
||||||
|
const filename = path.basename(filePath)
|
||||||
|
const fileType = file['type']
|
||||||
|
|
||||||
|
copyImage(filePath, this.props.storageKey).then((imagePath) => {
|
||||||
|
var showPreview = ValidImageTypes.indexOf(fileType) > 0
|
||||||
|
const imageMd = `${showPreview ? '!' : ''}[${filename}](${path.join('/:storage', imagePath)})`
|
||||||
this.insertImageMd(imageMd)
|
this.insertImageMd(imageMd)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -395,6 +395,9 @@ export default class MarkdownPreview extends React.Component {
|
|||||||
|
|
||||||
_.forEach(this.refs.root.contentWindow.document.querySelectorAll('a'), (el) => {
|
_.forEach(this.refs.root.contentWindow.document.querySelectorAll('a'), (el) => {
|
||||||
this.fixDecodedURI(el)
|
this.fixDecodedURI(el)
|
||||||
|
el.href = this.markdown.normalizeLinkText(el.href)
|
||||||
|
if (!/\/:storage/.test(el.href)) return
|
||||||
|
el.href = `file:///${this.markdown.normalizeLinkText(path.join(storagePath, 'images', path.basename(el.href)))}`
|
||||||
el.addEventListener('click', this.anchorClickHandler)
|
el.addEventListener('click', this.anchorClickHandler)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user