AI-native knowledge base & Evernote/Obsidian alternative with instant sync & native MCP. Free on Cloudflare or self-hosted via Docker.
HTML ai-agentcloudflarecloudflare-d1cloudflare-r2cloudflare-workersdockerelectronevernoteevernote-alternativeknowledge-basemcpnote-takingobsidian-alternativeoffline-firstpersonal-knowledge-basepwaself-hostedsqlitetiptapweb-clipper
refactor(web): unify note editor chrome
tianma-if20b046f49c22
diff --git a/apps/web/src/components/DiagramEditorPane.test.mjs b/apps/web/src/components/DiagramEditorPane.test.mjsindex d0fb3799..fef1f471 100644--- a/apps/web/src/components/DiagramEditorPane.test.mjs+++ b/apps/web/src/components/DiagramEditorPane.test.mjs@@ -104,12 +104,17 @@ describe("diagram editor canvas surface", () => {test("delegates every diagram kind to one shared toolbar shell", () => {expect(source).toContain("<DiagramToolbar");- expect(source).toContain("leading={!readOnly && !activeMindMapView?.focus ? (");+ expect(source).toContain("leading={!readOnly ? (");expect(toolbarSource).toContain('role="toolbar"');expect(toolbarSource).toContain("{leading ? <>{leading}<ToolbarDivider /></> : null}");expect(toolbarSource).toContain("{selectionEditor}");});+ test("keeps the mind-map canvas flush with the shared toolbar", () => {+ expect(source).not.toContain('t("diagram.branchView")');+ expect(source).not.toContain("MindMapFocusReader");+ });+test("reuses the architecture shape-library trigger across every diagram kind", () => {expect(toolbarSource).toContain("export const DiagramToolbarAddTrigger");expect(toolbarSource).toContain("<DropdownMenuTrigger asChild>");diff --git a/apps/web/src/components/DiagramEditorPane.tsx b/apps/web/src/components/DiagramEditorPane.tsxindex 49d3307b..76b7e048 100644--- a/apps/web/src/components/DiagramEditorPane.tsx+++ b/apps/web/src/components/DiagramEditorPane.tsx@@ -1,5 +1,5 @@import { diagramEditorSnapshot } from "@/lib/diagram-editor-snapshot";-import { projectMindMapView } from "@/lib/mind-map-view";+import { MemoTitleInput } from "@/components/MemoTitleInput";import { useCallback, useEffect, useRef, useState, type DragEvent as ReactDragEvent, type PointerEvent as ReactPointerEvent } from "react";import { Dom, Export, Graph, History, Keyboard, Selection, type Edge, type Node } from "@antv/x6";import * as m from "motion/react-m";@@ -1006,49 +1006,6 @@ const applyGraphPalette = (}};-const MindMapFocusReader = ({ source, focusId, theme, appearance, graphHandle, onZoom, onSelect }: {- source: DiagramDocument;- focusId: string;- theme: DiagramTheme;- appearance: DiagramAppearance;- graphHandle: { current: Graph | null };- onZoom: (value: number) => void;- onSelect: (id: string, label: string) => void;-}) => {- const container = useRef<HTMLDivElement>(null);- const { t } = useTranslation();- const callbacks = useRef({ onZoom, onSelect });- callbacks.current = { onZoom, onSelect };- useEffect(() => {- if (!container.current) return;- const visible = projectMindMapView(source.nodes, new Set(), focusId).visible;- const readingDocument: DiagramDocument = {- ...source,- nodes: source.nodes.filter((node) => visible.has(node.id)).map((node) => ({- ...node, ...diagramNodeSize(node, "mind-map"), ...(node.id === focusId ? { parentId: undefined } : {}),- })),- edges: source.edges.filter((edge) => visible.has(edge.source) && visible.has(edge.target)),- };- const layout = computeDiagramLayoutResult(readingDocument);- const graph = new Graph({ container: container.current, autoResize: true, async: false, grid: false,- background: { color: resolveDiagramPalette(theme, appearance).canvas }, interacting: false,- panning: { enabled: true, eventTypes: ["leftMouseDown"] },- mousewheel: { enabled: true, modifiers: ["ctrl", "meta"], minScale: 0.1, maxScale: 2.5 },- });- const detachScroll = attachDiagramScroll(graph.container, graph);- graph.addNodes(readingDocument.nodes.map((node) => nodeMetadata({ ...node, ...layout.nodes[node.id] }, theme, "mind-map", appearance)));- graph.addEdges(readingDocument.edges.map((edge) => edgeMetadata(edge, "mind-map", theme, appearance)));- applyMindMapHierarchy(graph, theme, appearance);- graph.on("scale", () => callbacks.current.onZoom(Math.round(graph.scale().sx * 100)));- graph.on("node:click", ({ node }) => callbacks.current.onSelect(node.id, node.getData<NodeData>()?.label ?? ""));- graph.on("resize", () => fitDiagramContent(graph, readingDocument, container.current, 48));- graphHandle.current = graph;- fitDiagramContent(graph, readingDocument, container.current, 48);- return () => { graphHandle.current = null; detachScroll(); graph.dispose(); };- }, [source, focusId, theme, appearance, graphHandle]);- return <div ref={container} className="absolute inset-0 z-10" role="region" aria-label={t("diagram.branchReader")} />;-};-export const DiagramEditorPane = ({memo,repository,@@ -1083,12 +1040,7 @@ export const DiagramEditorPane = ({const themeRef = useRef<DiagramTheme>(documentTheme);const appearanceRef = useRef<DiagramAppearance>(resolvedTheme);const savedSnapshotRef = useRef(document ? diagramEditorSnapshot(memo.title ?? "", document) : "");- const [mindMapView, setMindMapView] = useState<{ memoId: string; collapsed: Set<string>; focus: string | null; snapshot?: DiagramDocument }>({ memoId: memo.id, collapsed: new Set(), focus: null });- const focusGraphRef = useRef<Graph | null>(null);const viewOnlyRef = useRef(false);- const lastMindMapProjectionRef = useRef<unknown>(null);- const activeMindMapView = mindMapView.memoId === memo.id ? mindMapView : null;- const mindMapChildren = document?.kind === "mind-map" ? projectMindMapView(document.nodes, new Set(), null).children : new Map<string, string[]>();const [selectedNodeId, setSelectedNodeId] = useState<string | null>(null);const [selectedNodeLabel, setSelectedNodeLabel] = useState("");const [selectedEdgeId, setSelectedEdgeId] = useState<string | null>(null);@@ -1191,10 +1143,6 @@ export const DiagramEditorPane = ({if (memoIdCopyTimerRef.current !== null) window.clearTimeout(memoIdCopyTimerRef.current);}, []);- useEffect(() => {- setMindMapView({ memoId: memo.id, collapsed: new Set(), focus: null });- }, [memo.id, memo.contentHash]);-useEffect(() => {memoRef.current = memo;setTitle(memo.title ?? "");@@ -1688,38 +1636,6 @@ export const DiagramEditorPane = ({};}, [beginNodeEdit, dismissFlowQuickCreate, memo.contentHash, memo.id, readOnly]);- useEffect(() => {- const graph = graphRef.current;- if (!graph || document?.kind !== "mind-map") return;- const view = mindMapView.memoId === memo.id ? mindMapView : null;- if (view?.focus) graph.disableKeyboard(); else if (!readOnly) graph.enableKeyboard();- const nodes = graph.getNodes();- const projection = projectMindMapView(nodes.map((node) => ({ id: node.id, parentId: node.getData<NodeData>()?.parentId })), view?.collapsed ?? new Set(), view?.focus ?? null);- const shouldFit = lastMindMapProjectionRef.current !== mindMapView;- lastMindMapProjectionRef.current = mindMapView;- const historyEnabled = graph.isHistoryEnabled();- viewOnlyRef.current = true;- if (historyEnabled) graph.disableHistory();- try {- for (const cell of graph.getSelectedCells()) {- const visible = cell.isNode() ? projection.visible.has(cell.id) : cell.isEdge()- && projection.visible.has(cell.getSourceCellId()) && projection.visible.has(cell.getTargetCellId());- if (!visible) graph.unselect(cell);- }- for (const node of nodes) node.setVisible(projection.visible.has(node.id));- for (const edge of graph.getEdges()) edge.setVisible(projection.visible.has(edge.getSourceCellId()) && projection.visible.has(edge.getTargetCellId()));- applyMindMapHierarchy(graph, themeRef.current, appearanceRef.current);- const bounds = graph.getCellsBBox(nodes.filter((node) => projection.visible.has(node.id)));- if (bounds && shouldFit) graph.zoomToRect(bounds, { padding: 48, maxScale: 1 });- } finally {- if (historyEnabled) graph.enableHistory();- viewOnlyRef.current = false;- }- setSelectedNodeId((current) => current && projection.visible.has(current) ? current : null);- setSelectedEdgeId((current) => current && graph.getCellById(current)?.isVisible() ? current : null);- setHasSelection(graph.getSelectedCells().length > 0);- }, [memo.id, memo.contentHash, mindMapView, dirtyVersion]);-useEffect(() => {if (!dirty) return;const warn = (event: BeforeUnloadEvent) => event.preventDefault();@@ -2376,15 +2292,12 @@ export const DiagramEditorPane = ({</div><div className="flex min-h-14 items-center gap-3 px-4 py-2.5 sm:px-7">- <input- className="min-w-0 flex-1 bg-transparent text-xl font-semibold text-slate-950 outline-none placeholder:text-slate-400 disabled:text-slate-600 sm:text-2xl"+ <MemoTitleInputvalue={title}- disabled={readOnly}- maxLength={160}+ readOnly={readOnly}placeholder={kindLabel}- aria-label={t("diagram.title")}- onChange={(event) => {- const nextTitle = event.target.value;+ ariaLabel={t("diagram.title")}+ onValueChange={(nextTitle) => {titleRef.current = nextTitle;setTitle(nextTitle);setDirtyVersion((current) => current + 1);@@ -2406,7 +2319,7 @@ export const DiagramEditorPane = ({canRedo={historyState.redo}canUndo={historyState.undo}hasSelection={hasSelection}- leading={!readOnly && !activeMindMapView?.focus ? (+ leading={!readOnly ? (document.kind === "mind-map" ? (<DiagramInsertMenuitems={[@@ -2437,26 +2350,26 @@ export const DiagramEditorPane = ({onUndo={() => runHistoryAction("undo")}zoomPercent={zoomPercent}onRead={document.kind === "flowchart" ? () => { if (graphRef.current) readFlowchart(graphRef.current, document, containerRef.current); } : undefined}- onFit={() => { const graph = focusGraphRef.current ?? graphRef.current; if (graph) fitDiagramContent(graph, document, containerRef.current); }}+ onFit={() => { const graph = graphRef.current; if (graph) fitDiagramContent(graph, document, containerRef.current); }}onResetZoom={() => {- const graph = focusGraphRef.current ?? graphRef.current;+ const graph = graphRef.current;if (!graph) return;graph.zoomTo(1);const bounds = graph.getCellsBBox(graph.getNodes().filter((node) => node.isVisible()));if (bounds) graph.centerPoint(bounds.center.x, bounds.center.y);}}- onZoomIn={() => (focusGraphRef.current ?? graphRef.current)?.zoom(0.1)}- onZoomOut={() => (focusGraphRef.current ?? graphRef.current)?.zoom(-0.1)}- readOnly={readOnly || Boolean(activeMindMapView?.focus)}+ onZoomIn={() => graphRef.current?.zoom(0.1)}+ onZoomOut={() => graphRef.current?.zoom(-0.1)}+ readOnly={readOnly}selectionEditor={(<>- {selectedNodeId && !readOnly && !activeMindMapView?.focus && (+ {selectedNodeId && !readOnly && (<div className="ml-auto flex min-w-[220px] flex-1 items-center gap-2 sm:max-w-sm"><span className="shrink-0 text-xs font-medium text-slate-500">{t("diagram.nodeText")}</span><Input value={selectedNodeLabel} maxLength={120} onChange={(event) => updateSelectedLabel(event.target.value)} /></div>)}- {selectedEdgeId && !readOnly && !activeMindMapView?.focus && (+ {selectedEdgeId && !readOnly && (<div className="ml-auto flex min-w-[220px] flex-1 items-center gap-2 sm:max-w-sm"><span className="shrink-0 text-xs font-medium text-slate-500">{t("diagram.edgeText")}</span><Input value={selectedEdgeLabel} maxLength={80} onChange={(event) => updateSelectedEdgeLabel(event.target.value)} />@@ -2466,44 +2379,15 @@ export const DiagramEditorPane = ({)}theme={theme}/>- {document.kind === "mind-map" ? (- <div className="flex flex-wrap items-center gap-2 border-b border-slate-200 bg-white px-3 py-1.5 text-xs text-slate-500" role="toolbar" aria-label={t("diagram.branchView")}>- <span>{t("diagram.branchView")}</span>- <Button size="sm" variant="ghost" onClick={() => setMindMapView({ memoId: memo.id, focus: null, collapsed: new Set(document.nodes.filter((node) => node.parentId && document.nodes.some((parent) => parent.id === node.parentId && !parent.parentId)).map((node) => node.id)) })}>{t("diagram.branchOverview")}</Button>- <Button size="sm" variant="ghost" disabled={Boolean(activeMindMapView?.focus) || !selectedNodeId || !mindMapChildren.has(selectedNodeId)} onClick={() => {- if (!selectedNodeId) return;- const collapsed = new Set(activeMindMapView?.collapsed);- if (collapsed.has(selectedNodeId)) collapsed.delete(selectedNodeId); else collapsed.add(selectedNodeId);- setMindMapView({ memoId: memo.id, collapsed, focus: activeMindMapView?.focus ?? null });- }}>{selectedNodeId && activeMindMapView?.collapsed.has(selectedNodeId) ? t("diagram.expandBranch") : t("diagram.collapseBranch")}</Button>- <Button size="sm" variant="ghost" disabled={!selectedNodeId} onClick={() => {- if (selectedNodeId) setMindMapView({ memoId: memo.id, collapsed: new Set(), focus: selectedNodeId, snapshot: graphRef.current ? graphToDocument(graphRef.current, "mind-map", themeRef.current) : document });- }}>{t("diagram.focusBranch")}</Button>- <Button size="sm" variant="ghost" disabled={!activeMindMapView?.focus && !activeMindMapView?.collapsed.size} onClick={() => setMindMapView({ memoId: memo.id, collapsed: new Set(), focus: null })}>{t("diagram.showFullMap")}</Button>- <span className="ml-auto" role="status">{activeMindMapView?.focus ? t("diagram.focusedBranch", { label: document.nodes.find((node) => node.id === activeMindMapView.focus)?.label ?? "" }) : activeMindMapView?.collapsed.size ? t("diagram.collapsedBranches", { count: activeMindMapView.collapsed.size }) : t("diagram.selectBranchHint")}</span>- </div>- ) : null}-<div className="relative min-h-0 flex-1">- {activeMindMapView?.focus && activeMindMapView.snapshot ? <MindMapFocusReader- source={activeMindMapView.snapshot} focusId={activeMindMapView.focus} theme={theme} appearance={resolvedTheme}- graphHandle={focusGraphRef} onZoom={setZoomPercent}- onSelect={(id, label) => {- const graph = graphRef.current;- const node = graph?.getCellById(id);- if (graph && node) { graph.cleanSelection(); graph.select(node); }- setSelectedNodeId(id); setSelectedNodeLabel(label); setSelectedEdgeId(null); setHasSelection(Boolean(node));- }}- /> : null}<divref={containerRef}- aria-hidden={activeMindMapView?.focus ? true : undefined}className={cn("edgeever-diagram-canvas absolute inset-0 touch-none outline-none", pendingArchitectureItem && "cursor-crosshair")}data-architecture-placement={pendingArchitectureItem ? "active" : undefined}data-diagram-appearance={resolvedTheme}data-diagram-kind={document.kind}data-diagram-theme={theme}- tabIndex={activeMindMapView?.focus ? -1 : 0}+ tabIndex={0}aria-label={t("diagram.canvas", { type: kindLabel })}onDragOver={handleArchitectureDragOver}onDrop={handleArchitectureDrop}diff --git a/apps/web/src/components/EditorPane.tsx b/apps/web/src/components/EditorPane.tsxindex 8fd14824..b7437e25 100644--- a/apps/web/src/components/EditorPane.tsx+++ b/apps/web/src/components/EditorPane.tsx@@ -18,7 +18,6 @@ import {RotateCcw,Trash2,Tags,- Save,ReplaceAll,MoreHorizontal,Maximize2,@@ -45,6 +44,7 @@ import {import { Button } from "@/components/ui/button";import { GitHubRepositoryLink } from "@/components/GitHubRepositoryLink";import { ClipboardCopyNotice } from "@/components/ClipboardCopyNotice";+import { MemoTitleInput } from "@/components/MemoTitleInput";import { Input } from "@/components/ui/input";import {DropdownMenu,@@ -4038,25 +4038,6 @@ const RichEditorPane = ({{companionDiscoveryHub}<ExecutionCenterButton className="h-8 w-8" onClick={onOpenExecutionCenter} /><ThemeToggle />- {!effectiveReadOnly && (- <IconTooltip label={t("editor.save")}>- <Button- className={cn(- "hidden h-8 w-8 transition-colors sm:inline-flex",- hasUnsavedChanges- ? "text-emerald-600 hover:bg-emerald-50 hover:text-emerald-800 focus-visible:ring-2 focus-visible:ring-emerald-300"- : "text-slate-400 hover:bg-slate-100 hover:text-slate-600 focus-visible:ring-2 focus-visible:ring-slate-300"- )}- size="icon"- variant="ghost"- aria-label={t("editor.save")}- onClick={() => saveMutation.mutate()}- disabled={!editor || saveMutation.isPending || !hasUnsavedChanges}- >- <Save className="h-4 w-4" />- </Button>- </IconTooltip>- )}<DropdownMenu><DropdownMenuTrigger asChild><Button@@ -4207,15 +4188,14 @@ const RichEditorPane = ({</div><div className="space-y-1.5 px-4 pb-2.5 pt-2.5 sm:space-y-3 sm:px-7 sm:pb-4 sm:pt-4 lg:space-y-0 lg:pb-0.5 lg:pt-1.5">- <input+ <MemoTitleInputvalue={title}readOnly={effectiveReadOnly}- onChange={(event) => {- setTitle(event.target.value);- persistCurrentDraft(event.target.value, tagsText, getMobilePlainTextValue());+ onValueChange={(nextTitle) => {+ setTitle(nextTitle);+ persistCurrentDraft(nextTitle, tagsText, getMobilePlainTextValue());markDirty();}}- className="block w-full rounded-md border-0 bg-transparent text-xl font-bold leading-snug text-slate-950 outline-none transition placeholder:text-slate-300 focus-visible:bg-muted focus-visible:shadow-[inset_3px_0_0_var(--brand-green)] sm:text-2xl lg:text-[26px]"placeholder={t("common.untitledMemo")}/><div className="flex flex-wrap items-center gap-1.5 sm:gap-2">diff --git a/apps/web/src/components/EditorSaveControls.test.mjs b/apps/web/src/components/EditorSaveControls.test.mjsnew file mode 100644index 00000000..727c022d--- /dev/null+++ b/apps/web/src/components/EditorSaveControls.test.mjs@@ -0,0 +1,23 @@+import { describe, expect, test } from "bun:test";+import { readFileSync } from "node:fs";++const editorSource = readFileSync(new URL("./EditorPane.tsx", import.meta.url), "utf8");+const workspaceSource = readFileSync(new URL("./WorkspaceApp.tsx", import.meta.url), "utf8");+const helperSource = readFileSync(new URL("../lib/app-helpers.ts", import.meta.url), "utf8");++describe("editor save controls", () => {+ test("autosaves without a persistent toolbar save button", () => {+ expect(editorSource).toContain("EDITOR_LOCAL_SAVE_DELAY_MS");+ expect(editorSource).toContain("const timer = window.setTimeout(() => {");+ expect(editorSource).toContain("mutateSave();");+ expect(editorSource).not.toContain('<Save className="h-4 w-4" />');+ expect(editorSource).not.toContain('aria-label={t("editor.save")}');+ });++ test("keeps Ctrl or Command S as the explicit save and sync action", () => {+ expect(helperSource).toContain('saveAndSync: { key: "s", ctrlOrMeta: true');+ expect(workspaceSource).toContain('action === "saveAndSync"');+ expect(workspaceSource).toContain("setNoteSaveAndSyncToken((value) => value + 1)");+ expect(editorSource).toContain("saveAndSyncEditor({");+ });+});diff --git a/apps/web/src/components/MemoTitleInput.test.mjs b/apps/web/src/components/MemoTitleInput.test.mjsnew file mode 100644index 00000000..3173ec87--- /dev/null+++ b/apps/web/src/components/MemoTitleInput.test.mjs@@ -0,0 +1,22 @@+import { describe, expect, test } from "bun:test";+import { readFileSync } from "node:fs";++const componentSource = readFileSync(new URL("./MemoTitleInput.tsx", import.meta.url), "utf8");+const editorSource = readFileSync(new URL("./EditorPane.tsx", import.meta.url), "utf8");+const diagramSource = readFileSync(new URL("./DiagramEditorPane.tsx", import.meta.url), "utf8");++describe("shared memo title input", () => {+ test("owns the title appearance and input constraints", () => {+ expect(componentSource).toContain("text-xl font-bold");+ expect(componentSource).toContain("focus-visible:bg-muted");+ expect(componentSource).toContain("maxLength={160}");+ expect(componentSource).toContain("readOnly={readOnly}");+ });++ test("is reused by text and diagram notes", () => {+ expect(editorSource).toContain('import { MemoTitleInput } from "@/components/MemoTitleInput"');+ expect(diagramSource).toContain('import { MemoTitleInput } from "@/components/MemoTitleInput"');+ expect(editorSource).toContain("<MemoTitleInput");+ expect(diagramSource).toContain("<MemoTitleInput");+ });+});diff --git a/apps/web/src/components/MemoTitleInput.tsx b/apps/web/src/components/MemoTitleInput.tsxnew file mode 100644index 00000000..c5d284c8--- /dev/null+++ b/apps/web/src/components/MemoTitleInput.tsx@@ -0,0 +1,25 @@+type MemoTitleInputProps = {+ ariaLabel?: string;+ onValueChange: (value: string) => void;+ placeholder: string;+ readOnly?: boolean;+ value: string;+};++export const MemoTitleInput = ({+ ariaLabel,+ onValueChange,+ placeholder,+ readOnly = false,+ value,+}: MemoTitleInputProps) => (+ <input+ aria-label={ariaLabel ?? placeholder}+ className="block w-full rounded-md border-0 bg-transparent text-xl font-bold leading-snug text-slate-950 outline-none transition placeholder:text-slate-300 focus-visible:bg-muted focus-visible:shadow-[inset_3px_0_0_var(--brand-green)] read-only:text-slate-600 read-only:focus-visible:bg-transparent read-only:focus-visible:shadow-none sm:text-2xl lg:text-[26px]"+ maxLength={160}+ onChange={(event) => onValueChange(event.target.value)}+ placeholder={placeholder}+ readOnly={readOnly}+ value={value}+ />+);diff --git a/apps/web/src/lib/mind-map-view.test.mjs b/apps/web/src/lib/mind-map-view.test.mjsdeleted file mode 100644index 18e9806d..00000000--- a/apps/web/src/lib/mind-map-view.test.mjs+++ /dev/null@@ -1,24 +0,0 @@-import { describe, expect, test } from 'bun:test';-import { projectMindMapView } from './mind-map-view.ts';--const nodes = [{ id: 'root' }, { id: 'a', parentId: 'root' }, { id: 'b', parentId: 'root' }, { id: 'leaf', parentId: 'a' }, { id: 'detail', parentId: 'leaf' }];-describe('mind-map reading projection', () => {- test('collapsing a branch keeps its heading and other branches; expanding restores every node', () => {- const original = JSON.stringify(nodes);- expect([...projectMindMapView(nodes, new Set(['a']), null).visible]).toEqual(['root', 'a', 'b']);- expect([...projectMindMapView(nodes, new Set(), null).visible]).toEqual(nodes.map(n => n.id));- expect(JSON.stringify(nodes)).toBe(original);- });- test('focus shows the selected subtree even when an ancestor was collapsed', () => {- expect([...projectMindMapView(nodes, new Set(['root']), 'a').visible]).toEqual(['a', 'leaf', 'detail']);- expect([...projectMindMapView(nodes, new Set(['a']), 'a').visible]).toEqual(['a']);- });- test('nested collapsed branches retain their state after opening their parent', () => {- expect([...projectMindMapView(nodes, new Set(['leaf']), null).visible]).toEqual(['root', 'a', 'b', 'leaf']);- });- test('stale focus, orphaned nodes and cyclic parents remain safe', () => {- expect(projectMindMapView(nodes, new Set(['missing']), 'missing').visible.size).toBe(5);- const malformed = [{ id: 'orphan', parentId: 'missing' }, { id: 'x', parentId: 'y' }, { id: 'y', parentId: 'x' }];- expect(projectMindMapView(malformed, new Set(), null).visible.size).toBe(3);- });-});diff --git a/apps/web/src/lib/mind-map-view.ts b/apps/web/src/lib/mind-map-view.tsdeleted file mode 100644index d83e616f..00000000--- a/apps/web/src/lib/mind-map-view.ts+++ /dev/null@@ -1,28 +0,0 @@-/** A view projection only: never removes or rewrites nodes in a diagram document. */-export type MindMapViewNode = { id: string; parentId?: string };--export function projectMindMapView(nodes: MindMapViewNode[], collapsed: ReadonlySet<string>, focusId: string | null) {- const byId = new Map(nodes.map((node) => [node.id, node]));- const focus = focusId && byId.has(focusId) ? focusId : null;- const visible = new Set<string>();- const children = new Map<string, string[]>();- for (const node of nodes) {- if (node.parentId && byId.has(node.parentId)) {- const siblings = children.get(node.parentId) ?? [];- siblings.push(node.id);- children.set(node.parentId, siblings);- }- let current: MindMapViewNode | undefined = node;- let belongsToFocus = !focus;- let hidden = false;- const visited = new Set<string>();- while (current && !visited.has(current.id)) {- visited.add(current.id);- if (current.id === focus) { belongsToFocus = true; break; }- current = current.parentId ? byId.get(current.parentId) : undefined;- if (current && collapsed.has(current.id)) hidden = true;- }- if (belongsToFocus && !hidden) visible.add(node.id);- }- return { visible, children };-}diff --git a/packages/shared/src/i18n/en-US.ts b/packages/shared/src/i18n/en-US.tsindex 4240d5e1..efd37f86 100644--- a/packages/shared/src/i18n/en-US.ts+++ b/packages/shared/src/i18n/en-US.ts@@ -352,16 +352,6 @@ export const enUS = {zoomIn: "Zoom in",zoomOut: "Zoom out",listCounts: "{{nodes}} nodes · {{edges}} links",- branchReader: "Branch reading canvas (read-only)",- branchView: "Branch view",- branchOverview: "Overview",- expandBranch: "Expand branch",- collapseBranch: "Collapse branch",- focusBranch: "Focus branch",- showFullMap: "Show full map",- focusedBranch: "Reading (read-only): {{label}}",- collapsedBranches: "{{count}} branches collapsed",- selectBranchHint: "Select a topic to collapse or focus; exports always include the full map",resetZoom: "Reset to 100% and center",readFlow: "Read from start",readFlowHint: "Read at 100%; scroll or drag to pan, Ctrl / ⌘ + scroll to zoom",diff --git a/packages/shared/src/i18n/zh-CN.ts b/packages/shared/src/i18n/zh-CN.tsindex 24f49b64..a1452c1d 100644--- a/packages/shared/src/i18n/zh-CN.ts+++ b/packages/shared/src/i18n/zh-CN.ts@@ -352,16 +352,6 @@ export const zhCN = {zoomIn: "放大",zoomOut: "缩小",listCounts: "{{nodes}} 节点 · {{edges}} 连线",- branchReader: "分支阅读画布(只读)",- branchView: "分支视图",- branchOverview: "概览",- expandBranch: "展开分支",- collapseBranch: "折叠分支",- focusBranch: "聚焦分支",- showFullMap: "显示完整导图",- focusedBranch: "聚焦阅读(只读):{{label}}",- collapsedBranches: "已折叠 {{count}} 个分支",- selectBranchHint: "选择主题可折叠或聚焦;导出始终包含完整导图",resetZoom: "恢复 100% 并居中",readFlow: "从起点阅读",readFlowHint: "以原始字号从起点阅读;滚轮或拖动画布浏览,Ctrl / ⌘ + 滚轮缩放",