fix: improve drag position for node views

This commit is contained in:
Philipp Kühn 2021-04-08 23:53:47 +02:00
parent 992986bc46
commit 5e5b8db6eb

View File

@ -67,8 +67,13 @@ export class NodeView<Component, Editor extends CoreEditor = CoreEditor> impleme
return
}
const domBox = this.dom.getBoundingClientRect()
const handleBox = target.getBoundingClientRect()
const x = handleBox.x - domBox.x
const y = handleBox.y - domBox.y
// sometimes `event.target` is not the `dom` element
event.dataTransfer?.setDragImage(this.dom, 0, 0)
event.dataTransfer?.setDragImage(this.dom, x, y)
const selection = NodeSelection.create(view.state.doc, this.getPos())
const transaction = view.state.tr.setSelection(selection)