feat(touchbar): delete note in note tree

This commit is contained in:
Elian Doran 2025-04-13 21:42:28 +03:00
parent 9d9ed2edcb
commit f98ac84829
No known key found for this signature in database

View File

@ -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*/`
<div class="tree-wrapper">
@ -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<TreeCommandNames>(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;
}
}