Skip to content

Commit 2b6e4e3

Browse files
fix: Prevent drag event from being ignored (#3677)
1 parent 33ef3f0 commit 2b6e4e3

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

packages/core/src/NodeView.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,12 @@ export class NodeView<
113113
return false
114114
}
115115

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

119120
// any input event within node views should be ignored by ProseMirror
120-
if (isInput && !isDropEvent) {
121+
if (isInput && !isDropEvent && !isDragEvent) {
121122
return true
122123
}
123124

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

134134
// ProseMirror tries to drag selectable nodes
135135
// even if `draggable` is set to `false`
@@ -159,6 +159,14 @@ export class NodeView<
159159
{ once: true },
160160
)
161161

162+
document.addEventListener(
163+
'drop',
164+
() => {
165+
this.isDragging = false
166+
},
167+
{ once: true },
168+
)
169+
162170
document.addEventListener(
163171
'mouseup',
164172
() => {

0 commit comments

Comments
 (0)