diff --git a/packages/editor/src/components/global-keyboard-shortcuts/index.js b/packages/editor/src/components/global-keyboard-shortcuts/index.js index a46d4b55a7bfd8..1837529c1694da 100644 --- a/packages/editor/src/components/global-keyboard-shortcuts/index.js +++ b/packages/editor/src/components/global-keyboard-shortcuts/index.js @@ -10,6 +10,7 @@ import { store as blockEditorStore } from '@wordpress/block-editor'; * Internal dependencies */ import { store as editorStore } from '../../store'; +import { unlock } from '../../lock-unlock'; /** * Handles the keyboard shortcuts for the editor. @@ -24,7 +25,12 @@ export default function EditorKeyboardShortcuts() { select( editorStore ).getEditorSettings(); return ! richEditingEnabled || ! codeEditingEnabled; }, [] ); - const { getBlockSelectionStart } = useSelect( blockEditorStore ); + const { getBlockSelectionStart, isZoomOut } = unlock( + useSelect( blockEditorStore ) + ); + const { setZoomLevel, resetZoomLevel } = unlock( + useDispatch( blockEditorStore ) + ); const { getActiveComplementaryArea } = useSelect( interfaceStore ); const { enableComplementaryArea, disableComplementaryArea } = useDispatch( interfaceStore ); @@ -118,5 +124,13 @@ export default function EditorKeyboardShortcuts() { } } ); + useShortcut( 'core/editor/zoom', () => { + if ( isZoomOut() ) { + resetZoomLevel(); + } else { + setZoomLevel( 'auto-scaled' ); + } + } ); + return null; } diff --git a/packages/editor/src/components/global-keyboard-shortcuts/register-shortcuts.js b/packages/editor/src/components/global-keyboard-shortcuts/register-shortcuts.js index 26a07166c106c4..c4bbec42ed9503 100644 --- a/packages/editor/src/components/global-keyboard-shortcuts/register-shortcuts.js +++ b/packages/editor/src/components/global-keyboard-shortcuts/register-shortcuts.js @@ -144,6 +144,16 @@ function EditorKeyboardShortcutsRegister() { }, ], } ); + + registerShortcut( { + name: 'core/editor/zoom', + category: 'global', + description: __( 'Enter or exit zoom out.' ), + keyCombination: { + modifier: 'primaryShift', + character: 'z', + }, + } ); }, [ registerShortcut ] ); return ;