CKEditor 4 - 使用自定义配置替换所有()

时间:2015-05-13 12:18:56

标签: javascript ckeditor config

检查源代码后,似乎CKEDITOR.replaceAll函数无法在调用时传递任何自定义配置。

是否有任何解决方法,以便我可以将不同的自定义配置传递给特定的textarea?

e.g。我希望所有具有“高级”类的textarea具有不同的浏览图像路径,从textarea到类“normal”

2 个答案:

答案 0 :(得分:1)

CKEDITOR.replaceAll(function(textarea,config) {
    if(textarea.className == "advanced")
    {
        config.removeButtons = 'About';
        return true;
    }
    else if(textarea.className == "basic")
    {
        config.removeButtons = 'Cut,Copy,Paste,About,Save,NewPage,DocProps,Preview,Templates,PasteFromWord,SelectAll,Scayt,SpellChecker,Form,Checkbox,Radio,TextField,Textarea,Select,Button,ImageButton,HiddenField,JustifyLeft,JustifyCenter,JustifyRight,JustifyBlock,Flash,Smiley,Styles,Font,FontSize,Blockquote,Format,Image,Table,Link';
        config.uiColor = '#AADC6E';
        return true;
    }
});

答案 1 :(得分:0)

对于其他在Google搜索后登陆这里的人,Anna Oleksiuk的回答为我实现了想要的目标指明了正确的方向。我在页面上有多个textarea字段,有些需要基本的配置(即注释),有些需要标准的配置,有些需要保留为标准的textarea,以下对我有用:

CKEDITOR.replaceAll(function (textarea, config) {
  if (textarea.className === "ck-standard") {
    config.customConfig = "/theme/js/ckeditor/standard.js";
    return true;
  }
  else if (textarea.className === "ck-basic") {
    config.customConfig = "/theme/js/ckeditor/basic.js";
    return true;
  }

  return false;
});

就我而言,关键要素是return false;,以阻止其他任何字段被转换。