Skip to content

Build your personal knowledge base with Trilium Notes

refactor(client): remove the ribbon's note map tab

Elian Doran340cce464f8b
diff --git a/apps/client/src/components/root_command_executor.ts b/apps/client/src/components/root_command_executor.ts
index 68fc72b8e0..10089addd5 100644
--- a/apps/client/src/components/root_command_executor.ts
+++ b/apps/client/src/components/root_command_executor.ts
@@ -199,11 +199,9 @@ export default class RootCommandExecutor extends Component {
appContext.triggerEvent("zenModeChanged", { isEnabled });
}
- async toggleRibbonTabNoteMapCommand(data: CommandListenerData<"toggleRibbonTabNoteMap">) {
- // A phone has neither the ribbon the map was a tab of nor the pane it is a card of, so it is
- // shown the way the pane's card shows it expanded: as the quick-edit popup, which is the map at
- // the size of the window wherever there is no card to expand from. The popup carries the note's
- // title, steps aside when a note of the map is pressed, and can be taken on to a tab.
+ toggleRibbonTabNoteMapCommand() {
+ // Mobile has no right pane, so the map opens in the quick edit popup with the `note-map` view
+ // mode, the same view the sidebar card's expand button opens.
if (utils.isMobile()) {
const notePath = appContext.tabManager.getActiveContext()?.notePath;
if (notePath) {
@@ -212,18 +210,8 @@ export default class RootCommandExecutor extends Component {
return;
}
- const { isExperimentalFeatureEnabled } = await import("../services/experimental_features.js");
- const isNewLayout = isExperimentalFeatureEnabled("new-layout");
- if (!isNewLayout) {
- this.triggerEvent("toggleRibbonTabNoteMap", data);
- return;
- }
-
- // The sidebar's map is the note map of the new layout: it is the one that follows the note being
- // read, so the menu points at it rather than opening a second copy beside it that would then go
- // stale. Peeked rather than docked, as the connection badges of the status bar are: a press for
- // the tab already docked would otherwise close the pane out from under the card it is meant to
- // expand (see reduceTabSelection).
+ // Peeks the right pane rather than docking it: with the connections tab already docked,
+ // `reduceTabSelection()` closes the pane instead of expanding the card.
void appContext.triggerEvent("selectRightPaneTab", {
tabId: "connections",
peek: true,
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json
index 4f35cf803c..07f1ccb186 100644
--- a/apps/client/src/translations/en/translation.json
+++ b/apps/client/src/translations/en/translation.json
@@ -1359,9 +1359,7 @@
"show_similar_notes": "Show similar notes"
},
"note_map": {
- "open_full": "Expand to full",
"expand": "Expand map",
- "collapse": "Collapse to normal size",
"title": "Note Map",
"fix-nodes": "Fix nodes",
"link-distance": "Link distance",
diff --git a/apps/client/src/widgets/note_map/NoteMap.tsx b/apps/client/src/widgets/note_map/NoteMap.tsx
index 2464ffa316..94cc23da9e 100644
--- a/apps/client/src/widgets/note_map/NoteMap.tsx
+++ b/apps/client/src/widgets/note_map/NoteMap.tsx
@@ -242,7 +242,7 @@ export default function NoteMap({ note, widgetMode, parentRef }: NoteMapProps) {
*
* The connections tab's map is a lens on whatever note is being read, so which map it draws is the
* reader's own preference and is kept as an option (see {@link usesReaderPreference}). Everywhere
- * else the map is a note's own thing — a note map note, a hoisted map, the ribbon's tab — and the
+ * else the map is a note's own thing — a note map note or a hoisted map — and the
* note it belongs to says which to draw through its `mapType` label.
*/
function useMapType(note: FNote, widgetMode: NoteMapWidgetMode): [ MapType, (mapType: MapType) => void ] {
diff --git a/apps/client/src/widgets/note_map/rendering.ts b/apps/client/src/widgets/note_map/rendering.ts
index e5b2eaf393..5829f76186 100644
--- a/apps/client/src/widgets/note_map/rendering.ts
+++ b/apps/client/src/widgets/note_map/rendering.ts
@@ -710,8 +710,8 @@ export function createFade<T>(elements: T[], getTarget: (element: T) => number)
}
/**
- * Keeps the view framed on the interesting part of the graph — the subtree the current note belongs
- * to in the ribbon, the linked notes elsewhere — while the layout settles.
+ * Keeps the view framed on the interesting part of the graph — the notes reachable from the current
+ * note in the maps rooted at it, the linked notes elsewhere — while the layout settles.
*
* The fit runs on every tick of the simulation rather than once after a fixed delay: the layout
* keeps expanding for seconds after the data lands, so a single delayed fit leaves the map at
diff --git a/apps/client/src/widgets/note_map/utils.spec.ts b/apps/client/src/widgets/note_map/utils.spec.ts
index 83614dd6c2..9474262b79 100644
--- a/apps/client/src/widgets/note_map/utils.spec.ts
+++ b/apps/client/src/widgets/note_map/utils.spec.ts
@@ -95,7 +95,6 @@ describe("usesReaderPreference", () => {
expect(usesReaderPreference("sidebar")).toBe(true);
expect(usesReaderPreference("expanded")).toBe(true);
- expect(usesReaderPreference("ribbon")).toBe(false);
expect(usesReaderPreference("type")).toBe(false);
expect(usesReaderPreference("hoisted")).toBe(false);
});
@@ -116,8 +115,6 @@ describe("getFitPadding", () => {
// The maps with room of their own keep their fixed margins whatever is in them — the same map
// expanded to the window included, which has the room the card was short of.
- expect(getFitPadding("ribbon", 1)).toBe(50);
- expect(getFitPadding("ribbon", 500)).toBe(50);
expect(getFitPadding("expanded", 500)).toBe(50);
expect(getFitPadding("type", 500)).toBe(30);
expect(getFitPadding("hoisted", 500)).toBe(30);
diff --git a/apps/client/src/widgets/note_map/utils.ts b/apps/client/src/widgets/note_map/utils.ts
index e029bebd0c..bbeb19ff11 100644
--- a/apps/client/src/widgets/note_map/utils.ts
+++ b/apps/client/src/widgets/note_map/utils.ts
@@ -3,7 +3,7 @@
* which the card's expand button opens — the only thing that opens it — so it is that card's map
* rather than a surface of its own, and reads what the card reads.
*/
-export type NoteMapWidgetMode = "ribbon" | "sidebar" | "expanded" | "hoisted" | "type";
+export type NoteMapWidgetMode = "sidebar" | "expanded" | "hoisted" | "type";
export type MapType = "tree" | "link";
/**
@@ -27,7 +27,7 @@ export function usesReaderPreference(widgetMode: NoteMapWidgetMode) {
/** Whether the map is rooted at the note being read, rather than at a configured or hoisted note. */
export function isRootedAtCurrentNote(widgetMode: NoteMapWidgetMode) {
- return widgetMode === "ribbon" || widgetMode === "sidebar" || widgetMode === "expanded";
+ return widgetMode === "sidebar" || widgetMode === "expanded";
}
/** The map a note asks to be drawn as through its `mapType` label, the link map standing for anything else. */
@@ -39,7 +39,6 @@ export function toMapType(labelValue: string | null | undefined): MapType {
const FIT_PADDING: Record<NoteMapWidgetMode, number> = {
// The sidebar's is not a fixed one — see getFitPadding.
sidebar: 0,
- ribbon: 50,
// Not the sidebar's own, small enough that a graph fitted with room to spare is a thumbnail: what
// the card is short of, a map given the greater part of the window has plenty of.
expanded: 50,
diff --git a/apps/client/src/widgets/ribbon/NoteActions.tsx b/apps/client/src/widgets/ribbon/NoteActions.tsx
index c116187e22..221dd1afd5 100644
--- a/apps/client/src/widgets/ribbon/NoteActions.tsx
+++ b/apps/client/src/widgets/ribbon/NoteActions.tsx
@@ -135,7 +135,7 @@ export function NoteContextMenu({ note, noteContext, itemsAtStart, itemsNearNote
<CommandItem command="findInText" icon="bx bx-search" disabled={!isSearchable} text={t("note_actions.search_in_note")} />
<CommandItem command="showAttachments" icon="bx bx-paperclip" disabled={isInOptionsOrHelp} text={t("note_actions.note_attachments")} />
- {isNewLayout && <CommandItem command="toggleRibbonTabNoteMap" icon="bx bxs-network-chart" disabled={isInOptionsOrHelp} text={t("note_actions.note_map")} />}
+ <CommandItem command="toggleRibbonTabNoteMap" icon="bx bxs-network-chart" disabled={isInOptionsOrHelp} text={t("note_actions.note_map")} />
{/* The attributes panel is a right pane tab where there is a right pane; on a phone the
menu is where it is reached, and a modal is where it is shown. */}
{isMobile && <CommandItem command="showNoteAttributes" icon="bx bx-list-check" disabled={isInOptionsOrHelp} text={t("note_actions.note_attributes")} />}
diff --git a/apps/client/src/widgets/ribbon/NoteMapTab.css b/apps/client/src/widgets/ribbon/NoteMapTab.css
deleted file mode 100644
index 2300b7e03a..0000000000
--- a/apps/client/src/widgets/ribbon/NoteMapTab.css
+++ /dev/null
@@ -1,13 +0,0 @@
-.note-map-ribbon-widget {
- position: relative;
-}
-
-.note-map-ribbon-widget .note-map-container {
- height: 100%;
-}
-
-.note-map-ribbon-widget .open-full-button, .note-map-ribbon-widget .collapse-button {
- position: absolute;
- inset-inline-end: 5px;
- bottom: 5px;
-}
diff --git a/apps/client/src/widgets/ribbon/NoteMapTab.tsx b/apps/client/src/widgets/ribbon/NoteMapTab.tsx
deleted file mode 100644
index c977532205..0000000000
--- a/apps/client/src/widgets/ribbon/NoteMapTab.tsx
+++ /dev/null
@@ -1,49 +0,0 @@
-import "./NoteMapTab.css";
-
-import { TabContext } from "./ribbon-interface";
-import { useElementSize, useWindowSize } from "../react/hooks";
-import ActionButton from "../react/ActionButton";
-import { t } from "../../services/i18n";
-import { useEffect, useRef, useState } from "preact/hooks";
-import NoteMap from "../note_map/NoteMap";
-
-const SMALL_SIZE_HEIGHT = "300px";
-
-export default function NoteMapTab({ note }: TabContext) {
- const [ isExpanded, setExpanded ] = useState(false);
- const [ height, setHeight ] = useState(SMALL_SIZE_HEIGHT);
- const containerRef = useRef<HTMLDivElement>(null);
- const { windowHeight } = useWindowSize();
- const containerSize = useElementSize(containerRef);
-
- useEffect(() => {
- if (isExpanded && containerRef.current && containerSize) {
- const height = windowHeight - containerSize.top;
- setHeight(height + "px");
- } else {
- setHeight(SMALL_SIZE_HEIGHT);
- }
- }, [ isExpanded, containerRef, windowHeight, containerSize?.top ]);
-
- return (
- <div className="note-map-ribbon-widget" style={{ height }} ref={containerRef}>
- {note && <NoteMap note={note} widgetMode="ribbon" parentRef={containerRef} />}
-
- {!isExpanded ? (
- <ActionButton
- icon="bx bx-expand-vertical"
- text={t("note_map.open_full")}
- className="open-full-button"
- onClick={() => setExpanded(true)}
- />
- ) : (
- <ActionButton
- icon="bx bx-collapse-vertical"
- text={t("note_map.collapse")}
- className="collapse-button"
- onClick={() => setExpanded(false)}
- />
- )}
- </div>
- );
-}
diff --git a/apps/client/src/widgets/ribbon/RibbonDefinition.ts b/apps/client/src/widgets/ribbon/RibbonDefinition.ts
index ec440fa81d..0b2b7ad73f 100644
--- a/apps/client/src/widgets/ribbon/RibbonDefinition.ts
+++ b/apps/client/src/widgets/ribbon/RibbonDefinition.ts
@@ -4,7 +4,6 @@ import EditedNotesTab from "./EditedNotesTab";
import FilePropertiesTab from "./FilePropertiesTab";
import ImagePropertiesTab from "./ImagePropertiesTab";
import NoteInfoTab from "./NoteInfoTab";
-import NoteMapTab from "./NoteMapTab";
import NotePropertiesTab from "./NotePropertiesTab";
import { TabConfiguration } from "./ribbon-interface";
import ScriptTab from "./ScriptTab";
@@ -58,13 +57,6 @@ export const RIBBON_TAB_DEFINITIONS: TabConfiguration[] = [
toggleCommand: "toggleRibbonTabImageProperties",
activate: true,
},
- {
- title: t("note_map.title"),
- icon: "bx bxs-network-chart",
- content: NoteMapTab,
- show: true,
- toggleCommand: "toggleRibbonTabNoteMap"
- },
{
title: t("similar_notes.title"),
icon: "bx bx-bar-chart",
diff --git a/apps/client/src/widgets/sidebar/NoteMapGraph.tsx b/apps/client/src/widgets/sidebar/NoteMapGraph.tsx
index a9d3a6f505..e8d1182d6f 100644
--- a/apps/client/src/widgets/sidebar/NoteMapGraph.tsx
+++ b/apps/client/src/widgets/sidebar/NoteMapGraph.tsx
@@ -2,8 +2,7 @@ import "./NoteMap.css";
import { useRef } from "preact/hooks";
-// The map itself is shared with the ribbon's note map tab and the note map note type;
-// only the framing differs here.
+// The map itself is shared with the note map note type; only the framing differs here.
import NoteMapEl from "../note_map/NoteMap";
import { useActiveNoteContext } from "../react/hooks";