improve node view handling with inputs, fix #211
This commit is contained in:
@@ -88,11 +88,18 @@ export class NodeView<Component, Editor extends CoreEditor = CoreEditor> impleme
|
|||||||
const target = (event.target as HTMLElement)
|
const target = (event.target as HTMLElement)
|
||||||
const isInElement = this.dom.contains(target) && !this.contentDOM?.contains(target)
|
const isInElement = this.dom.contains(target) && !this.contentDOM?.contains(target)
|
||||||
|
|
||||||
// ignore all events from child nodes
|
// any event from child nodes should be handled by ProseMirror
|
||||||
if (!isInElement) {
|
if (!isInElement) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const isInput = ['INPUT', 'BUTTON', 'SELECT', 'TEXTAREA'].includes(target.tagName)
|
||||||
|
|
||||||
|
// any input event within node views should be ignored by ProseMirror
|
||||||
|
if (isInput) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
const { isEditable } = this.editor
|
const { isEditable } = this.editor
|
||||||
const { isDragging } = this
|
const { isDragging } = this
|
||||||
const isDraggable = !!this.node.type.spec.draggable
|
const isDraggable = !!this.node.type.spec.draggable
|
||||||
@@ -123,9 +130,14 @@ export class NodeView<Component, Editor extends CoreEditor = CoreEditor> impleme
|
|||||||
|
|
||||||
if (isValidDragHandle) {
|
if (isValidDragHandle) {
|
||||||
this.isDragging = true
|
this.isDragging = true
|
||||||
|
|
||||||
document.addEventListener('dragend', () => {
|
document.addEventListener('dragend', () => {
|
||||||
this.isDragging = false
|
this.isDragging = false
|
||||||
}, { once: true })
|
}, { once: true })
|
||||||
|
|
||||||
|
document.addEventListener('mouseup', () => {
|
||||||
|
this.isDragging = false
|
||||||
|
}, { once: true })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user