1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-22 06:01:45 +00:00

Merge pull request #1824 from ZeroX-DG/fix-paste-image

Fixed image not displaying after paste
This commit is contained in:
Kazz Yokomizo
2018-04-26 22:39:03 +09:00
committed by GitHub
2 changed files with 13 additions and 4 deletions

View File

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