A document node that only accepts inline elements (no paragraphs)
Hard breaks (i.e., <br>), and Enter is tweaked to insert line breaks
And text nodes, of course
The idea here is to have plain-text editor augmented with extensions such as mentions (which are also inline elements).
However, I’m having an issue when I paste HTML content (for instance, copying code from VS Code and pasting into a ProseMirror editor). The content is pasted succesfully, but line breaks are ignored and the text is pasted into a single line.
What’s the best way to work around this? What’s the best event handler for this? Would love some pointers in the right direction, as I’m a bit clueless.
I’m guessing the pasted HTML contains either newlines or block nodes wrapping the text, instead of <br> nodes? You could try using transformPastedHTML to pre-process it into something your scheme’s DOM parser can handle.
It’s still not finished, because it’s stripping spaces (imagine indented code), which I don’t want. Will need to look further into this tomorrow. But I’m open to ideas/improvements on this
@marijn With the solution above, I wasn’t able to preserve spaces from pasted text for some reason (I have initialized the editor with preserveWhitespace: true), so I had to find a different solution.