feat: add deleteNode method to node views

This commit is contained in:
Philipp Kühn
2021-05-19 00:01:49 +02:00
parent 0f299d228e
commit fcee5f82c6
7 changed files with 24 additions and 0 deletions

View File

@@ -238,4 +238,10 @@ export class NodeView<Component, Editor extends CoreEditor = CoreEditor> impleme
this.editor.view.dispatch(transaction)
}
deleteNode(): void {
const from = this.getPos()
const to = from + this.node.nodeSize
this.editor.commands.deleteRange({ from, to })
}
}

View File

@@ -142,6 +142,7 @@ export type NodeViewProps = {
extension: Node,
getPos: () => number,
updateAttributes: (attributes: Record<string, any>) => void,
deleteNode: () => void,
}
export type NodeViewRendererProps = {