|
|
|
@ -12,9 +12,21 @@ import { isString } from 'underscore'; |
|
|
|
const keymaster = require('keymaster'); |
|
|
|
|
|
|
|
module.exports = () => { |
|
|
|
let em; |
|
|
|
let config; |
|
|
|
const configDef = {}; |
|
|
|
const keymaps = {}; |
|
|
|
const configDef = { |
|
|
|
defaults: { |
|
|
|
'core:undo': { |
|
|
|
keys: '⌘+z, ctrl+z', |
|
|
|
handler: 'core:undo', |
|
|
|
}, |
|
|
|
'core:redo': { |
|
|
|
keys: '⌘+shift+z, ctrl+shift+z', |
|
|
|
handler: 'core:redo', |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
return { |
|
|
|
|
|
|
|
@ -39,11 +51,23 @@ module.exports = () => { |
|
|
|
* @private |
|
|
|
*/ |
|
|
|
init(opts = {}) { |
|
|
|
config = { ...opts, ...configDef }; |
|
|
|
this.em = config.em; |
|
|
|
config = { ...configDef, ...opts }; |
|
|
|
em = config.em; |
|
|
|
this.em = em; |
|
|
|
return this; |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
onLoad() { |
|
|
|
const defKeys = config.defaults; |
|
|
|
|
|
|
|
for (let id in defKeys) { |
|
|
|
const value = defKeys[id]; |
|
|
|
this.add(id, value.keys, value.handler); |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* Add new keymap |
|
|
|
* @param {string} id Keymap id |
|
|
|
|