From 27a98e0641ae638b1ff2aced779198feb7658813 Mon Sep 17 00:00:00 2001 From: Alexander Onnikov Date: Mon, 27 May 2024 14:25:23 +0700 Subject: [PATCH] UBERF-7065 Fix file and image upload extensions (#5668) Signed-off-by: Alexander Onnikov --- .../src/components/extension/fileUploadExt.ts | 9 ++++++--- .../src/components/extension/imageUploadExt.ts | 9 ++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/packages/text-editor/src/components/extension/fileUploadExt.ts b/packages/text-editor/src/components/extension/fileUploadExt.ts index b7e0a5576f..6c4030a780 100644 --- a/packages/text-editor/src/components/extension/fileUploadExt.ts +++ b/packages/text-editor/src/components/extension/fileUploadExt.ts @@ -92,11 +92,14 @@ export const FileUploadExtension = Extension.create({ } }, handleDrop (view, event) { - event.preventDefault() - event.stopPropagation() const dataTransfer = event.dataTransfer if (dataTransfer !== null) { - return handleDrop(view, view.posAtCoords({ left: event.x, top: event.y }), dataTransfer) + const res = handleDrop(view, view.posAtCoords({ left: event.x, top: event.y }), dataTransfer) + if (res === true) { + event.preventDefault() + event.stopPropagation() + } + return res } } } diff --git a/packages/text-editor/src/components/extension/imageUploadExt.ts b/packages/text-editor/src/components/extension/imageUploadExt.ts index bee4b3963b..852346e22c 100644 --- a/packages/text-editor/src/components/extension/imageUploadExt.ts +++ b/packages/text-editor/src/components/extension/imageUploadExt.ts @@ -118,11 +118,14 @@ export const ImageUploadExtension = Extension.create({ } }, handleDrop (view, event) { - event.preventDefault() - event.stopPropagation() const dataTransfer = event.dataTransfer if (dataTransfer !== null) { - return handleDrop(view, view.posAtCoords({ left: event.x, top: event.y }), dataTransfer) + const res = handleDrop(view, view.posAtCoords({ left: event.x, top: event.y }), dataTransfer) + if (res === true) { + event.preventDefault() + event.stopPropagation() + } + return res } } }