Skip to content

Commit

Permalink
Fix drag behavior to ignore internal drags but allow dragging the who…
Browse files Browse the repository at this point in the history
…le element when `draggable:true`
  • Loading branch information
salmenf committed Sep 1, 2024
1 parent 86b1596 commit 2d3ab4a
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions @webwriter/core/view/editor/nodeviews.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,14 @@ export class WidgetView implements NodeView {
dom.addEventListener("keydown", e => this.emitWidgetInteract(e), {passive: true})
dom.addEventListener("click", e => this.emitWidgetInteract(e))
dom.addEventListener("touchstart", e => this.emitWidgetInteract(e), {passive: true})
if(!this.node.type.spec.draggable) {
dom.addEventListener("dragstart", e => e.preventDefault())
}
dom.addEventListener("dragstart", e => {
if(e.composedPath()[0] !== this.dom) {
e.stopPropagation()
}
else if(!this.node.type.spec.draggable) {
e.preventDefault()
}
})
// dom.addEventListener("selectstart", e => e.preventDefault())
}
return dom
Expand Down

0 comments on commit 2d3ab4a

Please sign in to comment.