Make WordPress Core

Opened 14 years ago

Closed 12 years ago

#13070 closed enhancement (fixed)

Add RTL/LTR button to html editor

Reported by: yoavf's profile yoavf Owned by: yoavf's profile yoavf
Milestone: 3.4 Priority: normal
Severity: normal Version:
Component: Editor Keywords: has-patch rtl commit
Focuses: Cc:

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 14 years ago.
13070.1.patch (2.0 KB) - added by yoavf 12 years ago.
Refreshed patch
13070.2.patch (2.1 KB) - added by yoavf 12 years ago.

Download all attachments as: .zip

Change History (19)

#2 @nacin
13 years ago

  • Milestone changed from Awaiting Triage to Future Release

#3 @yoavf
12 years ago

  • Keywords changed from has-patch, rtl to has-patch rtl

related #19598

#4 follow-up: @azaozz
12 years 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.

#5 in reply to: ↑ 4 @yoavf
12 years 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.

#6 @nacin
12 years ago

  • Keywords needs-refresh added

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

@yoavf
12 years ago

Refreshed patch

#7 @yoavf
12 years ago

  • Keywords needs-refresh removed

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

#8 @yoavf
12 years ago

  • Milestone changed from Future Release to 3.4

#9 @azaozz
12 years ago

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).

@yoavf
12 years ago

#10 @yoavf
12 years 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 :)

#11 @nacin
12 years ago

  • Keywords commit added

#12 @ramiy
12 years ago

  • Cc r_a_m_i@… added

#13 follow-up: @nacin
12 years 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?

#14 in reply to: ↑ 13 ; follow-up: @yoavf
12 years 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.

#15 in reply to: ↑ 14 @nacin
12 years ago

Replying to yoavf:

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

Great, thanks.

#16 @azaozz
12 years ago

  • 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.