Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to define allowed tags in CKEditor?

Tags:

ckeditor

  • 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?

like image 240
kenpeter Avatar asked May 26 '10 12:05

kenpeter


People also ask

How do I allow all HTML tags in CKEditor?

config. allowedContent = { $1: { // Use the ability to specify elements as an object. elements: CKEDITOR. dtd, attributes: true, styles: true, classes: true } }; config.

How do I add BR tags to CKEditor?

You need to press Shift + Enter in order to get just a <br> tag. This functionality is also 100% configurable. the SHIFT+ENTER works well thank you.

How do I add codes to CKEditor?

If you would like to use inline code formatting in your WYSIWYG editor, check out the basic text styles feature with its support for inline <code> element. The code block feature is enabled by default in the superbuild only. See the installation section to learn how to enable it in your editor.


1 Answers

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.

like image 103
Rafael Berlanda Avatar answered Nov 26 '22 13:11

Rafael Berlanda