WordPress.org

Make WordPress Core

Opened 20 months ago

Closed 19 months ago

Last modified 17 months ago

#21718 closed enhancement (fixed)

Remove default_post_edit_rows

Reported by: nacin Owned by: 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 19 months ago.
21718.diff (4.0 KB) - added by nacin 19 months ago.
21718-3.patch (10.3 KB) - added by azaozz 19 months ago.
21718-4.patch (11.8 KB) - added by azaozz 19 months ago.
21718.2.diff (11.4 KB) - added by nacin 19 months ago.
21718-5.patch (13.2 KB) - added by azaozz 19 months ago.
21718.3.diff (13.1 KB) - added by nacin 19 months ago.

Download all attachments as: .zip

Change History (23)

comment:1 johnbillion20 months ago

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

comment:2 azaozz20 months 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.

azaozz19 months ago

comment:3 azaozz19 months 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.

comment:4 azaozz19 months ago

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

if ( $mce_cookie ) 
    set_user_state( 'content_ed_size', $mce_cookie['y'] );
Last edited 19 months ago by azaozz (previous) (diff)

nacin19 months ago

comment:5 nacin19 months 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.

comment:6 azaozz19 months 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).

azaozz19 months ago

comment:7 azaozz19 months 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.

azaozz19 months ago

comment:8 azaozz19 months 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.

comment:9 nacin19 months ago

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

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

nacin19 months ago

azaozz19 months ago

comment:10 azaozz19 months 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.

nacin19 months ago

comment:11 nacin19 months 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.

comment:12 azaozz19 months 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

comment:13 azaozz19 months ago

In [22017]:

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

comment:14 azaozz18 months ago

In [22251]:

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

comment:15 azaozz18 months ago

In 22458:

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

comment:16 azaozz17 months 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.