mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-08-06 13:38:49 +08:00
improve node view handling with inputs, fix #211
This commit is contained in:
parent
923775ae39
commit
1a74bbb0fb
@ -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 })
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user