UNPKG

@wordpress/editor

Version:
141 lines (139 loc) 4.16 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _element = require("@wordpress/element"); var _data = require("@wordpress/data"); var _i18n = require("@wordpress/i18n"); var _blockEditor = require("@wordpress/block-editor"); var _keyboardShortcuts = require("@wordpress/keyboard-shortcuts"); var _keycodes = require("@wordpress/keycodes"); var _jsxRuntime = require("react/jsx-runtime"); /** * WordPress dependencies */ /** * Component for registering editor keyboard shortcuts. * * @return {Element} The component to be rendered. */function EditorKeyboardShortcutsRegister() { // Registering the shortcuts. const { registerShortcut } = (0, _data.useDispatch)(_keyboardShortcuts.store); (0, _element.useEffect)(() => { registerShortcut({ name: 'core/editor/toggle-mode', category: 'global', description: (0, _i18n.__)('Switch between visual editor and code editor.'), keyCombination: { modifier: 'secondary', character: 'm' } }); registerShortcut({ name: 'core/editor/save', category: 'global', description: (0, _i18n.__)('Save your changes.'), keyCombination: { modifier: 'primary', character: 's' } }); registerShortcut({ name: 'core/editor/undo', category: 'global', description: (0, _i18n.__)('Undo your last changes.'), keyCombination: { modifier: 'primary', character: 'z' } }); registerShortcut({ name: 'core/editor/redo', category: 'global', description: (0, _i18n.__)('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: (0, _keycodes.isAppleOS)() ? [] : [{ modifier: 'primary', character: 'y' }] }); registerShortcut({ name: 'core/editor/toggle-list-view', category: 'global', description: (0, _i18n.__)('Open the List View.'), keyCombination: { modifier: 'access', character: 'o' } }); registerShortcut({ name: 'core/editor/toggle-distraction-free', category: 'global', description: (0, _i18n.__)('Toggle distraction free mode.'), keyCombination: { modifier: 'primaryShift', character: '\\' } }); registerShortcut({ name: 'core/editor/toggle-sidebar', category: 'global', description: (0, _i18n.__)('Show or hide the Settings sidebar.'), keyCombination: { modifier: 'primaryShift', character: ',' } }); registerShortcut({ name: 'core/editor/keyboard-shortcuts', category: 'main', description: (0, _i18n.__)('Display these keyboard shortcuts.'), keyCombination: { modifier: 'access', character: 'h' } }); registerShortcut({ name: 'core/editor/next-region', category: 'global', description: (0, _i18n.__)('Navigate to the next part of the editor.'), keyCombination: { modifier: 'ctrl', character: '`' }, aliases: [{ modifier: 'access', character: 'n' }] }); registerShortcut({ name: 'core/editor/previous-region', category: 'global', description: (0, _i18n.__)('Navigate to the previous part of the editor.'), keyCombination: { modifier: 'ctrlShift', character: '`' }, aliases: [{ modifier: 'access', character: 'p' }, { modifier: 'ctrlShift', character: '~' }] }); }, [registerShortcut]); return /*#__PURE__*/(0, _jsxRuntime.jsx)(_blockEditor.BlockEditorKeyboardShortcuts.Register, {}); } var _default = exports.default = EditorKeyboardShortcutsRegister; //# sourceMappingURL=register-shortcuts.js.map