Search code examples
ckeditorckeditor4.x

CKeditor 4.8 not removing styles on paste


We recently upgrade our CKeditor to 4. (was a big jump, we were on I think 4.3) and how when a user pastes in code, the editor is not automatically removing styling, specifically font and text color. I do have forcePasteAsPlainText : true in my config, but I can reliably reproduce pasting in text that preserves the font color (ex: red) as it was in an email. How can I make it so all text pasted in is stripped of HTML styles?


Solution

  • I'm assuming that this happens when you use Paste from Word plugin, because according to forcePasteAsPlainText info:

    Whether to force all pasting operations to insert on plain text into the editor, losing any formatting information possibly available in the source text.

    Note: paste from word (dialog) is not affected by this configuration.

    So, I would use forcePasteAsPlainText and disable this plugin with:

    forcePasteAsPlainText : true,
    removePlugins: 'pastefromword'