New lines change when pasting and copying

ProseMirror seems to affect new lines when pasting in and when copying out.

Sample text:

a
b

c
d

If I copy the text above from a plaintext editor, and paste it into ProseMirror (e.g. the instance on prosemirror.net) it will remove the double new line (in the middle).

If I then copy the text, and paste it back in the plaintext editor, it will add a double new line after each line, like the following:

a

b

c

d

If I copy the text from a rich text editor, then it will add a new line to the double new line (i.e., so it becomes three new lines in a row). Copying from ProseMirror into a rich text editor seems to treat new lines properly, as expected.

ProseMirror does not work with ‘newlines’—its document model uses paragraph (or other textblock) containers. If you’re copying plain text, it won’t create empty paragraphs for blank lines.

Shouldn’t ProseMirror detect that plain text is coming in, and replace new lines with paragraphs as expected? I’ve tested with a few other popular editors and that seems to be the common behavior.

Also, an issue exists when copying from a rich text editor, as noted above.

3 Likes

should be:

<p>
a<br/>
b
</p>

<p>
c<br/>
d</p>