Skip to content

Commit d3f7e3c

Browse files
committed
fix: use default spacing for document export diagrams, add pages tooltip
1. Document export now uses default editor spacing (nodeSpacing: 40, layerSpacing: 60) instead of compact (25/40) for both the overview diagram and per-branch diagrams. This matches the image export fix and produces cleaner smoothstep edge routing. 2. Add info tooltip next to the "Pages" label in the diagram options explaining that per-branch mode splits the diagram by top-level branches for readability.
1 parent ff60514 commit d3f7e3c

2 files changed

Lines changed: 33 additions & 6 deletions

File tree

components/modals/_share-modal/document-export-section.tsx

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use client";
22

3-
import { ChevronDown, Download, Loader2 } from "lucide-react";
3+
import { ChevronDown, Download, Info, Loader2 } from "lucide-react";
44
import { useState } from "react";
55
import type { Edge, Node } from "reactflow";
66
import { getDocumentExportData } from "@/actions/export-document";
@@ -25,6 +25,12 @@ import {
2525
SelectTrigger,
2626
SelectValue,
2727
} from "../../ui/select";
28+
import {
29+
Tooltip,
30+
TooltipContent,
31+
TooltipProvider,
32+
TooltipTrigger,
33+
} from "../../ui/tooltip";
2834

2935
/**
3036
* Section labels for display in the customisation panel
@@ -368,7 +374,22 @@ export function DocumentExportSection({
368374
</Select>
369375
</div>
370376
<div className="flex items-center gap-4">
371-
<Label className="text-xs">Pages</Label>
377+
<div className="flex items-center gap-1">
378+
<Label className="text-xs">Pages</Label>
379+
<TooltipProvider>
380+
<Tooltip>
381+
<TooltipTrigger asChild>
382+
<Info className="h-3.5 w-3.5 cursor-help text-muted-foreground" />
383+
</TooltipTrigger>
384+
<TooltipContent side="top">
385+
<p className="max-w-52">
386+
Per-branch splits the diagram by each top-level branch,
387+
creating a separate page per branch for readability.
388+
</p>
389+
</TooltipContent>
390+
</Tooltip>
391+
</TooltipProvider>
392+
</div>
372393
<RadioGroup
373394
className="flex items-center gap-4"
374395
onValueChange={(v) => setDiagramMode(v as DiagramMode)}

lib/case/document-export.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -427,12 +427,15 @@ async function captureBranchDiagrams(
427427
hidden: !(branch.nodeIds.has(e.source) && branch.nodeIds.has(e.target)),
428428
}));
429429

430-
// Layout only the visible branch nodes
430+
// Layout only the visible branch nodes (default spacing for cleaner edges)
431431
const {
432432
nodes: layoutedNodes,
433433
edges: layoutedEdges,
434434
direction,
435-
} = await layoutForExport(branchNodes, branchEdges, layoutDirection);
435+
} = await layoutForExport(branchNodes, branchEdges, layoutDirection, {
436+
nodeSpacing: 40,
437+
layerSpacing: 60,
438+
});
436439

437440
// Push to DOM (including direction for correct handle positioning)
438441
applyLayout(layoutedNodes, layoutedEdges, direction);
@@ -499,12 +502,15 @@ export async function exportDocument(
499502
exportEdges = pruned.edges;
500503
}
501504

502-
// Apply compact export layout
505+
// Apply export layout with default spacing for cleaner edge routing
503506
const {
504507
nodes: layoutedNodes,
505508
edges: layoutedEdges,
506509
direction,
507-
} = await layoutForExport(exportNodes, exportEdges, layoutDirection);
510+
} = await layoutForExport(exportNodes, exportEdges, layoutDirection, {
511+
nodeSpacing: 40,
512+
layerSpacing: 60,
513+
});
508514

509515
// Push export layout to DOM (including direction for correct handle positioning)
510516
applyLayout(layoutedNodes, layoutedEdges, direction);

0 commit comments

Comments
 (0)