Opened 3 years ago

Closed 13 months ago

#13070 closed enhancement (fixed)

Add RTL/LTR button to html editor

Reported by: yoavf Owned by: yoavf
Priority: normal Milestone: 3.4
Component: Editor Version:
Severity: normal Keywords: has-patch rtl commit
Cc: r_a_m_i@…

Description (last modified by yoavf)

When using WordPress in an RTL language (Farsi, Hebrew, Arabic etc... ) it's a real pain to use the HTML editor when the content actually includes HTML.

TinyMCE has the directionality plugin to add a RTL/LTR button, but there's no equivalent in the HTML editor.

This patch adds the missing button

Attachments (3)

quicktags-rtl.patch (2.0 KB) - added by yoavf 3 years ago.
13070.1.patch (2.0 KB) - added by yoavf 16 months ago.
Refreshed patch
13070.2.patch (2.1 KB) - added by yoavf 16 months ago.

Download all attachments as: .zip

Change History (19)

yoavf3 years ago

  • Description modified (diff)
  • Milestone changed from Awaiting Triage to Future Release
  • Keywords changed from has-patch, rtl to has-patch rtl

related #19598

comment:4 follow-up: ↓ 5   azaozz16 months ago

Wouldn't it be better to use the dir="..." attribute on the textarea to change directions (this seems suggested at W3.org)?

Also the current patch works but only because of the back-compat in Quicktags. The "new" method of adding buttons is described here. Thinking if we are doing this, it should be included in wp_editor() and added automatically when the text direction is RTL, similar to the "directionality" plugin for TinyMCE.

comment:5 in reply to: ↑ 4   yoavf16 months ago

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

Replying to azaozz:

Wouldn't it be better to use the dir="..." attribute on the textarea to change directions
Also the current patch works but only because of the back-compat in Quicktags. The "new" method of adding buttons is described here. Thinking if we are doing this, it should be included in wp_editor() and added automatically when the text direction is RTL, similar to the "directionality" plugin for TinyMCE.

Absolutely - this patch is 22months old, but I'll be happy to work on a refresh.

  • Keywords needs-refresh added

If it gets refreshed, I'm game for this for 3.4.

yoavf16 months ago

Refreshed patch

  • Keywords needs-refresh removed

Made it a default button now, but only when the global(ish) isRtl is true.

  • Milestone changed from Future Release to 3.4

The patch looks good. Wondering if we can use something like:

document.getElementsByTagName('html')[0].dir

to determine the initial text direction, instead of relying on the global isRtl being set (it's set only in the admin).

yoavf16 months ago

Makes sense, 13070.2.patch does that instead of using isRtl.

I didn't bother "caching" the value of document.getElementsByTagName('html')[0].dir since it's only used twice - but if you think I should, I will :)

  • Keywords commit added
  • Cc r_a_m_i@… added

comment:13 follow-up: ↓ 14   nacin14 months ago

This patch changes how the text is viewed in the HTML editor, but it doesn't do anything to the HTML.

When pressing the direction button in TinyMCE, the HTML underneath changes, so I get <p dir="ltr"> for example. I imagine you'd want that here, right?

comment:14 in reply to: ↑ 13 ; follow-up: ↓ 15   yoavf14 months ago

When pressing the direction button in TinyMCE, the HTML underneath changes, so I get <p dir="ltr"> for example. I imagine you'd want that here, right?

Actually, no - it doesn't make sense in the HTML editor.

The default in the HTML editor is RTL, but if you want to actually edit HTML tags and code, it's a mess, so you just want to switch the entire box to LTR (and back, when you're done).

The button isn't supposed to affect the content, just the editor.

Maybe in the next version we can find a way to differentiate the 'Fullscreen' and 'Text direction' buttons so they don't look like the other, content altering, buttons.

comment:15 in reply to: ↑ 14   nacin14 months ago

Replying to yoavf:

The button isn't supposed to affect the content, just the editor.

Great, thanks.

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

In [20451]:

Add RTL/LTR button to the html editor, props yoavf, fixes #13070

Note: See TracTickets for help on using tickets.