4

I saw a lot of posts here but each one of them is too old and its not connected with tinyMCE 4.x I am searching the web from days and I can't find an option to set tinyMCE 4.x in readonly mode.

At this moment I just hide toolbars and menubars but I still can delete text and so on...

cyrat
  • 628
  • 1
  • 11
  • 20

3 Answers3

4

This is how I make it read-only.

tinymce.init({
  selector: "#id",
  readonly: true,
  toolbar: false,
  menubar: false,
  statusbar: false
  // more inits...
});

You may need to tweak your styles to fix the editor borders.

xdarsie
  • 101
  • 1
  • 9
  • 1
    Yes but I can't select text when I do that... There are Code Snippets inside articles which users can copy / paste just like in tinymce version 3 http://www.tinymce.com/tryit/3_x/read_only_mode.php – cyrat Dec 08 '13 at 10:32
1

As stated in the TinyMCE docs as seen via this link https://www.tiny.cloud/docs-3x/reference/configuration/Configuration3x@readonly/, the readonly attribute should be set to '1' not to 'true'.

// Move focus to specific element
tinyMCE.init({
  theme : "advanced",
  readonly : 1
});

Hope this helps

Prince Michael
  • 85
  • 3
  • 3
  • 10
0

This take me some time to research how to make tinymce in readonly mode.

The key point here is set readonly to 1 or 0, not true or false. For example here is my init code:

tinymce.init({
            selector: "#html-textarea",
            menubar: false,
            statusbar: false,
            resize: "both",
            plugins: [
                "textcolor image link preview code table media noneditable"
            ],
            readonly: status, // **status hold value 0 or 1, NOT true or false**
            toolbar: 'preview | undo redo | removeformat | cut copy paste | formatselect fontselect fontsizeselect | forecolor backcolor | bold italic underline strikethrough subscript superscript | alignleft aligncenter alignright alignjustify | link unlink image media | code table | bullist numlist | outdent indent blockquote'
        });
Envil
  • 2,687
  • 1
  • 30
  • 42