Search code examples
angulartinymceangular4-forms

Set tinymce editor content as readonly in angular 4


I have two editors in my form. I am using angular 4. I have applied the following code to set the editor as readonly:

tinymce.activeEditor.getBody().setAttribute('contenteditable', false);
tinymce.activeEditor.getBody().style.backgroundColor = '#ecf0f5';

But from the above code, only one editor content set as readonly. How to perform this on all editors?


Solution

  • You can get an array of all the editors on the page with

    tinymce.editors
    

    This returns an array with references to each editor. You can then iterate over the array and perform those commands on each editor instance.