From 2ad834fe5bd5bc4ef51a36fa795d7a37e7fda668 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Wed, 16 Apr 2025 14:55:00 +0300 Subject: [PATCH] fix(client): unable to trigger move to dialog via keyboard shortcut --- docs/Release Notes/Release Notes/v0.93.0.md | 1 + src/public/app/components/app_context.ts | 4 ++-- src/public/app/components/main_tree_executors.ts | 16 ++++++++++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/docs/Release Notes/Release Notes/v0.93.0.md b/docs/Release Notes/Release Notes/v0.93.0.md index dfa83b73b..8015bd79e 100644 --- a/docs/Release Notes/Release Notes/v0.93.0.md +++ b/docs/Release Notes/Release Notes/v0.93.0.md @@ -16,6 +16,7 @@ * [Return correct HTTP status code on failed login attempts instead of 200](https://github.com/TriliumNext/Notes/issues/1707) by @pano9000 * [Calendar stops displaying notes after adding a Day Note](https://github.com/TriliumNext/Notes/issues/1705) * Full anonymization not redacting attachment titles. +* Unable to trigger "Move to" dialog via keyboard shortcut. ## ✨ Improvements diff --git a/src/public/app/components/app_context.ts b/src/public/app/components/app_context.ts index 68f50218a..ff1f3fa50 100644 --- a/src/public/app/components/app_context.ts +++ b/src/public/app/components/app_context.ts @@ -53,8 +53,8 @@ export interface ContextMenuCommandData extends CommandData { node: Fancytree.FancytreeNode; notePath?: string; noteId?: string; - selectedOrActiveBranchIds?: any; // TODO: Remove any once type is defined - selectedOrActiveNoteIds: any; // TODO: Remove any once type is defined + selectedOrActiveBranchIds: string[]; + selectedOrActiveNoteIds?: string[]; } export interface NoteCommandData extends CommandData { diff --git a/src/public/app/components/main_tree_executors.ts b/src/public/app/components/main_tree_executors.ts index 984da0656..9bc037ccf 100644 --- a/src/public/app/components/main_tree_executors.ts +++ b/src/public/app/components/main_tree_executors.ts @@ -18,10 +18,26 @@ export default class MainTreeExecutors extends Component { } async cloneNotesToCommand({ selectedOrActiveNoteIds }: EventData<"cloneNotesTo">) { + if (!selectedOrActiveNoteIds && this.tree) { + selectedOrActiveNoteIds = this.tree.getSelectedOrActiveNodes().map((node) => node.data.noteId); + } + + if (!selectedOrActiveNoteIds) { + return; + } + this.triggerCommand("cloneNoteIdsTo", { noteIds: selectedOrActiveNoteIds }); } async moveNotesToCommand({ selectedOrActiveBranchIds }: EventData<"moveNotesTo">) { + if (!selectedOrActiveBranchIds && this.tree) { + selectedOrActiveBranchIds = this.tree.getSelectedOrActiveNodes().map((node) => node.data.branchId); + } + + if (!selectedOrActiveBranchIds) { + return; + } + this.triggerCommand("moveBranchIdsTo", { branchIds: selectedOrActiveBranchIds }); }