Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TinyMCE width and height disobedient!

According to the (conflicting) documentation of TinyMCE, the editor takes on the size of the textarea (or other) element that it replaces. It also says that you can set the size of the editor by specifying { height: '123', width: '123' } in the init method.

I have tried BOTH and still get only one result - the editor resizes itself to (how it remembers is beyond me) what it was the last time a user resized it.

like image 296
Jimbo Avatar asked Jun 22 '11 08:06

Jimbo


People also ask

How do I change the width on TinyMCE editor?

min_width. This option sets the minimum 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 from the autoresize plugin, which controls the resizing of the editable area only, not the entire editor.

How do I change the height on TinyMCE editor?

Under the hood: You can see string like "height": 120, in data-mce-conf attribute of the generated HTML for the textarea.

How do I make my TinyMCE editor responsive?

The TinyMCE editor can be made responsive by using css media queries. Simply add css rules that set the width property of table. mceLayout and the tinyMCE textareas. You will need to enforce these css rules using !


2 Answers

Its saves the last size because of the theme settings. You can turn it off by using the following

$('textarea.tinymce').tinymce({     theme_advanced_resizing: true,     theme_advanced_resizing_use_cookie : false, 
like image 176
Stuart Avatar answered Oct 02 '22 20:10

Stuart


I know all about this, it is very annoying.

Adding this to any loaded CSS file fixed the width for me (I just put it in the global css, not in any of the TinyMCE css files, I did not test with height):

.mceEditor > table {     width:/* my width */ !important; } 

This would affect all instances, which was fine in my case. You can target the toolbar itself with .mceToolbar

You kind of do want TinyMCE to resize the textarea, so it can be wide enough to fit all the toolbar icons.

like image 40
Wesley Murch Avatar answered Oct 02 '22 21:10

Wesley Murch