Drag and drop drop location #4512
TheEponymousBob
started this conversation in
General
Replies: 1 comment
-
In case anyone else finds themselves needing this, there are a couple of nonstandard, browser-dependent ways to get this. Some browsers (not Firefox) offer Document.caretRangeFromPoint(), Firefox offers DragEvent.rangeParent/rangeOffset. I was able to use these in conjunction with Quill.find() and getIndex() to determine the drop location in Chrome/Edge/FF. Not sure about Safari (I can't currently test this), but it looks like it defines Document.caretRangeFromPoint(). Looks like there is also a Document.caretPositionFromPoint() that's not flagged as non-standard, but is definitely unsupported in Safari. Take your pick. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
I'm trying to implement some drag and drop functionality in a Quill editor. I can see when I drag, say, a hyperlink over the editor that a drop-cursor appears at the nearest drop location within the text. But I haven't been able to find any way to get the screen coordinates of this cursor or relate that to a logical position within the document.
I can get the screen coordinates of the mouse cursor at drop, but that doesn't always match the drop-cursor location:
Is this something that anyone else has tried and/or succeeded at?
Beta Was this translation helpful? Give feedback.
All reactions