Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tiny MCE - set full-screen when editor is loaded?

I use tiny_mce as word-like editor in textareas that are in iframes. I want to use whole iframe space. TinyMCE has a fullscreen button, but I need to set full-screen mode automatically when plugin has loaded. Is there a function/trigger to call this mode (or the button)? Thanks for help.

like image 533
Martin Ille Avatar asked Apr 19 '10 19:04

Martin Ille


People also ask

How do I resize TinyMCE?

max_width. This option sets the maximum width that a user can stretch the entire TinyMCE interface (by grabbing the draggable area in the bottom right of the editor interface). This behavior is different than the autoresize plugin, which controls the resizing of the editable area only, not the entire editor.

How do I get rid of powered by tiny?

Use the branding option to disable the “Powered by Tiny” link displayed in the status bar for product attribution.


2 Answers

In the IFRAME document you can instruct TinyMCE to switch to fullscreen mode once the textarea has initialized. The following code will need to go into your IFRAME:

<script type="text/javascript">
tinyMCE.init({
    mode : "exact",
    elements : "description",  // This is the id of the textarea
    plugins : "fullscreen",
    theme : "advanced",
    theme_advanced_buttons1 : "fullscreen,code",
    theme_advanced_buttons2 : "",
    theme_advanced_toolbar_location : "top",
    theme_advanced_toolbar_align : "left",
    theme_advanced_statusbar_location : "bottom",
    oninit : function() {  // Once initialized, tell the editor to go fullscreen
        tinyMCE.get('description').execCommand('mceFullScreen');
    }
});
</script>

....

<textarea id="description"></textarea>

The TinyMCE fullscreen plugin will fill up the current window - and, since the IFRAME is it's own window, the this should fill the IFRAME.

Edit: This technique can also be used with the TinyMCE JQuery library. The options are the same but the invocation syntax is a little different. Again, the key lines are the oninit callback:

$(document).ready(function() {
    $('#description').tinymce({   // "description" is the id of the TEXTAREA
        // ... same options inserted here ...
        oninit : function() {
            tinyMCE.get('description').execCommand('mceFullScreen');
        }
    });
});
like image 70
leepowers Avatar answered Oct 05 '22 23:10

leepowers


You just need to insert the following code into the tinyMCE.init({}) function:

setup : function(ed) {
  ed.on('load',function(e){
      ed.execCommand('mceFullScreen');
  });

},

Ps: remember the comma if you have other instruction after it or it will fail. ;-)

like image 29
Pinonirvana Avatar answered Oct 05 '22 22:10

Pinonirvana