Hi, I am looking for an example of an alternative to the previous get/set content methods that were in prior to 0.8 release.
The document is in state.doc
in 0.11.0. To set the document (which you usually shouldn’t do – if you can transform it, do that), create a new state with your new document.
I see, is there an example of transforming the documents state into something more suitable for storing in a database for a CMS like WordPress.
Maybe its toJSON
method?
We use toJson for storage (with postgres JSONB) and chose to go with whatever Prosemirror produces. I strongly advise against any lossy format. We have made the mistake and it burns badly.
Hi after some more playing around with Prose, I am saving the content of the editor as JSON, but then when I want to use it on the front end in a blog for example. I need to convert that JSON string back to HTML. What would be the best way to do that.
I could make a PHP parser and loop through the content and convert it to standard HTML. But I would like to know if there is already a method to do this in Prose itself.
Thanks all.
You can parse it as a ProseMirror Node
again, and then run that through a DOMSerializer
.