diff --git a/data/shortcuts.json b/data/shortcuts.json index 39a81889f..5097a8965 100644 --- a/data/shortcuts.json +++ b/data/shortcuts.json @@ -62,12 +62,12 @@ "text": "shortcuts.browsing.display_options.map_data" }, { - "modifiers": ["⌃","⌘"], + "modifiers": ["⌃", "⌘"], "shortcuts": ["F", "F11"], "text": "shortcuts.browsing.display_options.fullscreen" }, { - "shortcuts": ["sidebar.key"], + "shortcuts": ["sidebar.key", "`", "²"], "text": "shortcuts.browsing.display_options.sidebar" }, { @@ -127,19 +127,19 @@ "text": "shortcuts.browsing.vertex_selected.previous" }, { - "shortcuts": ["]","↘"], + "shortcuts": ["]", "↘"], "text": "shortcuts.browsing.vertex_selected.next" }, { - "shortcuts": ["{","⇞"], + "shortcuts": ["{", "⇞"], "text": "shortcuts.browsing.vertex_selected.first" }, { - "shortcuts": ["}","⇟"], + "shortcuts": ["}", "⇟"], "text": "shortcuts.browsing.vertex_selected.last" }, { - "shortcuts": ["\\","shortcuts.key.pause"], + "shortcuts": ["\\", "shortcuts.key.pause"], "text": "shortcuts.browsing.vertex_selected.change_parent" } ] @@ -173,7 +173,7 @@ "text": "shortcuts.editing.drawing.add_note" }, { - "shortcuts": ["Left-click","shortcuts.key.space"], + "shortcuts": ["Left-click", "shortcuts.key.space"], "text": "shortcuts.editing.drawing.place_point" }, { @@ -181,7 +181,7 @@ "text": "shortcuts.editing.drawing.disable_snap" }, { - "shortcuts": ["↵","⎋"], + "shortcuts": ["↵", "⎋"], "text": "shortcuts.editing.drawing.stop_line" }, { @@ -204,7 +204,7 @@ "text": "shortcuts.editing.commands.undo" }, { - "modifiers": ["⌘","⇧"], + "modifiers": ["⌘", "⇧"], "shortcuts": ["Z"], "text": "shortcuts.editing.commands.redo" }, @@ -294,22 +294,22 @@ "text": "shortcuts.tools.info.all" }, { - "modifiers": ["⌘","⇧"], + "modifiers": ["⌘", "⇧"], "shortcuts": ["info_panels.background.key"], "text": "shortcuts.tools.info.background" }, { - "modifiers": ["⌘","⇧"], + "modifiers": ["⌘", "⇧"], "shortcuts": ["info_panels.history.key"], "text": "shortcuts.tools.info.history" }, { - "modifiers": ["⌘","⇧"], + "modifiers": ["⌘", "⇧"], "shortcuts": ["info_panels.location.key"], "text": "shortcuts.tools.info.location" }, { - "modifiers": ["⌘","⇧"], + "modifiers": ["⌘", "⇧"], "shortcuts": ["info_panels.measurement.key"], "text": "shortcuts.tools.info.measurement" } diff --git a/modules/ui/init.js b/modules/ui/init.js index 0ec03e0d7..ac45e1b44 100644 --- a/modules/ui/init.js +++ b/modules/ui/init.js @@ -1,5 +1,3 @@ -import _uniq from 'lodash-es/uniq'; - import { event as d3_event, select as d3_select @@ -300,10 +298,9 @@ export function uiInit(context) { var panPixels = 80; - var sidebarKeys = _uniq([t('sidebar.key'), '`', '²']); // #5663 context.keybinding() .on('⌫', function() { d3_event.preventDefault(); }) - .on(sidebarKeys, ui.sidebar.toggle) + .on([t('sidebar.key'), '`', '²'], ui.sidebar.toggle) // #5663 - common QWERTY, AZERTY .on('←', pan([panPixels, 0])) .on('↑', pan([0, panPixels])) .on('→', pan([-panPixels, 0])) diff --git a/modules/ui/shortcuts.js b/modules/ui/shortcuts.js index 99c31e9bd..e9d95cb87 100644 --- a/modules/ui/shortcuts.js +++ b/modules/ui/shortcuts.js @@ -179,11 +179,14 @@ export function uiShortcuts(context) { arr = ['Y']; } else if (detected.os !== 'mac' && d.text === 'shortcuts.browsing.display_options.fullscreen') { arr = ['F11']; - } else if (d.text === 'shortcuts.browsing.display_options.sidebar') { - arr = _uniq([t('sidebar.key'), '`', '²']); // #5663 } - return arr.map(function(s) { + // replace translations + arr = arr.map(function(s) { + return uiCmd.display(s.indexOf('.') !== -1 ? t(s) : s); + }); + + return _uniq(arr).map(function(s) { return { shortcut: s, separator: d.separator @@ -195,17 +198,14 @@ export function uiShortcuts(context) { var selection = d3_select(this); var click = d.shortcut.toLowerCase().match(/(.*).click/); - if (click && click[1]) { + if (click && click[1]) { // replace "left_click", "right_click" with mouse icon selection .call(svgIcon('#iD-walkthrough-mouse', 'mouseclick', click[1])); } else { selection .append('kbd') .attr('class', 'shortcut') - .text(function (d) { - var key = d.shortcut; - return key.indexOf('.') !== -1 ? uiCmd.display(t(key)) : uiCmd.display(key); - }); + .text(function (d) { return d.shortcut; }); } if (i < nodes.length - 1) { diff --git a/modules/util/keybinding.js b/modules/util/keybinding.js index ec643b09c..6ca9ab1db 100644 --- a/modules/util/keybinding.js +++ b/modules/util/keybinding.js @@ -1,4 +1,5 @@ import _isFunction from 'lodash-es/isFunction'; +import _uniq from 'lodash-es/uniq'; import { event as d3_event, @@ -125,7 +126,7 @@ export function utilKeybinding(namespace) { // Remove one or more keycode bindings. keybinding.off = function(codes, capture) { - var arr = [].concat(codes); + var arr = _uniq([].concat(codes)); for (var i = 0; i < arr.length; i++) { var id = arr[i] + (capture ? '-capture' : '-bubble'); @@ -141,7 +142,7 @@ export function utilKeybinding(namespace) { return keybinding.off(codes, capture); } - var arr = [].concat(codes); + var arr = _uniq([].concat(codes)); for (var i = 0; i < arr.length; i++) { var id = arr[i] + (capture ? '-capture' : '-bubble');