@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.
- package/README.md +14 -4
- package/dist/{build-Nl7EeJ6x.js → build-RlcGG-Ve.js} +1 -1
- package/dist/cli/bin.js +4 -4
- package/dist/{config-CpC0nM3r.js → config-BJT87wE9.js} +4756 -2012
- package/dist/{dev-BB3THd5I.js → dev-DR-j_xda.js} +2 -2
- package/dist/{preview-BGjgTg7H.js → preview-BTAhTb5B.js} +1 -1
- package/dist/{update-DsxZBtwv.js → update-CMRxtTc9.js} +18 -8
- package/dist/vite/index.js +1 -1
- package/package.json +2 -2
- package/src/agent/types.ts +14 -2
- package/src/app/components/agent/agent-panel.tsx +17 -5
- package/src/app/components/agent/connect-view.tsx +1 -1
- package/src/app/components/agent/provider-logo.tsx +10 -1
- package/src/app/lemonriver/agent/provider-marks.tsx +53 -0
- package/src/app/lemonriver/agent-providers/section.tsx +75 -0
- package/src/app/lemonriver/agent-providers/use-providers.ts +61 -0
- package/src/app/lemonriver/board/blocks/block-panel.tsx +666 -0
- package/src/app/lemonriver/board/blocks/cache.ts +28 -0
- package/src/app/lemonriver/board/blocks/change-list.tsx +189 -0
- package/src/app/lemonriver/board/blocks/classify.test.ts +209 -0
- package/src/app/lemonriver/board/blocks/classify.ts +152 -0
- package/src/app/lemonriver/board/blocks/snapshot.ts +116 -0
- package/src/app/lemonriver/board/board-canvas.tsx +627 -104
- package/src/app/lemonriver/board/board-page.tsx +1702 -91
- package/src/app/lemonriver/board/board.css +58 -7
- package/src/app/lemonriver/board/layout.test.ts +84 -0
- package/src/app/lemonriver/board/layout.ts +112 -11
- package/src/app/lemonriver/board/model/agent-tasks.test.ts +200 -0
- package/src/app/lemonriver/board/model/agent-tasks.ts +223 -0
- package/src/app/lemonriver/board/model/apply-prompt.test.ts +121 -0
- package/src/app/lemonriver/board/model/apply-prompt.ts +115 -0
- package/src/app/lemonriver/board/model/apply.ts +71 -0
- package/src/app/lemonriver/board/model/cards.test.ts +95 -2
- package/src/app/lemonriver/board/model/cards.ts +88 -20
- package/src/app/lemonriver/board/model/changes.test.ts +244 -0
- package/src/app/lemonriver/board/model/changes.ts +268 -0
- package/src/app/lemonriver/board/model/filter.test.ts +50 -0
- package/src/app/lemonriver/board/model/filter.ts +42 -0
- package/src/app/lemonriver/board/model/history.test.ts +71 -0
- package/src/app/lemonriver/board/model/history.ts +51 -0
- package/src/app/lemonriver/board/model/restructure.test.ts +205 -0
- package/src/app/lemonriver/board/model/restructure.ts +169 -0
- package/src/app/lemonriver/board/model/self-check.test.ts +329 -0
- package/src/app/lemonriver/board/model/self-check.ts +489 -0
- package/src/app/lemonriver/board/model/structure.test.ts +249 -0
- package/src/app/lemonriver/board/model/structure.ts +209 -0
- package/src/app/lemonriver/board/model/timing.test.ts +113 -0
- package/src/app/lemonriver/board/model/timing.ts +117 -0
- package/src/app/lemonriver/board/page-node.tsx +258 -55
- package/src/app/lemonriver/board/self-check-jump.ts +23 -0
- package/src/app/lemonriver/board/self-check-panel.tsx +272 -0
- package/src/app/lemonriver/board/self-check-runner.tsx +150 -0
- package/src/app/lemonriver/board/status-style.ts +25 -0
- package/src/app/lemonriver/board/use-board-apply.ts +206 -0
- package/src/app/lemonriver/board/use-board-cards.ts +108 -5
- package/src/app/lemonriver/board/use-board-changes.ts +108 -0
- package/src/app/lemonriver/board/use-board-columns.ts +37 -56
- package/src/app/lemonriver/board/use-board-comments.ts +36 -0
- package/src/app/lemonriver/board/use-board-restructures.ts +107 -0
- package/src/app/lemonriver/board/use-history.ts +86 -0
- package/src/app/lemonriver/board/use-page-order.ts +65 -38
- package/src/app/lemonriver/board/use-self-check.ts +117 -0
- package/src/app/lemonriver/board/use-target-minutes.ts +47 -0
- package/src/app/lemonriver/board/views/block-readings.tsx +46 -0
- package/src/app/lemonriver/board/views/list-view.tsx +356 -0
- package/src/app/lemonriver/board/views/progress.tsx +32 -0
- package/src/app/lemonriver/board/views/timeline-view.tsx +341 -0
- package/src/app/lemonriver/chrome/filter-pill.tsx +30 -0
- package/src/app/lemonriver/chrome/sidebar-extras.tsx +12 -1
- package/src/app/lemonriver/features.test.ts +5 -0
- package/src/app/lemonriver/features.ts +2 -1
- package/src/app/lemonriver/home/deck-card.tsx +10 -0
- package/src/app/lemonriver/home/home-page.tsx +55 -6
- package/src/app/lemonriver/home/use-deck-times.ts +4 -1
- package/src/app/lemonriver/outline/build-team.tsx +42 -0
- package/src/app/lemonriver/outline/describe-page.tsx +128 -27
- package/src/app/lemonriver/outline/draft.ts +38 -0
- package/src/app/lemonriver/outline/model.test.ts +118 -0
- package/src/app/lemonriver/outline/model.ts +92 -7
- package/src/app/lemonriver/outline/outline-page.tsx +90 -7
- package/src/app/lemonriver/outline/pick-style.tsx +282 -0
- package/src/app/lemonriver/routes.test.tsx +17 -5
- package/src/app/lemonriver/routes.tsx +28 -0
- package/src/app/lemonriver/settings/settings-page.tsx +3 -0
- package/src/app/lemonriver/slide-extensions.tsx +14 -2
- package/src/app/lemonriver/templates/client.ts +60 -0
- package/src/app/lemonriver/templates/demo-page.tsx +79 -0
- package/src/app/lemonriver/templates/knobs.test.ts +62 -0
- package/src/app/lemonriver/templates/knobs.ts +62 -0
- package/src/app/lemonriver/templates/library-page.tsx +292 -0
- package/src/app/lemonriver/templates/model.test.ts +175 -0
- package/src/app/lemonriver/templates/model.ts +339 -0
- package/src/app/lemonriver/templates/preview-content.test.ts +117 -0
- package/src/app/lemonriver/templates/preview-content.ts +149 -0
- package/src/app/lemonriver/templates/recommend.test.ts +71 -0
- package/src/app/lemonriver/templates/recommend.ts +72 -0
- package/src/app/lemonriver/templates/use-library.ts +58 -0
- package/src/app/lemonriver/templates/virtual.d.ts +28 -0
- package/src/app/lemonriver/text/en.ts +228 -0
- package/src/app/lemonriver/text/es.ts +220 -0
- package/src/app/lemonriver/text/ja.ts +220 -0
- package/src/app/lemonriver/text/types.ts +243 -0
- package/src/app/lemonriver/text/zh-cn.ts +218 -0
- package/src/app/lemonriver/text/zh-tw.ts +218 -0
- package/src/app/lemonriver/theme/lemon-icon.tsx +6 -0
- package/src/app/lemonriver/theme/pages.test.ts +4 -0
- package/src/app/lemonriver/theme/pages.ts +6 -1
- package/src/app/lemonriver/theme/theme-menu.tsx +3 -2
- package/src/app/lemonriver/theme/use-theme.tsx +2 -2
- package/src/app/lemonriver/update/prompt.ts +1 -1
- package/src/app/lib/agent/use-agent.ts +4 -3
- package/src/app/routes/slide.tsx +1 -1
- package/src/app/assets/open-slide.svg +0 -39
- package/src/app/favicon.ico +0 -0
- package/src/app/favicon.svg +0 -39
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { format } from '../../../../locale/format';
|
|
2
|
+
import type { Locale } from '../../../../locale/types';
|
|
3
|
+
import { lrTextFor } from '../../text/all';
|
|
4
|
+
import type { Block } from '../blocks/classify';
|
|
5
|
+
|
|
6
|
+
/** How long a page takes to say, and what that number was read from. */
|
|
7
|
+
export type Timing = { seconds: number; basis: 'notes' | 'page' | 'none' };
|
|
8
|
+
|
|
9
|
+
const CHARS_PER_MINUTE = 240;
|
|
10
|
+
const WORDS_PER_MINUTE = 150;
|
|
11
|
+
const MIN_SECONDS = 15;
|
|
12
|
+
/** A picture the speaker has to talk over, when nothing else says how long. */
|
|
13
|
+
const PICTURE_SECONDS = 5;
|
|
14
|
+
const STEP = 5;
|
|
15
|
+
|
|
16
|
+
/** Han, kana and the punctuation that reads as a character of its own. */
|
|
17
|
+
const CJK = /[々〇-ヿ㐀-䶿一-鿿豈-ヲ-゚]/g;
|
|
18
|
+
|
|
19
|
+
/** Seconds to say `text`: Chinese and Japanese by the character, the rest by the word. */
|
|
20
|
+
export function speakingSeconds(text: string): number {
|
|
21
|
+
const chars = text.match(CJK)?.length ?? 0;
|
|
22
|
+
const words = text
|
|
23
|
+
.replace(CJK, ' ')
|
|
24
|
+
.split(/\s+/)
|
|
25
|
+
.filter((word) => /[\p{L}\p{N}]/u.test(word)).length;
|
|
26
|
+
return (chars / CHARS_PER_MINUTE) * 60 + (words / WORDS_PER_MINUTE) * 60;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Rounded to five seconds, and never under the time it takes to switch pages. */
|
|
30
|
+
const settle = (seconds: number) => Math.max(MIN_SECONDS, Math.round(seconds / STEP) * STEP);
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Speaker notes win when the page has them — they are what will actually be
|
|
34
|
+
* said. Otherwise the words on the page stand in for them, with a few seconds
|
|
35
|
+
* for every picture or chart on it. A page whose blocks cannot be read only
|
|
36
|
+
* gets the minimum.
|
|
37
|
+
*/
|
|
38
|
+
export function estimateSeconds({
|
|
39
|
+
notes,
|
|
40
|
+
blocks,
|
|
41
|
+
}: {
|
|
42
|
+
notes?: string;
|
|
43
|
+
blocks: Block[] | null;
|
|
44
|
+
}): Timing {
|
|
45
|
+
if (notes?.trim()) return { seconds: settle(speakingSeconds(notes)), basis: 'notes' };
|
|
46
|
+
if (!blocks) return { seconds: MIN_SECONDS, basis: 'none' };
|
|
47
|
+
|
|
48
|
+
const words = blocks
|
|
49
|
+
.map((block) => block.text)
|
|
50
|
+
.filter(Boolean)
|
|
51
|
+
.join(' ');
|
|
52
|
+
const pictures = blocks.filter(
|
|
53
|
+
(block) => block.kind === 'image' || block.kind === 'chart',
|
|
54
|
+
).length;
|
|
55
|
+
return {
|
|
56
|
+
seconds: settle(speakingSeconds(words) + pictures * PICTURE_SECONDS),
|
|
57
|
+
basis: 'page',
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** "45s", "1m 20s", "12 min" — the units come from the deck's language. */
|
|
62
|
+
export function formatDuration(seconds: number, locale: Locale['id']): string {
|
|
63
|
+
const text = lrTextFor(locale).board;
|
|
64
|
+
const total = Math.max(0, Math.round(seconds));
|
|
65
|
+
const minutes = Math.floor(total / 60);
|
|
66
|
+
const rest = total % 60;
|
|
67
|
+
if (minutes === 0) return format(text.durationSeconds, { s: rest });
|
|
68
|
+
if (rest === 0) return format(text.durationMinutes, { m: minutes });
|
|
69
|
+
return format(text.durationMinSec, { m: minutes, s: rest });
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** Pixels a second takes on the timeline, and the narrowest a page may be drawn. */
|
|
73
|
+
export const PX_PER_SECOND = 4;
|
|
74
|
+
export const MIN_SEGMENT_PX = 48;
|
|
75
|
+
|
|
76
|
+
const TARGET_MAX_MINUTES = 180;
|
|
77
|
+
|
|
78
|
+
/** The length the deck is aiming for, in whole minutes, or null for no target. */
|
|
79
|
+
export function sanitizeTargetMinutes(raw: unknown): number | null {
|
|
80
|
+
const value =
|
|
81
|
+
typeof raw === 'string' && raw.trim() ? Number(raw) : typeof raw === 'number' ? raw : null;
|
|
82
|
+
if (value === null || !Number.isFinite(value)) return null;
|
|
83
|
+
const minutes = Math.round(value);
|
|
84
|
+
return minutes >= 1 && minutes <= TARGET_MAX_MINUTES ? minutes : null;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export type Segment = { start: number; width: number };
|
|
88
|
+
|
|
89
|
+
/** Where each page's stretch sits on the track, in track pixels. */
|
|
90
|
+
export function timelineSegments(seconds: number[]): Segment[] {
|
|
91
|
+
let at = 0;
|
|
92
|
+
return seconds.map((value) => {
|
|
93
|
+
const width = Math.max(MIN_SEGMENT_PX, value * PX_PER_SECOND);
|
|
94
|
+
const segment = { start: at, width };
|
|
95
|
+
at += width;
|
|
96
|
+
return segment;
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Where a moment of the talk falls on the track. Pages drawn at their minimum
|
|
102
|
+
* width take more room than their time, so the moment is read from the time up
|
|
103
|
+
* to the page's own start rather than from the pixel count.
|
|
104
|
+
*/
|
|
105
|
+
export function xForSeconds(seconds: number[], target: number): number {
|
|
106
|
+
const segments = timelineSegments(seconds);
|
|
107
|
+
const total = segments.reduce((sum, segment) => sum + segment.width, 0);
|
|
108
|
+
let spoken = 0;
|
|
109
|
+
for (const [index, value] of seconds.entries()) {
|
|
110
|
+
if (value <= 0) continue;
|
|
111
|
+
if (target <= spoken + value) {
|
|
112
|
+
return segments[index].start + ((target - spoken) / value) * segments[index].width;
|
|
113
|
+
}
|
|
114
|
+
spoken += value;
|
|
115
|
+
}
|
|
116
|
+
return total;
|
|
117
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Handle, type NodeProps, Position } from '@xyflow/react';
|
|
2
|
-
import { Copy, MoveRight, Trash2 } from 'lucide-react';
|
|
3
|
-
import { memo, useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { BarChart3, Copy, Maximize2, MoveRight, PenLine, StickyNote, Trash2 } from 'lucide-react';
|
|
3
|
+
import { memo, useCallback, useEffect, useRef, useState } from 'react';
|
|
4
4
|
import {
|
|
5
5
|
ContextMenu,
|
|
6
6
|
ContextMenuContent,
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
ContextMenuSubTrigger,
|
|
14
14
|
ContextMenuTrigger,
|
|
15
15
|
} from '@/components/ui/context-menu';
|
|
16
|
-
import { format, useLocale } from '@/lib/use-locale';
|
|
16
|
+
import { format, plural, useLocale } from '@/lib/use-locale';
|
|
17
17
|
import { cn, pad2 } from '@/lib/utils';
|
|
18
18
|
import { SlideCanvas } from '../../components/slide-canvas';
|
|
19
19
|
import type { DesignSystem } from '../../lib/design';
|
|
@@ -21,7 +21,11 @@ import { useNotes } from '../../lib/inspector/use-notes';
|
|
|
21
21
|
import { SlidePageProvider } from '../../lib/page-context';
|
|
22
22
|
import { CANVAS_WIDTH, type Page } from '../../lib/sdk';
|
|
23
23
|
import { useLrText } from '../text';
|
|
24
|
-
import {
|
|
24
|
+
import { type PageRead, pageReadOf, rememberPageRead, sameRead } from './blocks/cache';
|
|
25
|
+
import { readBlocks } from './blocks/classify';
|
|
26
|
+
import { snapshotPage } from './blocks/snapshot';
|
|
27
|
+
import type { CardMetrics, CardSize } from './layout';
|
|
28
|
+
import { PAGE_ACTIONS, type PageAction } from './model/agent-tasks';
|
|
25
29
|
import {
|
|
26
30
|
type BoardCard,
|
|
27
31
|
CARD_STATUSES,
|
|
@@ -29,6 +33,8 @@ import {
|
|
|
29
33
|
type CardStatus,
|
|
30
34
|
isCardStatus,
|
|
31
35
|
} from './model/cards';
|
|
36
|
+
import { findingsForPage, findingText, isPageUnread } from './self-check-panel';
|
|
37
|
+
import { STATUS_STYLE } from './status-style';
|
|
32
38
|
|
|
33
39
|
export type PageNodeData = {
|
|
34
40
|
slideId: string;
|
|
@@ -43,19 +49,30 @@ export type PageNodeData = {
|
|
|
43
49
|
canLink: boolean;
|
|
44
50
|
design?: DesignSystem;
|
|
45
51
|
canDelete: boolean;
|
|
52
|
+
size: CardSize;
|
|
53
|
+
metrics: CardMetrics;
|
|
54
|
+
/** True when a filter is on and this card is not one of the ones picked out. */
|
|
55
|
+
dimmed: boolean;
|
|
56
|
+
/** How many block moves this page is a source or a target of. */
|
|
57
|
+
changeCount?: number;
|
|
58
|
+
/** The last apply touched this page: it lights up for a moment. */
|
|
59
|
+
flash?: boolean;
|
|
46
60
|
onDuplicate: (index: number) => void;
|
|
47
61
|
onDelete: (index: number) => void;
|
|
48
62
|
onMoveToEnd: (index: number) => void;
|
|
49
63
|
onPatchCard: (index: number, patch: CardPatch) => void;
|
|
64
|
+
/** Why the one-page agent actions are off, or null when they can run. */
|
|
65
|
+
agentHint: string | null;
|
|
66
|
+
onPageTask: (index: number, action: PageAction) => void;
|
|
50
67
|
};
|
|
51
68
|
|
|
52
69
|
const hiddenHandle = { opacity: 0, width: 1, height: 1, minWidth: 1, minHeight: 1 } as const;
|
|
53
70
|
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
71
|
+
const ASK_ICON: Record<PageAction, typeof PenLine> = {
|
|
72
|
+
rewrite: PenLine,
|
|
73
|
+
chart: BarChart3,
|
|
74
|
+
memo: StickyNote,
|
|
75
|
+
expand: Maximize2,
|
|
59
76
|
};
|
|
60
77
|
|
|
61
78
|
export function useStatusLabels(): Record<CardStatus, string> {
|
|
@@ -80,63 +97,166 @@ export function PageNode({ data, selected, dragging }: NodeProps) {
|
|
|
80
97
|
canLink,
|
|
81
98
|
design,
|
|
82
99
|
canDelete,
|
|
100
|
+
size,
|
|
101
|
+
metrics,
|
|
102
|
+
dimmed,
|
|
103
|
+
changeCount = 0,
|
|
104
|
+
flash = false,
|
|
83
105
|
...actions
|
|
84
106
|
} = data as unknown as PageNodeData;
|
|
85
107
|
const t = useLocale();
|
|
86
108
|
const lr = useLrText();
|
|
87
109
|
const labels = useStatusLabels();
|
|
110
|
+
const askLabels: Record<PageAction, string> = {
|
|
111
|
+
rewrite: lr.board.askRewrite,
|
|
112
|
+
chart: lr.board.askChart,
|
|
113
|
+
memo: lr.board.askMemo,
|
|
114
|
+
expand: lr.board.askExpand,
|
|
115
|
+
};
|
|
88
116
|
const status = card?.status;
|
|
89
117
|
const [renaming, setRenaming] = useState(false);
|
|
118
|
+
const [readFor, setReadFor] = useState<{ page: Page; read: PageRead } | null>(null);
|
|
119
|
+
const onRead = useCallback(
|
|
120
|
+
(next: PageRead) =>
|
|
121
|
+
setReadFor((previous) =>
|
|
122
|
+
previous && previous.page === PageComp && sameRead(previous.read, next)
|
|
123
|
+
? previous
|
|
124
|
+
: { page: PageComp, read: next },
|
|
125
|
+
),
|
|
126
|
+
[PageComp],
|
|
127
|
+
);
|
|
128
|
+
const read = readFor && readFor.page === PageComp ? readFor.read : pageReadOf(PageComp);
|
|
129
|
+
const whole = read && 'whole' in read ? read.whole : null;
|
|
90
130
|
// A menu hands focus back to the card as it closes, which would pull the caret
|
|
91
131
|
// straight out of the name field "Rename" just opened.
|
|
92
132
|
const renameFromMenu = useRef(false);
|
|
93
133
|
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
134
|
+
const ring = selected
|
|
135
|
+
? 'ring-2 ring-brand'
|
|
136
|
+
: status
|
|
137
|
+
? cn('ring-2', STATUS_STYLE[status].ring)
|
|
138
|
+
: 'ring-1 ring-hairline hover:ring-muted-foreground/30';
|
|
139
|
+
|
|
140
|
+
const statusLabel = status && (
|
|
141
|
+
<span className="flex shrink-0 items-center gap-1.5 text-[11px] text-muted-foreground">
|
|
142
|
+
<span className={cn('size-2 rounded-full', STATUS_STYLE[status].dot)} />
|
|
143
|
+
{labels[status]}
|
|
144
|
+
</span>
|
|
145
|
+
);
|
|
146
|
+
|
|
147
|
+
const findings = findingsForPage(index);
|
|
148
|
+
const unread = isPageUnread(index);
|
|
149
|
+
|
|
150
|
+
/** What the board knows about this page's blocks, beside its status. */
|
|
151
|
+
const meta = (whole || changeCount > 0 || statusLabel || findings.length > 0 || unread) && (
|
|
152
|
+
<span className="ml-auto flex shrink-0 items-center gap-1.5">
|
|
153
|
+
{unread && (
|
|
154
|
+
<span
|
|
155
|
+
data-lr-card-unread
|
|
156
|
+
title={lr.board.cardUnread}
|
|
157
|
+
className="rounded-[3px] bg-muted px-1 py-0.5 text-[10.5px] text-muted-foreground"
|
|
158
|
+
>
|
|
159
|
+
{lr.board.cardUnread}
|
|
160
|
+
</span>
|
|
105
161
|
)}
|
|
106
|
-
|
|
107
|
-
|
|
162
|
+
{findings.length > 0 && (
|
|
163
|
+
<span
|
|
164
|
+
data-lr-card-findings={findings.length}
|
|
165
|
+
title={findings.map((finding) => findingText(lr.board, finding)).join(' · ')}
|
|
166
|
+
className="rounded-[3px] bg-[var(--lr-accent)]/12 px-1 py-0.5 text-[10.5px] text-[var(--lr-accent)]"
|
|
167
|
+
>
|
|
168
|
+
{format(lr.board.cardFindings, { n: findings.length })}
|
|
169
|
+
</span>
|
|
170
|
+
)}
|
|
171
|
+
{whole && (
|
|
172
|
+
<span
|
|
173
|
+
title={lr.board.whole[whole]}
|
|
174
|
+
className="rounded-[3px] bg-muted px-1 py-0.5 text-[10.5px] text-muted-foreground"
|
|
175
|
+
>
|
|
176
|
+
{lr.board.wholeBadge}
|
|
177
|
+
</span>
|
|
178
|
+
)}
|
|
179
|
+
{changeCount > 0 && (
|
|
180
|
+
<span className="rounded-[3px] bg-[var(--lr-accent)]/12 px-1 py-0.5 text-[10.5px] text-[var(--lr-accent)]">
|
|
181
|
+
{format(plural(changeCount, lr.board.pageChanges), { n: changeCount })}
|
|
182
|
+
</span>
|
|
183
|
+
)}
|
|
184
|
+
{statusLabel}
|
|
185
|
+
</span>
|
|
186
|
+
);
|
|
187
|
+
|
|
188
|
+
const title = (
|
|
189
|
+
<CardTitle
|
|
190
|
+
title={card?.title}
|
|
191
|
+
editing={renaming}
|
|
192
|
+
disabled={!cardsReady}
|
|
193
|
+
onEditingChange={setRenaming}
|
|
194
|
+
onCommit={(next) => actions.onPatchCard(index, { title: next })}
|
|
195
|
+
/>
|
|
196
|
+
);
|
|
197
|
+
|
|
198
|
+
const view =
|
|
199
|
+
size === 'title' ? (
|
|
108
200
|
<div
|
|
109
|
-
className=
|
|
110
|
-
|
|
201
|
+
className={cn(
|
|
202
|
+
'osd-board-card group/card flex items-center gap-2 rounded-[8px] bg-card px-2.5',
|
|
203
|
+
'motion-safe:transition-[box-shadow,ring-color,scale,opacity]',
|
|
204
|
+
ring,
|
|
205
|
+
flash && 'osd-board-applied',
|
|
206
|
+
dragging ? 'cursor-grabbing' : 'cursor-grab',
|
|
207
|
+
)}
|
|
208
|
+
style={{ width: metrics.boxW, height: metrics.boxH, opacity: dimmed ? 0.35 : 1 }}
|
|
111
209
|
>
|
|
112
|
-
<PagePreview page={PageComp} index={index} total={total} design={design} />
|
|
113
|
-
</div>
|
|
114
|
-
<div className="flex h-6 items-center gap-2 px-0.5">
|
|
115
210
|
<span className="font-mono text-[10.5px] tracking-[0.08em] tabular-nums text-muted-foreground/70">
|
|
116
211
|
{pad2(index + 1)}
|
|
117
212
|
</span>
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
213
|
+
{title}
|
|
214
|
+
{meta}
|
|
215
|
+
</div>
|
|
216
|
+
) : (
|
|
217
|
+
<div
|
|
218
|
+
className={cn(
|
|
219
|
+
'osd-board-card group/card flex flex-col gap-2 rounded-[8px] bg-card p-1.5',
|
|
220
|
+
'motion-safe:transition-[box-shadow,ring-color,scale,opacity]',
|
|
221
|
+
ring,
|
|
222
|
+
flash && 'osd-board-applied',
|
|
223
|
+
dragging ? 'cursor-grabbing' : 'cursor-grab',
|
|
224
|
+
)}
|
|
225
|
+
style={{ width: metrics.boxW, opacity: dimmed ? 0.35 : 1 }}
|
|
226
|
+
>
|
|
227
|
+
<div
|
|
228
|
+
className="relative overflow-hidden rounded-[4px] bg-white ring-1 ring-hairline"
|
|
229
|
+
style={{ width: metrics.cardW, height: metrics.cardH }}
|
|
230
|
+
>
|
|
231
|
+
<PagePreview
|
|
232
|
+
page={PageComp}
|
|
233
|
+
index={index}
|
|
234
|
+
total={total}
|
|
235
|
+
design={design}
|
|
236
|
+
scale={metrics.cardW / CANVAS_WIDTH}
|
|
237
|
+
onRead={onRead}
|
|
238
|
+
/>
|
|
239
|
+
</div>
|
|
240
|
+
<div className="flex h-6 items-center gap-2 px-0.5">
|
|
241
|
+
<span className="font-mono text-[10.5px] tracking-[0.08em] tabular-nums text-muted-foreground/70">
|
|
242
|
+
{pad2(index + 1)}
|
|
129
243
|
</span>
|
|
244
|
+
{title}
|
|
245
|
+
{meta}
|
|
246
|
+
</div>
|
|
247
|
+
{size === 'large' && (
|
|
248
|
+
<NoteStrip slideId={slideId} index={index} initial={note} height={metrics.noteH} />
|
|
249
|
+
)}
|
|
250
|
+
{size === 'large' && (
|
|
251
|
+
<MemoStrip
|
|
252
|
+
memo={card?.memo}
|
|
253
|
+
disabled={!cardsReady}
|
|
254
|
+
height={metrics.memoH}
|
|
255
|
+
onCommit={(memo) => actions.onPatchCard(index, { memo })}
|
|
256
|
+
/>
|
|
130
257
|
)}
|
|
131
258
|
</div>
|
|
132
|
-
|
|
133
|
-
<MemoStrip
|
|
134
|
-
memo={card?.memo}
|
|
135
|
-
disabled={!cardsReady}
|
|
136
|
-
onCommit={(memo) => actions.onPatchCard(index, { memo })}
|
|
137
|
-
/>
|
|
138
|
-
</div>
|
|
139
|
-
);
|
|
259
|
+
);
|
|
140
260
|
|
|
141
261
|
return (
|
|
142
262
|
<>
|
|
@@ -192,6 +312,31 @@ export function PageNode({ data, selected, dragging }: NodeProps) {
|
|
|
192
312
|
</ContextMenuSubContent>
|
|
193
313
|
</ContextMenuSub>
|
|
194
314
|
<ContextMenuSeparator />
|
|
315
|
+
<ContextMenuSub>
|
|
316
|
+
<ContextMenuSubTrigger>{lr.board.askAgent}</ContextMenuSubTrigger>
|
|
317
|
+
<ContextMenuSubContent className="min-w-[210px]">
|
|
318
|
+
{PAGE_ACTIONS.map((action) => {
|
|
319
|
+
const needsMemo = action === 'memo' && !card?.memo?.trim();
|
|
320
|
+
const hint =
|
|
321
|
+
actions.agentHint ??
|
|
322
|
+
(changeCount > 0 ? lr.board.askHasChanges : null) ??
|
|
323
|
+
(needsMemo ? lr.board.askNeedsMemo : null);
|
|
324
|
+
const Icon = ASK_ICON[action];
|
|
325
|
+
return (
|
|
326
|
+
<ContextMenuItem
|
|
327
|
+
key={action}
|
|
328
|
+
disabled={hint !== null}
|
|
329
|
+
title={hint ?? undefined}
|
|
330
|
+
onClick={() => actions.onPageTask(index, action)}
|
|
331
|
+
>
|
|
332
|
+
<Icon />
|
|
333
|
+
{askLabels[action]}
|
|
334
|
+
</ContextMenuItem>
|
|
335
|
+
);
|
|
336
|
+
})}
|
|
337
|
+
</ContextMenuSubContent>
|
|
338
|
+
</ContextMenuSub>
|
|
339
|
+
<ContextMenuSeparator />
|
|
195
340
|
<ContextMenuItem onClick={() => actions.onDuplicate(index)}>
|
|
196
341
|
<Copy />
|
|
197
342
|
{t.thumbnailRail.duplicatePage}
|
|
@@ -239,25 +384,79 @@ export function PageNode({ data, selected, dragging }: NodeProps) {
|
|
|
239
384
|
|
|
240
385
|
/**
|
|
241
386
|
* The live page, kept apart so editing a card's title, status or memo does not
|
|
242
|
-
* re-render a page that can carry thousands of elements.
|
|
387
|
+
* re-render a page that can carry thousands of elements. It is also where a
|
|
388
|
+
* page is read for its blocks: the DOM is already here, and the reading waits
|
|
389
|
+
* for the browser to be idle so a board of thirty cards still opens quickly.
|
|
243
390
|
*/
|
|
244
|
-
const PagePreview = memo(function PagePreview({
|
|
391
|
+
export const PagePreview = memo(function PagePreview({
|
|
245
392
|
page: PageComp,
|
|
246
393
|
index,
|
|
247
394
|
total,
|
|
248
395
|
design,
|
|
396
|
+
scale,
|
|
397
|
+
onRead,
|
|
249
398
|
}: {
|
|
250
399
|
page: Page;
|
|
251
400
|
index: number;
|
|
252
401
|
total: number;
|
|
253
402
|
design?: DesignSystem;
|
|
403
|
+
scale: number;
|
|
404
|
+
onRead?: (read: PageRead) => void;
|
|
254
405
|
}) {
|
|
406
|
+
const host = useRef<HTMLDivElement | null>(null);
|
|
407
|
+
|
|
408
|
+
useEffect(() => {
|
|
409
|
+
let cancelled = false;
|
|
410
|
+
let timer: number | null = null;
|
|
411
|
+
|
|
412
|
+
const read = () => {
|
|
413
|
+
const canvas = host.current?.querySelector<HTMLElement>('[data-osd-canvas]');
|
|
414
|
+
if (!canvas) return;
|
|
415
|
+
const next = readBlocks(snapshotPage(canvas, scale));
|
|
416
|
+
rememberPageRead(PageComp, next);
|
|
417
|
+
onRead?.(next);
|
|
418
|
+
};
|
|
419
|
+
|
|
420
|
+
const idle =
|
|
421
|
+
typeof window.requestIdleCallback === 'function'
|
|
422
|
+
? window.requestIdleCallback(read, { timeout: 2000 })
|
|
423
|
+
: window.setTimeout(read, 200);
|
|
424
|
+
|
|
425
|
+
// Editing a page in another tab, or a hot update to its source, redraws the
|
|
426
|
+
// same component in place, so the read is refreshed when the canvas changes.
|
|
427
|
+
const canvas = host.current?.querySelector<HTMLElement>('[data-osd-canvas]');
|
|
428
|
+
const observer = canvas
|
|
429
|
+
? new MutationObserver(() => {
|
|
430
|
+
if (timer !== null) window.clearTimeout(timer);
|
|
431
|
+
timer = window.setTimeout(() => {
|
|
432
|
+
timer = null;
|
|
433
|
+
if (!cancelled) read();
|
|
434
|
+
}, 300);
|
|
435
|
+
})
|
|
436
|
+
: null;
|
|
437
|
+
observer?.observe(canvas as HTMLElement, {
|
|
438
|
+
childList: true,
|
|
439
|
+
subtree: true,
|
|
440
|
+
characterData: true,
|
|
441
|
+
});
|
|
442
|
+
|
|
443
|
+
return () => {
|
|
444
|
+
cancelled = true;
|
|
445
|
+
observer?.disconnect();
|
|
446
|
+
if (timer !== null) window.clearTimeout(timer);
|
|
447
|
+
if (typeof window.cancelIdleCallback === 'function') window.cancelIdleCallback(idle);
|
|
448
|
+
else window.clearTimeout(idle);
|
|
449
|
+
};
|
|
450
|
+
}, [PageComp, scale, onRead]);
|
|
451
|
+
|
|
255
452
|
return (
|
|
256
|
-
<
|
|
257
|
-
<
|
|
258
|
-
<
|
|
259
|
-
|
|
260
|
-
|
|
453
|
+
<div ref={host} className="h-full w-full">
|
|
454
|
+
<SlideCanvas scale={scale} center={false} flat freezeMotion design={design}>
|
|
455
|
+
<SlidePageProvider index={index} total={total}>
|
|
456
|
+
<PageComp />
|
|
457
|
+
</SlidePageProvider>
|
|
458
|
+
</SlideCanvas>
|
|
459
|
+
</div>
|
|
261
460
|
);
|
|
262
461
|
});
|
|
263
462
|
|
|
@@ -339,10 +538,12 @@ function NoteStrip({
|
|
|
339
538
|
slideId,
|
|
340
539
|
index,
|
|
341
540
|
initial,
|
|
541
|
+
height,
|
|
342
542
|
}: {
|
|
343
543
|
slideId: string;
|
|
344
544
|
index: number;
|
|
345
545
|
initial?: string;
|
|
546
|
+
height: number;
|
|
346
547
|
}) {
|
|
347
548
|
const t = useLocale();
|
|
348
549
|
const lr = useLrText();
|
|
@@ -357,7 +558,7 @@ function NoteStrip({
|
|
|
357
558
|
const shared = 'w-full rounded-[4px] px-1.5 py-1 text-left text-[11px] leading-[1.45]';
|
|
358
559
|
|
|
359
560
|
return (
|
|
360
|
-
<div className="nodrag nopan" style={{ height
|
|
561
|
+
<div className="nodrag nopan" style={{ height }}>
|
|
361
562
|
{editing ? (
|
|
362
563
|
<textarea
|
|
363
564
|
ref={ref}
|
|
@@ -416,10 +617,12 @@ function NoteStrip({
|
|
|
416
617
|
function MemoStrip({
|
|
417
618
|
memo,
|
|
418
619
|
disabled,
|
|
620
|
+
height,
|
|
419
621
|
onCommit,
|
|
420
622
|
}: {
|
|
421
623
|
memo?: string;
|
|
422
624
|
disabled: boolean;
|
|
625
|
+
height: number;
|
|
423
626
|
onCommit: (memo: string) => void;
|
|
424
627
|
}) {
|
|
425
628
|
const lr = useLrText();
|
|
@@ -434,7 +637,7 @@ function MemoStrip({
|
|
|
434
637
|
const shared = 'w-full rounded-[4px] px-1.5 py-1 text-left text-[11px] leading-[1.45]';
|
|
435
638
|
|
|
436
639
|
return (
|
|
437
|
-
<div className="nodrag nopan" style={{ height
|
|
640
|
+
<div className="nodrag nopan" style={{ height }}>
|
|
438
641
|
{editing ? (
|
|
439
642
|
<textarea
|
|
440
643
|
ref={ref}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { SnapBox } from './blocks/classify';
|
|
2
|
+
|
|
3
|
+
export type HighlightRequest = { page: number; boxes?: SnapBox[] };
|
|
4
|
+
|
|
5
|
+
let pending: HighlightRequest | null = null;
|
|
6
|
+
|
|
7
|
+
/** The findings list asks; the editor page, once it shows that page, draws it. */
|
|
8
|
+
export function requestHighlight(request: HighlightRequest): void {
|
|
9
|
+
pending = request;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function takeHighlight(page: number): HighlightRequest | null {
|
|
13
|
+
if (!pending || pending.page !== page) return null;
|
|
14
|
+
const found = pending;
|
|
15
|
+
pending = null;
|
|
16
|
+
return found;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function dropHighlight(): void {
|
|
20
|
+
pending = null;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const CANVAS_WIDTH = 1920;
|