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
fix(client): type errors due to command change
Elian Doran2ab22e7b0ed5
diff --git a/src/public/app/components/app_context.ts b/src/public/app/components/app_context.tsindex 029182a865..408abd62d0 100644--- a/src/public/app/components/app_context.ts+++ b/src/public/app/components/app_context.ts@@ -56,7 +56,7 @@ export interface ContextMenuCommandData extends CommandData {}export interface NoteCommandData extends CommandData {- notePath: string;+ notePath?: string;hoistedNoteId?: string;viewScope?: ViewScope;}@@ -79,6 +79,7 @@ export type CommandMappings = {ancestorNoteId?: string | null;};closeTocCommand: CommandData;+ closeHlt: CommandData;showLaunchBarSubtree: CommandData;showRevisions: CommandData;showOptions: CommandData & {@@ -113,6 +114,8 @@ export type CommandMappings = {openNoteInNewTab: CommandData;openNoteInNewSplit: CommandData;openNoteInNewWindow: CommandData;+ openAboutDialog: CommandData;+ hideFloatingButtons: {};hideLeftPane: CommandData;showLeftPane: CommandData;hoistNote: CommandData & { noteId: string };@@ -129,7 +132,7 @@ export type CommandMappings = {protectSubtree: ContextMenuCommandData;unprotectSubtree: ContextMenuCommandData;openBulkActionsDialog: ContextMenuCommandData | {- selectedOrActiveNoteIds: string[]+ selectedOrActiveNoteIds?: string[]};editBranchPrefix: ContextMenuCommandData;convertNoteToAttachment: ContextMenuCommandData;@@ -186,6 +189,7 @@ export type CommandMappings = {importMarkdownInline: CommandData;showPasswordNotSet: CommandData;showProtectedSessionPasswordDialog: CommandData;+ showUploadAttachmentsDialog: CommandData & { noteId: string };closeProtectedSessionPasswordDialog: CommandData;copyImageReferenceToClipboard: CommandData;copyImageToClipboard: CommandData;@@ -209,6 +213,7 @@ export type CommandMappings = {screen: Screen;};closeTab: CommandData;+ closeToc: CommandData;closeOtherTabs: CommandData;closeRightTabs: CommandData;closeAllTabs: CommandData;@@ -227,15 +232,20 @@ export type CommandMappings = {scrollContainerToCommand: CommandData & {position: number;};- moveThisNoteSplit: CommandData & {- isMovingLeft: boolean;- };+ scrollToEnd: CommandData;+ closeThisNoteSplit: CommandData;+ moveThisNoteSplit: CommandData & { isMovingLeft: boolean; };// GeomapdeleteFromMap: { noteId: string },openGeoLocation: { noteId: string, event: JQuery.MouseDownEvent }toggleZenMode: CommandData;++ updateAttributeList: CommandData & { attributes: Attribute[] };+ saveAttributes: CommandData;+ reloadAttributes: CommandData;+ refreshNoteList: CommandData & { noteId: string; };};type EventMappings = {@@ -336,7 +346,6 @@ type EventMappings = {showToc: {noteId: string;};- scrollToEnd: { ntxId: string };noteTypeMimeChanged: { noteId: string };zenModeChanged: { isEnabled: boolean };};diff --git a/src/public/app/components/component.ts b/src/public/app/components/component.tsindex ad35e911df..416449fc76 100644--- a/src/public/app/components/component.ts+++ b/src/public/app/components/component.ts@@ -80,8 +80,7 @@ export class TypedComponent<ChildT extends TypedComponent<ChildT>> {return promises.length > 0 ? Promise.all(promises) : null;}- triggerCommand<K extends CommandNames>(name: K, _data?: CommandMappings[K]): Promise<unknown> | undefined | null {- const data = _data || {};+ triggerCommand<K extends CommandNames>(name: K, data?: CommandMappings[K]): Promise<unknown> | undefined | null {const fun = (this as any)[`${name}Command`];if (fun) {diff --git a/src/public/app/menus/launcher_context_menu.ts b/src/public/app/menus/launcher_context_menu.tsindex bc219e5918..3aa436632c 100644--- a/src/public/app/menus/launcher_context_menu.ts+++ b/src/public/app/menus/launcher_context_menu.ts@@ -21,8 +21,8 @@ export default class LauncherContextMenu implements SelectMenuItemEventListener<async show(e: PointerEvent | JQuery.TouchStartEvent | JQuery.ContextMenuEvent) {contextMenu.show({- x: e.pageX,- y: e.pageY,+ x: e.pageX ?? 0,+ y: e.pageY ?? 0,items: await this.getMenuItems(),selectMenuItemHandler: (item, e) => this.selectMenuItemHandler(item)});diff --git a/src/public/app/menus/tree_context_menu.ts b/src/public/app/menus/tree_context_menu.tsindex c1bf3b07bd..96872b4842 100644--- a/src/public/app/menus/tree_context_menu.ts+++ b/src/public/app/menus/tree_context_menu.ts@@ -31,8 +31,8 @@ export default class TreeContextMenu implements SelectMenuItemEventListener<Treeasync show(e: PointerEvent | JQuery.TouchStartEvent | JQuery.ContextMenuEvent) {contextMenu.show({- x: e.pageX,- y: e.pageY,+ x: e.pageX ?? 0,+ y: e.pageY ?? 0,items: await this.getMenuItems(),selectMenuItemHandler: (item, e) => this.selectMenuItemHandler(item)});diff --git a/src/public/app/services/hoisted_note.ts b/src/public/app/services/hoisted_note.tsindex 597de9467d..f41f08e066 100644--- a/src/public/app/services/hoisted_note.ts+++ b/src/public/app/services/hoisted_note.ts@@ -1,5 +1,5 @@import appContext from "../components/app_context.js";-import treeService, { type Node } from "./tree.js";+import treeService from "./tree.js";import dialogService from "./dialog.js";import froca from "./froca.js";import type NoteContext from "../components/note_context.js";@@ -19,11 +19,11 @@ async function unhoist() {}}-function isTopLevelNode(node: Node) {+function isTopLevelNode(node: Fancytree.FancytreeNode) {return isHoistedNode(node.getParent());}-function isHoistedNode(node: Node) {+function isHoistedNode(node: Fancytree.FancytreeNode) {// even though check for 'root' should not be necessary, we keep it just in casereturn node.data.noteId === "root" || node.data.noteId === getHoistedNoteId();}diff --git a/src/routes/api/special_notes.ts b/src/routes/api/special_notes.tsindex cf339794bd..b443f9ec3e 100644--- a/src/routes/api/special_notes.ts+++ b/src/routes/api/special_notes.ts@@ -3,7 +3,7 @@import dateNoteService from "../../services/date_notes.js";import sql from "../../services/sql.js";import cls from "../../services/cls.js";-import specialNotesService from "../../services/special_notes.js";+import specialNotesService, { type LauncherType } from "../../services/special_notes.js";import becca from "../../becca/becca.js";import type { Request } from "express";@@ -85,7 +85,8 @@ function getHoistedNote() {function createLauncher(req: Request) {return specialNotesService.createLauncher({parentNoteId: req.params.parentNoteId,- launcherType: req.params.launcherType+ // TODO: Validate the parameter+ launcherType: req.params.launcherType as LauncherType});}diff --git a/src/services/special_notes.ts b/src/services/special_notes.tsindex c8dded954e..11c0fd2bc1 100644--- a/src/services/special_notes.ts+++ b/src/services/special_notes.ts@@ -156,9 +156,11 @@ function createScriptLauncher(parentNoteId: string, forceNoteId?: string) {return note;}+export type LauncherType = "launcher" | "note" | "script" | "customWidget" | "spacer";+interface LauncherConfig {parentNoteId: string;- launcherType: "launcher" | "note" | "script" | "customWidget" | "spacer";+ launcherType: LauncherType;noteId?: string;}