Quill: Restore getHTML for 1.0

Created on 26 May 2016  路  6Comments  路  Source: quilljs/quill

It'd be nice if the getHTML method was returned for version 1.0. Yes, as the migration guide says, it's possible to use native DOM methods to get the HTML content, but it's not as nice doing it that way.

Best case scenario, the 1.0 equivalent to editor.getHTML() seems to be:

var quill = new Quill(container, options);

var html = container.querySelector(".ql-editor").innerHTML;

That's not terrible, per se, but:

  1. It's not obvious, it's something that needs to be found in the documentation or through experimentation.
  2. It references classes added by the quill library, which is something that I could mistype or could be a breaking change down the road.
  3. It relies on having a way to reference the container element. If I want to get the HTML from a part of the code other than the code that initializes quill, I need to pass the container node (or a CSS selector or something), instead of just passing the quill instance around.

I'm absolutely nitpicking, but it's more annoying than simply being able to do quill.getHTML(). Plus, it'd simply be one less breaking change for people migrating from <1.0 .

All 6 comments

Removal of the method was motivated by the pit of success. Most people desiring direct interaction with HTML in Quill have wrong expectations and do not appreciate the ambiguity and complexity of HTML, especially between browsers. Those that do are very well aware of APIs available through the DOM.

getHTML is not coming back.

Just a thought - if it's been removed, would you mind removing it from the API documentation? It's quite frustrating when learning a library for the first time. http://quilljs.com/docs/api/#quillprototypegethtml

@ChuckkNorris It is removed in the beta docs.

Quill is adding this junk to the innerHTML

<div class="ql-editor ql-blank" contenteditable="true"><p><br></p></div><div class="ql-clipboard" contenteditable="true" tabindex="-1"></div><div class="ql-tooltip ql-hidden"><a class="ql-preview" target="_blank" href="about:blank"></a><input type="text" data-formula="e=mc^2" data-link="quilljs.com" data-video="Embed URL"><a class="ql-action"></a><a class="ql-remove"></a></div>

Without an API method I don't know how we're expected to get the HTML. And without the HTML... what good is Quill? Honest question. I thought Quill was supposed to be a WYSIWYG editor that would allow us to render the output outside the editor.

@mnpenner You're selecting the wrong container. ql-editor's innerHTML only has <p><br></p>.

Dope :disappointed: Thanks @jhchen. I thought it was the element I initialized it on.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

visore picture visore  路  3Comments

splacentino picture splacentino  路  3Comments

markstewie picture markstewie  路  3Comments

Kivylius picture Kivylius  路  3Comments

DaniilVeriga picture DaniilVeriga  路  3Comments