Share Quill toolbar across multiple editors

不打扰是莪最后的温柔 提交于 2019-12-23 08:03:28

问题


With the great Quill rich text editor for Javascript I'm trying to make two or more editors share the same toolbar.

I suppose (from documentation) that this is not possible right away at the moment, so I'm trying to "simulate" this by adding the toolbar module through API on the editor that has been clicked as the latter:

// this uses jQuery
$editorTag.click(function(e){
    var tag = e.target;
    var editor = getEditorByTag(tag);
    if( editor )
        editor.addModule('toolbar',{container:'#toolbar'});
});

It seems to work, but I suspect that Quill doesn't like adding many times the same module over and over on the same object since eventually it spits:

(node) warning: possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxListeners() to increase limit. quill.js (row 4727)

So is there a way to remove a previously added module? Something like:

// installs editor
var editor = new Quill('#editor');
// adds toolbar module
editor.addModule('toolbar',{container:'#toolbar'});
// removes just added toolbar module
editor.removeModule('toolbar');

来源:https://stackoverflow.com/questions/33441303/share-quill-toolbar-across-multiple-editors

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!