[wp-trac] [WordPress Trac] #36585: Editor: wptextpattern: space-triggered patterns are unreliable
WordPress Trac
noreply at wordpress.org
Tue Apr 19 03:54:18 UTC 2016
#36585: Editor: wptextpattern: space-triggered patterns are unreliable
--------------------------+-----------------------------
Reporter: jnylen0 | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: TinyMCE | Version: trunk
Severity: normal | Keywords:
Focuses: javascript |
--------------------------+-----------------------------
In wptextpattern, the
[https://codex.wordpress.org/Keyboard_Shortcuts#Formatting_Shortcuts
keyboard shortcuts for adding lists] are somewhat unreliable.
For example, typing `* ` or `- ` starts an unordered list. This
reformatting is performed upon receiving the `keyup` event of the space
key ([https://github.com/WordPress/WordPress/blob/4.5/wp-
includes/js/tinymce/plugins/wptextpattern/plugin.js#L67-L69 ref]), and it
is only performed if the current cursor position matches the length of the
`* ` patttern ([https://github.com/WordPress/WordPress/blob/4.5/wp-
includes/js/tinymce/plugins/wptextpattern/plugin.js#L207-L209 ref]).
This means that the following sequence of key events does not result in
conversion of the current line to a list:
- (Start on a blank line)
- Press and release `-`
- Press the spacebar but do not release it
- Press `a`
- Release the spacebar
- Release `a`
The attached patch removes the check for the cursor position. I'm not
sure why this check is there, and I couldn't find any breakage from
removing it. Also, I'm not sure why we need to call `setCursorLocation`,
but this doesn't work well in the situation I've described above (it puts
the cursor before the additional `a` character).
cc @iseulde @azaozz
--
Ticket URL: <https://core.trac.wordpress.org/ticket/36585>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list