Noneditable plugin
The noneditable plugin has been rewritten from scratch to use stability improvements to the TinyMCE core. It is now more reliable and has fewer browser-specific quirks.
|
This plugin enables you to prevent users from being able to edit content within elements assigned the mceNonEditable
class.
Basic setup
tinymce.init({
selector: 'textarea', // change this value according to your HTML
plugins: 'noneditable'
});
When you have existing classes that cannot be removed, you may combine MCE classes with the existing class in the following manner:
Options
These settings affect the execution of the noneditable
plugin. These settings help determine which areas of the editor’s editable area will remain editable and which will be converted to non-editable status.
noneditable_editable_class
This option allows you to specify the class name that TinyMCE will use to determine which areas of content are editable when using the noneditable
plugin. This would be the same as contenteditable=true
, forcing an element to be editable.
Note that classes with the mceItem
prefix are invisible within TinyMCE.
Type: String
Default Value: 'mceEditable'
noneditable_noneditable_class
This option allows you to specify the class name that TinyMCE will use to determine which areas of content are editable when using the noneditable
plugin. This would be the same as contenteditable=false
.
Note that classes with the mceItem
prefix are invisible within TinyMCE.
Type: String
Default Value: 'mceNonEditable'
noneditable_regexp
This option is used to specify a regular expression or array of regular expressions that TinyMCE will use to determine which areas of content are non-editable when using the noneditable
plugin. The regular expressions needs to be global so that all instances within the document are matched. The text content of the matches will be wrapped in spans, hiding the structure and styling while editing.
If elements are matched by the regular expression, the elements will be replaced with spans. Use noneditable_noneditable_class for elements.
|
Type: String
Making Content Non-editable
Procedure
-
Add
noneditable
toplugins
. For example:tinymce.init({ selector: 'textarea', // change this value according to your HTML plugins: 'code noneditable' });
-
Configure the
noneditable_noneditable_class
option, or the others as necessary in yourtinymce.init
. For example:tinymce.init({ selector: 'textarea', // change this value according to your HTML plugins: 'noneditable', noneditable_noneditable_class: 'mceNonEditable' });
Replace mceNonEditable
with the class name you want for your non-editable elements. -
Select the desired editor content.
-
From the menu bar, select
View
>Source code
. -
Add the non-editable class to the desired editor content. For example:
<div class="myclass mceNonEditable">Contents</div>