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

SqweeeRyan picture SqweeeRyan  路  29Comments

guoyangqin picture guoyangqin  路  47Comments

saw picture saw  路  34Comments

sachinrekhi picture sachinrekhi  路  49Comments

che3vinci picture che3vinci  路  39Comments