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
path: root/src/nodes
diff options
context:
space:
mode:
authorJulien Veyssier <eneiluj@posteo.net>2022-04-19 12:31:25 +0300
committernextcloud-command <nextcloud-command@users.noreply.github.com>2022-04-19 13:21:23 +0300
commit927801ebe2e31d536a50b2d3fc434d051f72aa19 (patch)
tree5e019b6f589f73ddeb66c5389d8923b2f91cf147 /src/nodes
parent35a4fc292afc260e760c511bc0c121724803f932 (diff)
move drop event handling to the Image node, fix position of dropped image
Signed-off-by: Julien Veyssier <eneiluj@posteo.net> Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com>
Diffstat (limited to 'src/nodes')
-rw-r--r--src/nodes/Image.js12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/nodes/Image.js b/src/nodes/Image.js
index 0d92f2108..11a05532a 100644
--- a/src/nodes/Image.js
+++ b/src/nodes/Image.js
@@ -44,6 +44,18 @@ const Image = TiptapImage.extend({
return [
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
+ },
handlePaste: (view, event, slice) => {
// only prevent the paste if it contains files
if (event.clipboardData.files && event.clipboardData.files.length > 0) {