Make WordPress Core

Opened 13 years ago

Closed 13 years ago

Last modified 12 years ago

#21718 closed enhancement (fixed)

Remove default_post_edit_rows

Reported by: nacin's profile nacin Owned by: azaozz's profile azaozz
Milestone: 3.5 Priority: low
Severity: normal Version:
Component: Editor Keywords: has-patch commit
Focuses: Cc:

Description

In options-writing, there is a setting for the "Size of the post box". This controls the <textarea> height for all users. It should disappear.

Ideally, in place of it, the HTML editor should retain memory of its previous size (given browser scaling). To do this, we would either need to read and potentially set the same cookie as TinyMCE does for the Visual editor, or use our own user setting in parallel. This will require some changes to editor.js, class-wp-editor.php, and possibly the wp_editor() call in edit-form-advanced.php.

Attachments (7)

21718.patch (8.2 KB) - added by azaozz 13 years ago.
21718.diff (4.0 KB) - added by nacin 13 years ago.
21718-3.patch (10.3 KB) - added by azaozz 13 years ago.
21718-4.patch (11.8 KB) - added by azaozz 13 years ago.
21718.2.diff (11.4 KB) - added by nacin 13 years ago.
21718-5.patch (13.2 KB) - added by azaozz 13 years ago.
21718.3.diff (13.1 KB) - added by nacin 13 years ago.

Download all attachments as: .zip

Change History (23)

#1 @johnbillion
13 years ago

The default height of the editor should be increased too. It's tiny by default.

#2 @azaozz
13 years ago

  • Owner set to azaozz
  • Status changed from new to assigned

When a textarea is resized directly in the browser, it sets inline style with the width and height. Shouldn't be hard to get the height, save it in user settings and/or apply it to TinyMCE.

@azaozz
13 years ago

#3 @azaozz
13 years ago

In 21718.patch:

  • Resize the Text editor when switching Text -> Visual and the Visual editor when switching back (when the user resizes the textarea).
  • Store each editor height as user state (only when TinyMCE).
  • Save the editor height on unload (only when TinyMCE).

To do:

  • Save the Text editor height when no TinyMCE.

#4 @azaozz
13 years ago

Also to-do: perhaps do one-time conversion from the TinyMCE cookie to user state. Something like:

set_user_state( 'content_ed_size', $mce_cookie['y'] );
Version 0, edited 13 years ago by azaozz (next)

@nacin
13 years ago

#5 @nacin
13 years ago

Some combination of the patches from me and azaozz should get us about 90% of the way there.

When do we actually save a cookie? setUserSetting is only available in the admin. TinyMCE is only used on the post screen (and that's the only place this option applied to). wp_editor() is additionally used when editing and replying to comments, but TinyMCE isn't loaded. editor.js works, but wouldn't handle quicktag-only editors. quicktags.js is probably better, but it is loaded on the frontend. We could even include it inline in the editor_js() method in the editors class.

What I think would be best is if a TinyMCE plugin handled this for all editors it handles in the admin (so, azaozz's patch), with extra code inline that is outputted only in the admin and only when TinyMCE is not defined for that editor. (Important in case the visual editor is disabled.)


Related bug report: In Chrome, you can't size the textarea smaller than the space the visual editor takes up behind it.

#6 @azaozz
13 years ago

The Chrome bug is really annoying. As long as we add style="height: 200px" on the textarea tag, WebKit would restrict resizing to anything smaller. The same happens when the inline style is set from JS.

The only workaround for now seems to be to use jQuery to remove the inline style and set the textarea height directly (for WebKit browsers).

@azaozz
13 years ago

#7 @azaozz
13 years ago

Well, converted the textarea height to rows for Chrome but it still wouldn't allow resizing the textarea to shorter. Not sure what else to try :)

Also discovered that Chrome now adds about 4px "non-removable bottom margin" to all textareas as they are styled as inline-block. Setting display: block fixes that.

@azaozz
13 years ago

#8 @azaozz
13 years ago

21718-4.patch works well. It adds some JS to resize the Text editor and save the height.

Didn't use UI resizable as it tries to do a lot of things that aren't needed. Went with something similar to the JS that resizes the textareas on trac, smaller and works better.

#9 @nacin
13 years ago

  • Keywords has-patch commit added; needs-patch removed

Awesome. Marking this as a commit candidate. Needs testing and final review.

@nacin
13 years ago

@azaozz
13 years ago

#10 @azaozz
13 years ago

21718-5.patch includes 21718.2.diff and moves saving of the TinyMCE height to post.js. Also changed how 'editor_height' works a little: it is only used for the main editor and needs to be passed in the settings so it doesn't affect PressThis and the Edit Comments editors.

@nacin
13 years ago

#11 @nacin
13 years ago

In [22006]:

Remove the 'Size of the post box' (default_post_edit_rows) option. This will instead be handled by a user cookie tracking the resizing of both TinyMCE and the main textarea. see #21718.

#12 @azaozz
13 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In [22007]:

Main editor: maintain the height when switching Visual to Text and back, save the height when resizing as user state, output the height in the textarea tag when loading, (thanks @nacin for the help), fixes #21718

#13 @azaozz
13 years ago

In [22017]:

Make sure TinyMCE is not disabled before adding the size saving functions, see #21718

#14 @azaozz
12 years ago

In [22251]:

Editor: fix setting wpActiveEditor when TinyMCE is not used, see #21718

#15 @azaozz
12 years ago

In 22458:

Editor: fix position of the resize handle in Text mode in RTL (also some minor css cleanup), see #21718

#16 @azaozz
12 years ago

In 22606:

Editor: disable the textarea resizing handle on touch devices (cannot be used there), don't save TinyMCE's height in iOS as the user cannot set/change it there (it expands the iframe to full height), see #21718

Note: See TracTickets for help on using tickets.