简体   繁体   English

按需启用/禁用笔芯

[英]Enable / disable Quill on demand

I'm using quill to make myDiv editable like this: 我正在使用鹅毛笔使myDiv可编辑,如下所示:

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 (eg by pressing a button). 我还希望按需(例如,通过按下按钮)激活或不激活Quill(用户无法再编辑内容)。

Is there something like myQuill.disable() or myQuill.enable() ? 是否有类似myQuill.disable()myQuill.enable()

I didn't see a Quill command for that, but you could use this to disable it : 我没有看到一个Quill命令,但是您可以使用它来禁用它:

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

where DIV_ID is your element id chosen when initializing Quill. 其中DIV_ID是初始化Quill时选择的元素ID。

For all editors, use the following : 对于所有编辑器,请使用以下命令:

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

Change false to true to enable back. false更改为true以启用。

Both enable() and disable() exist in Quill 1.0 for this purpose. 为此,Quill 1.0中同时存在enable()disable() In Quill 0.20 they are under the editor instance variable so you can do myQuill.editor.enable() . 在Quill 0.20中,它们位于editor实例变量下,因此您可以执行myQuill.editor.enable()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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