Skip to content

Commit

Permalink
Remove unused keyboard shortcut registration code (#49553)
Browse files Browse the repository at this point in the history
  • Loading branch information
talldan authored Apr 4, 2023
1 parent 7754a80 commit 6a7ff78
Showing 1 changed file with 1 addition and 155 deletions.
156 changes: 1 addition & 155 deletions packages/edit-site/src/components/keyboard-shortcuts/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
/**
* WordPress dependencies
*/
import { useEffect } from '@wordpress/element';
import {
useShortcut,
store as keyboardShortcutsStore,
} from '@wordpress/keyboard-shortcuts';
import { isAppleOS } from '@wordpress/keycodes';
import { useShortcut } from '@wordpress/keyboard-shortcuts';
import { useDispatch, useSelect } from '@wordpress/data';
import { __ } from '@wordpress/i18n';
import { store as coreStore } from '@wordpress/core-data';
import { store as blockEditorStore } from '@wordpress/block-editor';
import { store as interfaceStore } from '@wordpress/interface';
Expand Down Expand Up @@ -136,152 +130,4 @@ function KeyboardShortcuts() {
return null;
}

function KeyboardShortcutsRegister() {
// Registering the shortcuts.
const { registerShortcut } = useDispatch( keyboardShortcutsStore );
useEffect( () => {
registerShortcut( {
name: 'core/edit-site/save',
category: 'global',
description: __( 'Save your changes.' ),
keyCombination: {
modifier: 'primary',
character: 's',
},
} );

registerShortcut( {
name: 'core/edit-site/undo',
category: 'global',
description: __( 'Undo your last changes.' ),
keyCombination: {
modifier: 'primary',
character: 'z',
},
} );

registerShortcut( {
name: 'core/edit-site/redo',
category: 'global',
description: __( 'Redo your last undo.' ),
keyCombination: {
modifier: 'primaryShift',
character: 'z',
},
// Disable on Apple OS because it conflicts with the browser's
// history shortcut. It's a fine alias for both Windows and Linux.
// Since there's no conflict for Ctrl+Shift+Z on both Windows and
// Linux, we keep it as the default for consistency.
aliases: isAppleOS()
? []
: [
{
modifier: 'primary',
character: 'y',
},
],
} );

registerShortcut( {
name: 'core/edit-site/toggle-list-view',
category: 'global',
description: __( 'Open the block list view.' ),
keyCombination: {
modifier: 'access',
character: 'o',
},
} );

registerShortcut( {
name: 'core/edit-site/toggle-block-settings-sidebar',
category: 'global',
description: __( 'Show or hide the block settings sidebar.' ),
keyCombination: {
modifier: 'primaryShift',
character: ',',
},
} );

registerShortcut( {
name: 'core/edit-site/keyboard-shortcuts',
category: 'main',
description: __( 'Display these keyboard shortcuts.' ),
keyCombination: {
modifier: 'access',
character: 'h',
},
} );

registerShortcut( {
name: 'core/edit-site/next-region',
category: 'global',
description: __( 'Navigate to the next part of the editor.' ),
keyCombination: {
modifier: 'ctrl',
character: '`',
},
aliases: [
{
modifier: 'access',
character: 'n',
},
],
} );

registerShortcut( {
name: 'core/edit-site/previous-region',
category: 'global',
description: __( 'Navigate to the previous part of the editor.' ),
keyCombination: {
modifier: 'ctrlShift',
character: '`',
},
aliases: [
{
modifier: 'access',
character: 'p',
},
{
modifier: 'ctrlShift',
character: '~',
},
],
} );
registerShortcut( {
name: 'core/edit-site/toggle-mode',
category: 'global',
description: __( 'Switch between visual editor and code editor.' ),
keyCombination: {
modifier: 'secondary',
character: 'm',
},
} );

registerShortcut( {
name: `core/edit-site/transform-heading-to-paragraph`,
category: 'block-library',
description: __( 'Transform heading to paragraph.' ),
keyCombination: {
modifier: 'access',
character: `0`,
},
} );

[ 1, 2, 3, 4, 5, 6 ].forEach( ( level ) => {
registerShortcut( {
name: `core/edit-site/transform-paragraph-to-heading-${ level }`,
category: 'block-library',
description: __( 'Transform paragraph to heading.' ),
keyCombination: {
modifier: 'access',
character: `${ level }`,
},
} );
} );
}, [ registerShortcut ] );

return null;
}

KeyboardShortcuts.Register = KeyboardShortcutsRegister;
export default KeyboardShortcuts;

1 comment on commit 6a7ff78

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in 6a7ff78.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4602740128
📝 Reported issues:

Please sign in to comment.