mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 17:56:25 +00:00
fix dropping image from Firefox on Linux
This commit is contained in:
@@ -304,15 +304,20 @@ function handleAttachmentDrop (codeEditor, storageKey, noteKey, dropEvent) {
|
||||
}
|
||||
}))
|
||||
} else {
|
||||
promise = Promise.all(Array.from(dropEvent.dataTransfer.items).map(item => {
|
||||
if (item.type === 'text/html') {
|
||||
const html = dropEvent.dataTransfer.getData('text/html')
|
||||
let imageURL = dropEvent.dataTransfer.getData('text/plain')
|
||||
|
||||
const match = /<img[^>]*[\s"']src="([^"]+)"/.exec(html)
|
||||
if (!imageURL) {
|
||||
const match = /<img[^>]*[\s"']src="([^"]+)"/.exec(dropEvent.dataTransfer.getData('text/html'))
|
||||
if (match) {
|
||||
const imageURL = match[1]
|
||||
imageURL = match[1]
|
||||
}
|
||||
}
|
||||
|
||||
return getImage(imageURL)
|
||||
if (!imageURL) {
|
||||
return
|
||||
}
|
||||
|
||||
promise = Promise.all([getImage(imageURL)
|
||||
.then(image => {
|
||||
const canvas = document.createElement('canvas')
|
||||
const context = canvas.getContext('2d')
|
||||
@@ -326,10 +331,7 @@ function handleAttachmentDrop (codeEditor, storageKey, noteKey, dropEvent) {
|
||||
fileName,
|
||||
title: imageURL,
|
||||
isImage: true
|
||||
}))
|
||||
}
|
||||
}
|
||||
}))
|
||||
}))])
|
||||
}
|
||||
|
||||
promise.then(files => {
|
||||
|
||||
Reference in New Issue
Block a user