Adding spaces between pasted paragraphs in text-only schema

I have a ‘single line’ text-only schema:

	nodes: {
		doc: { content: 'text*' },
		text: {},

When I paste some html or any text with multiple paragraphs in this editor, like this text: image

This concatenates the paragraphs without any sort of spacing:

(Screenshot has the editor - state as JSON - plain text)

When I use the basic schema, that has paragraph support, the result is more natural:

How can I change this paste-behaviour? I have tried using transformPastedHTML, but I have no idea how to reliably detect where to add a space in the pasted HTML.


transformPastedHTML seems like a reasonable place to do this, or maybe transformPasted. Adding spaces at the start of every block element that isn’t the first would possibly be a good approach.

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 && === 'doc') {
			node.content.content[0].text = ' ' + node.content.content[0].text;

	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.