TinyMce has a plugin for it. It is called immutable : https://www.tinymce.com/docs/plugins/noneditable/
You can initiate tinymce as follows:
tinymce.init({ selector: 'texteditor', // change this value according to your HTML toolbar: 'undo redo', // disable most of the plugins ... context_menu: false, menubar: false, // ... to allow text edit only noneditable_editable_class: "editable", // class allowed to edit noneditable_noneditable_class: "non_editable" // the parent (everything else) });
You must define both attributes - I tried only with noneditable_editable_class , assuming that this leaves unchanged - without success.
Another solution (without tinyMce) would be to place the contenteditable attribute on the page elements you want to allow:
$('.editable').attr('contenteditable','true');
source share