How to define allowed tags in CKEditor?

kenpeter picture kenpeter · May 26, 2010 · Viewed 46.7k times · Source
  • Sometimes users copy and paste text from different sources to CKEditor, but I want to restrict what tags they can copy to CKEditor.

  • I only need to use certain tags in CKEditor: The list tag, break tag, etc...

  • Can I define them & disable the other tags in CKEditor?

Answer

Rafael Berlanda picture Rafael Berlanda · Dec 5, 2010

There are some settings you can use. You define these settings editing the config.js file in the ckeditor's root directory. For example, if you want to be radical like me, you could put:

config.forcePasteAsPlainText = true;

If you want to restrict only certain tags exactly like you said, I found the setting bellow:

config.removeFormatTags = 'b,big,code,del,dfn,em,font,i,ins,kbd';

The last will be done only when user execute the "remove format" command. More information: http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.config.html#.format_tags

Considering all the time, I think that you already have found your answer, but others can be helped.