diff --git a/web/src/templates.js b/web/src/templates.js index 1a3e4c99a8..b78563943e 100644 --- a/web/src/templates.js +++ b/web/src/templates.js @@ -127,3 +127,14 @@ Handlebars.registerHelper("tooltip_hotkey_hints", (...hotkeys) => { const result = `${hotkey_hints}`; return new Handlebars.SafeString(result); }); + +Handlebars.registerHelper("popover_hotkey_hints", (...hotkeys) => { + hotkeys.pop(); // Handlebars options + let hotkey_hints = ""; + common.adjust_mac_hotkey_hints(hotkeys); + for (const hotkey of hotkeys) { + hotkey_hints += `${hotkey}`; + } + const result = `${hotkey_hints}`; + return new Handlebars.SafeString(result); +}); diff --git a/web/styles/popovers.css b/web/styles/popovers.css index 3fedce159a..7c1ce3f3a4 100644 --- a/web/styles/popovers.css +++ b/web/styles/popovers.css @@ -1476,17 +1476,23 @@ ul.popover-menu-outer-list { } } -.popover-menu-hotkey-hint { - color: var(--color-hotkey-hint); - text-align: center; - font-size: 14px; - font-style: normal; - font-weight: 500; - line-height: 14px; - padding: 2px 4px; - border-radius: 3px; - border: 1px solid var(--color-hotkey-hint); +.popover-menu-hotkey-hints { + display: flex; + gap: 4px; margin-left: auto; + padding-left: 5px; + + > .popover-menu-hotkey-hint { + color: var(--color-hotkey-hint); + text-align: center; + font-size: 14px; + font-style: normal; + font-weight: 500; + line-height: 14px; + padding: 2px 4px; + border-radius: 3px; + border: 1px solid var(--color-hotkey-hint); + } } #theme-switcher { diff --git a/web/templates/navbar_help_menu.hbs b/web/templates/navbar_help_menu.hbs index edd2d9a8a6..86994b491c 100644 --- a/web/templates/navbar_help_menu.hbs +++ b/web/templates/navbar_help_menu.hbs @@ -9,7 +9,8 @@ @@ -22,7 +22,7 @@ {{editability_menu_item}} - (e) + {{popover_hotkey_hints "E"}} {{/if}} @@ -31,7 +31,7 @@ {{move_message_menu_item}} - (m) + {{popover_hotkey_hints "M"}} {{/if}} @@ -53,7 +53,7 @@ {{t "Add emoji reaction" }} - (:) + {{popover_hotkey_hints ":"}} @@ -67,7 +67,7 @@ 1 {{t "Mark as unread from here" }} - (U) + {{popover_hotkey_hints "Shift" "U"}} {{/if}} @@ -84,7 +84,7 @@ {{t "Collapse message" }} - (–) + {{popover_hotkey_hints "-"}} {{/if}} @@ -93,7 +93,7 @@ {{t "Expand message" }} - (–) + {{popover_hotkey_hints "-"}} {{/if}} @@ -107,7 +107,7 @@ {{view_source_menu_item}} - (e) + {{popover_hotkey_hints "E"}} {{/if}} @@ -116,7 +116,7 @@ {{t "View read receipts" }} - (V) + {{popover_hotkey_hints "Shift" "V"}} {{/if}} diff --git a/web/tests/templates.test.js b/web/tests/templates.test.js index a12765ad6f..6cd87a31a6 100644 --- a/web/tests/templates.test.js +++ b/web/tests/templates.test.js @@ -53,3 +53,14 @@ run_test("tooltip_hotkey_hints", () => { const expected_html = `${args.hotkey_one}${args.hotkey_two}\n`; assert.equal(html, expected_html); }); + +run_test("popover_hotkey_hints", () => { + const args = { + hotkey_one: "Shift", + hotkey_two: "V", + }; + + const html = require("./templates/popover_hotkey_hints.hbs")(args); + const expected_html = `${args.hotkey_one}${args.hotkey_two}\n`; + assert.equal(html, expected_html); +}); diff --git a/web/tests/templates/popover_hotkey_hints.hbs b/web/tests/templates/popover_hotkey_hints.hbs new file mode 100644 index 0000000000..60d397ff54 --- /dev/null +++ b/web/tests/templates/popover_hotkey_hints.hbs @@ -0,0 +1 @@ +{{popover_hotkey_hints hotkey_one hotkey_two}} diff --git a/web/webpack.config.ts b/web/webpack.config.ts index e4c49aa7d1..dc0b153b69 100644 --- a/web/webpack.config.ts +++ b/web/webpack.config.ts @@ -145,6 +145,7 @@ export default ( "tr", "rendered_markdown", "tooltip_hotkey_hints", + "popover_hotkey_hints", ], precompileOptions: {strict: true}, preventIndent: true,