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

Ctrl+V can paste an image

This commit is contained in:
Baptiste Augrain
2018-12-24 09:50:14 +01:00
parent 7a3cab8947
commit 073a5d4d68

View File

@@ -749,7 +749,13 @@ export default class CodeEditor extends React.Component {
this.handlePasteText(editor, pastedTxt) this.handlePasteText(editor, pastedTxt)
} else if (fetchUrlTitle && isURL(pastedTxt) && !isInLinkTag(editor)) { } else if (fetchUrlTitle && isURL(pastedTxt) && !isInLinkTag(editor)) {
this.handlePasteUrl(editor, pastedTxt) this.handlePasteUrl(editor, pastedTxt)
} else if (enableSmartPaste || forceSmartPaste) { } else if (attachmentManagement.isAttachmentLink(pastedTxt)) {
attachmentManagement
.handleAttachmentLinkPaste(storageKey, noteKey, pastedTxt)
.then(modifiedText => {
this.editor.replaceSelection(modifiedText)
})
} else {
const image = clipboard.readImage() const image = clipboard.readImage()
if (!image.isEmpty()) { if (!image.isEmpty()) {
attachmentManagement.handlePastNativeImage( attachmentManagement.handlePastNativeImage(
@@ -758,22 +764,16 @@ export default class CodeEditor extends React.Component {
noteKey, noteKey,
image image
) )
} else { } else if (enableSmartPaste || forceSmartPaste) {
const pastedHtml = clipboard.readHTML() const pastedHtml = clipboard.readHTML()
if (pastedHtml.length > 0) { if (pastedHtml.length > 0) {
this.handlePasteHtml(editor, pastedHtml) this.handlePasteHtml(editor, pastedHtml)
} else { } else {
this.handlePasteText(editor, pastedTxt) this.handlePasteText(editor, pastedTxt)
} }
} else {
this.handlePasteText(editor, pastedTxt)
} }
} else if (attachmentManagement.isAttachmentLink(pastedTxt)) {
attachmentManagement
.handleAttachmentLinkPaste(storageKey, noteKey, pastedTxt)
.then(modifiedText => {
this.editor.replaceSelection(modifiedText)
})
} else {
this.handlePasteText(editor, pastedTxt)
} }
} }