Convert Quill Delta To HTML


Answer :

Not very elegant, but this is how I had to do it.



function quillGetHTML(inputDelta) {
var tempCont = document.createElement("div");
(new Quill(tempCont)).setContents(inputDelta);
return tempCont.getElementsByClassName("ql-editor")[0].innerHTML;
}


Obviously this needs quill.js.



I guess you want the HTML inside it. Its fairly simple.



quill.root.innerHTML


If I've understood you correctly, there's a quill thread of discussion here, with the key information you're after.



I've quoted what should be of most value to you below:




Quill has always used Deltas as a more consistent and easier to use (no parsing)
data structure. There's no reason for Quill to reimplement DOM APIs in
addition to this. quill.root.innerHTML or document.querySelector(".ql-editor").innerHTML works just fine (quill.container.firstChild.innerHTML is a bit more brittle as it depends on child ordering) and the previous getHTML implementation did little more than this.




Comments

Popular posts from this blog

530 Valid Hostname Is Expected When Setting Up IIS 10 For Multiple Sites

C Perror Example

Converting A String To Int In Groovy