diff options
author | Julien Veyssier <eneiluj@posteo.net> | 2022-04-25 18:08:04 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-25 18:08:04 +0300 |
commit | d90332556192e36adc70bb4175b0384f52da4274 (patch) | |
tree | ac7e6f56b4cd15812ce8541c213b241f4ea3638b /src/nodes/Image.js | |
parent | 8069a4071f05a52df7c54eee058c3f73158b74d5 (diff) | |
parent | 82be39881ecc25dbf98992dc713e5b617f000fee (diff) |
Merge pull request #2332 from nextcloud/backport/2329/stable24v24.0.0rc2
[stable24] Fix drag&drop of non-image objects
Diffstat (limited to 'src/nodes/Image.js')
-rw-r--r-- | src/nodes/Image.js | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/src/nodes/Image.js b/src/nodes/Image.js index 11a05532a..6a1a250cf 100644 --- a/src/nodes/Image.js +++ b/src/nodes/Image.js @@ -45,19 +45,22 @@ const Image = TiptapImage.extend({ new Plugin({ props: { handleDrop: (view, event, slice) => { - const coordinates = view.posAtCoords({ left: event.clientX, top: event.clientY }) - const customEvent = new CustomEvent('image-drop', { - bubbles: true, - detail: { - files: event.dataTransfer.files, - position: coordinates.pos, - }, - }) - event.target.dispatchEvent(customEvent) - return true + // only catch the drop if it contains files + if (event.dataTransfer.files && event.dataTransfer.files.length > 0) { + const coordinates = view.posAtCoords({ left: event.clientX, top: event.clientY }) + const customEvent = new CustomEvent('image-drop', { + bubbles: true, + detail: { + files: event.dataTransfer.files, + position: coordinates.pos, + }, + }) + event.target.dispatchEvent(customEvent) + return true + } }, handlePaste: (view, event, slice) => { - // only prevent the paste if it contains files + // only catch the paste if it contains files if (event.clipboardData.files && event.clipboardData.files.length > 0) { // let the editor wrapper catch this custom event const customEvent = new CustomEvent('image-paste', { |