From f98ac84829f83f120d88bc0a81a689f642294831 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sun, 13 Apr 2025 21:42:28 +0300 Subject: [PATCH] feat(touchbar): delete note in note tree --- src/public/app/widgets/note_tree.ts | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/public/app/widgets/note_tree.ts b/src/public/app/widgets/note_tree.ts index 7fc801ecb..961432df9 100644 --- a/src/public/app/widgets/note_tree.ts +++ b/src/public/app/widgets/note_tree.ts @@ -25,6 +25,8 @@ import type FNote from "../entities/fnote.js"; import type { NoteType } from "../entities/fnote.js"; import type { AttributeRow, BranchRow } from "../services/load_results.js"; import type { SetNoteOpts } from "../components/note_context.js"; +import type { TouchBarItem } from "./touch_bar.js"; +import type { TreeCommandNames } from "../menus/tree_context_menu.js"; const TPL = /*html*/`
@@ -1760,4 +1762,28 @@ export default class NoteTreeWidget extends NoteContextAwareWidget { appContext.tabManager.getActiveContext()?.setNote(resp.note.noteId); } + + buildTouchBarCommand({ TouchBar, buildIcon }: CommandListenerData<"buildTouchBar">) { + const triggerCommand = (command: TreeCommandNames) => { + const node = this.getActiveNode(); + const notePath = treeService.getNotePath(node); + + this.triggerCommand(command, { + node, + notePath, + noteId: node.data.noteId, + selectedOrActiveBranchIds: this.getSelectedOrActiveBranchIds(node), + selectedOrActiveNoteIds: this.getSelectedOrActiveNoteIds(node) + }); + } + + const items: TouchBarItem[] = [ + new TouchBar.TouchBarButton({ + icon: buildIcon("NSImageNameTouchBarDeleteTemplate"), + click: () => triggerCommand("deleteNotes") + }) + ]; + + return items; + } }