动态设置CKEditor配置

3

我需要动态更改CKEditor配置中的一个设置。

我正在编写一个插件,将复选框添加到CKEditor工具栏中,并在选中/取消选中时更改forcePasteAsPlainText属性的值为true/false。

问题在于,在初始化CKEditor组件时读取配置文件,后续所有更改都会被忽略。是否有可能在运行中“即时”更改值?

1个回答

4
  1. You can specif settings in config file that are default initializations for any editor created.

    CKEDITOR.editorConfig = function(config) {
    config.forcePasteAsPlainText = false;
    ...
    }
    
  2. You can override the config settings in this way so only the editor initialized will get these changes.

    CKEDITOR.replace('myEditor', { forcePasteAsPlainText: ture });
    
  3. 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);
    

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接