@lemonriver/core 0.4.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/README.md +14 -4
  2. package/dist/{build-Nl7EeJ6x.js → build-RlcGG-Ve.js} +1 -1
  3. package/dist/cli/bin.js +4 -4
  4. package/dist/{config-CpC0nM3r.js → config-BJT87wE9.js} +4756 -2012
  5. package/dist/{dev-BB3THd5I.js → dev-DR-j_xda.js} +2 -2
  6. package/dist/{preview-BGjgTg7H.js → preview-BTAhTb5B.js} +1 -1
  7. package/dist/{update-DsxZBtwv.js → update-CMRxtTc9.js} +18 -8
  8. package/dist/vite/index.js +1 -1
  9. package/package.json +2 -2
  10. package/src/agent/types.ts +14 -2
  11. package/src/app/components/agent/agent-panel.tsx +17 -5
  12. package/src/app/components/agent/connect-view.tsx +1 -1
  13. package/src/app/components/agent/provider-logo.tsx +10 -1
  14. package/src/app/lemonriver/agent/provider-marks.tsx +53 -0
  15. package/src/app/lemonriver/agent-providers/section.tsx +75 -0
  16. package/src/app/lemonriver/agent-providers/use-providers.ts +61 -0
  17. package/src/app/lemonriver/board/blocks/block-panel.tsx +666 -0
  18. package/src/app/lemonriver/board/blocks/cache.ts +28 -0
  19. package/src/app/lemonriver/board/blocks/change-list.tsx +189 -0
  20. package/src/app/lemonriver/board/blocks/classify.test.ts +209 -0
  21. package/src/app/lemonriver/board/blocks/classify.ts +152 -0
  22. package/src/app/lemonriver/board/blocks/snapshot.ts +116 -0
  23. package/src/app/lemonriver/board/board-canvas.tsx +627 -104
  24. package/src/app/lemonriver/board/board-page.tsx +1702 -91
  25. package/src/app/lemonriver/board/board.css +58 -7
  26. package/src/app/lemonriver/board/layout.test.ts +84 -0
  27. package/src/app/lemonriver/board/layout.ts +112 -11
  28. package/src/app/lemonriver/board/model/agent-tasks.test.ts +200 -0
  29. package/src/app/lemonriver/board/model/agent-tasks.ts +223 -0
  30. package/src/app/lemonriver/board/model/apply-prompt.test.ts +121 -0
  31. package/src/app/lemonriver/board/model/apply-prompt.ts +115 -0
  32. package/src/app/lemonriver/board/model/apply.ts +71 -0
  33. package/src/app/lemonriver/board/model/cards.test.ts +95 -2
  34. package/src/app/lemonriver/board/model/cards.ts +88 -20
  35. package/src/app/lemonriver/board/model/changes.test.ts +244 -0
  36. package/src/app/lemonriver/board/model/changes.ts +268 -0
  37. package/src/app/lemonriver/board/model/filter.test.ts +50 -0
  38. package/src/app/lemonriver/board/model/filter.ts +42 -0
  39. package/src/app/lemonriver/board/model/history.test.ts +71 -0
  40. package/src/app/lemonriver/board/model/history.ts +51 -0
  41. package/src/app/lemonriver/board/model/restructure.test.ts +205 -0
  42. package/src/app/lemonriver/board/model/restructure.ts +169 -0
  43. package/src/app/lemonriver/board/model/self-check.test.ts +329 -0
  44. package/src/app/lemonriver/board/model/self-check.ts +489 -0
  45. package/src/app/lemonriver/board/model/structure.test.ts +249 -0
  46. package/src/app/lemonriver/board/model/structure.ts +209 -0
  47. package/src/app/lemonriver/board/model/timing.test.ts +113 -0
  48. package/src/app/lemonriver/board/model/timing.ts +117 -0
  49. package/src/app/lemonriver/board/page-node.tsx +258 -55
  50. package/src/app/lemonriver/board/self-check-jump.ts +23 -0
  51. package/src/app/lemonriver/board/self-check-panel.tsx +272 -0
  52. package/src/app/lemonriver/board/self-check-runner.tsx +150 -0
  53. package/src/app/lemonriver/board/status-style.ts +25 -0
  54. package/src/app/lemonriver/board/use-board-apply.ts +206 -0
  55. package/src/app/lemonriver/board/use-board-cards.ts +108 -5
  56. package/src/app/lemonriver/board/use-board-changes.ts +108 -0
  57. package/src/app/lemonriver/board/use-board-columns.ts +37 -56
  58. package/src/app/lemonriver/board/use-board-comments.ts +36 -0
  59. package/src/app/lemonriver/board/use-board-restructures.ts +107 -0
  60. package/src/app/lemonriver/board/use-history.ts +86 -0
  61. package/src/app/lemonriver/board/use-page-order.ts +65 -38
  62. package/src/app/lemonriver/board/use-self-check.ts +117 -0
  63. package/src/app/lemonriver/board/use-target-minutes.ts +47 -0
  64. package/src/app/lemonriver/board/views/block-readings.tsx +46 -0
  65. package/src/app/lemonriver/board/views/list-view.tsx +356 -0
  66. package/src/app/lemonriver/board/views/progress.tsx +32 -0
  67. package/src/app/lemonriver/board/views/timeline-view.tsx +341 -0
  68. package/src/app/lemonriver/chrome/filter-pill.tsx +30 -0
  69. package/src/app/lemonriver/chrome/sidebar-extras.tsx +12 -1
  70. package/src/app/lemonriver/features.test.ts +5 -0
  71. package/src/app/lemonriver/features.ts +2 -1
  72. package/src/app/lemonriver/home/deck-card.tsx +10 -0
  73. package/src/app/lemonriver/home/home-page.tsx +55 -6
  74. package/src/app/lemonriver/home/use-deck-times.ts +4 -1
  75. package/src/app/lemonriver/outline/build-team.tsx +42 -0
  76. package/src/app/lemonriver/outline/describe-page.tsx +128 -27
  77. package/src/app/lemonriver/outline/draft.ts +38 -0
  78. package/src/app/lemonriver/outline/model.test.ts +118 -0
  79. package/src/app/lemonriver/outline/model.ts +92 -7
  80. package/src/app/lemonriver/outline/outline-page.tsx +90 -7
  81. package/src/app/lemonriver/outline/pick-style.tsx +282 -0
  82. package/src/app/lemonriver/routes.test.tsx +17 -5
  83. package/src/app/lemonriver/routes.tsx +28 -0
  84. package/src/app/lemonriver/settings/settings-page.tsx +3 -0
  85. package/src/app/lemonriver/slide-extensions.tsx +14 -2
  86. package/src/app/lemonriver/templates/client.ts +60 -0
  87. package/src/app/lemonriver/templates/demo-page.tsx +79 -0
  88. package/src/app/lemonriver/templates/knobs.test.ts +62 -0
  89. package/src/app/lemonriver/templates/knobs.ts +62 -0
  90. package/src/app/lemonriver/templates/library-page.tsx +292 -0
  91. package/src/app/lemonriver/templates/model.test.ts +175 -0
  92. package/src/app/lemonriver/templates/model.ts +339 -0
  93. package/src/app/lemonriver/templates/preview-content.test.ts +117 -0
  94. package/src/app/lemonriver/templates/preview-content.ts +149 -0
  95. package/src/app/lemonriver/templates/recommend.test.ts +71 -0
  96. package/src/app/lemonriver/templates/recommend.ts +72 -0
  97. package/src/app/lemonriver/templates/use-library.ts +58 -0
  98. package/src/app/lemonriver/templates/virtual.d.ts +28 -0
  99. package/src/app/lemonriver/text/en.ts +228 -0
  100. package/src/app/lemonriver/text/es.ts +220 -0
  101. package/src/app/lemonriver/text/ja.ts +220 -0
  102. package/src/app/lemonriver/text/types.ts +243 -0
  103. package/src/app/lemonriver/text/zh-cn.ts +218 -0
  104. package/src/app/lemonriver/text/zh-tw.ts +218 -0
  105. package/src/app/lemonriver/theme/lemon-icon.tsx +6 -0
  106. package/src/app/lemonriver/theme/pages.test.ts +4 -0
  107. package/src/app/lemonriver/theme/pages.ts +6 -1
  108. package/src/app/lemonriver/theme/theme-menu.tsx +3 -2
  109. package/src/app/lemonriver/theme/use-theme.tsx +2 -2
  110. package/src/app/lemonriver/update/prompt.ts +1 -1
  111. package/src/app/lib/agent/use-agent.ts +4 -3
  112. package/src/app/routes/slide.tsx +1 -1
  113. package/src/app/assets/open-slide.svg +0 -39
  114. package/src/app/favicon.ico +0 -0
  115. package/src/app/favicon.svg +0 -39
@@ -22,9 +22,30 @@ import {
22
22
  useInternalNode,
23
23
  useReactFlow,
24
24
  } from '@xyflow/react';
25
- import { Link2, Link2Off, Maximize2, Minus, Plus, X } from 'lucide-react';
25
+ import {
26
+ Check,
27
+ ChevronDown,
28
+ ChevronRight,
29
+ Columns3,
30
+ GripVertical,
31
+ Link2,
32
+ Link2Off,
33
+ Maximize2,
34
+ Minus,
35
+ Plus,
36
+ Sparkles,
37
+ X,
38
+ } from 'lucide-react';
26
39
  import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
27
40
  import { Button } from '@/components/ui/button';
41
+ import {
42
+ DropdownMenu,
43
+ DropdownMenuContent,
44
+ DropdownMenuItem,
45
+ DropdownMenuSeparator,
46
+ DropdownMenuTrigger,
47
+ } from '@/components/ui/dropdown-menu';
48
+ import { format } from '@/lib/use-locale';
28
49
  import { cn, pad2 } from '@/lib/utils';
29
50
  import type { DesignSystem } from '../../lib/design';
30
51
  import type { Page } from '../../lib/sdk';
@@ -32,18 +53,21 @@ import { useLrText } from '../text';
32
53
  import {
33
54
  type BoardLayout,
34
55
  type Box,
35
- CARD_BOX_H,
36
- CARD_BOX_W,
56
+ type CardSize,
37
57
  cardAtPoint,
58
+ cardMetrics,
59
+ gapAtPoint,
38
60
  identityOrder,
39
61
  layoutBoard,
40
62
  linkCurve,
41
- orderAfterMove,
63
+ orderAfterMoveMany,
42
64
  slotAtPoint,
43
65
  } from './layout';
44
- import type { BoardCard, CardPatch } from './model/cards';
45
- import { type BoardColumn, columnsAfterMove } from './model/structure';
66
+ import type { PageAction } from './model/agent-tasks';
67
+ import type { BoardCard, CardPatch, LinkedPair, LinkKind } from './model/cards';
68
+ import { type BoardColumn, type ChapterProgress, columnsAfterMoveMany } from './model/structure';
46
69
  import { PageNode, type PageNodeData } from './page-node';
70
+ import { Progress } from './views/progress';
47
71
  import '@xyflow/react/dist/base.css';
48
72
  import './board.css';
49
73
 
@@ -55,40 +79,111 @@ type Props = {
55
79
  cards: (BoardCard | undefined)[];
56
80
  cardsReady: boolean;
57
81
  /** Linked pages, as deck positions. */
58
- links: [number, number][];
82
+ links: LinkedPair[];
59
83
  showLinks: boolean;
84
+ /** How far along each chapter is, one per chapter. */
85
+ progress: ChapterProgress[];
60
86
  design?: DesignSystem;
87
+ size: CardSize;
88
+ /** One flag per chapter: folded chapters draw no cards. */
89
+ collapsed: boolean[];
90
+ /** One flag per page: cards the filter does not pick out are drawn faint. */
91
+ dimmed: boolean[];
92
+ /** One count per page: block moves waiting to be applied. */
93
+ changeCounts: number[];
94
+ /** Pages the last apply touched, lit for a moment. */
95
+ flashed: number[];
96
+ /** Selected pages, by deck position. */
97
+ selected: number[];
98
+ onSelect: (indices: number[]) => void;
61
99
  onOpenPage: (index: number) => void;
62
- onMovePage: (from: number, to: number) => void;
100
+ onMovePages: (moving: number[], to: number) => void;
101
+ onMoveToNewChapter: (from: number, boundary: number) => void;
63
102
  onRenameColumn: (index: number, title: string) => void;
64
103
  onAddPage: (columnIndex: number) => void;
104
+ onAddChapter: (after: number) => void;
105
+ onDeleteChapter: (index: number) => void;
106
+ onToggleCollapse: (index: number) => void;
107
+ onMoveChapter: (from: number, to: number) => void;
65
108
  onDuplicate: (index: number) => void;
66
109
  onDelete: (index: number) => void;
67
110
  onMoveToEnd: (index: number) => void;
68
111
  onPatchCard: (index: number, patch: CardPatch) => void;
69
112
  onLink: (a: number, b: number) => void;
70
113
  onUnlink: (a: number, b: number) => void;
114
+ onSetLinkKind: (a: number, b: number, kind: LinkKind | null) => void;
115
+ /** Bring a page into view and select it. */
116
+ onJump: (index: number) => void;
71
117
  onToggleLinks: () => void;
118
+ /** Why the one-page agent actions are off, or null when they can run. */
119
+ agentHint: string | null;
120
+ onPageTask: (index: number, action: PageAction) => void;
121
+ /** 'planning' while the agent is out, the number of titles when ready. */
122
+ planFor: (column: number) => 'planning' | number | null;
123
+ onFillChapter: (column: number) => void;
124
+ onViewPlan: (column: number) => void;
72
125
  };
73
126
 
74
127
  type ColumnLabelData = {
75
128
  title: string;
76
129
  count: number;
77
130
  index: number;
131
+ width: number;
132
+ collapsed: boolean;
133
+ canDelete: boolean;
134
+ /** How much of this chapter is finished. */
135
+ progress: ChapterProgress;
136
+ /** 'planning' while the agent is out, the number of titles when ready, else null. */
137
+ plan: 'planning' | number | null;
78
138
  onRename: (index: number, title: string) => void;
79
139
  onAddPage: (index: number) => void;
140
+ onAddChapter: (after: number) => void;
141
+ onDelete: (index: number) => void;
142
+ onToggleCollapse: (index: number) => void;
143
+ onFillChapter: (index: number) => void;
144
+ onViewPlan: (index: number) => void;
80
145
  };
81
146
 
82
147
  function ColumnLabel({ data }: NodeProps) {
83
- const { title, count, index, onRename, onAddPage } = data as unknown as ColumnLabelData;
148
+ const {
149
+ title,
150
+ count,
151
+ index,
152
+ width,
153
+ collapsed,
154
+ canDelete,
155
+ progress,
156
+ plan,
157
+ onRename,
158
+ onAddPage,
159
+ onAddChapter,
160
+ onDelete,
161
+ onToggleCollapse,
162
+ onFillChapter,
163
+ onViewPlan,
164
+ } = data as unknown as ColumnLabelData;
84
165
  const lr = useLrText();
85
166
  const [editing, setEditing] = useState(false);
86
167
 
87
168
  return (
88
- <div
89
- className="nodrag pointer-events-auto flex items-baseline gap-2"
90
- style={{ width: CARD_BOX_W }}
91
- >
169
+ <div className="pointer-events-auto flex items-baseline gap-1.5" style={{ width }}>
170
+ <GripVertical
171
+ className="size-3.5 shrink-0 cursor-grab self-center text-muted-foreground/40"
172
+ strokeWidth={1.8}
173
+ />
174
+ <button
175
+ type="button"
176
+ onClick={() => onToggleCollapse(index)}
177
+ aria-label={collapsed ? lr.board.expand : lr.board.collapse}
178
+ aria-expanded={!collapsed}
179
+ className="nodrag flex size-5 shrink-0 items-center justify-center rounded-[4px] text-muted-foreground/60 motion-safe:transition-colors hover:bg-muted hover:text-foreground"
180
+ >
181
+ {collapsed ? (
182
+ <ChevronRight className="size-3.5" strokeWidth={2} />
183
+ ) : (
184
+ <ChevronDown className="size-3.5" strokeWidth={2} />
185
+ )}
186
+ </button>
92
187
  {editing ? (
93
188
  <input
94
189
  // biome-ignore lint/a11y/noAutofocus: the field only exists once the title is clicked
@@ -109,47 +204,108 @@ function ColumnLabel({ data }: NodeProps) {
109
204
  const next = e.currentTarget.value.trim();
110
205
  if (next && next !== title) onRename(index, next);
111
206
  }}
112
- className="eyebrow min-w-0 flex-1 rounded-[4px] bg-muted/60 px-1.5 py-1 text-foreground outline-none ring-1 ring-brand/40"
207
+ className="nodrag eyebrow min-w-0 flex-1 rounded-[4px] bg-muted/60 px-1.5 py-1 text-foreground outline-none ring-1 ring-brand/40"
113
208
  />
114
209
  ) : (
115
210
  <button
116
211
  type="button"
117
212
  onClick={() => setEditing(true)}
118
213
  aria-label={lr.board.renameColumn}
119
- className="eyebrow min-w-0 truncate rounded-[4px] px-1.5 py-1 text-left motion-safe:transition-colors hover:bg-muted/60"
214
+ className="nodrag eyebrow min-w-0 truncate rounded-[4px] px-1.5 py-1 text-left motion-safe:transition-colors hover:bg-muted/60"
120
215
  >
121
216
  {title}
122
217
  </button>
123
218
  )}
124
219
  <span className="folio">{pad2(count)}</span>
125
- <button
126
- type="button"
127
- onClick={() => onAddPage(index)}
128
- aria-label={lr.board.addPage}
129
- className={cn(
130
- 'ml-auto flex size-6 items-center justify-center rounded-[4px] text-muted-foreground/60',
131
- 'motion-safe:transition-colors hover:bg-muted hover:text-foreground',
132
- )}
133
- >
134
- <Plus className="size-3.5" strokeWidth={1.9} />
135
- </button>
220
+ {progress.total > 0 && <Progress progress={progress} />}
221
+ <div className={cn('flex items-center', progress.total === 0 && 'ml-auto')}>
222
+ {plan === 'planning' ? (
223
+ <span className="mr-1 text-[11px] text-muted-foreground" data-lr-planning>
224
+ {lr.board.planning}
225
+ </span>
226
+ ) : typeof plan === 'number' ? (
227
+ <button
228
+ type="button"
229
+ onClick={() => onViewPlan(index)}
230
+ data-lr-view-plan
231
+ className="nodrag mr-1 rounded-[4px] px-1.5 py-0.5 text-[11px] text-[var(--lr-accent)] motion-safe:transition-colors hover:bg-muted"
232
+ >
233
+ {format(lr.board.viewPlan, { n: plan })}
234
+ </button>
235
+ ) : null}
236
+ <button
237
+ type="button"
238
+ onClick={() => onFillChapter(index)}
239
+ aria-label={lr.board.fillChapter}
240
+ title={lr.board.fillChapter}
241
+ data-lr-fill-chapter
242
+ className="nodrag flex size-6 items-center justify-center rounded-[4px] text-muted-foreground/60 motion-safe:transition-colors hover:bg-muted hover:text-foreground"
243
+ >
244
+ <Sparkles className="size-3.5" strokeWidth={1.9} />
245
+ </button>
246
+ <button
247
+ type="button"
248
+ onClick={() => onAddPage(index)}
249
+ aria-label={lr.board.addPage}
250
+ className={cn(
251
+ 'nodrag flex size-6 items-center justify-center rounded-[4px] text-muted-foreground/60',
252
+ 'motion-safe:transition-colors hover:bg-muted hover:text-foreground',
253
+ )}
254
+ >
255
+ <Plus className="size-3.5" strokeWidth={1.9} />
256
+ </button>
257
+ <button
258
+ type="button"
259
+ onClick={() => onAddChapter(index)}
260
+ aria-label={lr.board.addChapter}
261
+ className="nodrag flex size-6 items-center justify-center rounded-[4px] text-muted-foreground/60 motion-safe:transition-colors hover:bg-muted hover:text-foreground"
262
+ >
263
+ <Columns3 className="size-3.5" strokeWidth={1.9} />
264
+ </button>
265
+ <button
266
+ type="button"
267
+ disabled={!canDelete}
268
+ onClick={() => onDelete(index)}
269
+ aria-label={lr.board.deleteChapter}
270
+ className="nodrag flex size-6 items-center justify-center rounded-[4px] text-muted-foreground/60 motion-safe:transition-colors hover:bg-muted hover:text-destructive disabled:pointer-events-none disabled:opacity-30"
271
+ >
272
+ <X className="size-3.5" strokeWidth={1.9} />
273
+ </button>
274
+ </div>
136
275
  </div>
137
276
  );
138
277
  }
139
278
 
140
279
  /** Marks the slot a dragged card will take, so the drop point is visible. */
141
- function DropSlot() {
280
+ function DropSlot({ data }: NodeProps) {
281
+ const { width, height, newChapter } = data as unknown as {
282
+ width: number;
283
+ height: number;
284
+ newChapter: boolean;
285
+ };
142
286
  return (
143
287
  <div
144
- className="rounded-[8px] border-2 border-dashed border-brand/45 bg-brand/[0.04]"
145
- style={{ width: CARD_BOX_W, height: CARD_BOX_H }}
146
- />
288
+ className={cn(
289
+ 'rounded-[8px] border-2 border-dashed border-brand/45 bg-brand/[0.04]',
290
+ newChapter && 'flex items-center justify-center border-brand/70 bg-brand/[0.08]',
291
+ )}
292
+ style={{ width, height }}
293
+ >
294
+ {newChapter && <Plus className="size-6 text-brand/70" strokeWidth={1.8} />}
295
+ </div>
147
296
  );
148
297
  }
149
298
 
150
299
  const nodeTypes: NodeTypes = { page: PageNode, columnLabel: ColumnLabel, dropSlot: DropSlot };
151
300
 
152
- type LinkEdgeData = { a: number; b: number; onUnlink: (a: number, b: number) => void };
301
+ type LinkEdgeData = {
302
+ a: number;
303
+ b: number;
304
+ kind?: LinkKind;
305
+ onUnlink: (a: number, b: number) => void;
306
+ onSetKind: (a: number, b: number, kind: LinkKind | null) => void;
307
+ onJump: (index: number) => void;
308
+ };
153
309
 
154
310
  function boxOf(node: InternalNode | undefined): Box | null {
155
311
  if (!node) return null;
@@ -157,37 +313,116 @@ function boxOf(node: InternalNode | undefined): Box | null {
157
313
  return {
158
314
  x,
159
315
  y,
160
- width: node.measured.width ?? CARD_BOX_W,
161
- height: node.measured.height ?? CARD_BOX_H,
316
+ width: node.measured.width ?? 0,
317
+ height: node.measured.height ?? 0,
162
318
  };
163
319
  }
164
320
 
321
+ const LINK_EDGE_CLASS: Record<LinkKind | 'plain', string> = {
322
+ plain: 'osd-board-link osd-board-link--plain',
323
+ cause: 'osd-board-link osd-board-link--cause',
324
+ contrast: 'osd-board-link osd-board-link--contrast',
325
+ echo: 'osd-board-link osd-board-link--echo',
326
+ };
327
+
165
328
  /**
166
- * A loose association between two pages. It is drawn thin and dashed so it can
167
- * never be read as the deck's order, and it follows the cards as they move.
329
+ * A loose association between two pages. It is drawn thin so it can never be
330
+ * read as the deck's order, and it follows the cards as they move. Its midpoint
331
+ * names what the two pages have to do with each other, and offers to jump
332
+ * between them.
168
333
  */
169
334
  function LinkEdge({ id, source, target, data }: EdgeProps) {
170
335
  const lr = useLrText();
171
- const { a, b, onUnlink } = data as unknown as LinkEdgeData;
336
+ const { a, b, kind, onUnlink, onSetKind, onJump } = data as unknown as LinkEdgeData;
172
337
  const from = boxOf(useInternalNode(source));
173
338
  const to = boxOf(useInternalNode(target));
174
339
  if (!from || !to) return null;
175
340
  const curve = linkCurve(from, to);
341
+ const className = LINK_EDGE_CLASS[kind ?? 'plain'];
342
+ const tag =
343
+ kind === 'cause'
344
+ ? lr.board.linkCause
345
+ : kind === 'contrast'
346
+ ? lr.board.linkContrast
347
+ : kind === 'echo'
348
+ ? lr.board.linkEchoShort
349
+ : '';
176
350
 
177
351
  return (
178
352
  <>
179
- <BaseEdge id={id} path={curve.path} className="osd-board-link" interactionWidth={14} />
353
+ {kind === 'contrast' ? (
354
+ // Two lines side by side: a comparison is two things held up together.
355
+ <>
356
+ <BaseEdge
357
+ id={id}
358
+ path={linkCurve({ ...from, y: from.y - 2.5 }, { ...to, y: to.y - 2.5 }).path}
359
+ className={className}
360
+ interactionWidth={14}
361
+ />
362
+ <BaseEdge
363
+ id={`${id}-pair`}
364
+ path={linkCurve({ ...from, y: from.y + 2.5 }, { ...to, y: to.y + 2.5 }).path}
365
+ className={className}
366
+ interactionWidth={14}
367
+ />
368
+ </>
369
+ ) : (
370
+ <BaseEdge id={id} path={curve.path} className={className} interactionWidth={14} />
371
+ )}
180
372
  <EdgeLabelRenderer>
181
- <button
182
- type="button"
183
- aria-label={lr.board.removeLink}
184
- title={lr.board.removeLink}
185
- onClick={() => onUnlink(a, b)}
186
- className="osd-board-link-remove nodrag nopan"
187
- style={{ transform: `translate(-50%, -50%) translate(${curve.x}px, ${curve.y}px)` }}
373
+ <div
374
+ className="nodrag nopan flex items-center gap-1"
375
+ style={{
376
+ position: 'absolute',
377
+ transform: `translate(-50%, -50%) translate(${curve.x}px, ${curve.y}px)`,
378
+ }}
188
379
  >
189
- <X className="size-3" strokeWidth={2.2} />
190
- </button>
380
+ <DropdownMenu>
381
+ <DropdownMenuTrigger
382
+ type="button"
383
+ aria-label={lr.board.linkRelation}
384
+ title={lr.board.linkRelation}
385
+ data-lr-link-menu
386
+ className="osd-board-link-menu nodrag nopan"
387
+ >
388
+ <Link2 className="size-3" strokeWidth={2.2} />
389
+ </DropdownMenuTrigger>
390
+ <DropdownMenuContent align="center" className="min-w-[176px]">
391
+ {(
392
+ [
393
+ ['cause', lr.board.linkCause],
394
+ ['contrast', lr.board.linkContrast],
395
+ ['echo', lr.board.linkEcho],
396
+ ] as const
397
+ ).map(([value, label]) => (
398
+ <DropdownMenuItem key={value} onClick={() => onSetKind(a, b, value)}>
399
+ <Check className={cn('size-3.5', kind === value ? 'opacity-100' : 'opacity-0')} />
400
+ {label}
401
+ </DropdownMenuItem>
402
+ ))}
403
+ <DropdownMenuItem onClick={() => onSetKind(a, b, null)}>
404
+ <Check className={cn('size-3.5', kind ? 'opacity-0' : 'opacity-100')} />
405
+ {lr.board.linkPlain}
406
+ </DropdownMenuItem>
407
+ <DropdownMenuSeparator />
408
+ <DropdownMenuItem onClick={() => onJump(a)}>
409
+ {format(lr.board.jumpToPage, { n: a + 1 })}
410
+ </DropdownMenuItem>
411
+ <DropdownMenuItem onClick={() => onJump(b)}>
412
+ {format(lr.board.jumpToPage, { n: b + 1 })}
413
+ </DropdownMenuItem>
414
+ <DropdownMenuSeparator />
415
+ <DropdownMenuItem onClick={() => onUnlink(a, b)}>
416
+ {lr.board.removeLink}
417
+ </DropdownMenuItem>
418
+ </DropdownMenuContent>
419
+ </DropdownMenu>
420
+ {tag && (
421
+ <span className="osd-board-link-tag" data-lr-link-kind={kind}>
422
+ {tag}
423
+ </span>
424
+ )}
425
+ </div>
191
426
  </EdgeLabelRenderer>
192
427
  </>
193
428
  );
@@ -221,11 +456,26 @@ type BuildArgs = {
221
456
  cards: (BoardCard | undefined)[];
222
457
  cardsReady: boolean;
223
458
  design?: DesignSystem;
224
- actions: Pick<PageNodeData, 'onDuplicate' | 'onDelete' | 'onMoveToEnd' | 'onPatchCard'>;
225
- columnActions: {
226
- onRename: (index: number, title: string) => void;
227
- onAddPage: (index: number) => void;
228
- };
459
+ dimmed: boolean[];
460
+ changeCounts: number[];
461
+ flashed: number[];
462
+ selected: Set<number>;
463
+ size: CardSize;
464
+ actions: Pick<
465
+ PageNodeData,
466
+ 'onDuplicate' | 'onDelete' | 'onMoveToEnd' | 'onPatchCard' | 'agentHint' | 'onPageTask'
467
+ >;
468
+ columnActions: Pick<
469
+ ColumnLabelData,
470
+ | 'onRename'
471
+ | 'onAddPage'
472
+ | 'onAddChapter'
473
+ | 'onDelete'
474
+ | 'onToggleCollapse'
475
+ | 'onFillChapter'
476
+ | 'onViewPlan'
477
+ > & { columns: number; planFor: (column: number) => 'planning' | number | null };
478
+ progress: ChapterProgress[];
229
479
  };
230
480
 
231
481
  /**
@@ -241,48 +491,71 @@ function buildNodes({
241
491
  cards,
242
492
  cardsReady,
243
493
  design,
494
+ dimmed,
495
+ changeCounts,
496
+ flashed,
497
+ selected,
498
+ size,
244
499
  actions,
245
500
  columnActions,
501
+ progress,
246
502
  }: BuildArgs): Node[] {
503
+ const { metrics } = layout;
247
504
  const labels: Node[] = layout.columns.map((column, i) => ({
248
505
  id: `column-${i}`,
249
506
  type: 'columnLabel',
250
507
  position: { x: column.x, y: column.y },
251
- width: CARD_BOX_W,
508
+ width: column.boxW,
252
509
  height: 24,
253
510
  data: {
254
511
  title: column.title,
255
512
  count: column.size,
256
513
  index: i,
257
- ...columnActions,
514
+ width: column.boxW,
515
+ collapsed: column.collapsed,
516
+ canDelete: columnActions.columns > 1,
517
+ progress: progress[i] ?? { done: 0, review: 0, total: 0 },
518
+ plan: columnActions.planFor(i),
519
+ onRename: columnActions.onRename,
520
+ onAddPage: columnActions.onAddPage,
521
+ onAddChapter: columnActions.onAddChapter,
522
+ onDelete: columnActions.onDelete,
523
+ onToggleCollapse: columnActions.onToggleCollapse,
524
+ onFillChapter: columnActions.onFillChapter,
525
+ onViewPlan: columnActions.onViewPlan,
258
526
  },
259
- draggable: false,
527
+ draggable: true,
260
528
  selectable: false,
261
529
  deletable: false,
262
530
  // React Flow switches pointer events off for a node that is neither
263
531
  // selectable nor draggable, which would make the buttons in here dead.
264
- style: { pointerEvents: 'all' },
532
+ style: { pointerEvents: 'all' as const },
265
533
  }));
266
534
  const drop: Node = {
267
535
  id: 'drop-slot',
268
536
  type: 'dropSlot',
269
537
  position: { x: 0, y: 0 },
270
- width: CARD_BOX_W,
271
- height: CARD_BOX_H,
538
+ width: metrics.boxW,
539
+ height: metrics.boxH,
272
540
  draggable: false,
273
541
  selectable: false,
274
542
  deletable: false,
275
543
  hidden: true,
276
- data: {},
544
+ data: { width: metrics.boxW, height: metrics.boxH, newChapter: false },
277
545
  };
278
- const pageNodes: Node[] = layout.slots.map((slot) => {
546
+ // The structure and the deck are written by separate requests, so for a
547
+ // moment a chapter can still count a page the deck no longer has. Drawing
548
+ // that slot would mount an undefined page.
549
+ const pageNodes: Node[] = layout.slots.flatMap((slot) => {
279
550
  const pageIndex = order[slot.index] ?? slot.index;
551
+ if (pageIndex < 0 || pageIndex >= pages.length) return [];
280
552
  return {
281
553
  id: `page-${pageIndex}`,
282
554
  type: 'page',
283
555
  position: { x: slot.x, y: slot.y },
284
- width: CARD_BOX_W,
285
- height: CARD_BOX_H,
556
+ width: metrics.boxW,
557
+ height: metrics.boxH,
558
+ selected: selected.has(pageIndex),
286
559
  data: {
287
560
  slideId,
288
561
  page: pages[pageIndex],
@@ -294,11 +567,22 @@ function buildNodes({
294
567
  total: pages.length,
295
568
  design,
296
569
  canDelete: pages.length > 1,
570
+ size,
571
+ metrics,
572
+ dimmed: dimmed[pageIndex] === true,
573
+ changeCount: changeCounts[pageIndex] ?? 0,
574
+ flash: flashed.includes(pageIndex),
297
575
  ...actions,
298
576
  } satisfies PageNodeData as unknown as Record<string, unknown>,
299
577
  };
300
578
  });
301
- return [...labels, drop, ...pageNodes];
579
+ return [...labels, drop, ...pageNodes] as Node[];
580
+ }
581
+
582
+ function sameSelection(a: number[], b: number[]): boolean {
583
+ if (a.length !== b.length) return false;
584
+ const set = new Set(a);
585
+ return b.every((value) => set.has(value));
302
586
  }
303
587
 
304
588
  function BoardFlow({
@@ -311,48 +595,122 @@ function BoardFlow({
311
595
  links,
312
596
  showLinks,
313
597
  design,
598
+ size,
599
+ collapsed,
600
+ dimmed,
601
+ changeCounts,
602
+ flashed,
603
+ selected,
604
+ onSelect,
314
605
  onOpenPage,
315
- onMovePage,
606
+ onMovePages,
607
+ onMoveToNewChapter,
316
608
  onRenameColumn,
317
609
  onAddPage,
610
+ onAddChapter,
611
+ onDeleteChapter,
612
+ onToggleCollapse,
613
+ onMoveChapter,
318
614
  onDuplicate,
319
615
  onDelete,
320
616
  onMoveToEnd,
321
617
  onPatchCard,
322
618
  onLink,
323
619
  onUnlink,
620
+ onSetLinkKind,
621
+ onJump,
324
622
  onToggleLinks,
623
+ agentHint,
624
+ onPageTask,
625
+ planFor,
626
+ onFillChapter,
627
+ onViewPlan,
628
+ progress: columnProgress,
325
629
  }: Props) {
326
630
  const lr = useLrText();
327
- const { fitView, zoomIn, zoomOut, screenToFlowPosition } = useReactFlow();
631
+ const { fitView, zoomIn, zoomOut, screenToFlowPosition, setCenter, getNode, getZoom } =
632
+ useReactFlow();
633
+ const metrics = cardMetrics(size);
634
+
635
+ const layout = useMemo(
636
+ () => layoutBoard(columns, { size, collapsed }),
637
+ [columns, size, collapsed],
638
+ );
328
639
 
329
- const layout = useMemo(() => layoutBoard(columns), [columns]);
640
+ const selectedSet = useMemo(() => new Set(selected), [selected]);
330
641
 
331
642
  const actions = useMemo(
332
- () => ({ onDuplicate, onDelete, onMoveToEnd, onPatchCard }),
333
- [onDuplicate, onDelete, onMoveToEnd, onPatchCard],
643
+ () => ({ onDuplicate, onDelete, onMoveToEnd, onPatchCard, agentHint, onPageTask }),
644
+ [onDuplicate, onDelete, onMoveToEnd, onPatchCard, agentHint, onPageTask],
334
645
  );
335
646
 
336
647
  const columnActions = useMemo(
337
- () => ({ onRename: onRenameColumn, onAddPage }),
338
- [onRenameColumn, onAddPage],
648
+ () => ({
649
+ onRename: onRenameColumn,
650
+ onAddPage,
651
+ onAddChapter,
652
+ onDelete: onDeleteChapter,
653
+ onToggleCollapse,
654
+ onFillChapter,
655
+ onViewPlan,
656
+ planFor,
657
+ columns: columns.length,
658
+ }),
659
+ [
660
+ onRenameColumn,
661
+ onAddPage,
662
+ onAddChapter,
663
+ onDeleteChapter,
664
+ onToggleCollapse,
665
+ onFillChapter,
666
+ onViewPlan,
667
+ planFor,
668
+ columns.length,
669
+ ],
670
+ );
671
+
672
+ const buildArgs = useMemo(
673
+ () => ({
674
+ slideId,
675
+ pages,
676
+ notes,
677
+ cards,
678
+ cardsReady,
679
+ design,
680
+ dimmed,
681
+ changeCounts,
682
+ flashed,
683
+ size,
684
+ actions,
685
+ columnActions,
686
+ progress: columnProgress,
687
+ }),
688
+ [
689
+ slideId,
690
+ pages,
691
+ notes,
692
+ cards,
693
+ cardsReady,
694
+ design,
695
+ dimmed,
696
+ changeCounts,
697
+ flashed,
698
+ size,
699
+ actions,
700
+ columnActions,
701
+ columnProgress,
702
+ ],
339
703
  );
340
704
 
341
705
  const baseNodes = useMemo<Node[]>(
342
706
  () =>
343
707
  buildNodes({
708
+ ...buildArgs,
344
709
  layout,
345
710
  order: identityOrder(pages.length),
346
- slideId,
347
- pages,
348
- notes,
349
- cards,
350
- cardsReady,
351
- design,
352
- actions,
353
- columnActions,
711
+ selected: selectedSet,
354
712
  }),
355
- [layout, slideId, pages, notes, cards, cardsReady, design, actions, columnActions],
713
+ [buildArgs, layout, pages.length, selectedSet],
356
714
  );
357
715
 
358
716
  const [nodes, setNodes] = useState<Node[]>(baseNodes);
@@ -361,46 +719,122 @@ function BoardFlow({
361
719
  useEffect(() => setNodes(baseNodes), [baseNodes]);
362
720
 
363
721
  const dropIndexRef = useRef<number | null>(null);
722
+ const dropGapRef = useRef<number | null>(null);
723
+ const shiftAnchorRef = useRef<number | null>(null);
364
724
 
365
725
  const onNodesChange = useCallback(
366
- (changes: NodeChange[]) => setNodes((current) => applyNodeChanges(changes, current)),
367
- [],
726
+ (changes: NodeChange[]) => {
727
+ // A box selection arrives as one change per node; the board keeps its own
728
+ // list so the toolbar can act on it, and rebuilds the flags from there.
729
+ const selecting = changes.some((change) => change.type === 'select');
730
+ if (selecting) {
731
+ setNodes((current) =>
732
+ applyNodeChanges(
733
+ changes.filter((c) => c.type !== 'select'),
734
+ current,
735
+ ),
736
+ );
737
+ const picked = new Set(selected);
738
+ for (const change of changes) {
739
+ if (change.type !== 'select') continue;
740
+ const index = pageIndexOf(change.id);
741
+ if (change.selected) picked.add(index);
742
+ else picked.delete(index);
743
+ }
744
+ const next = [...picked].filter((index) => Number.isInteger(index)).sort((a, b) => a - b);
745
+ if (!sameSelection(next, selected)) onSelect(next);
746
+ return;
747
+ }
748
+ setNodes((current) => applyNodeChanges(changes, current));
749
+ },
750
+ [onSelect, selected],
751
+ );
752
+
753
+ /** The pages a drag carries: the whole selection when the card is part of it. */
754
+ const movingFor = useCallback(
755
+ (from: number) => (selectedSet.has(from) && selected.length > 1 ? [...selected] : [from]),
756
+ [selected, selectedSet],
368
757
  );
369
758
 
370
759
  const handleDrag = useCallback<OnNodeDrag>(
371
760
  (_event, node) => {
372
761
  if (node.type !== 'page') return;
373
762
  const from = pageIndexOf(node.id);
763
+ const moving = movingFor(from).sort((a, b) => a - b);
764
+
765
+ // Dropping in the gap between two chapters starts a chapter there.
766
+ const gap =
767
+ moving.length === 1
768
+ ? gapAtPoint(
769
+ layout,
770
+ node.position.x + metrics.boxW / 2,
771
+ node.position.y + metrics.boxH / 2,
772
+ )
773
+ : null;
774
+ if (gap !== dropGapRef.current) {
775
+ dropGapRef.current = gap;
776
+ dropIndexRef.current = null;
777
+ }
778
+ if (gap !== null) {
779
+ const left = layout.columns[gap - 1];
780
+ const right = layout.columns[gap];
781
+ const center = (left.x + left.boxW + right.x) / 2;
782
+ dropIndexRef.current = null;
783
+ setNodes((current) =>
784
+ current.map((n) =>
785
+ n.id === 'drop-slot'
786
+ ? {
787
+ ...n,
788
+ hidden: false,
789
+ position: { x: center - metrics.boxW / 2, y: 48 },
790
+ data: { width: metrics.boxW, height: metrics.boxH, newChapter: true },
791
+ }
792
+ : n.id === node.id
793
+ ? { ...n, position: n.position, dragging: true, zIndex: 20 }
794
+ : n,
795
+ ),
796
+ );
797
+ return;
798
+ }
799
+
374
800
  // Hit-testing stays on the settled layout: testing against the preview
375
801
  // would move the target out from under the cursor and oscillate.
376
- const to = slotAtPoint(layout, node.position.x, node.position.y, from);
802
+ const to = slotAtPoint(layout, node.position.x, node.position.y, moving[0]);
377
803
  if (dropIndexRef.current === to) return;
378
804
  dropIndexRef.current = to;
379
805
 
380
806
  // Chapters re-form when a chapter page moves, and a column's length decides
381
807
  // where the next column starts — so the preview has to be laid out from the
382
808
  // prospective deck rather than by shuffling cards through today's geometry.
383
- const order = orderAfterMove(pages.length, from, to);
384
- const previewLayout = layoutBoard(columnsAfterMove(columns, from, to));
809
+ const order = orderAfterMoveMany(pages.length, moving, to);
810
+ const previewLayout = layoutBoard(columnsAfterMoveMany(columns, moving, to), {
811
+ size,
812
+ collapsed,
813
+ });
385
814
  const preview = buildNodes({
815
+ ...buildArgs,
386
816
  layout: previewLayout,
387
817
  order,
388
- slideId,
389
- pages,
390
- notes,
391
- cards,
392
- cardsReady,
393
- design,
394
- actions,
395
- columnActions,
818
+ selected: selectedSet,
396
819
  });
397
- const target = previewLayout.slots[order.indexOf(from)];
820
+ const target = previewLayout.slots[order.indexOf(moving[0])];
398
821
 
399
822
  setNodes((current) => {
400
823
  const live = current.find((n) => n.id === node.id);
401
824
  return preview.map((n) => {
402
825
  if (n.id === 'drop-slot') {
403
- return target ? { ...n, hidden: false, position: { x: target.x, y: target.y } } : n;
826
+ return target
827
+ ? {
828
+ ...n,
829
+ hidden: false,
830
+ position: { x: target.x, y: target.y },
831
+ data: {
832
+ width: metrics.boxW,
833
+ height: metrics.boxH,
834
+ newChapter: false,
835
+ },
836
+ }
837
+ : n;
404
838
  }
405
839
  // The card under the cursor keeps following the pointer.
406
840
  if (n.id === node.id) {
@@ -410,26 +844,64 @@ function BoardFlow({
410
844
  });
411
845
  });
412
846
  },
413
- [layout, columns, slideId, pages, notes, cards, cardsReady, design, actions, columnActions],
847
+ [layout, columns, collapsed, size, metrics, pages.length, buildArgs, movingFor, selectedSet],
414
848
  );
415
849
 
416
850
  const handleDragStop = useCallback<OnNodeDrag>(
417
851
  (_event, node) => {
418
- if (node.type !== 'page') return;
419
- const from = pageIndexOf(node.id);
420
- const to = dropIndexRef.current ?? from;
852
+ const gap = dropGapRef.current;
853
+ const to = dropIndexRef.current;
854
+ dropGapRef.current = null;
421
855
  dropIndexRef.current = null;
856
+
422
857
  setNodes((current) =>
423
858
  current.map((n) => (n.id === 'drop-slot' ? { ...n, hidden: true } : n)),
424
859
  );
425
- if (to === from) {
860
+
861
+ if (node.type === 'columnLabel') {
862
+ const from = Number(node.id.replace('column-', ''));
863
+ const center = node.position.x + metrics.boxW / 2;
864
+ let to1 = from;
865
+ let best = Number.POSITIVE_INFINITY;
866
+ layout.columns.forEach((column, i) => {
867
+ const distance = Math.abs(column.x + column.boxW / 2 - center);
868
+ if (distance < best) {
869
+ best = distance;
870
+ to1 = i;
871
+ }
872
+ });
873
+ setNodes(baseNodes);
874
+ if (to1 !== from) onMoveChapter(from, to1);
875
+ return;
876
+ }
877
+ if (node.type !== 'page') return;
878
+
879
+ const from = pageIndexOf(node.id);
880
+ if (gap !== null) {
881
+ setNodes(baseNodes);
882
+ onMoveToNewChapter(from, gap);
883
+ return;
884
+ }
885
+ const moving = movingFor(from).sort((a, b) => a - b);
886
+ const target = to ?? from;
887
+ const order = orderAfterMoveMany(pages.length, moving, target);
888
+ if (order.every((value, i) => value === i)) {
426
889
  // Snap the card back to its own slot instead of leaving it where it was dropped.
427
890
  setNodes(baseNodes);
428
891
  return;
429
892
  }
430
- onMovePage(from, to);
893
+ onMovePages(moving, target);
431
894
  },
432
- [baseNodes, onMovePage],
895
+ [
896
+ baseNodes,
897
+ layout,
898
+ metrics,
899
+ pages.length,
900
+ movingFor,
901
+ onMovePages,
902
+ onMoveToNewChapter,
903
+ onMoveChapter,
904
+ ],
433
905
  );
434
906
 
435
907
  // Opening on the whole board squeezes a long deck down to unreadable cards, so
@@ -439,7 +911,9 @@ function BoardFlow({
439
911
  const opening = layout.slots.filter((slot) => slot.column === 0);
440
912
  if (opening.length === 0) return;
441
913
  fitView({
442
- nodes: opening.map((slot) => ({ id: `page-${slot.index}` })),
914
+ // The chapter label sits above its first card, so framing only the cards
915
+ // would cut it off at the top edge.
916
+ nodes: [{ id: 'column-0' }, ...opening.map((slot) => ({ id: `page-${slot.index}` }))],
443
917
  padding: 0.22,
444
918
  maxZoom: 0.75,
445
919
  });
@@ -447,6 +921,29 @@ function BoardFlow({
447
921
 
448
922
  const fitAll = useCallback(() => fitView({ padding: 0.12, maxZoom: 0.9 }), [fitView]);
449
923
 
924
+ /** Puts a page in the middle of the canvas, at a size its text can be read at. */
925
+ const centerOn = useCallback(
926
+ (index: number) => {
927
+ const node = getNode(`page-${index}`);
928
+ if (!node) return;
929
+ const width = node.measured?.width ?? metrics.boxW;
930
+ const height = node.measured?.height ?? metrics.boxH;
931
+ void setCenter(node.position.x + width / 2, node.position.y + height / 2, {
932
+ zoom: Math.max(getZoom(), 0.6),
933
+ duration: 400,
934
+ });
935
+ },
936
+ [getNode, getZoom, metrics, setCenter],
937
+ );
938
+
939
+ const jump = useCallback(
940
+ (index: number) => {
941
+ onJump(index);
942
+ centerOn(index);
943
+ },
944
+ [centerOn, onJump],
945
+ );
946
+
450
947
  const edges = useMemo<Edge[]>(() => {
451
948
  const byIndex = new Map(layout.slots.map((slot) => [slot.index, slot]));
452
949
  const mainLine: Edge[] = pages.slice(0, -1).map((_, i) => {
@@ -465,17 +962,26 @@ function BoardFlow({
465
962
  };
466
963
  });
467
964
  if (!showLinks) return mainLine;
468
- const linkLines: Edge[] = links.map(([a, b]) => ({
965
+ const linkLines: Edge[] = links.map(({ a, b, kind }) => ({
469
966
  id: `link-${Math.min(a, b)}-${Math.max(a, b)}`,
470
967
  source: `page-${a}`,
471
968
  target: `page-${b}`,
472
969
  type: 'link',
473
- data: { a, b, onUnlink } satisfies LinkEdgeData,
970
+ data: {
971
+ a,
972
+ b,
973
+ kind,
974
+ onUnlink,
975
+ onSetKind: onSetLinkKind,
976
+ onJump: jump,
977
+ } satisfies LinkEdgeData,
978
+ // A cause points the way it was drawn; the other relations have no direction.
979
+ markerEnd: kind === 'cause' ? marker : undefined,
474
980
  selectable: false,
475
981
  focusable: false,
476
982
  }));
477
983
  return [...mainLine, ...linkLines];
478
- }, [layout, pages, links, showLinks, onUnlink]);
984
+ }, [layout, pages, links, showLinks, onUnlink, onSetLinkKind, jump]);
479
985
 
480
986
  // A link is drawn by dragging a card's dot onto another card. The whole card is
481
987
  // the target rather than a handle on it, because a handle is too small to hit
@@ -503,6 +1009,19 @@ function BoardFlow({
503
1009
  onNodesChange={onNodesChange}
504
1010
  onNodeDrag={handleDrag}
505
1011
  onNodeDragStop={handleDragStop}
1012
+ onNodeClick={(event, node) => {
1013
+ if (node.type !== 'page') return;
1014
+ const index = pageIndexOf(node.id);
1015
+ if (event.shiftKey) {
1016
+ const anchor = shiftAnchorRef.current ?? index;
1017
+ const [a, b] = [Math.min(anchor, index), Math.max(anchor, index)];
1018
+ const range: number[] = [];
1019
+ for (let i = a; i <= b; i++) range.push(i);
1020
+ onSelect(range);
1021
+ return;
1022
+ }
1023
+ shiftAnchorRef.current = index;
1024
+ }}
506
1025
  onNodeDoubleClick={(_, node) => {
507
1026
  if (node.type === 'page') onOpenPage(pageIndexOf(node.id));
508
1027
  }}
@@ -515,6 +1034,10 @@ function BoardFlow({
515
1034
  maxZoom={1.5}
516
1035
  panOnScroll
517
1036
  selectionOnDrag
1037
+ // A page is removed only through the board's own confirmation dialog.
1038
+ deleteKeyCode={null}
1039
+ multiSelectionKeyCode={['Meta', 'Control']}
1040
+ selectionKeyCode={null}
518
1041
  className="osd-board"
519
1042
  >
520
1043
  <Background variant={BackgroundVariant.Dots} gap={28} size={1} className="osd-board-bg" />