diff --git a/apps/client/src/menus/context_menu.ts b/apps/client/src/menus/context_menu.ts index 4411db9dc..983c0a48c 100644 --- a/apps/client/src/menus/context_menu.ts +++ b/apps/client/src/menus/context_menu.ts @@ -1,4 +1,5 @@ -import keyboardActionService from "../services/keyboard_actions.js"; +import { KeyboardActionNames } from "@triliumnext/commons"; +import keyboardActionService, { getActionSync } from "../services/keyboard_actions.js"; import note_tooltip from "../services/note_tooltip.js"; import utils from "../services/utils.js"; @@ -38,6 +39,7 @@ export interface MenuCommandItem { handler?: MenuHandler; items?: MenuItem[] | null; shortcut?: string; + keyboardShortcut?: KeyboardActionNames; spellingSuggestion?: string; checked?: boolean; columns?: number; @@ -185,7 +187,23 @@ class ContextMenu { } } - if ("shortcut" in item && item.shortcut) { + if ("keyboardShortcut" in item && item.keyboardShortcut) { + const shortcuts = getActionSync(item.keyboardShortcut).effectiveShortcuts; + if (shortcuts) { + const allShortcuts: string[] = []; + for (const effectiveShortcut of shortcuts) { + allShortcuts.push(effectiveShortcut.split("+") + .map(key => `${key}`) + .join("+")); + } + + if (allShortcuts.length) { + const container = $("").addClass("keyboard-shortcut"); + container.append($(allShortcuts.join(","))); + $link.append(container); + } + } + } else if ("shortcut" in item && item.shortcut) { $link.append($("").text(item.shortcut)); } diff --git a/apps/client/src/menus/tree_context_menu.ts b/apps/client/src/menus/tree_context_menu.ts index 7181261a8..4ef517912 100644 --- a/apps/client/src/menus/tree_context_menu.ts +++ b/apps/client/src/menus/tree_context_menu.ts @@ -76,27 +76,29 @@ export default class TreeContextMenu implements SelectMenuItemEventListener | null)[] = [ - { title: `${t("tree-context-menu.open-in-a-new-tab")}`, command: "openInTab", uiIcon: "bx bx-link-external", enabled: noSelectedNotes }, + { title: t("tree-context-menu.open-in-a-new-tab"), command: "openInTab", shortcut: "Ctrl+Click", uiIcon: "bx bx-link-external", enabled: noSelectedNotes }, { title: t("tree-context-menu.open-in-a-new-split"), command: "openNoteInSplit", uiIcon: "bx bx-dock-right", enabled: noSelectedNotes }, { title: t("tree-context-menu.open-in-popup"), command: "openNoteInPopup", uiIcon: "bx bx-edit", enabled: noSelectedNotes }, isHoisted ? null : { - title: `${t("tree-context-menu.hoist-note")} `, + title: `${t("tree-context-menu.hoist-note")}`, command: "toggleNoteHoisting", + keyboardShortcut: "toggleNoteHoisting", uiIcon: "bx bxs-chevrons-up", enabled: noSelectedNotes && notSearch }, !isHoisted || !isNotRoot ? null - : { title: `${t("tree-context-menu.unhoist-note")} `, command: "toggleNoteHoisting", uiIcon: "bx bx-door-open" }, + : { title: t("tree-context-menu.unhoist-note"), command: "toggleNoteHoisting", keyboardShortcut: "toggleNoteHoisting", uiIcon: "bx bx-door-open" }, { title: "----" }, { - title: `${t("tree-context-menu.insert-note-after")}`, + title: t("tree-context-menu.insert-note-after"), command: "insertNoteAfter", + keyboardShortcut: "createNoteAfter", uiIcon: "bx bx-plus", items: insertNoteAfterEnabled ? await noteTypesService.getNoteTypeItems("insertNoteAfter") : null, enabled: insertNoteAfterEnabled && noSelectedNotes && notOptionsOrHelp, @@ -104,8 +106,9 @@ export default class TreeContextMenu implements SelectMenuItemEventListener`, + title: t("tree-context-menu.insert-child-note"), command: "insertChildNote", + keyboardShortcut: "createNoteInto", uiIcon: "bx bx-plus", items: notSearch ? await noteTypesService.getNoteTypeItems("insertChildNote") : null, enabled: notSearch && noSelectedNotes && notOptionsOrHelp, @@ -130,8 +133,9 @@ export default class TreeContextMenu implements SelectMenuItemEventListener`, + title: t("tree-context-menu.edit-branch-prefix"), command: "editBranchPrefix", + keyboardShortcut: "editBranchPrefix", uiIcon: "bx bx-rename", enabled: isNotRoot && parentNotSearch && noSelectedNotes && notOptionsOrHelp }, @@ -139,11 +143,12 @@ export default class TreeContextMenu implements SelectMenuItemEventListener`, command: "expandSubtree", uiIcon: "bx bx-expand", enabled: noSelectedNotes }, - { title: `${t("tree-context-menu.collapse-subtree")} `, command: "collapseSubtree", uiIcon: "bx bx-collapse", enabled: noSelectedNotes }, + { title: t("tree-context-menu.expand-subtree"), command: "expandSubtree", keyboardShortcut: "expandSubtree", uiIcon: "bx bx-expand", enabled: noSelectedNotes }, + { title: t("tree-context-menu.collapse-subtree"), command: "collapseSubtree", keyboardShortcut: "collapseSubtree", uiIcon: "bx bx-collapse", enabled: noSelectedNotes }, { - title: `${t("tree-context-menu.sort-by")} `, + title: t("tree-context-menu.sort-by"), command: "sortChildNotes", + keyboardShortcut: "sortChildNotes", uiIcon: "bx bx-sort-down", enabled: noSelectedNotes && notSearch }, @@ -158,17 +163,19 @@ export default class TreeContextMenu implements SelectMenuItemEventListener`, + title: t("tree-context-menu.cut"), command: "cutNotesToClipboard", + keyboardShortcut: "cutNotesToClipboard", uiIcon: "bx bx-cut", enabled: isNotRoot && !isHoisted && parentNotSearch }, - { title: `${t("tree-context-menu.copy-clone")} `, command: "copyNotesToClipboard", uiIcon: "bx bx-copy", enabled: isNotRoot && !isHoisted }, + { title: t("tree-context-menu.copy-clone"), command: "copyNotesToClipboard", keyboardShortcut: "copyNotesToClipboard", uiIcon: "bx bx-copy", enabled: isNotRoot && !isHoisted }, { - title: `${t("tree-context-menu.paste-into")} `, + title: t("tree-context-menu.paste-into"), command: "pasteNotesFromClipboard", + keyboardShortcut: "pasteNotesFromClipboard", uiIcon: "bx bx-paste", enabled: !clipboard.isClipboardEmpty() && notSearch && noSelectedNotes }, @@ -181,17 +188,19 @@ export default class TreeContextMenu implements SelectMenuItemEventListener`, + title: t("tree-context-menu.move-to"), command: "moveNotesTo", + keyboardShortcut: "moveNotesTo", uiIcon: "bx bx-transfer", enabled: isNotRoot && !isHoisted && parentNotSearch }, - { title: `${t("tree-context-menu.clone-to")} `, command: "cloneNotesTo", uiIcon: "bx bx-duplicate", enabled: isNotRoot && !isHoisted }, + { title: t("tree-context-menu.clone-to"), command: "cloneNotesTo", keyboardShortcut: "cloneNotesTo", uiIcon: "bx bx-duplicate", enabled: isNotRoot && !isHoisted }, { - title: `${t("tree-context-menu.duplicate")} `, + title: t("tree-context-menu.duplicate"), command: "duplicateSubtree", + keyboardShortcut: "duplicateSubtree", uiIcon: "bx bx-outline", enabled: parentNotSearch && isNotRoot && !isHoisted && notOptionsOrHelp }, @@ -225,8 +234,9 @@ export default class TreeContextMenu implements SelectMenuItemEventListener`, + title: t("tree-context-menu.delete"), command: "deleteNotes", + keyboardShortcut: "deleteNotes", uiIcon: "bx bx-trash destructive-action-icon", enabled: isNotRoot && !isHoisted && parentNotSearch && notOptionsOrHelp }, @@ -240,8 +250,9 @@ export default class TreeContextMenu implements SelectMenuItemEventListener`, + title: t("tree-context-menu.search-in-subtree"), command: "searchInSubtree", + keyboardShortcut: "searchInSubtree", uiIcon: "bx bx-search", enabled: notSearch && noSelectedNotes } diff --git a/apps/client/src/translations/cn/translation.json b/apps/client/src/translations/cn/translation.json index 4de4f3463..175b4928c 100644 --- a/apps/client/src/translations/cn/translation.json +++ b/apps/client/src/translations/cn/translation.json @@ -1426,7 +1426,7 @@ "button-tree-map": "树形地图" }, "tree-context-menu": { - "open-in-a-new-tab": "在新标签页中打开 Ctrl+Click", + "open-in-a-new-tab": "在新标签页中打开", "open-in-a-new-split": "在新分栏中打开", "insert-note-after": "在后面插入笔记", "insert-child-note": "插入子笔记", diff --git a/apps/client/src/translations/de/translation.json b/apps/client/src/translations/de/translation.json index f8b097b55..6037a51c6 100644 --- a/apps/client/src/translations/de/translation.json +++ b/apps/client/src/translations/de/translation.json @@ -1376,7 +1376,7 @@ "button-tree-map": "Baumkarte" }, "tree-context-menu": { - "open-in-a-new-tab": "In neuem Tab öffnen Strg+Klick", + "open-in-a-new-tab": "In neuem Tab öffnen", "open-in-a-new-split": "In neuem Split öffnen", "insert-note-after": "Notiz dahinter einfügen", "insert-child-note": "Unternotiz einfügen", diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json index a052de13c..af9c47ee3 100644 --- a/apps/client/src/translations/en/translation.json +++ b/apps/client/src/translations/en/translation.json @@ -1590,7 +1590,7 @@ "button-tree-map": "Tree map" }, "tree-context-menu": { - "open-in-a-new-tab": "Open in a new tab Ctrl+Click", + "open-in-a-new-tab": "Open in a new tab", "open-in-a-new-split": "Open in a new split", "insert-note-after": "Insert note after", "insert-child-note": "Insert child note", diff --git a/apps/client/src/translations/es/translation.json b/apps/client/src/translations/es/translation.json index 545815a58..d040703e2 100644 --- a/apps/client/src/translations/es/translation.json +++ b/apps/client/src/translations/es/translation.json @@ -1563,7 +1563,7 @@ "button-tree-map": "Mapa de Árbol" }, "tree-context-menu": { - "open-in-a-new-tab": "Abrir en nueva pestaña Ctrl+Click", + "open-in-a-new-tab": "Abrir en nueva pestaña", "open-in-a-new-split": "Abrir en nueva división", "insert-note-after": "Insertar nota después de", "insert-child-note": "Insertar subnota", diff --git a/apps/client/src/translations/fr/translation.json b/apps/client/src/translations/fr/translation.json index 82e41ae33..377a23ff0 100644 --- a/apps/client/src/translations/fr/translation.json +++ b/apps/client/src/translations/fr/translation.json @@ -1357,7 +1357,7 @@ "button-tree-map": "Carte de l'arborescence" }, "tree-context-menu": { - "open-in-a-new-tab": "Ouvrir dans un nouvel onglet Ctrl+Clic", + "open-in-a-new-tab": "Ouvrir dans un nouvel onglet", "open-in-a-new-split": "Ouvrir dans une nouvelle division", "insert-note-after": "Insérer une note après", "insert-child-note": "Insérer une note enfant", diff --git a/apps/client/src/translations/ja/translation.json b/apps/client/src/translations/ja/translation.json index 2a89c0c33..f81a18b21 100644 --- a/apps/client/src/translations/ja/translation.json +++ b/apps/client/src/translations/ja/translation.json @@ -365,7 +365,7 @@ }, "tree-context-menu": { "advanced": "高度", - "open-in-a-new-tab": "新しいタブで開く Ctrl+Click", + "open-in-a-new-tab": "新しいタブで開く", "open-in-a-new-split": "新しく分割して開く", "insert-note-after": "ノートを後ろに挿入", "insert-child-note": "子ノートを挿入", diff --git a/apps/client/src/translations/pt_br/translation.json b/apps/client/src/translations/pt_br/translation.json index 09173533a..4d6cc3c4f 100644 --- a/apps/client/src/translations/pt_br/translation.json +++ b/apps/client/src/translations/pt_br/translation.json @@ -744,7 +744,7 @@ "button-tree-map": "Mapa em Árvore" }, "tree-context-menu": { - "open-in-a-new-tab": "Abrir em uma nova aba Ctrl+Click", + "open-in-a-new-tab": "Abrir em uma nova aba", "open-in-a-new-split": "Abrir em um novo painel dividido", "insert-note-after": "Inserir nota após", "insert-child-note": "Inserir nota filha", diff --git a/apps/client/src/translations/ro/translation.json b/apps/client/src/translations/ro/translation.json index 19cc921a1..72c70f526 100644 --- a/apps/client/src/translations/ro/translation.json +++ b/apps/client/src/translations/ro/translation.json @@ -1377,7 +1377,7 @@ "insert-note-after": "Inserează după notiță", "move-to": "Mutare la...", "open-in-a-new-split": "Deschide în lateral", - "open-in-a-new-tab": "Deschide în tab nou Ctrl+Clic", + "open-in-a-new-tab": "Deschide în tab nou", "paste-after": "Lipește după notiță", "paste-into": "Lipește în notiță", "protect-subtree": "Protejează ierarhia", diff --git a/apps/client/src/translations/ru/translation.json b/apps/client/src/translations/ru/translation.json index fdd0338fa..cf16095a6 100644 --- a/apps/client/src/translations/ru/translation.json +++ b/apps/client/src/translations/ru/translation.json @@ -809,7 +809,7 @@ "cut": "Вырезать", "duplicate": "Создать дубликат", "export": "Экспорт", - "open-in-a-new-tab": "Открыть в новой вкладке Ctrl+Click", + "open-in-a-new-tab": "Открыть в новой вкладке", "open-in-a-new-split": "Открыть в новой панели", "unhoist-note": "Отрепить заметку", "hoist-note": "Закрепить заметку", diff --git a/apps/client/src/translations/tw/translation.json b/apps/client/src/translations/tw/translation.json index 3fdfaf8dc..432f561a2 100644 --- a/apps/client/src/translations/tw/translation.json +++ b/apps/client/src/translations/tw/translation.json @@ -1385,7 +1385,7 @@ "button-tree-map": "樹狀地圖" }, "tree-context-menu": { - "open-in-a-new-tab": "在新分頁中打開 Ctrl+Click", + "open-in-a-new-tab": "在新分頁中打開", "open-in-a-new-split": "在新頁面分割中打開", "insert-note-after": "在後面插入筆記", "insert-child-note": "插入子筆記", diff --git a/apps/client/src/translations/uk/translation.json b/apps/client/src/translations/uk/translation.json index 0ae0273b5..cad50a27b 100644 --- a/apps/client/src/translations/uk/translation.json +++ b/apps/client/src/translations/uk/translation.json @@ -1897,7 +1897,7 @@ "button-tree-map": "Карта дерева" }, "tree-context-menu": { - "open-in-a-new-tab": "Відкрити в новій вкладці Ctrl+Клік", + "open-in-a-new-tab": "Відкрити в новій вкладці", "open-in-a-new-split": "Відкрити в новому розділі", "insert-note-after": "Вставити нотатку після", "insert-child-note": "Вставити дочірню нотатку",