Thanks. I took some inspiration from this post and came up with this:
transformPasted(slice) {
const newNodes = [];
slice.content.forEach((node, index) => {
if (index !== 0 && node.type.name === 'doc') {
node.content.content[0].text = ' ' + node.content.content[0].text;
}
newNodes.push(node);
});
return new Slice(Fragment.fromArray(newNodes), slice.openStart, slice.openEnd);
},
I discoverd that when multiparagraphed html/text is pasted into an editor with a schema that has only 1 node-type (‘doc’ with content ‘text*’), all the pasted nodes have the name ‘doc’. When I paste in an editor with paragraph support, all pasted nodes are recognised as ‘paragraph’. As I use both types in my application, I conditionally check the node name and only add a space before all but the first one.
Is this the right way to handle this? It does work, but I don’t know what else it could possibly break.