开发者

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

Ckeditor : How can i make few tags like h开发者_C百科3 , h4 , h5 non editable in ckeditor

open to js solution or css any will do


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'


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>.


You can add attribute contenteditable=false to the tag. E.g.

ckeditor.insertHtml('<h1 contenteditable="false">Not editable text</h1>');
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜