mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Fix keymap entries with multiple keys for same action
This commit is contained in:
parent
3dc696b2a9
commit
39532a9d65
@ -76,20 +76,29 @@ RED.keyboard = (function() {
|
||||
}
|
||||
|
||||
function mergeKeymaps(defaultKeymap, themeKeymap) {
|
||||
// defaultKeymap has format: { scope: { action: key , action: key }}
|
||||
// defaultKeymap has format: { scope: { key: action , key: action }}
|
||||
// themeKeymap has format: {action: {scope,key}, action: {scope:key}}
|
||||
|
||||
|
||||
var mergedKeymap = {};
|
||||
for (var scope in defaultKeymap) {
|
||||
if (defaultKeymap.hasOwnProperty(scope)) {
|
||||
var keys = defaultKeymap[scope];
|
||||
for (var key in keys) {
|
||||
if (keys.hasOwnProperty(key)) {
|
||||
mergedKeymap[keys[key]] = {
|
||||
if (!mergedKeymap[keys[key]]) {
|
||||
mergedKeymap[keys[key]] = [{
|
||||
scope:scope,
|
||||
key:key,
|
||||
user:false
|
||||
};
|
||||
}];
|
||||
} else {
|
||||
mergedKeymap[keys[key]].push({
|
||||
scope:scope,
|
||||
key:key,
|
||||
user:false
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -100,13 +109,13 @@ RED.keyboard = (function() {
|
||||
// No key for this action - default is no keybinding
|
||||
delete mergedKeymap[action]
|
||||
} else {
|
||||
mergedKeymap[action] = {
|
||||
mergedKeymap[action] = [{
|
||||
scope: themeKeymap[action].scope || "*",
|
||||
key: themeKeymap[action].key,
|
||||
key: [themeKeymap[action].key],
|
||||
user: false
|
||||
}
|
||||
if (mergedKeymap[action].scope === "workspace") {
|
||||
mergedKeymap[action].scope = "red-ui-workspace";
|
||||
}]
|
||||
if (mergedKeymap[action][0].scope === "workspace") {
|
||||
mergedKeymap[action][0].scope = "red-ui-workspace";
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -121,15 +130,17 @@ RED.keyboard = (function() {
|
||||
var userKeymap = RED.settings.get('editor.keymap', {});
|
||||
$.getJSON("red/keymap.json",function(defaultKeymap) {
|
||||
var keymap = mergeKeymaps(defaultKeymap, RED.settings.theme('keymap',{}));
|
||||
// keymap has the format: {action: {scope,key}, action: {scope:key}}
|
||||
// keymap has the format: {action: [{scope,key},{scope,key}], action: [{scope:key}]}
|
||||
|
||||
var action;
|
||||
for (action in keymap) {
|
||||
if (keymap.hasOwnProperty(action)) {
|
||||
if (!userKeymap.hasOwnProperty(action)) {
|
||||
addHandler(keymap[action].scope,keymap[action].key,action,false);
|
||||
keymap[action].forEach(function(km) {
|
||||
addHandler(km.scope,km.key,action,false);
|
||||
});
|
||||
}
|
||||
defaultKeyMap[action] = keymap[action];
|
||||
defaultKeyMap[action] = keymap[action][0];
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user