Hi there,
is there a way to access the quill instance after having called the constructor?
I basically instantiate the editor in a main JS file with a shared set of configurations. I would like to access to the instance in another called JS file to grab the content.
I tried to look at the source code but didn't see anything that could make that possible.
I'll mark this as a feature request.
If you need this functionality and are okay with a short term solution, Quill stores its instances in a static array Quill.editors. If you have more than one editor on the page, you can check the instance's id (Quill.editors[0].options.id) and compare it to the dom id. I will likely be removing this in 1.0.
@ouhman if your using jQuery you could just attach the editor to the data for that element. Makes it easy to retrieve it. If your not using jQuery you could still store the instance on the element's properties itself.
var $div = $('<div id="test">');
var editor = new Quill($div[0]);
$div.data('quill', $editor);
// In your other js file:
var editor = $('#test').data('quill');
editor.getHTML();
I decided against adding this API to 1.0 as it's already possible as @garygreen pointed out and a separate storage structure would introduce memory leaks if not nontrivially managed.
Most helpful comment
@ouhman if your using jQuery you could just attach the editor to the data for that element. Makes it easy to retrieve it. If your not using jQuery you could still store the instance on the element's properties itself.