Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
chore(client/ts): port components/main_tree_executors
Elian Doran68d4f9f507f5
diff --git a/src/public/app/components/app_context.ts b/src/public/app/components/app_context.tsindex d755d826e4..5b0749c013 100644--- a/src/public/app/components/app_context.ts+++ b/src/public/app/components/app_context.ts@@ -21,6 +21,7 @@ import { ConfirmWithMessageOptions, ConfirmWithTitleOptions } from "../widgets/dimport { Node } from "../services/tree.js";import LoadResults from "../services/load_results.js";import { Attribute } from "../services/attribute_parser.js";+import NoteTreeWidget from "../widgets/note_tree.js";interface Layout {getRootWidget: (appContext: AppContext) => RootWidget;@@ -149,6 +150,13 @@ export type CommandMappings = {addNewRelation: CommandData;addNewLabelDefinition: CommandData;addNewRelationDefinition: CommandData;++ cloneNoteIdsTo: CommandData & {+ noteIds: string[];+ };+ moveBranchIdsTo: CommandData & {+ branchIds: string[];+ };}type EventMappings = {@@ -204,6 +212,7 @@ class AppContext extends Component {beforeUnloadListeners: WeakRef<BeforeUploadListener>[];tabManager!: TabManager;layout?: Layout;+ noteTreeWidget?: NoteTreeWidget;constructor(isMainWindow: boolean) {super();diff --git a/src/public/app/components/main_tree_executors.js b/src/public/app/components/main_tree_executors.tssimilarity index 92%rename from src/public/app/components/main_tree_executors.jsrename to src/public/app/components/main_tree_executors.tsindex 956d652c83..9446176d4e 100644--- a/src/public/app/components/main_tree_executors.js+++ b/src/public/app/components/main_tree_executors.ts@@ -15,12 +15,20 @@ export default class MainTreeExecutors extends Component {}async cloneNotesToCommand() {+ if (!this.tree) {+ return;+ }+const selectedOrActiveNoteIds = this.tree.getSelectedOrActiveNodes().map(node => node.data.noteId);this.triggerCommand('cloneNoteIdsTo', {noteIds: selectedOrActiveNoteIds});}async moveNotesToCommand() {+ if (!this.tree) {+ return;+ }+const selectedOrActiveBranchIds = this.tree.getSelectedOrActiveNodes().map(node => node.data.branchId);this.triggerCommand('moveBranchIdsTo', {branchIds: selectedOrActiveBranchIds});@@ -40,6 +48,10 @@ export default class MainTreeExecutors extends Component {}async createNoteAfterCommand() {+ if (!this.tree) {+ return;+ }+const node = this.tree.getActiveNode();if (!node) {