我需要动态更改CKEditor配置中的一个设置。
我正在编写一个插件,将复选框添加到CKEditor工具栏中,并在选中/取消选中时更改forcePasteAsPlainText
属性的值为true/false。
问题在于,在初始化CKEditor组件时读取配置文件,后续所有更改都会被忽略。是否有可能在运行中“即时”更改值?
You can specif settings in config file that are default initializations for any editor created.
CKEDITOR.editorConfig = function(config) {
config.forcePasteAsPlainText = false;
...
}
You can override the config settings in this way so only the editor initialized will get these changes.
CKEDITOR.replace('myEditor', { forcePasteAsPlainText: ture });
You can also use editor destroy and recreate with custom configs.
var editor = CKEDITOR.instances.myEditor;
if (editor) { editor.destroy(true); }
CKEDITOR.config.forcePasteAsPlainText = false;
CKEDITOR.config.width = 400;
CKEDITOR.config.height = 300;
CKEDITOR.replace('myEditor', CKEDITOR.config);