Hi,

Quoting myself from here:
http://drupal.org/node/308912#comment-1067862

...it happens something curious now. I'm using 1280x1024 resolution, so the TinyMCE textarea is quite wide. If I resize the browser window to 1024x768, then the TinyMCE textarea keeps its width and so it gets wider than page (Garland them, fluid layout). Please, see attached screenshot tinymce_textarea_crossing_page_edge.png.

When I start to edit at 1024x768 and then resize the browser window back to 1280x1024, then the TinyMCE textarea keeps its width, and so, it gets thick compared to the new page width. Please, see attached screenshot tinymce_textarea_leaves_empty_space.png.

This effect doesn't happen here:
http://tinymce.moxiecode.com/examples/full.php

ie. the whole text area is resized when the browser window resizes.

Screenshots:

tinymce_textarea_leaves_empty_space.png
tinymce_textarea_crossing_page_edge.png

sun said:

That's a different issue. Quick inspection tells that they are setting width: 100%, and the default width is set based on the textarea that has been replaced: http://wiki.moxiecode.com/index.php/TinyMCE:Configuration/width - please open a new issue for this.

Ok, just tested adding width:100% using inline style for the textarea, and it worked. Also tested adding 'width' => '100%' to TinyMCE settings, and it also worked.

HTH+

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

markus_petrux’s picture

Title: TinyMCE does not reasize textarea when browser window is resized. » TinyMCE does not resize textarea when browser window is resized.

oops, typo in title

markus_petrux’s picture

One additional problem I noticed when enabling Font buttons in TinyMCE is that dropdown arrows get broken when window is resized. Also tested this adding style="100%" to textareas, and this particular problem persists.

Attached image shows what I mean. I added a couple of red arrows to point to the arrows that appear under the dropdown element.

This is not the same problem as reported on top, but still related to resizing the browser window, so I posted this here rather than opening a different issue.

markus_petrux’s picture

Title: TinyMCE does not resize textarea when browser window is resized. » TinyMCE issues when browser window is resized.

A more generic title related to issues when browser window is resized.

sun’s picture

Title: TinyMCE issues when browser window is resized. » TinyMCE not resized when browser is resized
Status: Active » Needs review
FileSize
602 bytes

Reverting title and topic of this issue. The width setting alone is debatable enough. Please open a new issue for the other issue you encountered.

Attached patch adds 'width' => '100%' to TinyMCE's default settings. This would be hard-coded though.

For custom form layouts, f.e. two-column layouts where the form element label is floated left and the field is right next to it, this means that the editor is automatically rendered using 100% width of the parent's container, i.e. the editor *overflows* the parent's container area. Themers can fix this with sufficient knowledge of CSS and theme override functions by clearing the floats for textareas only. However, they are not able to remove or disable this setting without hacking the module.

markus_petrux’s picture

This solution worked for me, so I would say RTBC.

sun’s picture

Title: TinyMCE not resized when browser is resized » TinyMCE: Editor not resized when browser is resized
Component: User interface » Editor - TinyMCE

Well, I already thought about it, but this reply certainly does not qualify you as a co-maintainer. ;) That said, your contributions to Wysiwyg API are very valuable. If you could break with that habit and start to think about generic use-cases, upgrade paths, aso. then I would really like to reconsider this. :)

My example was not hypothetical: I am using custom form layouts and needed to justify my stylesheets after applying this patch, which was a big pain. So, what I am thinking of is to enhance our tinymce.css, so that a potential floating textarea is cleared automatically.

markus_petrux’s picture

Oh, I haven't thought about co-maintainership. I'm currently concerned on trying to help because it seems to be the time to do so, now that a) you're there driving the car, and b) me here needing this for the sites I'm working on. :)

My example was not hypothetical: I am using custom form layouts and needed to justify my stylesheets after applying this patch, which was a big pain. So, what I am thinking of is to enhance our tinymce.css, so that a potential floating textarea is cleared automatically.

Passing the width from CSS class would not work.

Looking at tinymce code, they compute the width of the editor like this:

w = s.width || e.style.width || e.offsetWidth;

That is a) tinymce width parameter, b) width retrieved from the textarea style attribute, and c) the current width of the textarea, which is absolute.

If we use CSS class, something like the snippet below, then a) and b) are undefined, so tinymce gets the width from c).

.form-textarea {
  width: 100%;
}

I would vote for solving this by exposing hooks that external modules and/or themes could implement to change editor settings on the fly.

Edited: Oh, and keep width 100% by default in tinymce editor implementation, as suggested in your patch above.

sun’s picture

Ok, let me clarify: If we apply this setting to TinyMCE's settings, it is possible that we break custom form layouts, because the editor will take up 100% of the container in which a textarea lives. Since TinyMCE applies this width directly to the editor container via JavaScript, themers have no chance to override this width. To visualize:

- form
-- form-item
--- label (float: left)
--- textarea (display: hidden by TinyMCE)
--- span.mceLayout (width: 100% by TinyMCE)

In my case, the regular layout is: labels take up ~30% of the total form width and the textarea takes up the rest. Because the textarea is hidden and TinyMCE applies width: 100% to the editor container, this resulted in forms, where the editor overflowed (exceeded) the total width of the form - completely breaking the layout of the site.

My not so trivial fix for this was:

body textarea, .mceEditor { clear: left; }
table.mceLayout { clear: left; }

However, I am unsure whether we can add this fix to editors/css/tinymce.css, i.e. apply it safely on all sites.

markus_petrux’s picture

That's why I was thinking this could be solved by letting themes override TinyMCE settings.

clearing textareas left would work in your case, but not for others.

Themes set these things using their own CSS stylesheets, but that doesn't work in TinyMCE, as explained above. TinyMCE needs the width as an instance setting or inline style, otherwise the current width of the element is taken from the DOM, which is then a fixed width which is not correctly recalculated when the window is resized.

Then, we have use cases of themes using different % for textareas (garland is 100%, drupal.org is 95%, etc.).

Ideally themes would have to be able to influence the way tinymce deals with the width of the editor, as well as any other thing they need, yours in one valid example of this.

So, I would implement a setting that may cover the most common use cases (maybe that 100%, because garland), but also let themes override tinymce settings. So you leave them the option to do whatever they need.

sun’s picture

Status: Needs review » Fixed
FileSize
1.68 KB

I have tested a few themes with this additional clearing and it didn't break something. Because I expect more support issues/bug reports in this queue if it would be left out, I committed it in attached patch to all branches.

Let's think about editor theme settings in a separate issue - I think that's a good idea.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

mzvarik’s picture