1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 17:56:25 +00:00

Fixed image not displaying after paste

This commit is contained in:
Hung Nguyen
2018-04-17 20:47:13 +07:00
parent f4024f4683
commit 2994420160

View File

@@ -331,9 +331,14 @@ export default class CodeEditor extends React.Component {
const imageDir = path.join(storagePath, 'images') const imageDir = path.join(storagePath, 'images')
if (!fs.existsSync(imageDir)) fs.mkdirSync(imageDir) if (!fs.existsSync(imageDir)) fs.mkdirSync(imageDir)
const imagePath = path.join(imageDir, `${imageName}.png`) const imagePath = path.join(imageDir, `${imageName}.png`)
fs.writeFile(imagePath, binaryData, 'binary') fs.writeFile(imagePath, binaryData, 'binary', (error) => {
const imageMd = `![${imageName}](${path.join('/:storage', `${imageName}.png`)})` if (error) {
this.insertImageMd(imageMd) throw error
} else {
const imageMd = `![${imageName}](${path.join('/:storage', `${imageName}.png`)})`
this.insertImageMd(imageMd)
}
})
} }
} else if (this.props.fetchUrlTitle && isURL(pastedTxt) && !isInLinkTag(editor)) { } else if (this.props.fetchUrlTitle && isURL(pastedTxt) && !isInLinkTag(editor)) {
this.handlePasteUrl(e, editor, pastedTxt) this.handlePasteUrl(e, editor, pastedTxt)