mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
parent
f878ffc01b
commit
ebe604e1af
@ -21,7 +21,18 @@ RED.actions = (function() {
|
||||
var result = [];
|
||||
Object.keys(actions).forEach(function(action) {
|
||||
var shortcut = RED.keyboard.getShortcut(action);
|
||||
result.push({id:action,scope:shortcut?shortcut.scope:undefined,key:shortcut?shortcut.key:undefined,user:shortcut?shortcut.user:undefined})
|
||||
var isUser = false;
|
||||
if (shortcut) {
|
||||
isUser = shortcut.user;
|
||||
} else {
|
||||
isUser = !!RED.keyboard.getUserShortcut(action);
|
||||
}
|
||||
result.push({
|
||||
id:action,
|
||||
scope:shortcut?shortcut.scope:undefined,
|
||||
key:shortcut?shortcut.key:undefined,
|
||||
user:isUser
|
||||
})
|
||||
})
|
||||
return result;
|
||||
}
|
||||
|
@ -70,6 +70,11 @@ RED.keyboard = (function() {
|
||||
}
|
||||
}
|
||||
}
|
||||
function getUserKey(action) {
|
||||
var currentEditorSettings = RED.settings.get('editor') || {};
|
||||
var userKeymap = currentEditorSettings.keymap || {};
|
||||
return userKeymap[action];
|
||||
}
|
||||
function init() {
|
||||
// Migrate from pre-0.18
|
||||
migrateOldKeymap();
|
||||
@ -255,6 +260,19 @@ RED.keyboard = (function() {
|
||||
var i=0;
|
||||
if (typeof key === 'string') {
|
||||
if (typeof cbdown === 'string') {
|
||||
if (!ondown && !defaultKeyMap.hasOwnProperty(cbdown)) {
|
||||
defaultKeyMap[cbdown] = {
|
||||
scope:scope,
|
||||
key:key,
|
||||
user:false
|
||||
}
|
||||
}
|
||||
if (!ondown) {
|
||||
var userAction = getUserKey(cbdown);
|
||||
if (userAction) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
actionToKeyMap[cbdown] = {scope:scope,key:key};
|
||||
if (typeof ondown === 'boolean') {
|
||||
actionToKeyMap[cbdown].user = ondown;
|
||||
@ -417,11 +435,9 @@ RED.keyboard = (function() {
|
||||
});
|
||||
revertButton.on("click", function(e) {
|
||||
e.stopPropagation();
|
||||
RED.keyboard.revertToDefault(object.id);
|
||||
container.empty();
|
||||
container.removeClass('keyboard-shortcut-entry-expanded');
|
||||
var shortcut = RED.keyboard.getShortcut(object.id);
|
||||
var userKeymap = RED.settings.get('keymap') || {};
|
||||
// var userKeymap = RED.settings.get('keymap') || {};
|
||||
|
||||
var currentEditorSettings = RED.settings.get('editor') || {};
|
||||
var userKeymap = currentEditorSettings.keymap || {};
|
||||
@ -429,6 +445,9 @@ RED.keyboard = (function() {
|
||||
currentEditorSettings.keymap = userKeymap;
|
||||
RED.settings.set('editor',currentEditorSettings);
|
||||
|
||||
RED.keyboard.revertToDefault(object.id);
|
||||
|
||||
var shortcut = RED.keyboard.getShortcut(object.id);
|
||||
var obj = {
|
||||
id:object.id,
|
||||
scope:shortcut?shortcut.scope:undefined,
|
||||
@ -589,6 +608,7 @@ RED.keyboard = (function() {
|
||||
getShortcut: function(actionName) {
|
||||
return actionToKeyMap[actionName];
|
||||
},
|
||||
getUserShortcut: getUserKey,
|
||||
revertToDefault: revertToDefault,
|
||||
formatKey: formatKey,
|
||||
validateKey: validateKey,
|
||||
|
Loading…
Reference in New Issue
Block a user