Continuing the discussion from Drag'n'Drop - a drag handle element:
I used MyNodeView
for code block
node. Everything works as expected, until I add a plugin which contains:
handleDrop: (view, event, slice) => {
const posAtCoords = view.posAtCoords({
left: event.clientX,
top: event.clientY,
})
if (!posAtCoords) return false
console.log(posAtCoords.pos)
//// this is problematic as the `pos` depends on how many nodeviews before
const node = view.state.doc.resolve(posAtCoords.pos)
......
}
Given a code block
node at the beginning of the editor, if you drag and drop some node before the code block
node, it prints 1 with MyNodeView
and 0 without MyNodeView
.
I am not sure if I am using the pos
wrong, but I want to get the right node where drop happens with/without MyNodeView
.