Hello, I would like to prevent pasting a specific node type. The following code works for children at the root of the pasted slice’s content:
handlePaste(view, event, slice) {
let filteredContent = []
slice.content.forEach((node) => {
if (node.type.name !== "node_type") {
filteredContent.push(node)
}
})
// and then...
view.dispatch(
view.state.tr.replaceSelection(
new Slice(
Fragment.fromArray(filteredContent),
slice.openStart,
slice.openEnd
)
)
)
}
But this doesn’t work if this node is nested inside another node (e.g. a blockquote or a bullet list). I guess I should make a recursive function, but I believe I cannot directly edit a Node
's content?
Thanks in advance for your help!