UNPKG

@wordpress/editor

Version:
49 lines (43 loc) 1.22 kB
/** * WordPress dependencies */ import { useEffect } from '@wordpress/element'; import { useDispatch } from '@wordpress/data'; import { __ } from '@wordpress/i18n'; import { BlockEditorKeyboardShortcuts } from '@wordpress/block-editor'; import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts'; function EditorKeyboardShortcutsRegister() { // Registering the shortcuts const { registerShortcut } = useDispatch( keyboardShortcutsStore ); useEffect( () => { registerShortcut( { name: 'core/editor/save', category: 'global', description: __( 'Save your changes.' ), keyCombination: { modifier: 'primary', character: 's', }, } ); registerShortcut( { name: 'core/editor/undo', category: 'global', description: __( 'Undo your last changes.' ), keyCombination: { modifier: 'primary', character: 'z', }, } ); registerShortcut( { name: 'core/editor/redo', category: 'global', description: __( 'Redo your last undo.' ), keyCombination: { modifier: 'primaryShift', character: 'z', }, } ); }, [ registerShortcut ] ); return <BlockEditorKeyboardShortcuts.Register />; } export default EditorKeyboardShortcutsRegister;