@lemonriver/core 1.0.2 → 1.2.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-DYN-H65n.js → build-CSkdswfd.js} +1 -1
- package/dist/cli/bin.js +5 -5
- package/dist/{config-DW1wSoxa.js → config-C5-myPY6.js} +2087 -1439
- package/dist/{dev-_VDoRfAK.js → dev-DHtYH8sw.js} +2 -2
- package/dist/{mcp-CjYDzcJa.js → mcp-B2UeO1un.js} +1 -1
- package/dist/{preview-CYIGh3Z8.js → preview-C1B6-umF.js} +1 -1
- package/dist/{update-b1dSg_FW.js → update-DzL8fpcI.js} +1 -1
- package/dist/vite/index.js +1 -1
- package/package.json +5 -2
- package/release-notes.json +19 -0
- package/src/app/components/command/slide-command-menu.tsx +0 -9
- package/src/app/lemonriver/backup/client.ts +25 -1
- package/src/app/lemonriver/backup/model.ts +63 -18
- package/src/app/lemonriver/board/board-page.tsx +2 -2
- package/src/app/lemonriver/chrome/app-chrome.tsx +52 -0
- package/src/app/lemonriver/chrome/sidebar-extras.tsx +8 -1
- package/src/app/lemonriver/feedback/dialog.tsx +222 -0
- package/src/app/lemonriver/feedback/export.ts +21 -2
- package/src/app/lemonriver/feedback/first-success.ts +30 -0
- package/src/app/lemonriver/feedback/install.ts +18 -0
- package/src/app/lemonriver/feedback/model.ts +88 -0
- package/src/app/lemonriver/help/help-page.tsx +16 -1
- package/src/app/lemonriver/help/model.ts +1 -1
- package/src/app/lemonriver/home/drafts.ts +57 -0
- package/src/app/lemonriver/home/home-page.tsx +94 -10
- package/src/app/lemonriver/home/organize-drafts.tsx +192 -0
- package/src/app/lemonriver/links.ts +16 -0
- package/src/app/lemonriver/outline/outline-page.tsx +8 -1
- package/src/app/lemonriver/settings/backup-restore-dialog.tsx +15 -1
- package/src/app/lemonriver/settings/backup-section.tsx +159 -28
- package/src/app/lemonriver/settings/settings-page.tsx +23 -0
- package/src/app/lemonriver/settings/workspace-card.tsx +53 -0
- package/src/app/lemonriver/settings/workspace.ts +37 -0
- package/src/app/lemonriver/share/editor-share.tsx +58 -0
- package/src/app/lemonriver/share/import-dialog.tsx +14 -0
- package/src/app/lemonriver/share/naming.ts +6 -1
- package/src/app/lemonriver/share/share-dialog.tsx +2 -0
- package/src/app/lemonriver/slide-extensions.tsx +37 -53
- package/src/app/lemonriver/text/en.ts +91 -11
- package/src/app/lemonriver/text/es.ts +81 -6
- package/src/app/lemonriver/text/ja.ts +80 -6
- package/src/app/lemonriver/text/types.ts +89 -6
- package/src/app/lemonriver/text/zh-cn.ts +92 -11
- package/src/app/lemonriver/text/zh-tw.ts +92 -11
- package/src/app/lemonriver/theme/pages.ts +4 -0
- package/src/app/lemonriver/update/beta-badge.tsx +69 -0
- package/src/app/lemonriver/update/release-notes.ts +22 -0
- package/src/app/lemonriver/update/update-prompt.tsx +28 -4
- package/src/app/lib/export-html.ts +5 -3
- package/src/app/lib/export-pptx.ts +5 -4
- package/src/app/routes/slide.tsx +6 -57
- package/src/app/components/note-markdown.test.tsx +0 -42
- package/src/app/components/thumbnail-rail-scroll.test.ts +0 -60
- package/src/app/lemonriver/agent-prefs/prefs.test.ts +0 -173
- package/src/app/lemonriver/backup/guide.test.ts +0 -45
- package/src/app/lemonriver/backup/model.test.ts +0 -96
- package/src/app/lemonriver/backup/places.test.ts +0 -154
- package/src/app/lemonriver/board/blocks/classify.test.ts +0 -209
- package/src/app/lemonriver/board/layout.test.ts +0 -245
- package/src/app/lemonriver/board/model/agent-tasks.test.ts +0 -200
- package/src/app/lemonriver/board/model/apply-prompt.test.ts +0 -121
- package/src/app/lemonriver/board/model/cards.test.ts +0 -332
- package/src/app/lemonriver/board/model/changes.test.ts +0 -244
- package/src/app/lemonriver/board/model/filter.test.ts +0 -50
- package/src/app/lemonriver/board/model/history.test.ts +0 -71
- package/src/app/lemonriver/board/model/restructure.test.ts +0 -205
- package/src/app/lemonriver/board/model/self-check.test.ts +0 -329
- package/src/app/lemonriver/board/model/structure.test.ts +0 -350
- package/src/app/lemonriver/board/model/timing.test.ts +0 -113
- package/src/app/lemonriver/features.test.ts +0 -49
- package/src/app/lemonriver/feedback/pending-toast.test.ts +0 -44
- package/src/app/lemonriver/feedback/upload.test.ts +0 -26
- package/src/app/lemonriver/help/model.test.ts +0 -179
- package/src/app/lemonriver/home/brief.test.ts +0 -38
- package/src/app/lemonriver/home/sorting.test.ts +0 -24
- package/src/app/lemonriver/home/time.test.ts +0 -33
- package/src/app/lemonriver/outline/files.test.ts +0 -90
- package/src/app/lemonriver/outline/model.test.ts +0 -751
- package/src/app/lemonriver/public-links.test.ts +0 -32
- package/src/app/lemonriver/routes.test.tsx +0 -54
- package/src/app/lemonriver/share/codes.test.ts +0 -49
- package/src/app/lemonriver/share/compare.test.ts +0 -199
- package/src/app/lemonriver/share/folder.test.ts +0 -42
- package/src/app/lemonriver/share/guide.test.ts +0 -78
- package/src/app/lemonriver/share/naming.test.ts +0 -59
- package/src/app/lemonriver/share/paths.test.ts +0 -116
- package/src/app/lemonriver/share/pdf.test.ts +0 -79
- package/src/app/lemonriver/templates/knobs.test.ts +0 -62
- package/src/app/lemonriver/templates/model.test.ts +0 -175
- package/src/app/lemonriver/templates/preview-content.test.ts +0 -117
- package/src/app/lemonriver/templates/recommend.test.ts +0 -71
- package/src/app/lemonriver/text/text.test.ts +0 -90
- package/src/app/lemonriver/theme/pages.test.ts +0 -74
- package/src/app/lemonriver/theme/themes.test.ts +0 -18
- package/src/app/lemonriver/trash/api.test.ts +0 -19
- package/src/app/lemonriver/update/prompt.test.ts +0 -84
- package/src/app/lemonriver/update/version.test.ts +0 -14
- package/src/app/lib/asset-filter.test.ts +0 -176
- package/src/app/lib/inspector/fiber.test.ts +0 -154
- package/src/app/lib/inspector/geometry.test.ts +0 -324
- package/src/app/lib/inspector/text-edit-timeline.test.ts +0 -121
- package/src/app/lib/note-markdown.test.ts +0 -147
- package/src/app/lib/pptx/css.test.ts +0 -205
- package/src/app/lib/pptx/ooxml.test.ts +0 -199
- package/src/app/lib/pptx/text-lines.test.ts +0 -82
- package/src/app/lib/print-ready.test.ts +0 -32
- package/src/app/lib/sdk.test.ts +0 -13
- package/src/app/lib/transition.test.ts +0 -31
- package/src/app/lib/use-document-title.test.ts +0 -14
- package/src/app/lib/utils.test.ts +0 -49
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { useEffect, useRef } from 'react';
|
|
2
2
|
import { useLocation } from 'react-router-dom';
|
|
3
3
|
import { toast } from 'sonner';
|
|
4
|
-
import {
|
|
4
|
+
import { Button } from '@/components/ui/button';
|
|
5
|
+
import { format, useLocale } from '@/lib/use-locale';
|
|
5
6
|
import { useRestartServer } from '@/lib/use-restart-server';
|
|
6
7
|
import { MASCOT_SRC } from '../brand/mascot';
|
|
8
|
+
import { openFeedback } from '../feedback/dialog';
|
|
7
9
|
import { useLrText } from '../text';
|
|
8
10
|
import { NoticeMascot } from './notice-mascot';
|
|
9
11
|
import {
|
|
@@ -14,6 +16,7 @@ import {
|
|
|
14
16
|
UPDATE_CHECK_INTERVAL_MS,
|
|
15
17
|
type UpdateCheck,
|
|
16
18
|
} from './prompt';
|
|
19
|
+
import { fetchReleaseNotes, releaseNotesLine } from './release-notes';
|
|
17
20
|
import { markUpdated, rememberNoticeIcons, UPDATE_TOAST_ID } from './state';
|
|
18
21
|
|
|
19
22
|
const TOAST_ID = UPDATE_TOAST_ID;
|
|
@@ -38,6 +41,7 @@ async function preloadMascot(src: string): Promise<string | null> {
|
|
|
38
41
|
export function UpdatePrompt() {
|
|
39
42
|
const { pathname } = useLocation();
|
|
40
43
|
const lr = useLrText();
|
|
44
|
+
const locale = useLocale();
|
|
41
45
|
const { canRestart, restartServer } = useRestartServer();
|
|
42
46
|
const phase = useRef<'idle' | 'busy' | 'done'>('idle');
|
|
43
47
|
const settled = useRef<string | null>(null);
|
|
@@ -81,7 +85,20 @@ export function UpdatePrompt() {
|
|
|
81
85
|
toast.error(lr.update.failed, {
|
|
82
86
|
id: TOAST_ID,
|
|
83
87
|
duration: Infinity,
|
|
84
|
-
description:
|
|
88
|
+
description: (
|
|
89
|
+
<span className="flex flex-col items-start gap-1.5">
|
|
90
|
+
<span>{lr.update.failedHint}</span>
|
|
91
|
+
<Button
|
|
92
|
+
type="button"
|
|
93
|
+
variant="outline"
|
|
94
|
+
size="sm"
|
|
95
|
+
data-lr-feedback-this
|
|
96
|
+
onClick={() => openFeedback({ category: 'issue', errorKind: 'update' })}
|
|
97
|
+
>
|
|
98
|
+
{lr.feedback.feedbackThis}
|
|
99
|
+
</Button>
|
|
100
|
+
</span>
|
|
101
|
+
),
|
|
85
102
|
icon: icons.needsYou ? <NoticeMascot src={icons.needsYou} /> : undefined,
|
|
86
103
|
action: { label: lr.update.retry, onClick: () => void runUpdate(latest) },
|
|
87
104
|
cancel: { label: lr.update.later, onClick: () => snooze(latest) },
|
|
@@ -93,11 +110,18 @@ export function UpdatePrompt() {
|
|
|
93
110
|
settled.current = latest;
|
|
94
111
|
markUpdated(latest);
|
|
95
112
|
if (cancelled) return;
|
|
113
|
+
const notesLine = releaseNotesLine(await fetchReleaseNotes(locale.id), lr.update);
|
|
114
|
+
if (cancelled) return;
|
|
96
115
|
toast.success(format(lr.update.updated, { version: latest }), {
|
|
97
116
|
id: TOAST_ID,
|
|
98
117
|
duration: Infinity,
|
|
99
118
|
icon: icons.done ? <NoticeMascot src={icons.done} /> : undefined,
|
|
100
|
-
description:
|
|
119
|
+
description: (
|
|
120
|
+
<span className="flex flex-col gap-1">
|
|
121
|
+
<span>{canRestart ? lr.update.updatedHint : lr.update.updatedManual}</span>
|
|
122
|
+
{notesLine !== null && <span data-lr-release-notes>{notesLine}</span>}
|
|
123
|
+
</span>
|
|
124
|
+
),
|
|
101
125
|
action: canRestart
|
|
102
126
|
? { label: lr.update.restart, onClick: () => void restartServer() }
|
|
103
127
|
: undefined,
|
|
@@ -136,7 +160,7 @@ export function UpdatePrompt() {
|
|
|
136
160
|
cancelled = true;
|
|
137
161
|
clearInterval(timer);
|
|
138
162
|
};
|
|
139
|
-
}, [pathname, lr, canRestart, restartServer]);
|
|
163
|
+
}, [pathname, lr, locale, canRestart, restartServer]);
|
|
140
164
|
|
|
141
165
|
return null;
|
|
142
166
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createElement } from 'react';
|
|
2
2
|
import { createRoot } from 'react-dom/client';
|
|
3
|
+
import { exportBaseName } from '../lemonriver/share/naming';
|
|
3
4
|
import { designToCssVars } from './design';
|
|
4
5
|
import { downloadBlob, nextFrame } from './dom';
|
|
5
6
|
import { SlidePageProvider } from './page-context';
|
|
@@ -14,6 +15,7 @@ export async function exportSlideAsHtml(slide: SlideModule, slideId: string): Pr
|
|
|
14
15
|
const pages = slide.default ?? [];
|
|
15
16
|
if (pages.length === 0) return;
|
|
16
17
|
const title = slide.meta?.title ?? slideId;
|
|
18
|
+
const fileBase = exportBaseName(slide.meta?.title, slideId);
|
|
17
19
|
|
|
18
20
|
const pagesHtml = await renderPagesToHtml(pages);
|
|
19
21
|
const bundledCss = collectCss();
|
|
@@ -53,20 +55,20 @@ export async function exportSlideAsHtml(slide: SlideModule, slideId: string): Pr
|
|
|
53
55
|
const htmlBytes = new TextEncoder().encode(html);
|
|
54
56
|
|
|
55
57
|
if (assets.size === 0) {
|
|
56
|
-
downloadBlob(new Blob([htmlBytes as BlobPart], { type: 'text/html' }), `${
|
|
58
|
+
downloadBlob(new Blob([htmlBytes as BlobPart], { type: 'text/html' }), `${fileBase}.html`);
|
|
57
59
|
return;
|
|
58
60
|
}
|
|
59
61
|
|
|
60
62
|
const { zipSync } = await import('fflate');
|
|
61
63
|
const zipTree: Record<string, Uint8Array | Record<string, Uint8Array>> = {
|
|
62
|
-
[`${
|
|
64
|
+
[`${fileBase}.html`]: htmlBytes,
|
|
63
65
|
assets: {},
|
|
64
66
|
};
|
|
65
67
|
for (const { name, bytes } of assets.values()) {
|
|
66
68
|
(zipTree.assets as Record<string, Uint8Array>)[name] = bytes;
|
|
67
69
|
}
|
|
68
70
|
const zipped = zipSync(zipTree as Parameters<typeof zipSync>[0]);
|
|
69
|
-
downloadBlob(new Blob([zipped as BlobPart], { type: 'application/zip' }), `${
|
|
71
|
+
downloadBlob(new Blob([zipped as BlobPart], { type: 'application/zip' }), `${fileBase}.zip`);
|
|
70
72
|
}
|
|
71
73
|
|
|
72
74
|
async function renderPagesToHtml(pages: NonNullable<SlideModule['default']>): Promise<string[]> {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { exportBaseName } from '../lemonriver/share/naming';
|
|
1
2
|
import { downloadBlob } from './dom';
|
|
2
3
|
import { CANVAS_HEIGHT, CANVAS_WIDTH, type SlideModule } from './sdk';
|
|
3
4
|
|
|
@@ -44,10 +45,10 @@ function download(
|
|
|
44
45
|
files: Record<string, Uint8Array>,
|
|
45
46
|
zip: (f: Record<string, Uint8Array>) => Uint8Array,
|
|
46
47
|
mime: string,
|
|
47
|
-
|
|
48
|
+
fileBase: string,
|
|
48
49
|
) {
|
|
49
50
|
const zipped = zip(files);
|
|
50
|
-
downloadBlob(new Blob([zipped as BlobPart], { type: mime }), `${
|
|
51
|
+
downloadBlob(new Blob([zipped as BlobPart], { type: mime }), `${fileBase}.pptx`);
|
|
51
52
|
}
|
|
52
53
|
|
|
53
54
|
/**
|
|
@@ -94,7 +95,7 @@ export async function exportSlideAsPptx(
|
|
|
94
95
|
lib.buildPptxFiles({ slides, images: images.images }),
|
|
95
96
|
lib.zipSync,
|
|
96
97
|
lib.PPTX_MIME,
|
|
97
|
-
slideId,
|
|
98
|
+
exportBaseName(slide.meta?.title, slideId),
|
|
98
99
|
);
|
|
99
100
|
} finally {
|
|
100
101
|
onProgress?.({ phase: 'done', current: total, total, percent: 100 });
|
|
@@ -160,7 +161,7 @@ export async function exportSlideAsImagePptx(
|
|
|
160
161
|
lib.buildPptxFiles({ slides, images: images.images }),
|
|
161
162
|
lib.zipSync,
|
|
162
163
|
lib.PPTX_MIME,
|
|
163
|
-
slideId,
|
|
164
|
+
exportBaseName(slide.meta?.title, slideId),
|
|
164
165
|
);
|
|
165
166
|
} finally {
|
|
166
167
|
onProgress?.({ phase: 'done', current: total, total, percent: 100 });
|
package/src/app/routes/slide.tsx
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import config from 'virtual:open-slide/config';
|
|
2
2
|
import {
|
|
3
|
-
Check,
|
|
4
3
|
ChevronDown,
|
|
5
4
|
ChevronLeft,
|
|
6
5
|
Download,
|
|
7
6
|
FileCode2,
|
|
8
7
|
FileImage,
|
|
9
8
|
FileText,
|
|
10
|
-
Link2,
|
|
11
9
|
Loader2,
|
|
12
10
|
Maximize,
|
|
13
11
|
MonitorSpeaker,
|
|
@@ -98,6 +96,7 @@ import { isDeckWarmed, markDeckWarmed, SlidePreloadLayer } from '../components/s
|
|
|
98
96
|
import { SlideTransitionLayer } from '../components/slide-transition-layer';
|
|
99
97
|
import { type ThumbnailActions, ThumbnailRail } from '../components/thumbnail-rail';
|
|
100
98
|
import { exportFailedHint } from '../lemonriver/feedback/export';
|
|
99
|
+
import { ShareMenuEntry } from '../lemonriver/share/editor-share';
|
|
101
100
|
import { SlideExtensions } from '../lemonriver/slide-extensions';
|
|
102
101
|
import { exportSlideAsHtml } from '../lib/export-html';
|
|
103
102
|
import { exportSlideAsPdf, isSafari, type PdfExportProgress } from '../lib/export-pdf';
|
|
@@ -119,15 +118,10 @@ export function Slide() {
|
|
|
119
118
|
const { slideId = '' } = useParams();
|
|
120
119
|
const [searchParams, setSearchParams] = useSearchParams();
|
|
121
120
|
const navigate = useNavigate();
|
|
122
|
-
//
|
|
123
|
-
//
|
|
121
|
+
// Back always leads to the home view the editor was opened from, so the
|
|
122
|
+
// board and the pages opened from it never stack up in the history.
|
|
124
123
|
const goBack = useCallback(() => {
|
|
125
|
-
|
|
126
|
-
if (idx > 0) {
|
|
127
|
-
navigate(-1);
|
|
128
|
-
} else {
|
|
129
|
-
navigate(readLastHomeLocation(), { replace: true });
|
|
130
|
-
}
|
|
124
|
+
navigate(readLastHomeLocation(), { replace: true });
|
|
131
125
|
}, [navigate]);
|
|
132
126
|
const { slide, error } = useSlideModule(slideId);
|
|
133
127
|
useDocumentTitle(slide?.meta?.title);
|
|
@@ -143,8 +137,6 @@ export function Slide() {
|
|
|
143
137
|
index: number;
|
|
144
138
|
} | null>(null);
|
|
145
139
|
const [exporting, setExporting] = useState(false);
|
|
146
|
-
const [linkCopied, setLinkCopied] = useState(false);
|
|
147
|
-
const linkCopiedTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
148
140
|
const [designOpen, setDesignOpen] = useState(false);
|
|
149
141
|
const [overviewOpen, setOverviewOpen] = useState(false);
|
|
150
142
|
const [commandOpen, setCommandOpen] = useState(false);
|
|
@@ -161,11 +153,6 @@ export function Slide() {
|
|
|
161
153
|
setWarmedTick((n) => n + 1);
|
|
162
154
|
}, [slideId]);
|
|
163
155
|
|
|
164
|
-
useEffect(() => {
|
|
165
|
-
return () => {
|
|
166
|
-
if (linkCopiedTimerRef.current) clearTimeout(linkCopiedTimerRef.current);
|
|
167
|
-
};
|
|
168
|
-
}, []);
|
|
169
156
|
const { renameSlide } = useFolders();
|
|
170
157
|
const slideViewportRef = useRef<HTMLElement>(null);
|
|
171
158
|
const t = useLocale();
|
|
@@ -589,19 +576,6 @@ export function Slide() {
|
|
|
589
576
|
|
|
590
577
|
const title = slide.meta?.title ?? slideId;
|
|
591
578
|
|
|
592
|
-
const copyLink = async () => {
|
|
593
|
-
try {
|
|
594
|
-
await navigator.clipboard.writeText(window.location.href);
|
|
595
|
-
toast.success(t.slide.toastCopyLinkSuccess);
|
|
596
|
-
setLinkCopied(true);
|
|
597
|
-
if (linkCopiedTimerRef.current) clearTimeout(linkCopiedTimerRef.current);
|
|
598
|
-
linkCopiedTimerRef.current = setTimeout(() => setLinkCopied(false), 1200);
|
|
599
|
-
} catch (err) {
|
|
600
|
-
console.error('[open-slide] copy link failed', err);
|
|
601
|
-
toast.error(t.slide.toastCopyLinkFailed);
|
|
602
|
-
}
|
|
603
|
-
};
|
|
604
|
-
|
|
605
579
|
const exportHtml = async () => {
|
|
606
580
|
if (!slide || exporting) return;
|
|
607
581
|
setExporting(true);
|
|
@@ -766,28 +740,7 @@ export function Slide() {
|
|
|
766
740
|
<span aria-hidden className="mx-0.5 hidden h-5 w-px bg-hairline md:block" />
|
|
767
741
|
)}
|
|
768
742
|
{view === 'slides' && !compactToolbar && (
|
|
769
|
-
<
|
|
770
|
-
type="button"
|
|
771
|
-
aria-label={t.slide.copyLink}
|
|
772
|
-
title={t.slide.copyLink}
|
|
773
|
-
className={buttonVariants({ variant: 'ghost', size: 'icon-sm' })}
|
|
774
|
-
onClick={copyLink}
|
|
775
|
-
>
|
|
776
|
-
<span className="relative grid size-4 place-items-center">
|
|
777
|
-
<Link2
|
|
778
|
-
className={cn(
|
|
779
|
-
'col-start-1 row-start-1 size-4 transition-opacity duration-200',
|
|
780
|
-
linkCopied ? 'opacity-0' : 'opacity-100',
|
|
781
|
-
)}
|
|
782
|
-
/>
|
|
783
|
-
<Check
|
|
784
|
-
className={cn(
|
|
785
|
-
'col-start-1 row-start-1 size-4 transition-opacity duration-200',
|
|
786
|
-
linkCopied ? 'opacity-100' : 'opacity-0',
|
|
787
|
-
)}
|
|
788
|
-
/>
|
|
789
|
-
</span>
|
|
790
|
-
</button>
|
|
743
|
+
<span data-lr-header-actions className="contents" />
|
|
791
744
|
)}
|
|
792
745
|
{view === 'slides' && allowHtmlDownload && !compactToolbar && (
|
|
793
746
|
<DropdownMenu>
|
|
@@ -824,6 +777,7 @@ export function Slide() {
|
|
|
824
777
|
)}
|
|
825
778
|
</DropdownMenuTrigger>
|
|
826
779
|
<DropdownMenuContent align="end" className="min-w-[200px]">
|
|
780
|
+
<ShareMenuEntry />
|
|
827
781
|
{narrowToolbar && import.meta.env.DEV && (
|
|
828
782
|
<EditorMenuItems
|
|
829
783
|
designOpen={designOpen}
|
|
@@ -841,10 +795,6 @@ export function Slide() {
|
|
|
841
795
|
<Terminal />
|
|
842
796
|
{t.commandMenu.trigger}
|
|
843
797
|
</DropdownMenuItem>
|
|
844
|
-
<DropdownMenuItem onClick={copyLink}>
|
|
845
|
-
<Link2 />
|
|
846
|
-
{t.slide.copyLink}
|
|
847
|
-
</DropdownMenuItem>
|
|
848
798
|
</DropdownMenuGroup>
|
|
849
799
|
{allowHtmlDownload && <DropdownMenuSeparator />}
|
|
850
800
|
{allowHtmlDownload && exportMenuItems}
|
|
@@ -1026,7 +976,6 @@ export function Slide() {
|
|
|
1026
976
|
if (slideId) openPresenterWindow(slideId);
|
|
1027
977
|
present('window');
|
|
1028
978
|
},
|
|
1029
|
-
onCopyLink: copyLink,
|
|
1030
979
|
onOverview: () => setOverviewOpen(true),
|
|
1031
980
|
onToggleDesignPanel: () => setDesignOpen((v) => !v),
|
|
1032
981
|
onToggleAgentPanel: toggleAgent,
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { renderToStaticMarkup } from 'react-dom/server';
|
|
2
|
-
import { describe, expect, it } from 'vitest';
|
|
3
|
-
import { NoteMarkdown } from './note-markdown';
|
|
4
|
-
|
|
5
|
-
const render = (text: string) => renderToStaticMarkup(<NoteMarkdown text={text} />);
|
|
6
|
-
|
|
7
|
-
describe('NoteMarkdown', () => {
|
|
8
|
-
it('renders inline markdown as semantic elements', () => {
|
|
9
|
-
const html = render('a **bold** and *soft* `cmd`');
|
|
10
|
-
expect(html).toContain('<strong class="font-semibold">bold</strong>');
|
|
11
|
-
expect(html).toContain('<em>soft</em>');
|
|
12
|
-
expect(html).toContain('>cmd</code>');
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it('renders headings demoted to h4–h6', () => {
|
|
16
|
-
const html = render('# One\n## Two\n### Three');
|
|
17
|
-
expect(html).toContain('<h4');
|
|
18
|
-
expect(html).toContain('<h5');
|
|
19
|
-
expect(html).toContain('<h6');
|
|
20
|
-
expect(html).not.toContain('<h1');
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it('renders lists with the right element', () => {
|
|
24
|
-
expect(render('- a\n- b')).toMatch(/<ul[^>]*>.*<li>a<\/li><li>b<\/li>.*<\/ul>/);
|
|
25
|
-
expect(render('1. a\n2. b')).toMatch(/<ol[^>]*>.*<li>a<\/li><li>b<\/li>.*<\/ol>/);
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it('joins paragraph lines with <br/> and splits paragraphs', () => {
|
|
29
|
-
const html = render('one\ntwo\n\nthree');
|
|
30
|
-
expect(html).toMatch(/<p>one<br\/>two<\/p><p>three<\/p>/);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it('keeps escaped delimiters literal in the output', () => {
|
|
34
|
-
const html = render('\\*keep\\* the stars');
|
|
35
|
-
expect(html).toContain('*keep* the stars');
|
|
36
|
-
expect(html).not.toContain('<em>');
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it('preserves whitespace via a pre-wrap wrapper', () => {
|
|
40
|
-
expect(render('x')).toContain('whitespace-pre-wrap');
|
|
41
|
-
});
|
|
42
|
-
});
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import {
|
|
3
|
-
getCenteredThumbnailScrollTop,
|
|
4
|
-
getThumbnailOffscreenDirection,
|
|
5
|
-
} from './thumbnail-rail-scroll';
|
|
6
|
-
|
|
7
|
-
describe('getThumbnailOffscreenDirection', () => {
|
|
8
|
-
const visibleBounds = { visibleTop: 40, visibleBottom: 540 };
|
|
9
|
-
|
|
10
|
-
it('reports a thumbnail fully above the visible area', () => {
|
|
11
|
-
expect(getThumbnailOffscreenDirection({ itemTop: -80, itemBottom: 40, ...visibleBounds })).toBe(
|
|
12
|
-
'above',
|
|
13
|
-
);
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
it('reports a thumbnail fully below the visible area', () => {
|
|
17
|
-
expect(
|
|
18
|
-
getThumbnailOffscreenDirection({ itemTop: 540, itemBottom: 660, ...visibleBounds }),
|
|
19
|
-
).toBe('below');
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it('keeps the control hidden while a thumbnail is fully visible', () => {
|
|
23
|
-
expect(
|
|
24
|
-
getThumbnailOffscreenDirection({ itemTop: 120, itemBottom: 240, ...visibleBounds }),
|
|
25
|
-
).toBeNull();
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it('keeps the control hidden while either edge remains visible', () => {
|
|
29
|
-
expect(
|
|
30
|
-
getThumbnailOffscreenDirection({ itemTop: 20, itemBottom: 80, ...visibleBounds }),
|
|
31
|
-
).toBeNull();
|
|
32
|
-
expect(
|
|
33
|
-
getThumbnailOffscreenDirection({ itemTop: 500, itemBottom: 580, ...visibleBounds }),
|
|
34
|
-
).toBeNull();
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
describe('getCenteredThumbnailScrollTop', () => {
|
|
39
|
-
it('centers the thumbnail inside the unobscured viewport', () => {
|
|
40
|
-
expect(
|
|
41
|
-
getCenteredThumbnailScrollTop({
|
|
42
|
-
itemTop: 1040,
|
|
43
|
-
itemHeight: 120,
|
|
44
|
-
viewportHeight: 600,
|
|
45
|
-
topInset: 40,
|
|
46
|
-
}),
|
|
47
|
-
).toBe(780);
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
it('does not scroll before the start of the list', () => {
|
|
51
|
-
expect(
|
|
52
|
-
getCenteredThumbnailScrollTop({
|
|
53
|
-
itemTop: 40,
|
|
54
|
-
itemHeight: 120,
|
|
55
|
-
viewportHeight: 600,
|
|
56
|
-
topInset: 40,
|
|
57
|
-
}),
|
|
58
|
-
).toBe(0);
|
|
59
|
-
});
|
|
60
|
-
});
|
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import {
|
|
3
|
-
type AgentPrefs,
|
|
4
|
-
DEFAULT_PREFS,
|
|
5
|
-
PREFS_KEY,
|
|
6
|
-
prefsLines,
|
|
7
|
-
readPrefs,
|
|
8
|
-
sanitizePrefs,
|
|
9
|
-
savePrefs,
|
|
10
|
-
toneForUses,
|
|
11
|
-
} from './prefs';
|
|
12
|
-
|
|
13
|
-
function memoryStorage(initial: Record<string, string> = {}): Storage {
|
|
14
|
-
const data = new Map(Object.entries(initial));
|
|
15
|
-
return {
|
|
16
|
-
get length() {
|
|
17
|
-
return data.size;
|
|
18
|
-
},
|
|
19
|
-
clear: () => data.clear(),
|
|
20
|
-
getItem: (key: string) => data.get(key) ?? null,
|
|
21
|
-
key: (index: number) => [...data.keys()][index] ?? null,
|
|
22
|
-
removeItem: (key: string) => {
|
|
23
|
-
data.delete(key);
|
|
24
|
-
},
|
|
25
|
-
setItem: (key: string, value: string) => {
|
|
26
|
-
data.set(key, value);
|
|
27
|
-
},
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
describe('sanitizePrefs', () => {
|
|
32
|
-
it('returns the defaults for anything that is not an object', () => {
|
|
33
|
-
expect(sanitizePrefs(null)).toEqual(DEFAULT_PREFS);
|
|
34
|
-
expect(sanitizePrefs('dense')).toEqual(DEFAULT_PREFS);
|
|
35
|
-
expect(sanitizePrefs(['dense'])).toEqual(DEFAULT_PREFS);
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it('keeps the values it knows', () => {
|
|
39
|
-
const prefs: AgentPrefs = {
|
|
40
|
-
confirmEachPage: true,
|
|
41
|
-
askOnMismatch: false,
|
|
42
|
-
autoImages: false,
|
|
43
|
-
tone: 'concise',
|
|
44
|
-
research: 'web',
|
|
45
|
-
outline: 'direct',
|
|
46
|
-
design: 'dense',
|
|
47
|
-
review: 'numbers',
|
|
48
|
-
};
|
|
49
|
-
expect(sanitizePrefs(prefs)).toEqual(prefs);
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it('replaces the values it does not know with the defaults', () => {
|
|
53
|
-
expect(
|
|
54
|
-
sanitizePrefs({
|
|
55
|
-
confirmEachPage: 'yes',
|
|
56
|
-
askOnMismatch: 0,
|
|
57
|
-
autoImages: null,
|
|
58
|
-
tone: 'shouty',
|
|
59
|
-
research: 'library',
|
|
60
|
-
outline: 'auto',
|
|
61
|
-
design: 'sparse',
|
|
62
|
-
review: 'loose',
|
|
63
|
-
}),
|
|
64
|
-
).toEqual(DEFAULT_PREFS);
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it('fills a partial record', () => {
|
|
68
|
-
expect(sanitizePrefs({ design: 'visual' })).toEqual({ ...DEFAULT_PREFS, design: 'visual' });
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
describe('readPrefs and savePrefs', () => {
|
|
73
|
-
it('round-trips through storage', () => {
|
|
74
|
-
const storage = memoryStorage();
|
|
75
|
-
const prefs: AgentPrefs = { ...DEFAULT_PREFS, tone: 'friendly', confirmEachPage: true };
|
|
76
|
-
savePrefs(storage, prefs);
|
|
77
|
-
expect(storage.getItem(PREFS_KEY)).toBe(JSON.stringify(prefs));
|
|
78
|
-
expect(readPrefs(storage)).toEqual(prefs);
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
it('falls back to the defaults on junk or a missing key', () => {
|
|
82
|
-
expect(readPrefs(memoryStorage())).toEqual(DEFAULT_PREFS);
|
|
83
|
-
expect(readPrefs(memoryStorage({ [PREFS_KEY]: 'not json' }))).toEqual(DEFAULT_PREFS);
|
|
84
|
-
expect(readPrefs(memoryStorage({ [PREFS_KEY]: '{"tone":"loud"}' }))).toEqual(DEFAULT_PREFS);
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
it('swallows a storage that throws', () => {
|
|
88
|
-
const broken = {
|
|
89
|
-
getItem: () => {
|
|
90
|
-
throw new Error('blocked');
|
|
91
|
-
},
|
|
92
|
-
setItem: () => {
|
|
93
|
-
throw new Error('blocked');
|
|
94
|
-
},
|
|
95
|
-
} as unknown as Storage;
|
|
96
|
-
expect(readPrefs(broken)).toEqual(DEFAULT_PREFS);
|
|
97
|
-
expect(() => savePrefs(broken, DEFAULT_PREFS)).not.toThrow();
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
describe('prefsLines', () => {
|
|
102
|
-
const prefs = (patch: Partial<AgentPrefs> = {}): AgentPrefs => ({ ...DEFAULT_PREFS, ...patch });
|
|
103
|
-
|
|
104
|
-
it('gives every step the tone', () => {
|
|
105
|
-
for (const step of ['outline', 'page', 'review'] as const) {
|
|
106
|
-
expect(prefsLines(prefs(), step)[0]).toBe('Write in a steady, professional tone.');
|
|
107
|
-
}
|
|
108
|
-
expect(prefsLines(prefs({ tone: 'friendly' }), 'page')[0]).toBe(
|
|
109
|
-
'Write in a light, friendly tone.',
|
|
110
|
-
);
|
|
111
|
-
expect(prefsLines(prefs({ tone: 'concise' }), 'review')[0]).toBe(
|
|
112
|
-
'Keep the wording short and punchy.',
|
|
113
|
-
);
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
it('tells the outline step where facts may come from', () => {
|
|
117
|
-
expect(prefsLines(prefs(), 'outline')).toEqual([
|
|
118
|
-
'Write in a steady, professional tone.',
|
|
119
|
-
"Use only the user's reference files; do not look anything up on the web.",
|
|
120
|
-
]);
|
|
121
|
-
expect(prefsLines(prefs({ research: 'web' }), 'outline')).toContain(
|
|
122
|
-
'You may look up facts the files do not cover; say where each one came from.',
|
|
123
|
-
);
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
it('tells the page step how dense to lay out and whether to use images', () => {
|
|
127
|
-
expect(prefsLines(prefs(), 'page')).toEqual([
|
|
128
|
-
'Write in a steady, professional tone.',
|
|
129
|
-
'Balance text and visuals.',
|
|
130
|
-
'Use icons and image placeholders where a picture helps; never invent photos the user did not provide.',
|
|
131
|
-
]);
|
|
132
|
-
expect(prefsLines(prefs({ design: 'dense' }), 'page')).toContain(
|
|
133
|
-
'A page may carry more text and data when the content needs it.',
|
|
134
|
-
);
|
|
135
|
-
expect(prefsLines(prefs({ autoImages: false }), 'page')).toContain(
|
|
136
|
-
'Do not add any image the user did not provide.',
|
|
137
|
-
);
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
it('tells the review step how far to check and what to do with a mismatch', () => {
|
|
141
|
-
expect(prefsLines(prefs(), 'review')).toEqual([
|
|
142
|
-
'Write in a steady, professional tone.',
|
|
143
|
-
'Check wording, typos and every number.',
|
|
144
|
-
]);
|
|
145
|
-
expect(prefsLines(prefs({ review: 'numbers' }), 'review')).toContain(
|
|
146
|
-
'Check only the numbers against the reference files.',
|
|
147
|
-
);
|
|
148
|
-
const lenient = prefsLines(prefs({ askOnMismatch: false }), 'review');
|
|
149
|
-
expect(lenient).toContain(
|
|
150
|
-
'When two files disagree on a number, use the one from the spreadsheet (.xlsx, .xls or .csv) and say which you used.',
|
|
151
|
-
);
|
|
152
|
-
});
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
describe('toneForUses', () => {
|
|
156
|
-
it('picks a tone from what the deck is for', () => {
|
|
157
|
-
expect(toneForUses(['report'])).toBe('steady');
|
|
158
|
-
expect(toneForUses(['pitch'])).toBe('steady');
|
|
159
|
-
expect(toneForUses(['lecture'])).toBe('friendly');
|
|
160
|
-
expect(toneForUses(['training'])).toBe('friendly');
|
|
161
|
-
expect(toneForUses(['launch'])).toBe('concise');
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
it('lets a launch win over anything else picked with it', () => {
|
|
165
|
-
expect(toneForUses(['lecture', 'launch'])).toBe('concise');
|
|
166
|
-
expect(toneForUses(['report', 'training'])).toBe('friendly');
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
it('changes nothing for other or an empty pick', () => {
|
|
170
|
-
expect(toneForUses([])).toBeNull();
|
|
171
|
-
expect(toneForUses(['other'])).toBeNull();
|
|
172
|
-
});
|
|
173
|
-
});
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { buildRestoreGuide, formatSize, restoreGuideFileName } from './guide.ts';
|
|
3
|
-
|
|
4
|
-
const AT = new Date(2026, 10, 1, 21, 30).getTime();
|
|
5
|
-
|
|
6
|
-
describe('the restore guide inside a backup', () => {
|
|
7
|
-
it('says how to restore, in the language of the interface', () => {
|
|
8
|
-
const zh = buildRestoreGuide({
|
|
9
|
-
createdAt: AT,
|
|
10
|
-
decks: 3,
|
|
11
|
-
sizeBytes: 620 * 1024 * 1024,
|
|
12
|
-
appVersion: '0.8.0',
|
|
13
|
-
locale: 'zh-CN',
|
|
14
|
-
});
|
|
15
|
-
expect(zh).toContain('LemonRiver 备份 · 2026-11-01 21:30');
|
|
16
|
-
expect(zh).toContain('3 份演示 · 620 MB · 用 LemonRiver 0.8.0 备份');
|
|
17
|
-
expect(zh).toContain('从备份恢复');
|
|
18
|
-
expect(zh).toContain('https://github.com/SegawaBeer/lemonriver-slide/releases/latest');
|
|
19
|
-
expect(zh).not.toContain('<script');
|
|
20
|
-
|
|
21
|
-
const en = buildRestoreGuide({
|
|
22
|
-
createdAt: AT,
|
|
23
|
-
decks: 1,
|
|
24
|
-
sizeBytes: 2048,
|
|
25
|
-
appVersion: '0.8.0',
|
|
26
|
-
locale: 'en',
|
|
27
|
-
});
|
|
28
|
-
expect(en).toContain('LemonRiver backup · 2026-11-01 21:30');
|
|
29
|
-
expect(en).toContain('1 decks · 2 KB · Made with LemonRiver 0.8.0');
|
|
30
|
-
expect(en).toContain('Settings → Backup');
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it('names the file per language', () => {
|
|
34
|
-
expect(restoreGuideFileName('zh-CN')).toBe('怎么恢复.html');
|
|
35
|
-
expect(restoreGuideFileName('zh-TW')).toBe('怎麼還原.html');
|
|
36
|
-
expect(restoreGuideFileName('en')).toBe('How to restore.html');
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it('formats sizes the way the backup line shows them', () => {
|
|
40
|
-
expect(formatSize(900)).toBe('900 B');
|
|
41
|
-
expect(formatSize(18 * 1024)).toBe('18 KB');
|
|
42
|
-
expect(formatSize(620 * 1024 * 1024)).toBe('620 MB');
|
|
43
|
-
expect(formatSize(1.5 * 1024 * 1024 * 1024)).toBe('1.5 GB');
|
|
44
|
-
});
|
|
45
|
-
});
|