fix(editor): don't create empty "blob" files when pasting images
continuous-integration/drone/push Build is passing Details

This commit is contained in:
kolaente 2023-11-20 12:35:19 +01:00
parent 23d670525d
commit debae2326e
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
1 changed files with 9 additions and 5 deletions

View File

@ -507,12 +507,16 @@ onBeforeUnmount(() => {
})
function handleImagePaste(event) {
if (event?.clipboardData?.items?.length === 0) {
return
}
event.preventDefault()
event?.clipboardData?.items?.forEach(i => {
if (i.kind === 'file' && i.type.startsWith('image/')) {
uploadAndInsertFiles([i.getAsFile()])
}
})
const image = event.clipboardData.items[0]
if (image.kind === 'file' && image.type.startsWith('image/')) {
uploadAndInsertFiles([image.getAsFile()])
}
}
// See https://github.com/github/hotkey/discussions/85#discussioncomment-5214660