improve node view handling with inputs, fix #211

This commit is contained in:
Philipp Kühn 2021-03-18 13:54:48 +01:00
parent 923775ae39
commit 1a74bbb0fb

View File

@ -88,11 +88,18 @@ export class NodeView<Component, Editor extends CoreEditor = CoreEditor> impleme
const target = (event.target as HTMLElement)
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) {
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 { isDragging } = this
const isDraggable = !!this.node.type.spec.draggable
@ -123,9 +130,14 @@ export class NodeView<Component, Editor extends CoreEditor = CoreEditor> impleme
if (isValidDragHandle) {
this.isDragging = true
document.addEventListener('dragend', () => {
this.isDragging = false
}, { once: true })
document.addEventListener('mouseup', () => {
this.isDragging = false
}, { once: true })
}
}