From 71cff0111ee234ea372297e29a0b06c27fbd0479 Mon Sep 17 00:00:00 2001 From: iseulde Date: Fri, 1 Mar 2019 11:12:08 +0100 Subject: [PATCH 1/3] RichText: fix wordwise selection on Windows --- packages/editor/src/components/rich-text/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/editor/src/components/rich-text/index.js b/packages/editor/src/components/rich-text/index.js index ccfe32326d944..08d0c87be6f7c 100644 --- a/packages/editor/src/components/rich-text/index.js +++ b/packages/editor/src/components/rich-text/index.js @@ -576,10 +576,10 @@ export class RichText extends Component { * @param {KeyboardEvent} event The keydown event. */ onKeyDown( event ) { - const { keyCode, shiftKey, altKey, metaKey } = event; + const { keyCode, shiftKey, altKey, metaKey, crtlKey } = event; if ( - ! shiftKey && ! altKey && ! metaKey && + ! shiftKey && ! altKey && ! metaKey && ! crtlKey && ( keyCode === LEFT || keyCode === RIGHT ) ) { this.handleHorizontalNavigation( event ); From d758f4a3528cea525c9850bd626bf0a3037cb4b0 Mon Sep 17 00:00:00 2001 From: Andrea Fercia Date: Fri, 1 Mar 2019 12:19:06 +0100 Subject: [PATCH 2/3] Fix crtl ctrl typo. --- packages/editor/src/components/rich-text/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/editor/src/components/rich-text/index.js b/packages/editor/src/components/rich-text/index.js index 08d0c87be6f7c..f3c80fbcc3772 100644 --- a/packages/editor/src/components/rich-text/index.js +++ b/packages/editor/src/components/rich-text/index.js @@ -576,10 +576,10 @@ export class RichText extends Component { * @param {KeyboardEvent} event The keydown event. */ onKeyDown( event ) { - const { keyCode, shiftKey, altKey, metaKey, crtlKey } = event; + const { keyCode, shiftKey, altKey, metaKey, ctrlKey } = event; if ( - ! shiftKey && ! altKey && ! metaKey && ! crtlKey && + ! shiftKey && ! altKey && ! metaKey && ! ctrlKey && ( keyCode === LEFT || keyCode === RIGHT ) ) { this.handleHorizontalNavigation( event ); From 11aa1c5ac11435869c61a304372ce255b629d421 Mon Sep 17 00:00:00 2001 From: iseulde Date: Fri, 1 Mar 2019 13:20:20 +0100 Subject: [PATCH 3/3] Add docs --- packages/editor/src/components/rich-text/index.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/editor/src/components/rich-text/index.js b/packages/editor/src/components/rich-text/index.js index f3c80fbcc3772..d6be0a622307e 100644 --- a/packages/editor/src/components/rich-text/index.js +++ b/packages/editor/src/components/rich-text/index.js @@ -573,12 +573,13 @@ 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, ctrlKey } = event; if ( + // Only override left and right keys without modifiers pressed. ! shiftKey && ! altKey && ! metaKey && ! ctrlKey && ( keyCode === LEFT || keyCode === RIGHT ) ) { @@ -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;