@easy-editor/plugin-hotkey
v1.0.2
Published
Hotkey plugin for EasyEditor
Maintainers
Readme
@easy-editor/plugin-hotkey
Hotkey plugin for EasyEditor.
Default Hotkeys
| Action | Shortcut | |--------|----------| | Undo | ⌘ + Z / Ctrl + Z | | Redo | ⌘ + Y / Ctrl + Y | | Lock/Unlock | ⌘ + Shift + L / Ctrl + Shift + L | | Show/Hide | ⌘ + Shift + H / Ctrl + Shift + H | | Copy | ⌘ + C / Ctrl + C | | Paste | ⌘ + V / Ctrl + V | | Cut | ⌘ + X / Ctrl + X | | Delete | Backspace / Delete | | Clear Selection | Esc |
Customizing Hotkeys
The HotkeyPlugin now supports customizing hotkeys. You can modify the key combinations or disable specific hotkeys entirely.
Example Usage
import { HotkeyPlugin } from '@easy-editor/plugin-hotkey';
HotkeyPlugin({
config: {
// Change the "undo" shortcut to only use Alt+Z
HISTORY_UNDO: {
keys: ['alt+z']
},
// Disable the "show/hide" shortcut
SHOW_HIDE: false,
// Customize "delete" to use only the Delete key
DELETE: {
keys: ['del']
},
// Explicitly enable a shortcut (default is enabled)
COPY: true
}
})Configuration Options
The configuration object accepts the following hotkey actions (all lowercase):
HISTORY_UNDO- Undo last actionHISTORY_REDO- Redo last undone actionLOCK_UNLOCK- Lock or unlock selected elementsSHOW_HIDE- Show or hide selected elementsCOPY- Copy selected elementsPASTE- Paste copied elementsCUT- Cut selected elementsDELETE- Delete selected elementsCLEAR_SELECTION- Clear the current selection
For each action, you can provide:
- A boolean value:
trueto enable (default),falseto disable - Or an object with:
enabled(boolean, optional) - Set tofalseto disable the hotkey, defaults totruekeys(string[]) - Array of key combinations to use (replaces default keys)
Key Combination Format
Key combinations should be specified in the format:
- Modifier keys:
ctrl,alt,shift,command(ormeta) - Regular keys: letter keys (a-z), number keys (0-9), special keys (
esc,del,backspace, etc.) - Combined with
+symbol, e.g.,ctrl+sorcommand+shift+z
