我正在尝试从 ckeditor 实例中动态添加/删除按钮。
我在 stackoverflow 上找到了以下线程:动态更改 CKEditor 工具栏
触发 uiSpace 事件的解决方案工作正常,只是工具栏中的组合框存在问题。如果我在使用该方法更新工具栏后尝试更改编辑器的只读状态,则会出现以下异常:
未捕获的类型错误:无法读取空 ckeditor.js:752 CKEDITOR.ui.richCombo.CKEDITOR.tools.createClass.proto.setState ckeditor.js:746 的属性“setState”
组合框也没有被禁用。
我正在添加以下重新加载功能:
CKEDITOR.editor.prototype.reloadToolbar = function() {
if (!this._.events.themeSpace) {
CKEDITOR.plugins.registered.colorbutton.init(this);
CKEDITOR.plugins.registered.toolbar.init(this);
}
//According to CKEditor documentation
var obj = this.fire( 'uiSpace', { space: 'top', html: '' } ).html;
// Replace the toolbar HTML
var tbEleId = this.id +"_" + this.config.toolbarLocation;
var tbEle = document.getElementById(tbEleId);
tbEle.innerHTML = obj;
}
Run Code Online (Sandbox Code Playgroud)
然后我正在执行以下代码(缩短的示例):
CKEDITOR.config.toolbarGroups = [
{ name: 'clipboard', groups: [ 'clipboard', 'undo', 'find' ]},
{ name: …Run Code Online (Sandbox Code Playgroud)