With this example (https://prosemirror.net/examples/upload/), If I attempt to drag and drop an image onto a drop cursor in the editor, and the editor content contains only nodes like block images without any text, then state.selection
consistently returns from:0
.
However, if there is text present in the editor, state.selection
consistently provides the position of the last text cursor, whereas what I had anticipated was the position of the drop cursor.
I attempted to understand why this was happening and noticed that when I dropped an image onto the drop cursor, the console.log(state.selection)
indicated that the selection was not a ‘drop cursor’ but rather a ‘node’.
_NodeSelection {$anchor: _ResolvedPos, $head: _ResolvedPos, ranges: Array(1), node: _Node}
...
[[Prototype]]: Selection
jsonID: "node"
...
So, I have two questions:
- Why is the selection not identified as a
dropcursor
likegapcursor
but as anode
? I expected it to be thedropcursor
. - How can I obtain the correct position of the drop cursor?