How to get HTML that is fully equal to dom strucutre in editor?

I used to use DOMSerializer to get HTML that generated by prosemirror. But I found there’s some problems:

  1. If dom is rendered by nodeView, the generated HTML will take value in toDOM which may have difference with dom generated in nodeView.
  2. Sometimes there’re decorations in dom. Which is very common if we want to add highlight for codeblock using shiki or prism. DOMSerializer can’t keep the dom structure with decorations.

So, let’s say I’m using prosemirror as an blog editor. I want to save HTML that can be used to render blogs for users. What’s the recommand way to do this?

You could create an editor and take its innerHTML. Beyond than that, this isn’t something the editor provides.

1 Like