add option to get content as JSON
hi, thanks for this great editor!
if we can get a JSON export from editor, we can use it on other platforms that do not support html, like React Native for example.
something like:
editor.getJson()
or similar.
Can you show an example of the output?
Can you show an example of the output?
Sure,
A really basic example:
[ { "tag":"p", "attributes":[ { "style":[ { //CameCase style like React style "fontSize":10, "color":" red" } ] } ], "children":[ { "type":"text", "value":"Hello world!" }, ...rest ] } ]
I think it's pretty easy and straightforward to implement.
It's my be something like a virtual DOM.
We can define methods like this:
editor.getContents() ==> output HTML string default
editor.getContents({output: "JSON"}) ==> JSON output
and for settings data:
editor.setContents(data) ===> data could be JSON | String
The overall process could be like this:
editor -> HTML string -> JSON
JSON -> HTML string -> editor
This is an example and could be tuned.