Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ckeditor : How can i make few tags like h3 , h4 , h5 non editable in ckeditor

Ckeditor : How can i make few tags like h3 , h4 , h5 non editable in ckeditor

open to js solution or css any will do

like image 368
Ashish Mehra Avatar asked Feb 19 '10 13:02

Ashish Mehra


2 Answers

In config.js, use the following code to define which elements you want to allow in CKEditor (I removed h1) :

config.format_tags = 'p;h2;h3;h4;h5;h6;pre;address;div'
like image 151
Matthieu Avatar answered Sep 28 '22 23:09

Matthieu


The protectedSource configuration setting is the setting of choice for that.

{Array} CKEDITOR.config.protectedSource

List of regular expressions to be executed over the input HTML, indicating code that must stay untouched.

I'm no expert on regular expressions but something like this should do the trick:

config.protectedSource.push(/[^<]*(<h1>([^<]+)<\/h1>)/g);

you may have to play around with it a bit. Caveat: The regex in that form will catch only <h1>...</h1> tags, not for example deviations like < h1 >...< /h1>.

like image 45
Pekka Avatar answered Sep 28 '22 23:09

Pekka