mirror of https://github.com/artf/grapesjs.git
nocodeframeworkdrag-and-dropsite-buildersite-generatortemplate-builderui-builderweb-builderweb-builder-frameworkwebsite-builderno-codepage-builder
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1.8 KiB
1.8 KiB
isString
This module allows to create shortcuts for functions and commands (via command id)
You can access the module in this way
const keymaps = editor.Keymaps;
getConfig
Get module configurations
Returns Object Configuration object
add
Add new keymap
Parameters
idstring Keymap idkeysstring Keymap keys, eg.ctrl+a,⌘+z, ctrl+zhandler(Function | string) Keymap handler, might be a function
Examples
// 'ns' is just a custom namespace
keymaps.add('ns:my-keymap', '⌘+j, ⌘+u, ctrl+j, alt+u', editor => {
console.log('do stuff');
});
// or
keymaps.add('ns:my-keymap', '⌘+s, ctrl+s', 'some-gjs-command');
// listen to events
editor.on('keymap:emit', (id, shortcut, e) => {
// ...
})
Returns Object Added keymap or just a command id as a string
get
Get the keymap by id
Parameters
idstring Keymap id
Examples
keymaps.get('ns:my-keymap');
// -> {keys, handler};
Returns Object Keymap object
getAll
Get all keymaps
Examples
keymaps.getAll();
// -> {id1: {}, id2: {}};
Returns Object
remove
Remove the keymap by id
Parameters
idstring Keymap id
Examples
keymaps.remove('ns:my-keymap');
// -> {keys, handler};
Returns Object Removed keymap