From 726d6aad6522ce566b9c01d7ab3355216dacd5ff Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Thu, 11 Dec 2025 22:01:22 +0200 Subject: [PATCH] feat(layout): integrate note map --- .../src/components/root_command_executor.ts | 16 ++++++++++++++++ apps/client/src/services/link.ts | 2 +- apps/client/src/services/utils.ts | 2 +- apps/client/src/translations/en/translation.json | 3 ++- apps/client/src/widgets/NoteDetail.tsx | 4 +++- apps/client/src/widgets/ribbon/NoteActions.tsx | 1 + apps/client/src/widgets/ribbon/Ribbon.tsx | 2 +- .../src/widgets/ribbon/RibbonDefinition.ts | 2 +- apps/client/src/widgets/type_widgets/NoteMap.tsx | 7 +++++-- 9 files changed, 31 insertions(+), 8 deletions(-) diff --git a/apps/client/src/components/root_command_executor.ts b/apps/client/src/components/root_command_executor.ts index 4a1c987f7..dc614f555 100644 --- a/apps/client/src/components/root_command_executor.ts +++ b/apps/client/src/components/root_command_executor.ts @@ -193,6 +193,22 @@ export default class RootCommandExecutor extends Component { appContext.triggerEvent("zenModeChanged", { isEnabled }); } + async toggleRibbonTabNoteMapCommand() { + const { isExperimentalFeatureEnabled } = await import("../services/experimental_features.js"); + const isNewLayout = isExperimentalFeatureEnabled("new-layout"); + if (!isNewLayout) return; + + const activeContext = appContext.tabManager.getActiveContext(); + if (!activeContext) return; + + const subContexts = activeContext.getSubContexts(); + appContext.triggerCommand("openNewNoteSplit", { + ntxId: subContexts[subContexts.length - 1].ntxId, + notePath: activeContext.notePath, + viewScope: { viewMode: "note-map" } + }); + } + firstTabCommand() { this.#goToTab(1); } diff --git a/apps/client/src/services/link.ts b/apps/client/src/services/link.ts index 79bc18c2a..4ff3a39cf 100644 --- a/apps/client/src/services/link.ts +++ b/apps/client/src/services/link.ts @@ -27,7 +27,7 @@ async function getLinkIcon(noteId: string, viewMode: ViewMode | undefined) { return icon; } -export type ViewMode = "default" | "source" | "attachments" | "contextual-help"; +export type ViewMode = "default" | "source" | "attachments" | "contextual-help" | "note-map"; export interface ViewScope { /** diff --git a/apps/client/src/services/utils.ts b/apps/client/src/services/utils.ts index 2c999690d..aa4f0cebc 100644 --- a/apps/client/src/services/utils.ts +++ b/apps/client/src/services/utils.ts @@ -460,7 +460,7 @@ export async function openInAppHelpFromUrl(inAppHelpPage: string) { notePath: targetNote, hoistedNoteId: "_help", viewScope - }) + }); } else { // There is already a help window open, make sure it opens on the right note. helpSubcontext.setNote(targetNote, { viewScope }); diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json index 2e63ef777..7f49dea52 100644 --- a/apps/client/src/translations/en/translation.json +++ b/apps/client/src/translations/en/translation.json @@ -694,7 +694,8 @@ "convert_into_attachment_failed": "Converting note '{{title}}' failed.", "convert_into_attachment_successful": "Note '{{title}}' has been converted to attachment.", "convert_into_attachment_prompt": "Are you sure you want to convert note '{{title}}' into an attachment of the parent note?", - "print_pdf": "Export as PDF..." + "print_pdf": "Export as PDF...", + "note_map": "Note map" }, "onclick_button": { "no_click_handler": "Button widget '{{componentId}}' has no defined click handler" diff --git a/apps/client/src/widgets/NoteDetail.tsx b/apps/client/src/widgets/NoteDetail.tsx index 272385d25..a5bc62916 100644 --- a/apps/client/src/widgets/NoteDetail.tsx +++ b/apps/client/src/widgets/NoteDetail.tsx @@ -299,8 +299,10 @@ async function getWidgetType(note: FNote | null | undefined, noteContext: NoteCo if (noteContext?.viewScope?.viewMode === "source") { resultingType = "readOnlyCode"; - } else if (noteContext?.viewScope && noteContext.viewScope.viewMode === "attachments") { + } else if (noteContext.viewScope?.viewMode === "attachments") { resultingType = noteContext.viewScope.attachmentId ? "attachmentDetail" : "attachmentList"; + } else if (noteContext.viewScope?.viewMode === "note-map") { + resultingType = "noteMap"; } else if (type === "text" && (await noteContext?.isReadOnly())) { resultingType = "readOnlyText"; } else if ((type === "code" || type === "mermaid") && (await noteContext?.isReadOnly())) { diff --git a/apps/client/src/widgets/ribbon/NoteActions.tsx b/apps/client/src/widgets/ribbon/NoteActions.tsx index 85ce63013..3d1f8b4cc 100644 --- a/apps/client/src/widgets/ribbon/NoteActions.tsx +++ b/apps/client/src/widgets/ribbon/NoteActions.tsx @@ -116,6 +116,7 @@ function NoteContextMenu({ note, noteContext }: { note: FNote, noteContext?: Not + {isNewLayout && } {glob.isDev && <> diff --git a/apps/client/src/widgets/ribbon/Ribbon.tsx b/apps/client/src/widgets/ribbon/Ribbon.tsx index 3afd39b56..aff2c148f 100644 --- a/apps/client/src/widgets/ribbon/Ribbon.tsx +++ b/apps/client/src/widgets/ribbon/Ribbon.tsx @@ -67,7 +67,7 @@ export default function Ribbon({ children }: { children?: preact.ComponentChildr useTriliumEvents(eventsToListenTo, useCallback((e, toggleCommand) => { if (!computedTabs) return; const correspondingTab = computedTabs.find(tab => tab.toggleCommand === toggleCommand); - if (correspondingTab) { + if (correspondingTab?.shouldShow) { if (activeTabIndex !== correspondingTab.index) { setActiveTabIndex(correspondingTab.index); } else { diff --git a/apps/client/src/widgets/ribbon/RibbonDefinition.ts b/apps/client/src/widgets/ribbon/RibbonDefinition.ts index d29cd181f..0be6b9147 100644 --- a/apps/client/src/widgets/ribbon/RibbonDefinition.ts +++ b/apps/client/src/widgets/ribbon/RibbonDefinition.ts @@ -119,7 +119,7 @@ export const RIBBON_TAB_DEFINITIONS: TabConfiguration[] = [ title: t("note_map.title"), icon: "bx bxs-network-chart", content: NoteMapTab, - show: true, + show: !isNewLayout, toggleCommand: "toggleRibbonTabNoteMap" }, { diff --git a/apps/client/src/widgets/type_widgets/NoteMap.tsx b/apps/client/src/widgets/type_widgets/NoteMap.tsx index aca9f68d1..3f33fe586 100644 --- a/apps/client/src/widgets/type_widgets/NoteMap.tsx +++ b/apps/client/src/widgets/type_widgets/NoteMap.tsx @@ -3,12 +3,15 @@ import NoteMapEl from "../note_map/NoteMap"; import { useRef } from "preact/hooks"; import "./NoteMap.css"; -export default function NoteMap({ note }: TypeWidgetProps) { +export default function NoteMap({ note, noteContext }: TypeWidgetProps) { const containerRef = useRef(null); return (
- +
); }