简体   繁体   中英

Get Quill editor instance from HTML element

Assuming I created an editor instance for a certain element, eg via const editor = new Quill('#editor', {...some options});

Now, I would like to get this editor instance when only having the element available, eg something like const editor = Quill.existingEditorFromElement('#editor');

The reason is that I am building a component that can be plugged into existing websites that enhances their editors, and I need a way to get their editor instance.

This can be done by using Quill.find('#editor'); , see https://quilljs.com/docs/api/#find-experimental

According to Quill API Documentation you can get the editor instance by getting the DOM element by its ID (or classname or tagname...), and inserting it inside the find function.

Example:

var div = document.getElementById('editor');
var quill_instance = Quill.find(div);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM