Ckeditor: How can I make several tags, such as h3, h4, h5, not editable in ckeditor

Ckeditor: How can I make several tags, such as h3, h4, h5, not editable in ckeditor

open js solution or css anyone will do

+5
source share
3 answers

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

config.format_tags = 'p;h2;h3;h4;h5;h6;pre;address;div'
+7
source

Configuring protectedSource is the choice for this.

{Array} CKEDITOR.config.protectedSource

A list of regular expressions that will be executed on the input HTML, indicating the code that should remain intact.

I'm not a regular expression expert, but something like this should do the trick:

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

, , . : <h1>...</h1>, , < h1 >...< /h1>.

+2

You can add the attribute contenteditable = false to the tag. For example.

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

All Articles