Whitespace issue at the end of newly created paragraph node

Hello everyone! I seek your help on figuring out if the following behavior regarding whitespaces is expected and if anyone else has stumbled upon it.

I’m building a custom editor that contains multiple custom Plugins that manages their own state depending on the changes that occur in a Transaction, and tokenizing certain keywords that I’m interested. All is fine and works as intended, but I noticed some whitespaces characters disappearing when I have one at the end of a paragraph.

Let me explain in more detail. I have one custom Plugin that creates a new line Paragraph node when pressing enter, checks if the position is between 2 existing parenthesis of the same depth and moves the content between the parenthesis into the newly created Paragraph node using a Slice.

slice = view.state.doc.slice(startContext, endContext);

const newLine =  schema.nodes.paragraph.createAndFill(
		{
			nodeIndent: currentDepth
		},
		slice ? slice.content : undefined
	);

All works as expected, except the case when I have a whitespace before the endContext. When I log the textContent property of that slice, I see that I have the whitespace and also in the textContent property of the newly created Node, but in my HTML document, I don’t get the whitespace character.

What is the white-space CSS property set to, in your editor?

white-space is set to “normal”

You’ll want to load the CSS file that comes with prosemirror-view, to make sure the styles are as they should be.