Convert Quill Delta to HTML

km6 picture km6 · Sep 15, 2016 · Viewed 39.3k times · Source

How do I convert Deltas to pure HTML? I'm using Quill as a rich text editor, but I'm not sure how I would display the existing Deltas in a HTML context. Creating multiple Quill instances wouldn't be reasonable, but I couldn't come up with anything better yet.

I did my research, and I didn't find any way to do this.

Answer

km6 picture km6 · Sep 17, 2016

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.