Skip to content

Commit

Permalink
RichText: fix wordwise selection on Windows (#14184)
Browse files Browse the repository at this point in the history
* RichText: fix wordwise selection on Windows

* Fix crtl ctrl typo.

* Add docs
  • Loading branch information
ellatrix authored and youknowriad committed Mar 6, 2019
1 parent 8413505 commit aec207c
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions packages/editor/src/components/rich-text/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -573,13 +573,14 @@ export class RichText extends Component {
/**
* Handles a keydown event.
*
* @param {KeyboardEvent} event The keydown event.
* @param {SyntheticEvent} event A synthetic keyboard event.
*/
onKeyDown( event ) {
const { keyCode, shiftKey, altKey, metaKey } = event;
const { keyCode, shiftKey, altKey, metaKey, ctrlKey } = event;

if (
! shiftKey && ! altKey && ! metaKey &&
// Only override left and right keys without modifiers pressed.
! shiftKey && ! altKey && ! metaKey && ! ctrlKey &&
( keyCode === LEFT || keyCode === RIGHT )
) {
this.handleHorizontalNavigation( event );
Expand Down Expand Up @@ -661,6 +662,13 @@ export class RichText extends Component {
}
}

/**
* Handles horizontal keyboard navigation when no modifiers are pressed. The
* navigation is handled separately to move correctly around format
* boundaries.
*
* @param {SyntheticEvent} event A synthetic keyboard event.
*/
handleHorizontalNavigation( event ) {
const value = this.createRecord();
const { formats, text, start, end } = value;
Expand Down

0 comments on commit aec207c

Please sign in to comment.