How to set content for quill editor?

Viewed 6745

I am trying to set content like this:

  quill.setContents("<div class='r'>some text</div> ");

But it does not work. Please help.

2 Answers

assigning it to the innerHTML usually works. try this quill.root.innerHTML = "<div class='r'>Some text</div>";

Using setText you can set HTML data

var quill = new Quill(".editor", {
  modules: {
    toolbar: toolbarOptions
  },
  theme: "snow"
});

quill.setText("<div class='r'>some text</div>");

Read more from quilljs document

Related