[wp-trac] [WordPress Trac] #40194: Automatic text direction detection for input fields in the admin area

WordPress Trac noreply at wordpress.org
Sat Mar 18 14:59:53 UTC 2017


#40194: Automatic text direction detection for input fields in the admin area
-------------------------+-------------------------------------------------
 Reporter:  johnbillion  |       Owner:
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  Awaiting Review
Component:  I18N         |     Version:
 Severity:  normal       |  Resolution:
 Keywords:  needs-patch  |     Focuses:  accessibility, javascript, rtl,
                         |  administration
-------------------------+-------------------------------------------------
Changes (by shadyvb):

 * focuses:  accessibility, javascript, administration => accessibility,
     javascript, rtl, administration


Comment:

 While single-line inputs should be okay detecting the first character just
 like what Google currently does, this does not apply cleanly to WYSIWYG
 fields though, because switching the whole content to one direction
 assumes it is all expected to be in that direction, which is not always
 the case.

 So I think there are a few cases to discuss/handle here:

 '''# Inputs:'''

 Single-line inputs, minus those with URL/Email/etc types, should be safe
 to monitor/handle using the technique Google currently has.
 [https://jsbin.com/pakejeleve/edit?html,js,console,output| Basic demo on
 JSBin].

 TinyMCE already has RTL/LTR buttons possible via
 [https://wordpress.org/plugins/wp-rtl/| WP-RTL plugin], so what can be
 introduced here is the detection of each new line's first character and
 automatically switching the direction of that paragraph based on it. Which
 might mean :
 1. Updating the plugin to do that, and..
 2. Start thinking about the fundamental question of whether we should add
 an option for enabling RTL buttons instead of having to install a plugin
 for it.

 So far, apart from WYSIWYG/TinyMCE, this only handles the direction of the
 text during writing, but does not yet address how the value is displayed,
 either within admin area, or in front-end. So:

 '''# Output'''

 Unicode does support a feature called
 [http://unicode.org/reports/tr9/#Explicit_Directional_Embeddings|
 "Explicit Directional Embeddings"]  which allows adding zero-width unicode
 characters to manage the direction of a subset of text within a larger
 string.
 [https://core.trac.wordpress.org/attachment/ticket/40194/Screen%20Shot%202017-03-18%20at%2014.22.46.png|
 Check screenshot].

 This can be easily implemented by detecting RTL characters ( or LTR ones
 in an RTL website ) at writing time, and adding the necessary RLE/LRE/PDF
 characters, or even a single ALM/LRM one, so output maintains the proper
 flow of text in either direction.

 I'll work on POCs for input/output handling, as well as the proposed
 TinyMCE plugin update.

 Would appreciate some feedback on:
 >1 Inclusion of RTL buttons in core, enabled via an option in 'Writing'
 screen, coupled with auto-detection of the first paragraph character to
 switch its direction.
 >2 Using unicode characters to manage text flow, and whether we would
 store them in database, saving the processing time of doing it on-the-fly
 on every load, or provide a filter that can be opt-in/out by users/devs,
 or doing it via JS altogether ( a bit hacky and more painful to maintain
 IMHO, given the need to select what output should be processed and what
 not ).

--
Ticket URL: <https://core.trac.wordpress.org/ticket/40194#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list