CKEditor remove style for a specific instance

708 views Asked by At

How can I remove the styling for a specific CK editor instance. I have two CKEditors in my page. One restricted for summary and one rich for content.

For the summary I can't allow the copy paste styling because that can mess our design.

I tried this solution:

        CKEDITOR.config.forcePasteAsPlainText = true;
    CKEDITOR.replace( id, {
        // Define the toolbar groups as it is a more accessible solution.
        toolbarGroups: [
            {"name":"basicstyles","groups":["basicstyles"]},
            {"name":"links","groups":["links"]}
        ],
        // Remove the redundant buttons from toolbar groups defined above.
        removeButtons: 'Strike,Subscript,Superscript,Anchor,Styles,Specialchar'
    } );

This removes the styling but removes from the contents too.

So my question is how to remove the styling when I paste in the summary and how to keep the styling when I paste for the content.

1

There are 1 answers

0
Reinmar On BEST ANSWER

In your code snippet I can see:

CKEDITOR.config.forcePasteAsPlainText = true;

This isn't a correct way to set configuration options. This will change this setting for all existing editors. What you want to do is to move this setting to CKEDITOR.replace():

CKEDITOR.replace( 'content', {
     // some options for the "content" editor.
} );

CKEDITOR.replace( 'summary', {
    forcePasteAsPlainText: true,
    // some other options for the "summary" editor.
} );

Read more in setting configuration.