Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Draggable nodes should respect drag handles #3677

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions packages/core/src/NodeView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,12 @@ export class NodeView<
return false
}

const isDragEvent = event.type.startsWith('drag')
const isDropEvent = event.type === 'drop'
const isInput = ['INPUT', 'BUTTON', 'SELECT', 'TEXTAREA'].includes(target.tagName) || target.isContentEditable

// any input event within node views should be ignored by ProseMirror
if (isInput && !isDropEvent) {
if (isInput && !isDropEvent && !isDragEvent) {
return true
}

Expand All @@ -129,7 +130,6 @@ export class NodeView<
const isPasteEvent = event.type === 'paste'
const isCutEvent = event.type === 'cut'
const isClickEvent = event.type === 'mousedown'
const isDragEvent = event.type.startsWith('drag')

// ProseMirror tries to drag selectable nodes
// even if `draggable` is set to `false`
Expand Down Expand Up @@ -159,6 +159,14 @@ export class NodeView<
{ once: true },
)

document.addEventListener(
'drop',
() => {
this.isDragging = false
},
{ once: true },
)

document.addEventListener(
'mouseup',
() => {
Expand Down