Load content from Html
Hi,
Congrats for this nice tool. I'm trying it to see if it can replace an old Wysiwyg editor in a CMS.
The thing is at this time, contents are store in the database as HTML.
In the editor description you say "It is built on top of an internal model for an article that clients can translate to and from JSON and HTML".
But I was not able to find a way to load HTML content. Is this option already available ? Or can you advice a way to do such a thing ?
Thanks for your answer.
Regards.
Unfortunately there isn't a ready API interface to do this. However, a lot of the work is already done in our handling of pasting rich content where we parse the pasted HTML content and convert it into our JSON model preserving any inline styles and supported elements (h1,h2,h3, p, UL, LI, images...). However the implementation is not exposed to be used as a load function thought it shouldn't be too hard to refactor it a bit to use it like that.
The implementation is not complete (videos/embeds would be discarded from pasting at this current moment).
If you want to experiment, you can try putting your legacy HTML content into a tempEl.innerHTML and then call editor.processPastedContent(tempEl) which would return the operations needed to create the JSON model - feel free to refactor the code a bit and send a PR would love to take a look!
Hi mkhatib,
I've been playing with copy/paste and it works fine. I'll try the method you suggest and see what happens. Not sure to be able to write a nice enough js code to send a PR but I'll let you know
Thanks for your answer.