Page MenuHomePhabricator

Using browser functions to switch input direction is impossible in the new wikitext editor
Closed, ResolvedPublic8 Estimated Story Points


It's impossible to switch the element direction in the 2017 wikitext editor.

Usually the initial direction of a plain-text textarea is inherited or set by the dir attribute. Browsers allow users to switch this direction by a keyboard shortcut (Ctrl-Shift-X/Cmd-Shift-X in Firefox, Ctrl-Shift/Cmd-Shift in other browsers) or by a command in a context menu (something like right-click -> Switch text direction).

None of the above works in the 2017 wikitext editor, which is technically understandable, because it's not really a textarea, but a contenteditable with a monospaced font. From the user perspective, however, this is a major problem, because when editing wiki syntax, switching the direction is often needed for handling URLs, pieces of CSS, filenames, etc.

If I inspect the (more or less) root element of the editor, <div class="ve-ce-branchNode ve-ce-documentNode" contenteditable="true" dir="rtl">, and I change the value of dir to "ltr", then it does what is needed. But this is accessible only to very advanced users who can use the browsers' developer tools. If making Ctrl-Shift(-X) and the context menu direction switching is not possible, then having a toolbar button that switches the direction would be enough.

@eranroz can probably make a gadget for this in ten minutes ;) But this should be available to all users (at least in RTL wikis) and not as a gadget.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript
Jdforrester-WMF renamed this task from Switching direction is impossible in the new wikitext editor to Using browser IME to switch input direction is impossible in the new wikitext editor.Jan 19 2017, 8:09 PM
Jdforrester-WMF triaged this task as Medium priority.
Jdforrester-WMF set the point value for this task to 8.
Jdforrester-WMF moved this task from To Triage to TR3: Language support on the VisualEditor board.

What does the user have to have installed for this shortcut to be enabled?

In Chrome I can change the writing direction from the context menu, but only one line at a time.

Amire80 renamed this task from Using browser IME to switch input direction is impossible in the new wikitext editor to Using browser functions to switch input direction is impossible in the new wikitext editor.Mar 16 2017, 11:44 AM

Change 343040 had a related patch set uploaded (by Esanders):
[VisualEditor/VisualEditor] Add tool to change directionality of document view

Change 343069 had a related patch set uploaded (by Esanders):
[mediawiki/extensions/VisualEditor] [PULL THROUGH] Add tool to change directionality of document view

Change 343040 merged by jenkins-bot:
[VisualEditor/VisualEditor] Add tool to change directionality of document view

Jdforrester-WMF assigned this task to Esanders.
Jdforrester-WMF edited projects, added User-notice; removed Patch-For-Review.

Change 343069 merged by jenkins-bot:
[mediawiki/extensions/VisualEditor] Update VE core submodule to master (ef5dc965f)

Tested in

Works perfectly.

Thanks a lot!

New button text "View as left-to-right" (or the other way around) is quite confusing as visually it only changes text alignment not direction. Perhaps say "Type left-to-right" or "Switch to left-to-right typing" or something like that?

It does change the direction, not the alignment. For example, if you do it while editing an English Wikipedia article, you'll notice that the full stops in the end of the sentences jump to the left end of the paragraphs. This is usually not needed in all-English articles, but it is very useful when editing articles that have quotations in Arabic, Hebrew, Persian, Urdu, and other RTL languages, and vice versa—in the Arabic Wikipedia, while editing articles that have English quotations or XML-like markup, such as <ref>, <poem>, etc., so it's almost all articles in RTL wikis.

In technical HTML terms, it toggles the dir attribute value between ltr and rtl. If it was alignment, then it would change the CSS text-align property, but this is not the case.

Also, it's correctly named "View as left-to-right" because it only views the article with a different direction while editing. The different direction is not saved.

Technically it may be about changing direction, not alignment, but visually it doesn't look like that. Last full stop of the paragraph jumps, but other than that the reading direction remains the same and most notable change visually is the alignment change.

Anyways, even if current wording can be interpreted as technically correct, then what about my suggestion above? I'm aware of writing systems with different writing directions (as well as "dir" attributes) and still I had to seek for this task to understand if this button works as intended. I probably wouldn't have, if the the button text was more accurately about typing or writing.

The full stop change is the direction change. For the most part, the visual order of letters is not supposed to change. The biggest troubles are usually with English words in the middle of RTL paragraphs, with English paragraphs in the middle of RTL articles (and vice versa), with numbers, and with punctuation such as <, >, (, ), ;, ., etc.

I understand what RTL support is for. I only suggested different button text, not different functionality.

Anyways, let it be then. I'll just customize button text translations in my native language then in a way which is hopefully easier to understand.