Render doc.content to html

Hi, I’m trying to render the content of a doc.content object to html.

I use “prosemirror-schema-basic” as my schema and I have tried the toDOM() function but I get an error (“toDOM is not a function”).

I also found this post: Documentation: How to serialize / unserialize content to ProseMirror instance - #2 by rsaccon

But as a beginner I don’t understand the version differences they’re talking about in the post.

What is the easiest way to render my object to html?

Would be happy for any help! :slight_smile:

DOMSerializer.fromSchema(yourSchema).serializeFragment(doc.content) will give you a DOM tree. You can use innerHTML on that to get an HTML string.

1 Like

Thanks a lot for the quick reply! Really appreciate it :slight_smile: