From faf497687ff124717848c514efb2814c700c376a Mon Sep 17 00:00:00 2001 From: Daniel Richards Date: Thu, 9 Aug 2018 16:13:36 +0800 Subject: [PATCH] Update list of key shortcuts for the help modal --- .../keyboard-shortcut-help-modal/config.js | 29 +++++++++-- .../test/__snapshots__/index.js.snap | 48 +++++++++++++++---- packages/keycodes/src/index.js | 4 ++ 3 files changed, 67 insertions(+), 14 deletions(-) diff --git a/edit-post/components/keyboard-shortcut-help-modal/config.js b/edit-post/components/keyboard-shortcut-help-modal/config.js index 10090e8dadf435..7916d9fb895359 100644 --- a/edit-post/components/keyboard-shortcut-help-modal/config.js +++ b/edit-post/components/keyboard-shortcut-help-modal/config.js @@ -5,10 +5,17 @@ import { displayShortcutList } from '@wordpress/keycodes'; import { __ } from '@wordpress/i18n'; const { + // Cmd+ on a mac, Ctrl+ elsewhere primary, + // Shift+Cmd+ on a mac, Ctrl+Shift+ elsewhere primaryShift, + // Shift+Alt+Cmd+ on a mac, Ctrl+Shift+Akt+ elsewhere secondary, + // Ctrl+Alt+ on a mac, Shift+Alt+ elsewhere access, + ctrl, + ctrlShift, + shiftAlt, } = displayShortcutList; const globalShortcuts = { @@ -34,6 +41,22 @@ const globalShortcuts = { keyCombination: primaryShift( ',' ), description: __( 'Show or hide the settings sidebar.' ), }, + { + keyCombination: ctrl( '`' ), + description: __( 'Navigate to a the next part of the editor.' ), + }, + { + keyCombination: ctrlShift( '`' ), + description: __( 'Navigate to the previous part of the editor.' ), + }, + { + keyCombination: shiftAlt( 'n' ), + description: __( 'Navigate to a the next part of the editor (alternative).' ), + }, + { + keyCombination: shiftAlt( 'p' ), + description: __( 'Navigate to the previous part of the editor (alternative).' ), + }, { keyCombination: secondary( 'm' ), description: __( 'Switch between Visual Editor and Code Editor.' ), @@ -46,7 +69,7 @@ const selectionShortcuts = { shortcuts: [ { keyCombination: primary( 'a' ), - description: __( 'Select all text if typing, otherwise select all blocks.' ), + description: __( 'Select all text when typing. Press again to select all blocks.' ), }, { keyCombination: 'Esc', @@ -58,10 +81,6 @@ const selectionShortcuts = { const blockShortcuts = { title: __( 'Block shortcuts' ), shortcuts: [ - { - keyCombination: primary( 'del' ), - description: __( 'Delete the selected block(s).' ), - }, { keyCombination: primaryShift( 'd' ), description: __( 'Duplicate the selected block(s).' ), diff --git a/edit-post/components/keyboard-shortcut-help-modal/test/__snapshots__/index.js.snap b/edit-post/components/keyboard-shortcut-help-modal/test/__snapshots__/index.js.snap index 3834e744c3996e..601341308ffeed 100644 --- a/edit-post/components/keyboard-shortcut-help-modal/test/__snapshots__/index.js.snap +++ b/edit-post/components/keyboard-shortcut-help-modal/test/__snapshots__/index.js.snap @@ -72,6 +72,44 @@ exports[`KeyboardShortcutHelpModal should match snapshot when the modal is activ ",", ], }, + Object { + "description": "Navigate to a the next part of the editor.", + "keyCombination": Array [ + "Ctrl", + "+", + "\`", + ], + }, + Object { + "description": "Navigate to the previous part of the editor.", + "keyCombination": Array [ + "Ctrl", + "+", + "Shift", + "+", + "\`", + ], + }, + Object { + "description": "Navigate to a the next part of the editor (alternative).", + "keyCombination": Array [ + "Shift", + "+", + "Alt", + "+", + "N", + ], + }, + Object { + "description": "Navigate to the previous part of the editor (alternative).", + "keyCombination": Array [ + "Shift", + "+", + "Alt", + "+", + "P", + ], + }, Object { "description": "Switch between Visual Editor and Code Editor.", "keyCombination": Array [ @@ -93,7 +131,7 @@ exports[`KeyboardShortcutHelpModal should match snapshot when the modal is activ shortcuts={ Array [ Object { - "description": "Select all text if typing, otherwise select all blocks.", + "description": "Select all text when typing. Press again to select all blocks.", "keyCombination": Array [ "Ctrl", "+", @@ -112,14 +150,6 @@ exports[`KeyboardShortcutHelpModal should match snapshot when the modal is activ key="2" shortcuts={ Array [ - Object { - "description": "Delete the selected block(s).", - "keyCombination": Array [ - "Ctrl", - "+", - "Del", - ], - }, Object { "description": "Duplicate the selected block(s).", "keyCombination": Array [ diff --git a/packages/keycodes/src/index.js b/packages/keycodes/src/index.js index 352ba465706f61..eb8f7df62755c0 100644 --- a/packages/keycodes/src/index.js +++ b/packages/keycodes/src/index.js @@ -49,6 +49,10 @@ const modifiers = { primaryShift: ( _isMac ) => _isMac() ? [ SHIFT, COMMAND ] : [ CTRL, SHIFT ], secondary: ( _isMac ) => _isMac() ? [ SHIFT, ALT, COMMAND ] : [ CTRL, SHIFT, ALT ], access: ( _isMac ) => _isMac() ? [ CTRL, ALT ] : [ SHIFT, ALT ], + ctrl: () => [ CTRL ], + ctrlShift: () => [ CTRL, SHIFT ], + shift: () => [ SHIFT ], + shiftAlt: () => [ SHIFT, ALT ], }; /**