How to read in existing data into quill.js?

Member

by adan , in category: Javascript , a year ago

How to read in existing data into quill.js?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by cali_green , a year ago

@adan 

To read in existing data into quill.js, you can follow these steps:

  1. Initialize Quill.js with an empty editor instance:
1
2
3
var quill = new Quill('#editor', {
  theme: 'snow'
});


  1. Load the existing data (HTML or plain text) into the Quill editor:
1
2
var existingData = "<p>This is some existing data</p>";
quill.root.innerHTML = existingData;


  1. Alternatively, you can also use Quill's built-in setContents method to load the existing data as Delta object:
1
2
3
4
5
6
7
var existingDelta = {
  ops: [
    { insert: 'This is some existing data
' }
  ]
};
quill.setContents(existingDelta);


By following these steps, you can easily read in existing data into Quill.js and display it within the editor.

Related Threads:

How to modify existing xml data with powershell?
How to add new object to existing data in mongo?
How to read data from csv file in tensorflow?
How does d3.svg.diagonal read data?
How to read json data in laravel controller?
How to read json data in laravel controller?