Rowdy
Rowdy

Reputation: 1

Custom ckeditor config file

I am trying to add a custom ckeditor config file, without modifying the default file. I have tried adding the following to my master page but of course the editor1 refers to the name property of the textarea which will change. Is there an easy way to do this without creating some JavaScript that searches for all textarea elements?

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

Thanks.

Upvotes: 0

Views: 516

Answers (1)

Zach Perry
Zach Perry

Reputation: 756

The way I did this was to modify the form control for Rich Text Editor. I added a property called ConfigFile. In the code for the control (HtmlAreaControl.ascx.cs) i added the property:

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

I then added this to set the config file to use in 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;
    }

Now on anything that uses this control, when setting up the fields, I can click advanced, and set the config file I want to use, just need the name like Custom.js. The new config file goes in CMSAdminControls > CKEditor, right next to the default config.js file.

Upvotes: 1

Related Questions