Skip to content

Build your personal knowledge base with Trilium Notes

feat(command_palette): differentiate tree-based operations

Elian Doran1565a0fd808d
diff --git a/apps/client/src/services/command_registry.ts b/apps/client/src/services/command_registry.ts
index 965f7eaac8..3d73501e41 100644
--- a/apps/client/src/services/command_registry.ts
+++ b/apps/client/src/services/command_registry.ts
@@ -1,5 +1,6 @@
import appContext, { type CommandNames } from "../components/app_context.js";
import type NoteTreeWidget from "../widgets/note_tree.js";
+import { t, translationsInitializedPromise } from "./i18n.js";
import keyboardActions, { Action } from "./keyboard_actions.js";
export interface CommandDefinition {
@@ -150,6 +151,7 @@ class CommandRegistry {
private async loadKeyboardActionsAsync() {
try {
+ await translationsInitializedPromise;
const actions = await keyboardActions.getActions();
this.registerKeyboardActions(actions);
} catch (error) {
@@ -172,10 +174,15 @@ class CommandRegistry {
// Get the primary shortcut (first one in the list)
const primaryShortcut = action.effectiveShortcuts?.[0];
+ let name = action.friendlyName;
+ if (action.scope === "note-tree") {
+ name = t("command_palette.tree-action-name", { name: action.friendlyName });
+ }
+
// Create a command definition from the keyboard action
const commandDef: CommandDefinition = {
id: action.actionName,
- name: action.friendlyName,
+ name,
description: action.description,
icon: action.iconClass,
shortcut: primaryShortcut ? this.formatShortcut(primaryShortcut) : undefined,
diff --git a/apps/client/src/services/i18n.ts b/apps/client/src/services/i18n.ts
index 25c98fe396..a85df588ce 100644
--- a/apps/client/src/services/i18n.ts
+++ b/apps/client/src/services/i18n.ts
@@ -6,6 +6,11 @@ import type { Locale } from "@triliumnext/commons";
let locales: Locale[] | null;
+/**
+ * A deferred promise that resolves when translations are initialized.
+ */
+export let translationsInitializedPromise = jQuery.Deferred();
+
export async function initLocale() {
const locale = (options.get("locale") as string) || "en";
@@ -19,6 +24,8 @@ export async function initLocale() {
},
returnEmptyString: false
});
+
+ translationsInitializedPromise.resolve();
}
export function getAvailableLocales() {
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json
index 7fd0bc7003..651291b209 100644
--- a/apps/client/src/translations/en/translation.json
+++ b/apps/client/src/translations/en/translation.json
@@ -1987,5 +1987,8 @@
"delete-column-confirmation": "Are you sure you want to delete this column? The corresponding attribute will be deleted in the notes under this column as well.",
"new-item": "New item",
"add-column": "Add Column"
+ },
+ "command_palette": {
+ "tree-action-name": "Tree: {{name}}"
}
}