Quill: How to clear the contents in the editor?

Created on 14 Nov 2017  路  6Comments  路  Source: quilljs/quill

I need a way to clear the contents in the editor on the press of a button.

What is the clean way of doing this ??

screenshot from 2017-11-14 14-22-06

Most helpful comment

You can also setContents([]) and setText('') which will clear the text. Internally Quill's data model requires at least \n so this will be added for you.

All 6 comments

Thanks a lot @benbro ,
Was expecting a much clear way todo

You can also setContents([]) and setText('') which will clear the text. Internally Quill's data model requires at least \n so this will be added for you.

You can use DOM to clear the Editor
var element = document.getElementsByClassName("ql-editor");
element[0].innerHTML = "";

AbdullahElamir thank you. This works

Hello
Delete with api
quill.deleteText(0,quill.getLength());

Was this page helpful?
0 / 5 - 0 ratings

Related issues

aletorrado picture aletorrado  路  3Comments

GildedHonour picture GildedHonour  路  3Comments

DaniilVeriga picture DaniilVeriga  路  3Comments

CHR15- picture CHR15-  路  3Comments

sferoze picture sferoze  路  3Comments