Search code examples
ckeditorfckeditor

separate ckeditor template for each page


I want to have separate config for ckditor.

For example in page temp1.html i want to have 'links' and in page temp2.html i don't want to have links.

Whats the good config for this?

I think configuration in below code is proper place for do this.

    //var editor_data = CKEDITOR.instances.editor1.getData();
    $('textarea#editor').ckeditor(
    function () {
        /* callback code */
    },
    //configuration
    {
        toolbar: 'Basic',
        language: 'en',
    });

Solution

  • You can use config.removePlugins to control the presence of certain plugins, like link (also config.removeButtons). But please note that since CKEditor 4.1, by doing this you restrict the content of the editor associated with the plugin or button (no link plugin or button = no links in the content).

    So if you want to share the same content between different templates which use a different sets of plugins you need to explicitly expand config.extraAllowedContent of some editors:

    $('#editor-linkless').ckeditor( function() {}, {
        removePlugins: 'link',
        extraAllowedContent: 'a[href,name,id,target]'
    } );
    
    $('#editor-regular').ckeditor();
    

    JSFiddle.

    See the official guide about ACF. Also this answer to know more.