Skip to content

Commit

Permalink
Zoom out: Add keyboard shortcut in block editor
Browse files Browse the repository at this point in the history
  • Loading branch information
ntsekouras committed Oct 24, 2024
1 parent e9fb510 commit 8cdf4d5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/block-editor/src/components/block-tools/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ export default function BlockTools( {
moveBlocksUp,
moveBlocksDown,
expandBlock,
setZoomLevel,
resetZoomLevel,
} = unlock( useDispatch( blockEditorStore ) );

function onKeyDown( event ) {
Expand Down Expand Up @@ -175,6 +177,12 @@ export default function BlockTools( {
replaceBlocks( clientIds, newBlocks );
speak( __( 'Selected blocks are grouped.' ) );
}
} else if ( isMatch( 'core/block-editor/zoom', event ) ) {
if ( isZoomOutMode ) {
resetZoomLevel();
} else {
setZoomLevel( 'auto-scaled' );
}
}
}
const blockToolbarRef = usePopoverScroll( __unstableContentRef );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,15 @@ function KeyboardShortcutsRegister() {
character: 'g',
},
} );
registerShortcut( {
name: 'core/block-editor/zoom',
category: 'global',
description: __( 'Enter or exit zoom out.' ),
keyCombination: {
modifier: 'primaryShift',
character: 'z',
},
} );
}, [ registerShortcut ] );

return null;
Expand Down

0 comments on commit 8cdf4d5

Please sign in to comment.