onContent option in serializeFragment in DOMSerializer

Hi @marijn , you have done some recent changes to the prosemirror-model previously there was an onContent option that we can pass to the serializeFragment function in DOMSerializer, I was using this function to insert a <br> tag in empty paragraph and heading node while getting the html string from the editor, is it possible to get this option back or if you can share some way to do the same?

onContent: (node, contentDOM, serializingOptions) => {
    domSerializer.serializeFragment(node.content, serializingOptions, contentDOM);

    if (shouldInsertHardBreak(node)) {
      contentDOM.appendChild(DOMSerializer.renderSpec(window.document, ['br']).dom);

This option was never documented, and as such not part of the public interface. Is it not possible to post-process the output of the serializer as an alternative to this?

We are generating html string everytime the doc changes, and the document could be large and modifying the string every time for every paragaph and heading tag when the doc changes could be an expensive and complex operation. It would be really helpful if you could add this option.

I doubt that. Run, say, dom.querySelectorAll("p:empty") (and a similar one for your heading nodes) and insert a <br> element in all the matches before getting the innerHTML.