Search code examples
tinymce

TINYMCE Read Only affects print button


I have set TinyMCE to read only as below All I want is the Textarea to be read only

<script>
    tinymce.init({

        readonly : 1,
        selector: "#editor",

        plugins: "image lists searchreplace fullscreen hr print preview " +
            "anchor code save emoticons directionality spellchecker pagebreak insertdatetime template table",

        toolbar:
            "| print "
    });
</script>

I have even tried to make the textarea readonly but this also did not prevent editing.

The code I posted works but also prevents the print button from working. Any way around this as I want just the print button to work?


Solution

  • TinyMCE's readonly mode works by disabling the Editor itself. For the editor to truly be in a read-only mode, toolbar and menu items would have to be disabled to prevent them from changing the content.

    However, it is still possible to trigger TinyMCE's print command programmatically while the Editor itself is in readonly mode.

    I've created a Tiny Fiddle demonstrating one way to do this, using Tiny's execCommand API: http://fiddle.tinymce.com/iOgaab/1