Skip to content

Commit

Permalink
Rich Text: Clarify documentation around horizontal handling
Browse files Browse the repository at this point in the history
  • Loading branch information
aduth committed Jun 29, 2018
1 parent a79442b commit 48da235
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions editor/components/rich-text/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -467,16 +467,24 @@ export class RichText extends Component {

const isReverse = event.keyCode === LEFT;

// Look to previous character for ZWSP if navigating in reverse.
let offset = focusOffset;
if ( isReverse ) {
offset--;
}

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

0 comments on commit 48da235

Please sign in to comment.