WYSIWYG Html output

My idea would be to export the document from Prosemirror as HTML with all styles and css classes. Having tried many approaches - for example DOMSerializer with schema and also JSON document export, I ended up grabbing the EditorViews dom property. Here all classes are included and outerHtml just needs to be a bit CSS corrected to show just the document. As I am using react components within prosemirror to scale images, the markers are sometime visible (depending on the cursor at snapwhot of EditorView.dom).

Somehow it seems to be a dirty way - but I see no other way… DOMSerializer exports contain no CSS classes and loose all styling - just like the JSON document.

Does anybody know a cleaner way to export styled HTML?

Thank You


DOMSerializer allows you to completely control what classes are applied via the node type’s toDOM functions. If they are missing styling that they have in the editor, you’re probably using node views in the editor and didn’t define complete toDOM functions.

Thanks @marijn