mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-08-06 13:38:49 +08:00
fix: improve drag position for node views
This commit is contained in:
parent
992986bc46
commit
5e5b8db6eb
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user