I used your suggestion and got something to work. I used the method of
Now, my code saves empty paragraphs without hard breaks inside, so now re-editing the same text does not change the text – that’s good!
But now I think I understand why the editor inserts hard breaks during edit mode. When I display empty paragraphs in html, the empty paragraphs are essentially invisible – no vertical space is added even if I have many of them. But when I edit that same text (using the basic schema), each of those empty paragraphs shows up as a new block. So now the issue is that the editor version of the text and the static html version of the text look different…
ProseMirror is a toolkit so I can change editor and output behavior, but it’s not clear what the behavior should be. I tried some raw html experiments with using empty div elements but they are also invisible when viewed in html. (I did like that empty div give me less vertical space so writers have more control over the vertical dimension.)
The issue seems to be the html representation for text that allows writers to insert multiple new lines. That html representation needs to display properly in html and edit property in the editor. I’m assuming this is an issue that you have run into and thought about already. Any tips or suggestions or words of advice? Is there a simple representation for this or is this is one area where WYSIWYG and html have an impedance mismatch and solving it is really messy… What about workarounds like not allowing empty new lines (maybe the writer needs to have at least a non-breaking space in each new line)? Just want to know if I’m on the right track and facing a genuine issue with the editor.
PS: As a newbie, I’m glad you gave me the general direction for serialization. It seems like others who read ProseMirror Guide and especially the “Serialization and Parsing” section could benefit from that advice. Thanks for your help and the great editor toolkit!