Skip to content

Commit 48da235

Browse files
committed
Rich Text: Clarify documentation around horizontal handling
1 parent a79442b commit 48da235

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

editor/components/rich-text/index.js

+13-5
Original file line numberDiff line numberDiff line change
@@ -467,16 +467,24 @@ export class RichText extends Component {
467467

468468
const isReverse = event.keyCode === LEFT;
469469

470+
// Look to previous character for ZWSP if navigating in reverse.
470471
let offset = focusOffset;
471472
if ( isReverse ) {
472473
offset--;
473474
}
474475

475-
// [WORKAROUND]: When in a new paragraph in a new inline boundary node,
476-
// while typing the zero-width space occurs as the first child instead
477-
// of at the end of the inline boundary where the caret is. This should
478-
// only be exempt when focusNode is not _only_ the ZWSP, which occurs
479-
// when caret is placed on the right outside edge of inline boundary.
476+
// Workaround: In a new inline boundary node, the zero-width space
477+
// wrongly lingers at the beginning of the node, rather than following
478+
// the caret. If we are at the extent of the inline boundary, but the
479+
// ZWSP exists at the beginning, consider as though it were to be
480+
// handled as a transition outside the inline boundary.
481+
//
482+
// Since this condition could also be satisfied in the case that we're
483+
// on the right edge of an inline boundary -- where the ZWSP exists as
484+
// as an otherwise empty focus node -- ensure that the focus node is
485+
// non-empty.
486+
//
487+
// See: https://github.com/tinymce/tinymce/issues/4472
480488
if ( ! isReverse && focusOffset === nodeValue.length &&
481489
nodeValue.length > 1 && nodeValue[ 0 ] === TINYMCE_ZWSP ) {
482490
offset = 0;

0 commit comments

Comments
 (0)