diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/actions.js b/packages/node_modules/@node-red/editor-client/src/js/ui/actions.js index 6da89a394..8ebc97cda 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/ui/actions.js +++ b/packages/node_modules/@node-red/editor-client/src/js/ui/actions.js @@ -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; } diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/keyboard.js b/packages/node_modules/@node-red/editor-client/src/js/ui/keyboard.js index a202957ae..f8ade40c3 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/ui/keyboard.js +++ b/packages/node_modules/@node-red/editor-client/src/js/ui/keyboard.js @@ -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,