Ok, node.mark
is a nice one that I hadn’t known so far, thanks!
My challenge is then more with recursively replacing node content in the document. I have now put together the following code, does that look like the way to go?
export default new Plugin({
props: {
transformPasted(slice) {
return new Slice(stripDiffFromFragment(slice.content), slice.openStart, slice.openEnd);
}
}
});
function stripDiffFromFragment(fragment: Fragment): Fragment {
const newNodes: Node[] = [];
fragment.forEach(node => newNodes.push(stripDiffFromNode(node)));
return Fragment.fromArray(newNodes);
}
function stripDiffFromNode(node: Node): Node {
const newAttrs = supportsDiff(node.type)
? {...node.attrs, deleted: false, inserted: false, modified: false}
: node.attrs;
const newMarks = node.marks.filter(isDiffMark);
return schema.node(node.type, newAttrs, stripDiffFromFragment(node.content), newMarks);
}
Thanks!