javascriptquill

Enable / disable Quill on demand


I'm using quill to make myDiv editable like this:

var myQuill = new Quill(myDiv, {
                modules: {
                    toolbar: {
                        container: myToolbar
                    }
                },
                styles: false,
                theme: 'snow'
            });

I also want Quill to become active or not active (the user cannot edit contents anymore) on demand (e.g. by pressing a button).

Is there something like myQuill.disable() or myQuill.enable()?


Solution

  • I didn't see a Quill command for that, but you could use this to disable it :

    $("#DIV_ID .ql-editor").attr('contenteditable', false);
    

    where DIV_ID is your element id chosen when initializing Quill.

    For all editors, use the following :

    $(".ql-editor").attr('contenteditable', false);
    

    Change false to true to enable back.