From bf79be101b1493fb694c4bc47b6f9689241babcb Mon Sep 17 00:00:00 2001 From: yogeshbhutkar Date: Thu, 9 Jan 2025 12:04:43 +0530 Subject: [PATCH] Keyboard Shortcuts: Registered `cut` and `copy` as block level shortcuts --- .../block-settings-dropdown.js | 11 ++++------ .../components/keyboard-shortcuts/index.js | 20 +++++++++++++++++++ 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/packages/block-editor/src/components/block-settings-menu/block-settings-dropdown.js b/packages/block-editor/src/components/block-settings-menu/block-settings-dropdown.js index 9e26943e22ea7..1e3ab72647521 100644 --- a/packages/block-editor/src/components/block-settings-menu/block-settings-dropdown.js +++ b/packages/block-editor/src/components/block-settings-menu/block-settings-dropdown.js @@ -11,7 +11,6 @@ import { useDispatch, useSelect } from '@wordpress/data'; import { moreVertical } from '@wordpress/icons'; import { Children, cloneElement } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; -import { displayShortcut } from '@wordpress/keycodes'; import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts'; import { pipe, useCopyToClipboard } from '@wordpress/compose'; @@ -137,6 +136,8 @@ export function BlockSettingsDropdown( { const shortcuts = useSelect( ( select ) => { const { getShortcutRepresentation } = select( keyboardShortcutsStore ); return { + copy: getShortcutRepresentation( 'core/block-editor/copy' ), + cut: getShortcutRepresentation( 'core/block-editor/cut' ), duplicate: getShortcutRepresentation( 'core/block-editor/duplicate' ), @@ -276,18 +277,14 @@ export function BlockSettingsDropdown( { { + registerShortcut( { + name: 'core/block-editor/copy', + category: 'block', + description: __( 'Copy the selected block(s).' ), + keyCombination: { + modifier: 'primary', + character: 'c', + }, + } ); + + registerShortcut( { + name: 'core/block-editor/cut', + category: 'block', + description: __( 'Cut the selected block(s).' ), + keyCombination: { + modifier: 'primary', + character: 'x', + }, + } ); + registerShortcut( { name: 'core/block-editor/duplicate', category: 'block',