diff options
author | dan <dan.abramov@gmail.com> | 2024-06-27 18:36:06 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-27 18:36:06 +0100 |
commit | 58102377fd3c9142925a99546ca5efe8906fbdf4 (patch) | |
tree | 75db91c55eecff4b567883d9d02120cb230d8cf9 | |
parent | 49396451ec8c877aebd27299a98c1b9e5b1e6cd4 (diff) | |
download | voidsky-58102377fd3c9142925a99546ca5efe8906fbdf4.tar.zst |
Fix pasting images on web (#4670)
-rw-r--r-- | src/view/com/composer/text-input/TextInput.web.tsx | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/view/com/composer/text-input/TextInput.web.tsx b/src/view/com/composer/text-input/TextInput.web.tsx index a91524974..3c4aaf738 100644 --- a/src/view/com/composer/text-input/TextInput.web.tsx +++ b/src/view/com/composer/text-input/TextInput.web.tsx @@ -152,23 +152,22 @@ export const TextInput = React.forwardRef(function TextInputImpl( }, handlePaste: (view, event) => { const clipboardData = event.clipboardData + let preventDefault = false if (clipboardData) { if (clipboardData.types.includes('text/html')) { // Rich-text formatting is pasted, try retrieving plain text const text = clipboardData.getData('text/plain') - // `pasteText` will invoke this handler again, but `clipboardData` will be null. view.pasteText(text) - + preventDefault = true + } + getImageFromUri(clipboardData.items, (uri: string) => { + textInputWebEmitter.emit('photo-pasted', uri) + }) + if (preventDefault) { // Return `true` to prevent ProseMirror's default paste behavior. return true - } else { - // Otherwise, try retrieving images from the clipboard - - getImageFromUri(clipboardData.items, (uri: string) => { - textInputWebEmitter.emit('photo-pasted', uri) - }) } } }, |