@lemonriver/core 0.6.0 → 0.8.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/dist/{build-RlcGG-Ve.js → build-Bdagm0FU.js} +1 -1
- package/dist/cli/bin.js +4 -4
- package/dist/{config-BJT87wE9.js → config-Begts3gq.js} +6353 -2822
- package/dist/{dev-DR-j_xda.js → dev-DjjzmT28.js} +2 -2
- package/dist/{preview-BTAhTb5B.js → preview-C9y9MTY1.js} +1 -1
- package/dist/{update-CMRxtTc9.js → update-b1dSg_FW.js} +17 -17
- package/dist/vite/index.js +1 -1
- package/package.json +1 -1
- package/src/app/lemonriver/backup/client.ts +177 -0
- package/src/app/lemonriver/backup/guide.test.ts +45 -0
- package/src/app/lemonriver/backup/guide.ts +138 -0
- package/src/app/lemonriver/backup/model.test.ts +96 -0
- package/src/app/lemonriver/backup/model.ts +255 -0
- package/src/app/lemonriver/backup/places.test.ts +154 -0
- package/src/app/lemonriver/backup/places.ts +74 -0
- package/src/app/lemonriver/board/blocks/snapshot.ts +10 -2
- package/src/app/lemonriver/board/self-check-runner.tsx +60 -15
- package/src/app/lemonriver/chrome/app-chrome.tsx +12 -1
- package/src/app/lemonriver/features.test.ts +10 -0
- package/src/app/lemonriver/features.ts +12 -1
- package/src/app/lemonriver/feedback/pending-toast.ts +7 -2
- package/src/app/lemonriver/help/help-page.tsx +262 -0
- package/src/app/lemonriver/help/model.test.ts +107 -0
- package/src/app/lemonriver/help/model.ts +96 -0
- package/src/app/lemonriver/home/deck-card.tsx +10 -1
- package/src/app/lemonriver/home/home-page.tsx +52 -1
- package/src/app/lemonriver/routes.test.tsx +4 -2
- package/src/app/lemonriver/routes.tsx +2 -0
- package/src/app/lemonriver/settings/backup-restore-dialog.tsx +525 -0
- package/src/app/lemonriver/settings/backup-section.tsx +489 -0
- package/src/app/lemonriver/settings/settings-page.tsx +22 -0
- package/src/app/lemonriver/share/capture.ts +76 -0
- package/src/app/lemonriver/share/client.ts +168 -0
- package/src/app/lemonriver/share/codes.test.ts +49 -0
- package/src/app/lemonriver/share/codes.ts +30 -0
- package/src/app/lemonriver/share/compare.test.ts +199 -0
- package/src/app/lemonriver/share/compare.ts +367 -0
- package/src/app/lemonriver/share/drop.ts +84 -0
- package/src/app/lemonriver/share/folder.test.ts +42 -0
- package/src/app/lemonriver/share/folder.ts +29 -0
- package/src/app/lemonriver/share/freeze.ts +51 -0
- package/src/app/lemonriver/share/guide.test.ts +78 -0
- package/src/app/lemonriver/share/guide.ts +222 -0
- package/src/app/lemonriver/share/import-dialog.tsx +405 -0
- package/src/app/lemonriver/share/import-entry.tsx +106 -0
- package/src/app/lemonriver/share/model.ts +150 -0
- package/src/app/lemonriver/share/naming.test.ts +59 -0
- package/src/app/lemonriver/share/naming.ts +71 -0
- package/src/app/lemonriver/share/paths.test.ts +116 -0
- package/src/app/lemonriver/share/paths.ts +215 -0
- package/src/app/lemonriver/share/pdf.test.ts +79 -0
- package/src/app/lemonriver/share/pdf.ts +169 -0
- package/src/app/lemonriver/share/share-dialog.tsx +339 -0
- package/src/app/lemonriver/share/summary.ts +47 -0
- package/src/app/lemonriver/slide-extensions.tsx +69 -23
- package/src/app/lemonriver/templates/library-page.tsx +5 -2
- package/src/app/lemonriver/text/en.ts +588 -0
- package/src/app/lemonriver/text/es.ts +146 -0
- package/src/app/lemonriver/text/ja.ts +143 -0
- package/src/app/lemonriver/text/types.ts +168 -0
- package/src/app/lemonriver/text/zh-cn.ts +559 -0
- package/src/app/lemonriver/text/zh-tw.ts +559 -0
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
import { Share2 } from 'lucide-react';
|
|
2
|
+
import { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import { Link } from 'react-router-dom';
|
|
4
|
+
import { Button } from '@/components/ui/button';
|
|
5
|
+
import {
|
|
6
|
+
Dialog,
|
|
7
|
+
DialogContent,
|
|
8
|
+
DialogDescription,
|
|
9
|
+
DialogFooter,
|
|
10
|
+
DialogHeader,
|
|
11
|
+
DialogTitle,
|
|
12
|
+
} from '@/components/ui/dialog';
|
|
13
|
+
import { Progress } from '@/components/ui/progress';
|
|
14
|
+
import { format, useLocale } from '@/lib/use-locale';
|
|
15
|
+
import { CANVAS_HEIGHT, CANVAS_WIDTH, type SlideModule } from '../../lib/sdk';
|
|
16
|
+
import { loadSlide } from '../../lib/slides';
|
|
17
|
+
import { isFeatureEnabled } from '../features';
|
|
18
|
+
import { useLrText } from '../text';
|
|
19
|
+
import { CaptureCancelled, captureDeck, toBase64 } from './capture';
|
|
20
|
+
import { appVersion, packShare, revealShared } from './client';
|
|
21
|
+
import { buildGuideHtml, guideFileName, guideLocaleFor } from './guide';
|
|
22
|
+
import { safeFileName } from './naming';
|
|
23
|
+
import { buildImagePdf } from './pdf';
|
|
24
|
+
|
|
25
|
+
type Phase = 'idle' | 'working' | 'done' | 'failed';
|
|
26
|
+
|
|
27
|
+
type Result = {
|
|
28
|
+
name: string;
|
|
29
|
+
path: string;
|
|
30
|
+
size: number;
|
|
31
|
+
warnings: string[];
|
|
32
|
+
skipped: string[];
|
|
33
|
+
workFiles: number;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const MAX_LISTED_FILES = 10;
|
|
37
|
+
|
|
38
|
+
function estimateSeconds(pages: number): number {
|
|
39
|
+
return Math.max(2, Math.round(pages * 1.2));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function ShareDialog({
|
|
43
|
+
open,
|
|
44
|
+
slideId,
|
|
45
|
+
title,
|
|
46
|
+
onOpenChange,
|
|
47
|
+
}: {
|
|
48
|
+
open: boolean;
|
|
49
|
+
slideId: string;
|
|
50
|
+
title: string;
|
|
51
|
+
onOpenChange: (open: boolean) => void;
|
|
52
|
+
}) {
|
|
53
|
+
const t = useLocale();
|
|
54
|
+
const lr = useLrText();
|
|
55
|
+
const locale = useLocale();
|
|
56
|
+
const [attachPdf, setAttachPdf] = useState(true);
|
|
57
|
+
const [phase, setPhase] = useState<Phase>('idle');
|
|
58
|
+
const [pages, setPages] = useState<number | null>(null);
|
|
59
|
+
const [progress, setProgress] = useState({ current: 0, total: 0 });
|
|
60
|
+
const [packing, setPacking] = useState(false);
|
|
61
|
+
const [version, setVersion] = useState('');
|
|
62
|
+
const [result, setResult] = useState<Result | null>(null);
|
|
63
|
+
const [failure, setFailure] = useState<{ message: string; paths: string[] } | null>(null);
|
|
64
|
+
const abortRef = useRef<AbortController | null>(null);
|
|
65
|
+
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
if (!open) return;
|
|
68
|
+
setAttachPdf(true);
|
|
69
|
+
setPhase('idle');
|
|
70
|
+
setProgress({ current: 0, total: 0 });
|
|
71
|
+
setPacking(false);
|
|
72
|
+
setResult(null);
|
|
73
|
+
setFailure(null);
|
|
74
|
+
void appVersion().then(setVersion);
|
|
75
|
+
let cancelled = false;
|
|
76
|
+
loadSlide(slideId)
|
|
77
|
+
.then((slide) => {
|
|
78
|
+
if (!cancelled) setPages(slide.default?.length ?? 0);
|
|
79
|
+
})
|
|
80
|
+
.catch(() => {});
|
|
81
|
+
return () => {
|
|
82
|
+
cancelled = true;
|
|
83
|
+
};
|
|
84
|
+
}, [open, slideId]);
|
|
85
|
+
|
|
86
|
+
const cancel = () => {
|
|
87
|
+
abortRef.current?.abort();
|
|
88
|
+
abortRef.current = null;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
const close = (next: boolean) => {
|
|
92
|
+
if (!next) cancel();
|
|
93
|
+
onOpenChange(next);
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
const start = async () => {
|
|
97
|
+
const controller = new AbortController();
|
|
98
|
+
abortRef.current = controller;
|
|
99
|
+
setPhase('working');
|
|
100
|
+
setPacking(false);
|
|
101
|
+
setFailure(null);
|
|
102
|
+
setProgress({ current: 0, total: pages ?? 0 });
|
|
103
|
+
try {
|
|
104
|
+
const slide: SlideModule = await loadSlide(slideId);
|
|
105
|
+
const captured = await captureDeck(slide, {
|
|
106
|
+
signal: controller.signal,
|
|
107
|
+
onPage: (current, total) => setProgress({ current, total }),
|
|
108
|
+
});
|
|
109
|
+
setPacking(true);
|
|
110
|
+
const base = safeFileName(title, slideId);
|
|
111
|
+
const guideLocale = guideLocaleFor(locale.id);
|
|
112
|
+
const extras = [];
|
|
113
|
+
if (attachPdf) {
|
|
114
|
+
const pdf = buildImagePdf(
|
|
115
|
+
captured.map((page) => ({
|
|
116
|
+
jpeg: page.jpeg,
|
|
117
|
+
width: CANVAS_WIDTH,
|
|
118
|
+
height: CANVAS_HEIGHT,
|
|
119
|
+
})),
|
|
120
|
+
{ title: base },
|
|
121
|
+
);
|
|
122
|
+
extras.push({ name: `${base}.pdf`, base64: toBase64(pdf) });
|
|
123
|
+
}
|
|
124
|
+
const guide = buildGuideHtml({
|
|
125
|
+
title: base,
|
|
126
|
+
pages: captured.length,
|
|
127
|
+
appVersion: version,
|
|
128
|
+
createdAt: Date.now(),
|
|
129
|
+
locale: guideLocale,
|
|
130
|
+
hasPdf: attachPdf,
|
|
131
|
+
});
|
|
132
|
+
extras.push({
|
|
133
|
+
name: guideFileName(guideLocale),
|
|
134
|
+
base64: toBase64(new TextEncoder().encode(guide)),
|
|
135
|
+
});
|
|
136
|
+
const packed = await packShare({
|
|
137
|
+
slideIds: [slideId],
|
|
138
|
+
pages: { [slideId]: captured.length },
|
|
139
|
+
thumbs: { [slideId]: captured.map((page) => toBase64(page.thumb)) },
|
|
140
|
+
extras,
|
|
141
|
+
});
|
|
142
|
+
if (!packed.ok) {
|
|
143
|
+
setFailure({ message: packed.error, paths: packed.paths ?? [] });
|
|
144
|
+
setPhase('failed');
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
setResult({
|
|
148
|
+
name: packed.name,
|
|
149
|
+
path: packed.path,
|
|
150
|
+
size: packed.size,
|
|
151
|
+
warnings: packed.warnings,
|
|
152
|
+
skipped: packed.skipped,
|
|
153
|
+
workFiles: packed.workFiles,
|
|
154
|
+
});
|
|
155
|
+
setPhase('done');
|
|
156
|
+
} catch (err) {
|
|
157
|
+
if (err instanceof CaptureCancelled || controller.signal.aborted) {
|
|
158
|
+
setPhase('idle');
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
setFailure({ message: err instanceof Error ? err.message : String(err), paths: [] });
|
|
162
|
+
setPhase('failed');
|
|
163
|
+
} finally {
|
|
164
|
+
abortRef.current = null;
|
|
165
|
+
setPacking(false);
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
const total = progress.total || pages || 0;
|
|
170
|
+
const percent =
|
|
171
|
+
phase === 'done' ? 100 : packing ? 95 : total > 0 ? (progress.current / total) * 90 : 0;
|
|
172
|
+
|
|
173
|
+
return (
|
|
174
|
+
<Dialog open={open} onOpenChange={close}>
|
|
175
|
+
<DialogContent className="sm:max-w-[520px]">
|
|
176
|
+
<DialogHeader>
|
|
177
|
+
<DialogTitle>{format(lr.share.dialogTitle, { title })}</DialogTitle>
|
|
178
|
+
<DialogDescription>{lr.share.dialogDescription}</DialogDescription>
|
|
179
|
+
</DialogHeader>
|
|
180
|
+
|
|
181
|
+
{phase === 'idle' && (
|
|
182
|
+
<div className="flex flex-col gap-2">
|
|
183
|
+
<label className="flex items-start gap-2.5 text-[14px]">
|
|
184
|
+
<input
|
|
185
|
+
type="checkbox"
|
|
186
|
+
checked={attachPdf}
|
|
187
|
+
onChange={(e) => setAttachPdf(e.target.checked)}
|
|
188
|
+
className="mt-0.5 size-4 shrink-0 accent-[var(--lr-accent)]"
|
|
189
|
+
/>
|
|
190
|
+
<span>{lr.share.attachPdf}</span>
|
|
191
|
+
</label>
|
|
192
|
+
{pages !== null && pages > 0 && (
|
|
193
|
+
<p className="text-[13px] text-muted-foreground">
|
|
194
|
+
{format(lr.share.estimate, { n: pages, s: estimateSeconds(pages) })}
|
|
195
|
+
</p>
|
|
196
|
+
)}
|
|
197
|
+
</div>
|
|
198
|
+
)}
|
|
199
|
+
|
|
200
|
+
{(phase === 'working' || phase === 'done') && (
|
|
201
|
+
<div className="flex flex-col gap-2" data-lr-share-progress>
|
|
202
|
+
<Progress value={percent} className="h-1.5" />
|
|
203
|
+
<p className="text-[13px] text-muted-foreground">
|
|
204
|
+
{phase === 'done'
|
|
205
|
+
? format(lr.share.done, {
|
|
206
|
+
name: result?.name ?? '',
|
|
207
|
+
size: (Math.max(0, result?.size ?? 0) / (1024 * 1024)).toFixed(1),
|
|
208
|
+
})
|
|
209
|
+
: packing
|
|
210
|
+
? lr.share.preparing
|
|
211
|
+
: format(lr.share.capturing, {
|
|
212
|
+
k: Math.max(1, progress.current),
|
|
213
|
+
n: total || 1,
|
|
214
|
+
})}
|
|
215
|
+
</p>
|
|
216
|
+
</div>
|
|
217
|
+
)}
|
|
218
|
+
|
|
219
|
+
{phase === 'done' && result && result.warnings.length > 0 && (
|
|
220
|
+
<div className="rounded-[8px] border border-border bg-muted/40 px-3 py-2 text-[13px]">
|
|
221
|
+
<p className="font-semibold">{lr.share.warnings}</p>
|
|
222
|
+
<ul className="mt-1 list-disc pl-4 text-muted-foreground">
|
|
223
|
+
{result.warnings.map((warning) => (
|
|
224
|
+
<li key={warning}>{warning}</li>
|
|
225
|
+
))}
|
|
226
|
+
</ul>
|
|
227
|
+
</div>
|
|
228
|
+
)}
|
|
229
|
+
|
|
230
|
+
{phase === 'done' && result && (result.workFiles > 0 || result.skipped.length > 0) && (
|
|
231
|
+
<div
|
|
232
|
+
data-lr-share-skipped
|
|
233
|
+
className="rounded-[8px] border border-border bg-muted/40 px-3 py-2 text-[13px]"
|
|
234
|
+
>
|
|
235
|
+
<p className="font-semibold">
|
|
236
|
+
{format(lr.share.skippedTitle, { n: result.workFiles + result.skipped.length })}
|
|
237
|
+
</p>
|
|
238
|
+
{result.workFiles > 0 && (
|
|
239
|
+
<p className="mt-1 text-muted-foreground">
|
|
240
|
+
{format(lr.share.workFiles, { n: result.workFiles })}
|
|
241
|
+
</p>
|
|
242
|
+
)}
|
|
243
|
+
{result.skipped.length > 0 && (
|
|
244
|
+
<ul className="mt-1 list-disc pl-4 text-muted-foreground">
|
|
245
|
+
{result.skipped.slice(0, MAX_LISTED_FILES).map((path) => (
|
|
246
|
+
<li key={path} className="break-all">
|
|
247
|
+
{path}
|
|
248
|
+
</li>
|
|
249
|
+
))}
|
|
250
|
+
{result.skipped.length > MAX_LISTED_FILES && (
|
|
251
|
+
<li>
|
|
252
|
+
{format(lr.share.moreFiles, { n: result.skipped.length - MAX_LISTED_FILES })}
|
|
253
|
+
</li>
|
|
254
|
+
)}
|
|
255
|
+
</ul>
|
|
256
|
+
)}
|
|
257
|
+
</div>
|
|
258
|
+
)}
|
|
259
|
+
|
|
260
|
+
{phase === 'failed' && failure && (
|
|
261
|
+
<div data-lr-share-failed className="text-[13px] text-destructive">
|
|
262
|
+
<p className="font-semibold">{lr.share.failed}</p>
|
|
263
|
+
<p className="mt-1 break-words">{failure.message}</p>
|
|
264
|
+
{failure.paths.length > 0 && (
|
|
265
|
+
<ul className="mt-2 list-disc pl-4 font-mono text-[12px] text-muted-foreground">
|
|
266
|
+
{failure.paths.slice(0, MAX_LISTED_FILES).map((path) => (
|
|
267
|
+
<li key={path} className="break-all">
|
|
268
|
+
{path}
|
|
269
|
+
</li>
|
|
270
|
+
))}
|
|
271
|
+
{failure.paths.length > MAX_LISTED_FILES && (
|
|
272
|
+
<li>
|
|
273
|
+
{format(lr.share.moreFiles, { n: failure.paths.length - MAX_LISTED_FILES })}
|
|
274
|
+
</li>
|
|
275
|
+
)}
|
|
276
|
+
</ul>
|
|
277
|
+
)}
|
|
278
|
+
</div>
|
|
279
|
+
)}
|
|
280
|
+
|
|
281
|
+
{isFeatureEnabled('help') && phase !== 'working' && (
|
|
282
|
+
<p className="text-[12.5px]">
|
|
283
|
+
<Link
|
|
284
|
+
to="/help#share"
|
|
285
|
+
data-lr-share-help
|
|
286
|
+
className="text-muted-foreground underline-offset-2 hover:text-foreground hover:underline"
|
|
287
|
+
>
|
|
288
|
+
{lr.share.helpLink}
|
|
289
|
+
</Link>
|
|
290
|
+
</p>
|
|
291
|
+
)}
|
|
292
|
+
|
|
293
|
+
<DialogFooter>
|
|
294
|
+
{phase === 'idle' && (
|
|
295
|
+
<>
|
|
296
|
+
<Button type="button" variant="outline" size="sm" onClick={() => close(false)}>
|
|
297
|
+
{t.common.cancel}
|
|
298
|
+
</Button>
|
|
299
|
+
<Button type="button" size="sm" onClick={() => void start()}>
|
|
300
|
+
<Share2 className="size-3.5" aria-hidden />
|
|
301
|
+
{lr.share.generate}
|
|
302
|
+
</Button>
|
|
303
|
+
</>
|
|
304
|
+
)}
|
|
305
|
+
{phase === 'working' && (
|
|
306
|
+
<Button type="button" variant="outline" size="sm" onClick={cancel}>
|
|
307
|
+
{t.common.cancel}
|
|
308
|
+
</Button>
|
|
309
|
+
)}
|
|
310
|
+
{phase === 'done' && (
|
|
311
|
+
<>
|
|
312
|
+
<Button
|
|
313
|
+
type="button"
|
|
314
|
+
variant="outline"
|
|
315
|
+
size="sm"
|
|
316
|
+
onClick={() => result && void revealShared(result.path)}
|
|
317
|
+
>
|
|
318
|
+
{lr.share.reveal}
|
|
319
|
+
</Button>
|
|
320
|
+
<Button type="button" size="sm" onClick={() => close(false)}>
|
|
321
|
+
{lr.share.finish}
|
|
322
|
+
</Button>
|
|
323
|
+
</>
|
|
324
|
+
)}
|
|
325
|
+
{phase === 'failed' && (
|
|
326
|
+
<>
|
|
327
|
+
<Button type="button" variant="outline" size="sm" onClick={() => close(false)}>
|
|
328
|
+
{t.common.cancel}
|
|
329
|
+
</Button>
|
|
330
|
+
<Button type="button" size="sm" onClick={() => void start()}>
|
|
331
|
+
{lr.share.generate}
|
|
332
|
+
</Button>
|
|
333
|
+
</>
|
|
334
|
+
)}
|
|
335
|
+
</DialogFooter>
|
|
336
|
+
</DialogContent>
|
|
337
|
+
</Dialog>
|
|
338
|
+
);
|
|
339
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { format } from '../../../locale/format';
|
|
2
|
+
import type { LrText } from '../text/types';
|
|
3
|
+
import type { DeckChanges } from './compare';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The one-line answer to "what changed", joined the way the language joins
|
|
7
|
+
* clauses: Chinese commas, English middots.
|
|
8
|
+
*/
|
|
9
|
+
export function changeSummary(
|
|
10
|
+
changes: DeckChanges,
|
|
11
|
+
text: LrText['share'],
|
|
12
|
+
listSeparator: string,
|
|
13
|
+
clauseSeparator: string,
|
|
14
|
+
): string {
|
|
15
|
+
if (!changes.readable) return text.compareUnreadable;
|
|
16
|
+
const clauses: string[] = [];
|
|
17
|
+
const changedPages = changes.pages
|
|
18
|
+
.filter((page) => page.status === 'changed' && !page.notesOnly)
|
|
19
|
+
.map((page) => page.n);
|
|
20
|
+
const notesOnlyPages = changes.pages.filter((page) => page.notesOnly).map((page) => page.n);
|
|
21
|
+
const added = changes.pages.filter((page) => page.status === 'added').length;
|
|
22
|
+
const removed = changes.pages.filter((page) => page.status === 'removed').length;
|
|
23
|
+
const moved = changes.pages.some((page) => page.status === 'moved');
|
|
24
|
+
|
|
25
|
+
if (changedPages.length > 0) {
|
|
26
|
+
clauses.push(format(text.compareChanged, { pages: changedPages.join(listSeparator) }));
|
|
27
|
+
}
|
|
28
|
+
if (added > 0) clauses.push(format(text.compareAdded, { n: added }));
|
|
29
|
+
if (removed > 0) clauses.push(format(text.compareRemoved, { n: removed }));
|
|
30
|
+
if (moved) clauses.push(text.compareMoved);
|
|
31
|
+
if (notesOnlyPages.length > 0) {
|
|
32
|
+
clauses.push(format(text.compareNotesOnly, { pages: notesOnlyPages.join(listSeparator) }));
|
|
33
|
+
}
|
|
34
|
+
if (changes.shared) clauses.push(text.compareShared);
|
|
35
|
+
const { added: assetsAdded, changed: assetsChanged, removed: assetsRemoved } = changes.assets;
|
|
36
|
+
if (assetsAdded.length + assetsChanged.length + assetsRemoved.length > 0) {
|
|
37
|
+
clauses.push(
|
|
38
|
+
format(text.compareAssets, {
|
|
39
|
+
added: assetsAdded.length,
|
|
40
|
+
changed: assetsChanged.length,
|
|
41
|
+
removed: assetsRemoved.length,
|
|
42
|
+
}),
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return clauses.length > 0 ? clauses.join(clauseSeparator) : text.compareSame;
|
|
47
|
+
}
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import { Workflow } from 'lucide-react';
|
|
2
|
-
import { useEffect } from 'react';
|
|
1
|
+
import { Share2, Workflow } from 'lucide-react';
|
|
2
|
+
import { useEffect, useState } from 'react';
|
|
3
3
|
import { createPortal } from 'react-dom';
|
|
4
4
|
import { useNavigate } from 'react-router-dom';
|
|
5
5
|
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip';
|
|
6
6
|
import { hasModifier, isTypingTarget } from '@/lib/keys';
|
|
7
7
|
import { cn } from '@/lib/utils';
|
|
8
|
+
import { loadSlide } from '../lib/slides';
|
|
8
9
|
import { useSlot } from './chrome/use-slot';
|
|
9
10
|
import { isFeatureEnabled } from './features';
|
|
10
11
|
import { useNewDeckBrief } from './home/brief';
|
|
11
12
|
import { PendingPages } from './outline/pending-pages';
|
|
13
|
+
import { ShareDialog } from './share/share-dialog';
|
|
12
14
|
import { useLrText } from './text';
|
|
13
15
|
|
|
14
16
|
type Props = {
|
|
@@ -30,10 +32,25 @@ function isInsideOverlay(target: EventTarget | null): boolean {
|
|
|
30
32
|
|
|
31
33
|
export function SlideExtensions({ slideId, overviewOpen }: Props) {
|
|
32
34
|
const enabled = isFeatureEnabled('board');
|
|
35
|
+
const shareOn = isFeatureEnabled('share');
|
|
33
36
|
const navigate = useNavigate();
|
|
34
37
|
const slot = useSlot('data-lr-rail-actions', enabled);
|
|
35
38
|
useNewDeckBrief(slideId);
|
|
36
39
|
const lr = useLrText();
|
|
40
|
+
const [sharing, setSharing] = useState(false);
|
|
41
|
+
const [title, setTitle] = useState(slideId);
|
|
42
|
+
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
let cancelled = false;
|
|
45
|
+
loadSlide(slideId)
|
|
46
|
+
.then((slide) => {
|
|
47
|
+
if (!cancelled && slide.meta?.title) setTitle(slide.meta.title);
|
|
48
|
+
})
|
|
49
|
+
.catch(() => {});
|
|
50
|
+
return () => {
|
|
51
|
+
cancelled = true;
|
|
52
|
+
};
|
|
53
|
+
}, [slideId]);
|
|
37
54
|
|
|
38
55
|
useEffect(() => {
|
|
39
56
|
if (!enabled) return;
|
|
@@ -63,29 +80,58 @@ export function SlideExtensions({ slideId, overviewOpen }: Props) {
|
|
|
63
80
|
<>
|
|
64
81
|
{slot &&
|
|
65
82
|
createPortal(
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
<
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
83
|
+
<>
|
|
84
|
+
{shareOn && (
|
|
85
|
+
<Tooltip>
|
|
86
|
+
<TooltipTrigger
|
|
87
|
+
render={
|
|
88
|
+
<button
|
|
89
|
+
type="button"
|
|
90
|
+
onClick={() => setSharing(true)}
|
|
91
|
+
aria-label={lr.share.open}
|
|
92
|
+
data-lr-share-open
|
|
93
|
+
className={cn(
|
|
94
|
+
'flex size-5 items-center justify-center rounded-[3px] text-muted-foreground/70 outline-none',
|
|
95
|
+
'motion-safe:transition-colors hover:bg-muted hover:text-foreground',
|
|
96
|
+
'focus-visible:ring-1 focus-visible:ring-brand',
|
|
97
|
+
)}
|
|
98
|
+
>
|
|
99
|
+
<Share2 className="size-3.5" strokeWidth={1.75} />
|
|
100
|
+
</button>
|
|
101
|
+
}
|
|
102
|
+
/>
|
|
103
|
+
<TooltipContent side="bottom" sideOffset={6}>
|
|
104
|
+
{lr.share.open}
|
|
105
|
+
</TooltipContent>
|
|
106
|
+
</Tooltip>
|
|
107
|
+
)}
|
|
108
|
+
<Tooltip>
|
|
109
|
+
<TooltipTrigger
|
|
110
|
+
render={
|
|
111
|
+
<button
|
|
112
|
+
type="button"
|
|
113
|
+
onClick={() => navigate(`/s/${encodeURIComponent(slideId)}/board`)}
|
|
114
|
+
aria-label={lr.board.openBoard}
|
|
115
|
+
className={cn(
|
|
116
|
+
'flex size-5 items-center justify-center rounded-[3px] text-muted-foreground/70 outline-none',
|
|
117
|
+
'motion-safe:transition-colors hover:bg-muted hover:text-foreground',
|
|
118
|
+
'focus-visible:ring-1 focus-visible:ring-brand',
|
|
119
|
+
)}
|
|
120
|
+
>
|
|
121
|
+
<Workflow className="size-3.5" strokeWidth={1.75} />
|
|
122
|
+
</button>
|
|
123
|
+
}
|
|
124
|
+
/>
|
|
125
|
+
<TooltipContent side="bottom" sideOffset={6}>
|
|
126
|
+
{lr.board.openBoard}
|
|
127
|
+
</TooltipContent>
|
|
128
|
+
</Tooltip>
|
|
129
|
+
</>,
|
|
87
130
|
slot,
|
|
88
131
|
)}
|
|
132
|
+
{shareOn && (
|
|
133
|
+
<ShareDialog open={sharing} slideId={slideId} title={title} onOpenChange={setSharing} />
|
|
134
|
+
)}
|
|
89
135
|
<PendingPages slideId={slideId} />
|
|
90
136
|
</>
|
|
91
137
|
);
|
|
@@ -210,7 +210,10 @@ function TemplateDialog({
|
|
|
210
210
|
|
|
211
211
|
return (
|
|
212
212
|
<Dialog open onOpenChange={(next) => !next && onClose()}>
|
|
213
|
-
<DialogContent
|
|
213
|
+
<DialogContent
|
|
214
|
+
className="sm:max-w-[960px]"
|
|
215
|
+
style={{ maxHeight: '92dvh', gridTemplateRows: 'auto minmax(0, 1fr) auto' }}
|
|
216
|
+
>
|
|
214
217
|
<DialogHeader>
|
|
215
218
|
<DialogTitle>{template.name}</DialogTitle>
|
|
216
219
|
<DialogDescription>
|
|
@@ -218,7 +221,7 @@ function TemplateDialog({
|
|
|
218
221
|
</DialogDescription>
|
|
219
222
|
</DialogHeader>
|
|
220
223
|
|
|
221
|
-
<div className="grid gap-5 md:grid-cols-[minmax(0,3fr)_minmax(0,2fr)]">
|
|
224
|
+
<div className="grid min-h-0 gap-5 overflow-y-auto md:grid-cols-[minmax(0,3fr)_minmax(0,2fr)]">
|
|
222
225
|
<div className="min-w-0">
|
|
223
226
|
<div
|
|
224
227
|
data-lr-preview-main={indexes[active] + 1}
|