我想在编辑器实例化后禁用TinyMCE4中的所有按钮。TinyMCE4取消了访问controlManager内部按钮的功能。在TinyMCE3中,可以执行以下操作:
_.each(editor.controlManager.controls, function (property, index, controls) {
controls[property.id].setDisabled(disabled);
});
访问TinyMCE4生成的封装按钮实例的唯一方法似乎是通过postRender方法:
editor.addButton('example', {
title: 'My title',
image: '../js/tinymce/plugins/example/img/example.gif',
onPostRender: function () {
// this refers to button instance generated by TinyMCE4, where disabling/enabling functionality is available
}
});
我正在开发一个带有第三方WYSIWYG插件集成的定制CMS,因此我无法修改编辑器中使用的所有按钮的onPostRender方法。是否有任何方法可以从编辑器对象访问工具栏或按钮实例,以便调用其
disabled
方法如以下来源所述:
/**
* Sets/gets the disabled state on the control.
*
* @method disabled
* @param {Boolean} state Value to set to control.
* @return {Boolean/tinymce.ui.Control} Current control on a set operation or current state on a get.
*/
// disabled: function(state) {} -- Generated
我正在使用TinyMCE 4.6.4