Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/text.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/nodes/Image.js')
-rw-r--r--src/nodes/Image.js25
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', {