自定义ckeditor配置文件

时间:2018-03-22 10:22:59

标签: ckeditor kentico

我正在尝试添加自定义ckeditor配置文件,而不修改默认文件。我已经尝试将以下内容添加到我的母版页中,但当然editor1引用了textarea的name属性,它将更改。有没有创建一些搜索所有textarea元素的JavaScript的简单方法呢?

   CKEDITOR.replace( 'editor1', {
    customConfig: '/CMSAdminControls/CKeditor/custom.config.js'
   });

感谢。

1 个答案:

答案 0 :(得分:0)

我这样做的方法是修改Rich Text Editor的表单控件。我添加了一个名为ConfigFile的属性。在控件的代码(HtmlAreaControl.ascx.cs)中添加了属性:

   public string ConfigFile
{
    get
    {
        return GetValue("ConfigFile", "");
    }
    set
    {
        SetValue("ConfigFile", value);
    }
}

然后我添加了此项以设置要在Page_Load中使用的配置文件:

// Get editor area toolbar
//next two lines are already there, just so you can find the place to add it
    editor.ToolbarSet = DataHelper.GetNotEmpty(GetValue("toolbarset"), (Form != null) ? Form.HtmlAreaToolbar : String.Empty);
    editor.ToolbarLocation = DataHelper.GetNotEmpty(GetValue("toolbarlocation"), (Form != null) ? Form.HtmlAreaToolbarLocation : String.Empty);

    //Set Custom Config File
    if (ConfigFile != "")
    {
        editor.CustomConfig = ConfigFile;
    }

现在在使用此控件的任何内容上,在设置字段时,我可以单击高级,然后设置我想要使用的配置文件,只需要像Custom.js这样的名称。新的配置文件位于CMSAdminControls > CKEditor,紧挨着默认的config.js文件。

相关问题