@lemonriver/core 1.3.0 → 1.4.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-CSkdswfd.js → build-Cv0nNc4G.js} +1 -1
- package/dist/cli/bin.js +5 -5
- package/dist/{config-C5-myPY6.js → config-Di9kipre.js} +2773 -714
- package/dist/{config-CYNOR93W.d.ts → config-f1SqAhtR.d.ts} +1 -1
- package/dist/{dev-DHtYH8sw.js → dev-Az1UzCQp.js} +11 -11
- package/dist/index.d.ts +2 -2
- package/dist/index.js +21 -2
- package/dist/locale/index.d.ts +1 -1
- package/dist/locale/index.js +1 -1
- package/dist/{mcp-B2UeO1un.js → mcp-CW7H6oUg.js} +1 -1
- package/dist/{preview-C1B6-umF.js → preview-DtSq5uN1.js} +1 -1
- package/dist/{types-tdaXSyah.d.ts → types-C4VfD89E.d.ts} +12 -0
- package/dist/{update-DzL8fpcI.js → update-DVe2kQA7.js} +86 -13
- package/dist/vite/index.d.ts +1 -1
- package/dist/vite/index.js +1 -1
- package/dist/{zh-tw-BhYyMx0-.js → zh-tw-BX3oQAc2.js} +110 -0
- package/package.json +5 -6
- package/release-notes.json +20 -0
- package/src/agent/types.ts +9 -2
- package/src/app/app.tsx +2 -0
- package/src/app/components/agent/agent-panel.tsx +12 -3
- package/src/app/components/agent/agent-presence.tsx +1 -1
- package/src/app/components/command/home-command-menu.tsx +4 -1
- package/src/app/components/command/slide-command-menu.tsx +4 -1
- package/src/app/components/export-progress-toast.tsx +3 -1
- package/src/app/components/inspector/asset-picker-dialog.tsx +1 -1
- package/src/app/components/inspector/comment-layer.tsx +3 -3
- package/src/app/components/inspector/inline-text-editor.tsx +1 -12
- package/src/app/components/inspector/inspect-overlay.tsx +9 -1
- package/src/app/components/inspector/inspector-panel.tsx +7 -23
- package/src/app/components/inspector/inspector-provider.tsx +177 -36
- package/src/app/components/inspector/page-panel.tsx +270 -0
- package/src/app/components/language-toggle.tsx +13 -11
- package/src/app/components/overview-grid.tsx +3 -3
- package/src/app/components/panel/editor-sidebar.tsx +43 -8
- package/src/app/components/panel/panel-shell.tsx +9 -5
- package/src/app/components/panel/save-card.tsx +1 -1
- package/src/app/components/sidebar/folder-item.tsx +4 -1
- package/src/app/components/sidebar/sidebar.tsx +11 -8
- package/src/app/components/slide-canvas.tsx +1 -1
- package/src/app/components/style-panel/design-provider.tsx +48 -11
- package/src/app/components/style-panel/use-design.ts +6 -1
- package/src/app/components/theme-toggle.tsx +16 -22
- package/src/app/components/thumbnail-rail.tsx +69 -50
- package/src/app/components/ui/context-menu.tsx +9 -10
- package/src/app/components/ui/dialog.tsx +2 -4
- package/src/app/components/ui/dropdown-menu.tsx +9 -10
- package/src/app/components/ui/popover.tsx +1 -1
- package/src/app/components/ui/select.tsx +2 -2
- package/src/app/components/ui/sonner.tsx +2 -2
- package/src/app/index.html +7 -0
- package/src/app/lemonriver/agent-cli/model.ts +22 -0
- package/src/app/lemonriver/agent-install/model.ts +46 -0
- package/src/app/lemonriver/agent-install/section.tsx +178 -0
- package/src/app/lemonriver/agent-install/use-install.ts +51 -0
- package/src/app/lemonriver/agent-providers/section.tsx +385 -44
- package/src/app/lemonriver/agent-providers/use-providers.ts +50 -3
- package/src/app/lemonriver/backup/places.ts +22 -12
- package/src/app/lemonriver/chrome/sidebar-extras.tsx +1 -1
- package/src/app/lemonriver/feedback/dialog.tsx +1 -2
- package/src/app/lemonriver/feedback/model.ts +0 -5
- package/src/app/lemonriver/guide/clipboard.ts +19 -0
- package/src/app/lemonriver/guide/create-board.tsx +150 -0
- package/src/app/lemonriver/guide/install-board.tsx +208 -0
- package/src/app/lemonriver/guide/more-agents-page.tsx +89 -0
- package/src/app/lemonriver/guide/more-agents.ts +137 -0
- package/src/app/lemonriver/guide/quick-board.tsx +57 -0
- package/src/app/lemonriver/guide/start-board.tsx +38 -0
- package/src/app/lemonriver/guide/start-card.tsx +105 -0
- package/src/app/lemonriver/guide/start.ts +174 -0
- package/src/app/lemonriver/guide/state.ts +5 -21
- package/src/app/lemonriver/help/help-page.tsx +24 -6
- package/src/app/lemonriver/help/model.ts +1 -0
- package/src/app/lemonriver/home/home-page.tsx +12 -6
- package/src/app/lemonriver/home/sorting.ts +45 -0
- package/src/app/lemonriver/home/use-deck-times.ts +1 -2
- package/src/app/lemonriver/i18n/system-locale.ts +39 -0
- package/src/app/lemonriver/routes.tsx +2 -0
- package/src/app/lemonriver/settings/backup-section.tsx +3 -2
- package/src/app/lemonriver/settings/settings-page.tsx +5 -6
- package/src/app/lemonriver/settings/workspace-card.tsx +2 -1
- package/src/app/lemonriver/share/share-dialog.tsx +2 -1
- package/src/app/lemonriver/text/en.ts +592 -453
- package/src/app/lemonriver/text/es.ts +402 -271
- package/src/app/lemonriver/text/ja.ts +403 -274
- package/src/app/lemonriver/text/platform.ts +7 -0
- package/src/app/lemonriver/text/types.ts +118 -1
- package/src/app/lemonriver/text/zh-cn.ts +643 -508
- package/src/app/lemonriver/text/zh-tw.ts +679 -545
- package/src/app/lemonriver/theme/app.css +9 -0
- package/src/app/lemonriver/theme/controls.css +5 -2
- package/src/app/lemonriver/theme/index.css +9 -0
- package/src/app/lemonriver/theme/pages.ts +2 -0
- package/src/app/lemonriver/theme/theme-menu.tsx +10 -11
- package/src/app/lemonriver/update/restart-wait.ts +45 -0
- package/src/app/lemonriver/update/update-prompt.tsx +9 -0
- package/src/app/lib/agent/use-agent.ts +117 -30
- package/src/app/lib/desktop-host.ts +31 -0
- package/src/app/lib/desktop-routes.ts +22 -0
- package/src/app/lib/desktop.ts +106 -0
- package/src/app/lib/export-pdf.ts +15 -7
- package/src/app/lib/inspector/color.ts +51 -0
- package/src/app/lib/inspector/fiber.ts +6 -0
- package/src/app/lib/inspector/use-editor.ts +2 -1
- package/src/app/lib/inspector/use-notes.ts +331 -57
- package/src/app/lib/inspector/use-visual-editor.ts +9 -1
- package/src/app/lib/locale-store.ts +6 -1
- package/src/app/lib/transition.ts +43 -0
- package/src/app/lib/unsaved.ts +155 -0
- package/src/app/routes/home.tsx +1 -1
- package/src/app/routes/slide.tsx +116 -73
- package/src/app/styles.css +39 -1
- package/src/locale/en.ts +19 -0
- package/src/locale/es.ts +19 -0
- package/src/locale/ja.ts +19 -0
- package/src/locale/types.ts +12 -0
- package/src/locale/zh-cn.ts +19 -0
- package/src/locale/zh-tw.ts +19 -0
- package/src/app/lemonriver/guide/guide-prompt.tsx +0 -89
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { useEffect, useRef } from 'react';
|
|
2
|
+
import type { UnsavedAction, UnsavedOutcome, UnsavedStatus } from './desktop-host';
|
|
3
|
+
|
|
4
|
+
export type UnsavedSource = {
|
|
5
|
+
// A draft waits for the user to save it; autosaved work is unsaved only until its write lands.
|
|
6
|
+
kind: 'draft' | 'autosave';
|
|
7
|
+
dirty: () => boolean;
|
|
8
|
+
save: () => Promise<void>;
|
|
9
|
+
discard: () => void;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
type Write = () => Promise<unknown>;
|
|
13
|
+
|
|
14
|
+
const sources = new Set<UnsavedSource>();
|
|
15
|
+
const writes = new Map<unknown, Promise<unknown>>();
|
|
16
|
+
const failed = new Map<unknown, Write>();
|
|
17
|
+
const abandonListeners = new Set<() => void>();
|
|
18
|
+
|
|
19
|
+
export function registerUnsaved(source: UnsavedSource): () => void {
|
|
20
|
+
sources.add(source);
|
|
21
|
+
return () => {
|
|
22
|
+
sources.delete(source);
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// For a write that outlives the component that started it, such as a flush on
|
|
27
|
+
// unmount. A failed one is retried on the next save until it lands or the work
|
|
28
|
+
// is abandoned; a newer write under the same key replaces it.
|
|
29
|
+
export function trackWrite(key: unknown, write: Write): void {
|
|
30
|
+
const attempt = write();
|
|
31
|
+
writes.set(key, attempt);
|
|
32
|
+
failed.delete(key);
|
|
33
|
+
const finish = (retry?: Write) => {
|
|
34
|
+
if (writes.get(key) !== attempt) return;
|
|
35
|
+
writes.delete(key);
|
|
36
|
+
if (retry) failed.set(key, retry);
|
|
37
|
+
};
|
|
38
|
+
attempt.then(
|
|
39
|
+
() => finish(),
|
|
40
|
+
() => finish(write),
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function onAbandon(listener: () => void): () => void {
|
|
45
|
+
abandonListeners.add(listener);
|
|
46
|
+
return () => {
|
|
47
|
+
abandonListeners.delete(listener);
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// For work that reached disk some other way after its tracked write failed.
|
|
52
|
+
export function forgetWrite(key: unknown): void {
|
|
53
|
+
failed.delete(key);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function unsavedStatus(): UnsavedStatus {
|
|
57
|
+
let drafts = false;
|
|
58
|
+
let pending = writes.size > 0 || failed.size > 0;
|
|
59
|
+
for (const source of sources) {
|
|
60
|
+
if (!source.dirty()) continue;
|
|
61
|
+
if (source.kind === 'draft') drafts = true;
|
|
62
|
+
else pending = true;
|
|
63
|
+
}
|
|
64
|
+
return { drafts, pending };
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function hasUnsaved(): boolean {
|
|
68
|
+
const { drafts, pending } = unsavedStatus();
|
|
69
|
+
return drafts || pending;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function describe(error: unknown): string {
|
|
73
|
+
return error instanceof Error ? error.message : String(error);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export async function settleUnsaved(action: UnsavedAction): Promise<UnsavedOutcome> {
|
|
77
|
+
const errors: string[] = [];
|
|
78
|
+
for (const source of [...sources]) {
|
|
79
|
+
if (!source.dirty()) continue;
|
|
80
|
+
if (action === 'abandon' || (action === 'discard' && source.kind === 'draft')) {
|
|
81
|
+
source.discard();
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
try {
|
|
85
|
+
await source.save();
|
|
86
|
+
} catch (err) {
|
|
87
|
+
errors.push(describe(err));
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (action === 'abandon') {
|
|
91
|
+
// In-flight writes too, so one that fails later is not kept for a retry.
|
|
92
|
+
writes.clear();
|
|
93
|
+
failed.clear();
|
|
94
|
+
for (const listener of abandonListeners) listener();
|
|
95
|
+
return { ok: true };
|
|
96
|
+
}
|
|
97
|
+
for (const [key, write] of [...failed]) trackWrite(key, write);
|
|
98
|
+
for (const result of await Promise.allSettled([...writes.values()])) {
|
|
99
|
+
if (result.status === 'rejected') errors.push(describe(result.reason));
|
|
100
|
+
}
|
|
101
|
+
if (errors.length > 0) return { ok: false, error: errors.join(' ') };
|
|
102
|
+
if (hasUnsaved()) {
|
|
103
|
+
return { ok: false, error: 'More changes were made while saving.' };
|
|
104
|
+
}
|
|
105
|
+
return { ok: true };
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export function useUnsavedSource(source: UnsavedSource) {
|
|
109
|
+
const latest = useRef(source);
|
|
110
|
+
latest.current = source;
|
|
111
|
+
const { kind } = source;
|
|
112
|
+
useEffect(
|
|
113
|
+
() =>
|
|
114
|
+
registerUnsaved({
|
|
115
|
+
kind,
|
|
116
|
+
dirty: () => latest.current.dirty(),
|
|
117
|
+
save: () => latest.current.save(),
|
|
118
|
+
discard: () => latest.current.discard(),
|
|
119
|
+
}),
|
|
120
|
+
[kind],
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// For writes that carry no base revision: a retried one would otherwise replace
|
|
125
|
+
// a value that a newer write has saved since.
|
|
126
|
+
export function createWriteLedger() {
|
|
127
|
+
let seq = 0;
|
|
128
|
+
const saved = new Map<string, number>();
|
|
129
|
+
const superseded = (key: string, writeSeq: number) =>
|
|
130
|
+
(saved.get(key) ?? Number.NEGATIVE_INFINITY) > writeSeq;
|
|
131
|
+
return {
|
|
132
|
+
next: () => ++seq,
|
|
133
|
+
superseded,
|
|
134
|
+
record(key: string, writeSeq: number) {
|
|
135
|
+
if (!superseded(key, writeSeq)) saved.set(key, writeSeq);
|
|
136
|
+
},
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Runs saves one after another, each starting once the previous one settles.
|
|
141
|
+
export function createSaveQueue() {
|
|
142
|
+
let tail: Promise<unknown> = Promise.resolve();
|
|
143
|
+
let size = 0;
|
|
144
|
+
return {
|
|
145
|
+
run<T>(task: () => Promise<T>, onIdle?: () => void): Promise<T> {
|
|
146
|
+
size++;
|
|
147
|
+
const result = tail.then(task).finally(() => {
|
|
148
|
+
if (--size === 0) onIdle?.();
|
|
149
|
+
});
|
|
150
|
+
tail = result.catch(() => {});
|
|
151
|
+
return result;
|
|
152
|
+
},
|
|
153
|
+
busy: () => size > 0,
|
|
154
|
+
};
|
|
155
|
+
}
|
package/src/app/routes/home.tsx
CHANGED
|
@@ -592,7 +592,7 @@ function SlideCard({
|
|
|
592
592
|
<button
|
|
593
593
|
type="button"
|
|
594
594
|
onClick={(e) => e.stopPropagation()}
|
|
595
|
-
className="flex size-7 items-center justify-center rounded-[5px] bg-
|
|
595
|
+
className="flex size-7 items-center justify-center rounded-[5px] bg-material text-foreground shadow-edge ring-1 ring-border opacity-0 outline-none backdrop-blur-xl backdrop-saturate-150 hover:bg-card group-hover:opacity-100 focus-visible:opacity-100 focus-visible:ring-ring/40 aria-expanded:opacity-100 motion-safe:transition-opacity motion-safe:duration-150"
|
|
596
596
|
aria-label={tCard.home.slideActions}
|
|
597
597
|
>
|
|
598
598
|
<MoreHorizontal className="size-3.5" />
|
package/src/app/routes/slide.tsx
CHANGED
|
@@ -61,7 +61,13 @@ import {
|
|
|
61
61
|
} from '@/components/ui/dropdown-menu';
|
|
62
62
|
import { Tabs, TabsList, TabsTrigger } from '@/components/ui/tabs';
|
|
63
63
|
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip';
|
|
64
|
-
import {
|
|
64
|
+
import {
|
|
65
|
+
setDockOpen,
|
|
66
|
+
useAgentActivity,
|
|
67
|
+
useAgentDock,
|
|
68
|
+
useSessionHandoff,
|
|
69
|
+
} from '@/lib/agent/use-agent';
|
|
70
|
+
import { openHomeInHost } from '@/lib/desktop';
|
|
65
71
|
import { useFolders } from '@/lib/folders';
|
|
66
72
|
import {
|
|
67
73
|
hasModifier,
|
|
@@ -109,7 +115,7 @@ import {
|
|
|
109
115
|
exportSlideAsPptx,
|
|
110
116
|
type PptxExportProgress,
|
|
111
117
|
} from '../lib/export-pptx';
|
|
112
|
-
import {
|
|
118
|
+
import { changeNotesPages } from '../lib/inspector/use-notes';
|
|
113
119
|
import type { SlideModule } from '../lib/sdk';
|
|
114
120
|
import { usePrefersReducedMotion } from '../lib/use-prefers-reduced-motion';
|
|
115
121
|
import { useSlideModule } from '../lib/use-slide-module';
|
|
@@ -118,6 +124,12 @@ const { showSlideUi, showSlideBrowser, allowHtmlDownload } = config.build;
|
|
|
118
124
|
|
|
119
125
|
const noop = () => {};
|
|
120
126
|
|
|
127
|
+
type PagePlan = {
|
|
128
|
+
order: number[];
|
|
129
|
+
request: string;
|
|
130
|
+
init: RequestInit;
|
|
131
|
+
};
|
|
132
|
+
|
|
121
133
|
export function Slide() {
|
|
122
134
|
const { slideId = '' } = useParams();
|
|
123
135
|
const [searchParams, setSearchParams] = useSearchParams();
|
|
@@ -125,6 +137,9 @@ export function Slide() {
|
|
|
125
137
|
// Back always leads to the home view the editor was opened from, so the
|
|
126
138
|
// board and the pages opened from it never stack up in the history.
|
|
127
139
|
const goBack = useCallback(() => {
|
|
140
|
+
// Back always leads to the home view the editor was opened from, so the
|
|
141
|
+
// board and the pages opened from it never stack up in the history.
|
|
142
|
+
if (openHomeInHost()) return;
|
|
128
143
|
navigate(readLastHomeLocation(), { replace: true });
|
|
129
144
|
}, [navigate]);
|
|
130
145
|
const { slide, error } = useSlideModule(slideId);
|
|
@@ -145,6 +160,7 @@ export function Slide() {
|
|
|
145
160
|
const [overviewOpen, setOverviewOpen] = useState(false);
|
|
146
161
|
const [commandOpen, setCommandOpen] = useState(false);
|
|
147
162
|
const { open: agentOpen, toggle: toggleAgent } = useAgentDock();
|
|
163
|
+
useSessionHandoff(slideId);
|
|
148
164
|
useLayoutEffect(() => {
|
|
149
165
|
if (agentOpen) setDesignOpen(false);
|
|
150
166
|
}, [agentOpen]);
|
|
@@ -223,11 +239,16 @@ export function Slide() {
|
|
|
223
239
|
};
|
|
224
240
|
}, [curtain, playMode]);
|
|
225
241
|
|
|
242
|
+
const routedRef = useRef(slideId);
|
|
243
|
+
routedRef.current = slideId;
|
|
226
244
|
const modulePages = useMemo(() => slide?.default ?? [], [slide]);
|
|
227
|
-
|
|
245
|
+
// Tagged with its deck: right after a route change the old deck's module is
|
|
246
|
+
// still loaded under the new slideId.
|
|
247
|
+
const [deck, setDeck] = useState({ slideId, pages: modulePages });
|
|
228
248
|
useEffect(() => {
|
|
229
|
-
|
|
249
|
+
setDeck({ slideId: routedRef.current, pages: modulePages });
|
|
230
250
|
}, [modulePages]);
|
|
251
|
+
const pages = deck.pages;
|
|
231
252
|
const pageCount = pages.length;
|
|
232
253
|
const rawIndex = Number(searchParams.get('p') ?? '1') - 1;
|
|
233
254
|
const index = Number.isFinite(rawIndex) ? Math.max(0, Math.min(pageCount - 1, rawIndex)) : 0;
|
|
@@ -252,19 +273,23 @@ export function Slide() {
|
|
|
252
273
|
[navigate],
|
|
253
274
|
);
|
|
254
275
|
|
|
255
|
-
const
|
|
276
|
+
const showPage = useCallback(
|
|
256
277
|
(i: number) => {
|
|
257
|
-
const clamped = Math.max(0, Math.min(pageCount - 1, i));
|
|
258
278
|
setSearchParams(
|
|
259
279
|
(prev) => {
|
|
260
280
|
const next = new URLSearchParams(prev);
|
|
261
|
-
next.set('p', String(
|
|
281
|
+
next.set('p', String(i + 1));
|
|
262
282
|
return next;
|
|
263
283
|
},
|
|
264
284
|
{ replace: true },
|
|
265
285
|
);
|
|
266
286
|
},
|
|
267
|
-
[
|
|
287
|
+
[setSearchParams],
|
|
288
|
+
);
|
|
289
|
+
|
|
290
|
+
const goTo = useCallback(
|
|
291
|
+
(i: number) => showPage(Math.max(0, Math.min(pageCount - 1, i))),
|
|
292
|
+
[pageCount, showPage],
|
|
268
293
|
);
|
|
269
294
|
|
|
270
295
|
// While an agent writes this deck page by page, jump to each page as it
|
|
@@ -277,104 +302,114 @@ export function Slide() {
|
|
|
277
302
|
seenPageCount.current = pageCount;
|
|
278
303
|
}, [agentWriting, pageCount, goTo]);
|
|
279
304
|
|
|
305
|
+
const deckRef = useRef(deck);
|
|
306
|
+
deckRef.current = deck;
|
|
307
|
+
const indexRef = useRef(index);
|
|
308
|
+
indexRef.current = index;
|
|
309
|
+
|
|
310
|
+
// Notes can be mid-save when a page op is asked for, so the op is planned from
|
|
311
|
+
// the pages and position current once those writes settle, and dropped if the
|
|
312
|
+
// route has moved to another deck by then.
|
|
313
|
+
const changePages = useCallback(
|
|
314
|
+
(plan: (order: number[]) => PagePlan | null) =>
|
|
315
|
+
changeNotesPages(slideId, () => {
|
|
316
|
+
const { slideId: owner, pages: before } = deckRef.current;
|
|
317
|
+
if (routedRef.current !== slideId || owner !== slideId) return null;
|
|
318
|
+
const at = indexRef.current;
|
|
319
|
+
const next = plan(before.map((_, i) => i));
|
|
320
|
+
if (!next) return null;
|
|
321
|
+
const moved = next.order.map((i) => before[i]);
|
|
322
|
+
const position = next.order.indexOf(at);
|
|
323
|
+
const nextIndex = position < 0 ? Math.min(at, next.order.length - 1) : position;
|
|
324
|
+
return {
|
|
325
|
+
order: next.order,
|
|
326
|
+
apply: async () => {
|
|
327
|
+
setDeck({ slideId, pages: moved });
|
|
328
|
+
if (nextIndex !== at) showPage(nextIndex);
|
|
329
|
+
const res = await fetch(next.request, next.init);
|
|
330
|
+
const body = (await res.json().catch(() => ({ error: res.statusText }))) as {
|
|
331
|
+
error?: string;
|
|
332
|
+
layout?: string;
|
|
333
|
+
};
|
|
334
|
+
if (!res.ok) throw new Error(body.error ?? `HTTP ${res.status}`);
|
|
335
|
+
return body.layout;
|
|
336
|
+
},
|
|
337
|
+
revert: () => {
|
|
338
|
+
setDeck((current) => (current.pages === moved ? { slideId, pages: before } : current));
|
|
339
|
+
if (nextIndex !== at && routedRef.current === slideId) showPage(at);
|
|
340
|
+
},
|
|
341
|
+
};
|
|
342
|
+
}),
|
|
343
|
+
[slideId, showPage],
|
|
344
|
+
);
|
|
345
|
+
|
|
280
346
|
const reorderPage = useCallback(
|
|
281
347
|
async (from: number, to: number) => {
|
|
282
348
|
if (from === to) return;
|
|
283
|
-
const before = pages;
|
|
284
|
-
const nextPages = [...before];
|
|
285
|
-
const [moved] = nextPages.splice(from, 1);
|
|
286
|
-
nextPages.splice(to, 0, moved);
|
|
287
|
-
setPages(nextPages);
|
|
288
|
-
|
|
289
|
-
const order = before.map((_, i) => i);
|
|
290
|
-
const [movedIdx] = order.splice(from, 1);
|
|
291
|
-
order.splice(to, 0, movedIdx);
|
|
292
|
-
|
|
293
|
-
remapNotesSessionCacheAfterReorder(slideId, order);
|
|
294
|
-
|
|
295
|
-
// Keep the user looking at the same page they were on before the drag.
|
|
296
|
-
let nextIndex = index;
|
|
297
|
-
if (index === from) nextIndex = to;
|
|
298
|
-
else if (from < index && to >= index) nextIndex = index - 1;
|
|
299
|
-
else if (from > index && to <= index) nextIndex = index + 1;
|
|
300
|
-
if (nextIndex !== index) goTo(nextIndex);
|
|
301
|
-
|
|
302
349
|
try {
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
350
|
+
await changePages((order) => {
|
|
351
|
+
if (from < 0 || to < 0 || from >= order.length || to >= order.length) return null;
|
|
352
|
+
const [moved] = order.splice(from, 1);
|
|
353
|
+
order.splice(to, 0, moved);
|
|
354
|
+
return {
|
|
355
|
+
order,
|
|
356
|
+
request: `/__slides/${encodeURIComponent(slideId)}/reorder`,
|
|
357
|
+
init: {
|
|
358
|
+
method: 'PUT',
|
|
359
|
+
headers: { 'content-type': 'application/json' },
|
|
360
|
+
body: JSON.stringify({ order }),
|
|
361
|
+
},
|
|
362
|
+
};
|
|
307
363
|
});
|
|
308
|
-
if (!res.ok) {
|
|
309
|
-
const detail = await res.json().catch(() => ({ error: res.statusText }));
|
|
310
|
-
throw new Error(detail.error ?? `HTTP ${res.status}`);
|
|
311
|
-
}
|
|
312
364
|
} catch (err) {
|
|
313
|
-
setPages(before);
|
|
314
|
-
const inverse = order.map((_, i) => order.indexOf(i));
|
|
315
|
-
remapNotesSessionCacheAfterReorder(slideId, inverse);
|
|
316
365
|
toast.error(`Reorder failed: ${String((err as Error).message ?? err)}`);
|
|
317
366
|
}
|
|
318
367
|
},
|
|
319
|
-
[
|
|
368
|
+
[slideId, changePages],
|
|
320
369
|
);
|
|
321
370
|
|
|
322
371
|
const duplicatePage = useCallback(
|
|
323
372
|
async (i: number) => {
|
|
324
|
-
const before = pages;
|
|
325
|
-
if (i < 0 || i >= before.length) return;
|
|
326
|
-
const nextPages = [...before];
|
|
327
|
-
nextPages.splice(i + 1, 0, before[i]);
|
|
328
|
-
setPages(nextPages);
|
|
329
|
-
if (index > i) goTo(index + 1);
|
|
330
|
-
|
|
331
373
|
try {
|
|
332
|
-
const
|
|
333
|
-
|
|
374
|
+
const changed = await changePages((order) => {
|
|
375
|
+
if (i < 0 || i >= order.length) return null;
|
|
376
|
+
order.splice(i + 1, 0, i);
|
|
377
|
+
return {
|
|
378
|
+
order,
|
|
379
|
+
request: `/__slides/${encodeURIComponent(slideId)}/pages/${i}/duplicate`,
|
|
380
|
+
init: { method: 'POST' },
|
|
381
|
+
};
|
|
334
382
|
});
|
|
335
|
-
if (
|
|
336
|
-
const detail = await res.json().catch(() => ({ error: res.statusText }));
|
|
337
|
-
throw new Error(detail.error ?? `HTTP ${res.status}`);
|
|
338
|
-
}
|
|
339
|
-
toast.success(format(t.thumbnailRail.toastDuplicated, { n: i + 1 }));
|
|
383
|
+
if (changed) toast.success(format(t.thumbnailRail.toastDuplicated, { n: i + 1 }));
|
|
340
384
|
} catch (err) {
|
|
341
|
-
setPages(before);
|
|
342
385
|
toast.error(
|
|
343
386
|
`${t.thumbnailRail.toastDuplicateFailed}: ${String((err as Error).message ?? err)}`,
|
|
344
387
|
);
|
|
345
388
|
}
|
|
346
389
|
},
|
|
347
|
-
[
|
|
390
|
+
[slideId, changePages, t.thumbnailRail],
|
|
348
391
|
);
|
|
349
392
|
|
|
350
393
|
const deletePage = useCallback(
|
|
351
394
|
async (i: number) => {
|
|
352
|
-
const before = pages;
|
|
353
|
-
if (i < 0 || i >= before.length || before.length <= 1) return;
|
|
354
|
-
const nextPages = before.slice(0, i).concat(before.slice(i + 1));
|
|
355
|
-
setPages(nextPages);
|
|
356
|
-
if (index >= i && index > 0) {
|
|
357
|
-
const target = index === i ? Math.min(index, nextPages.length - 1) : index - 1;
|
|
358
|
-
goTo(target);
|
|
359
|
-
}
|
|
360
|
-
|
|
361
395
|
try {
|
|
362
|
-
const
|
|
363
|
-
|
|
396
|
+
const changed = await changePages((order) => {
|
|
397
|
+
if (i < 0 || i >= order.length || order.length <= 1) return null;
|
|
398
|
+
order.splice(i, 1);
|
|
399
|
+
return {
|
|
400
|
+
order,
|
|
401
|
+
request: `/__slides/${encodeURIComponent(slideId)}/pages/${i}`,
|
|
402
|
+
init: { method: 'DELETE' },
|
|
403
|
+
};
|
|
364
404
|
});
|
|
365
|
-
if (
|
|
366
|
-
const detail = await res.json().catch(() => ({ error: res.statusText }));
|
|
367
|
-
throw new Error(detail.error ?? `HTTP ${res.status}`);
|
|
368
|
-
}
|
|
369
|
-
toast.success(format(t.thumbnailRail.toastDeleted, { n: i + 1 }));
|
|
405
|
+
if (changed) toast.success(format(t.thumbnailRail.toastDeleted, { n: i + 1 }));
|
|
370
406
|
} catch (err) {
|
|
371
|
-
setPages(before);
|
|
372
407
|
toast.error(
|
|
373
408
|
`${t.thumbnailRail.toastDeleteFailed}: ${String((err as Error).message ?? err)}`,
|
|
374
409
|
);
|
|
375
410
|
}
|
|
376
411
|
},
|
|
377
|
-
[
|
|
412
|
+
[slideId, changePages, t.thumbnailRail],
|
|
378
413
|
);
|
|
379
414
|
|
|
380
415
|
const thumbnailActions = useMemo<ThumbnailActions | undefined>(
|
|
@@ -941,6 +976,14 @@ export function Slide() {
|
|
|
941
976
|
designOpen={designOpen}
|
|
942
977
|
onCloseDesign={() => setDesignOpen(false)}
|
|
943
978
|
agentOpen={agentOpen}
|
|
979
|
+
page={{
|
|
980
|
+
index,
|
|
981
|
+
total: pageCount,
|
|
982
|
+
component: pages[index],
|
|
983
|
+
transition: pages[index]?.transition ?? slide.transition,
|
|
984
|
+
inheritedTransition: !pages[index]?.transition && Boolean(slide.transition),
|
|
985
|
+
themed: Boolean(slide.design),
|
|
986
|
+
}}
|
|
944
987
|
agent={
|
|
945
988
|
import.meta.env.DEV && (
|
|
946
989
|
<SlideAgentDock
|
package/src/app/styles.css
CHANGED
|
@@ -1,11 +1,29 @@
|
|
|
1
1
|
@import "tailwindcss";
|
|
2
2
|
@import "tw-animate-css";
|
|
3
|
-
@import "shadcn/tailwind.css";
|
|
4
3
|
@import "@fontsource-variable/geist";
|
|
5
4
|
@import "./lemonriver/theme/index.css";
|
|
6
5
|
|
|
7
6
|
@custom-variant dark (&:is(.dark *));
|
|
8
7
|
|
|
8
|
+
@custom-variant data-active {
|
|
9
|
+
&:where([data-state="active"]),
|
|
10
|
+
&:where([data-active]:not([data-active="false"])) {
|
|
11
|
+
@slot;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
@custom-variant data-horizontal {
|
|
16
|
+
&:where([data-orientation="horizontal"]) {
|
|
17
|
+
@slot;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@custom-variant data-vertical {
|
|
22
|
+
&:where([data-orientation="vertical"]) {
|
|
23
|
+
@slot;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
9
27
|
@theme inline {
|
|
10
28
|
--font-sans: "Geist Variable", -apple-system, BlinkMacSystemFont, sans-serif;
|
|
11
29
|
--font-heading: "Geist Variable", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
|
|
@@ -31,6 +49,7 @@
|
|
|
31
49
|
--color-primary: var(--primary);
|
|
32
50
|
--color-popover-foreground: var(--popover-foreground);
|
|
33
51
|
--color-popover: var(--popover);
|
|
52
|
+
--color-material: var(--material);
|
|
34
53
|
--color-card-foreground: var(--card-foreground);
|
|
35
54
|
--color-card: var(--card);
|
|
36
55
|
--color-canvas: var(--canvas);
|
|
@@ -76,6 +95,9 @@
|
|
|
76
95
|
--card-foreground: oklch(0.145 0 0);
|
|
77
96
|
--popover: oklch(1 0 0);
|
|
78
97
|
--popover-foreground: oklch(0.145 0 0);
|
|
98
|
+
/* Translucent fill for floating surfaces; pair with backdrop-blur-xl
|
|
99
|
+
backdrop-saturate-150 so it reads like a native menu material. */
|
|
100
|
+
--material: oklch(1 0 0 / 0.72);
|
|
79
101
|
|
|
80
102
|
--primary: oklch(0.185 0 0);
|
|
81
103
|
--primary-foreground: oklch(0.985 0 0);
|
|
@@ -118,6 +140,7 @@
|
|
|
118
140
|
--card-foreground: oklch(0.93 0 0);
|
|
119
141
|
--popover: oklch(0.205 0 0);
|
|
120
142
|
--popover-foreground: oklch(0.93 0 0);
|
|
143
|
+
--material: oklch(0.22 0 0 / 0.72);
|
|
121
144
|
|
|
122
145
|
--primary: oklch(0.925 0 0);
|
|
123
146
|
--primary-foreground: oklch(0.17 0 0);
|
|
@@ -197,6 +220,16 @@
|
|
|
197
220
|
}
|
|
198
221
|
}
|
|
199
222
|
|
|
223
|
+
/* Lets the desktop window's native material show through the chrome; content
|
|
224
|
+
cards stay opaque, so nothing should scroll beneath a chrome surface. */
|
|
225
|
+
html[data-translucent] {
|
|
226
|
+
--sidebar: transparent;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
html[data-translucent] body {
|
|
230
|
+
background-color: transparent;
|
|
231
|
+
}
|
|
232
|
+
|
|
200
233
|
/*
|
|
201
234
|
* Grid entrance — a quiet rise used by card grids. Pair with a small
|
|
202
235
|
* per-item animation-delay for a capped stagger.
|
|
@@ -333,6 +366,11 @@
|
|
|
333
366
|
}
|
|
334
367
|
}
|
|
335
368
|
|
|
369
|
+
[data-osd-removed] {
|
|
370
|
+
/* biome-ignore lint/complexity/noImportantStyles: A pending removal must hide the element over any slide-authored display, including inline styles. */
|
|
371
|
+
display: none !important;
|
|
372
|
+
}
|
|
373
|
+
|
|
336
374
|
[data-osd-freeze-motion],
|
|
337
375
|
[data-osd-freeze-motion] *,
|
|
338
376
|
[data-osd-freeze-motion] *::before,
|
package/src/locale/en.ts
CHANGED
|
@@ -214,6 +214,24 @@ export const en: Locale = {
|
|
|
214
214
|
rotateHandle: 'Rotate element',
|
|
215
215
|
resizeHandle: 'Resize {handle}',
|
|
216
216
|
arrangeSection: 'Arrange',
|
|
217
|
+
pageLabel: 'Page {page} of {total}',
|
|
218
|
+
pageBackground: 'Background',
|
|
219
|
+
pageBackgroundTheme: 'From theme',
|
|
220
|
+
pageBackgroundShared: 'Shared across pages',
|
|
221
|
+
pageBackgroundComplex: 'Gradient or image',
|
|
222
|
+
pageTransition: 'Transition',
|
|
223
|
+
pageTransitionInherited: 'Deck default',
|
|
224
|
+
pageSteps: 'Steps',
|
|
225
|
+
pageStepsCount: { one: '1 step', other: '{count} steps' },
|
|
226
|
+
pageNone: 'None',
|
|
227
|
+
transitionKinds: {
|
|
228
|
+
fade: 'Fade',
|
|
229
|
+
slide: 'Slide',
|
|
230
|
+
zoom: 'Zoom',
|
|
231
|
+
wipe: 'Wipe',
|
|
232
|
+
morph: 'Morph',
|
|
233
|
+
custom: 'Custom',
|
|
234
|
+
},
|
|
217
235
|
selectionCount: '{count} elements selected',
|
|
218
236
|
positionLabel: 'Position',
|
|
219
237
|
positionX: 'Horizontal position',
|
|
@@ -459,6 +477,7 @@ export const en: Locale = {
|
|
|
459
477
|
title: 'Exporting PDF',
|
|
460
478
|
processing: 'Processing page {current} of {total}',
|
|
461
479
|
printing: 'Opening print dialog…',
|
|
480
|
+
saving: 'Saving PDF…',
|
|
462
481
|
done: 'Done',
|
|
463
482
|
},
|
|
464
483
|
|
package/src/locale/es.ts
CHANGED
|
@@ -218,6 +218,24 @@ export const es: Locale = {
|
|
|
218
218
|
rotateHandle: 'Rotar elemento',
|
|
219
219
|
resizeHandle: 'Redimensionar {handle}',
|
|
220
220
|
arrangeSection: 'Organizar',
|
|
221
|
+
pageLabel: 'Página {page} de {total}',
|
|
222
|
+
pageBackground: 'Fondo',
|
|
223
|
+
pageBackgroundTheme: 'Del tema',
|
|
224
|
+
pageBackgroundShared: 'Compartido entre páginas',
|
|
225
|
+
pageBackgroundComplex: 'Degradado o imagen',
|
|
226
|
+
pageTransition: 'Transición',
|
|
227
|
+
pageTransitionInherited: 'Predeterminada de la presentación',
|
|
228
|
+
pageSteps: 'Pasos',
|
|
229
|
+
pageStepsCount: { one: '1 paso', other: '{count} pasos' },
|
|
230
|
+
pageNone: 'Ninguna',
|
|
231
|
+
transitionKinds: {
|
|
232
|
+
fade: 'Fundido',
|
|
233
|
+
slide: 'Desplazar',
|
|
234
|
+
zoom: 'Zoom',
|
|
235
|
+
wipe: 'Barrido',
|
|
236
|
+
morph: 'Morph',
|
|
237
|
+
custom: 'Personalizada',
|
|
238
|
+
},
|
|
221
239
|
selectionCount: '{count} elementos seleccionados',
|
|
222
240
|
positionLabel: 'Posición',
|
|
223
241
|
positionX: 'Posición horizontal',
|
|
@@ -467,6 +485,7 @@ export const es: Locale = {
|
|
|
467
485
|
title: 'Exportando PDF',
|
|
468
486
|
processing: 'Procesando página {current} de {total}',
|
|
469
487
|
printing: 'Abriendo diálogo de impresión…',
|
|
488
|
+
saving: 'Guardando PDF…',
|
|
470
489
|
done: 'Hecho',
|
|
471
490
|
},
|
|
472
491
|
|
package/src/locale/ja.ts
CHANGED
|
@@ -216,6 +216,24 @@ export const ja: Locale = {
|
|
|
216
216
|
rotateHandle: '要素を回転',
|
|
217
217
|
resizeHandle: 'サイズ変更({handle})',
|
|
218
218
|
arrangeSection: '配置',
|
|
219
|
+
pageLabel: '{page} / {total} ページ',
|
|
220
|
+
pageBackground: '背景',
|
|
221
|
+
pageBackgroundTheme: 'テーマに従う',
|
|
222
|
+
pageBackgroundShared: '複数ページで共有',
|
|
223
|
+
pageBackgroundComplex: 'グラデーションまたは画像',
|
|
224
|
+
pageTransition: 'トランジション',
|
|
225
|
+
pageTransitionInherited: 'デッキの既定',
|
|
226
|
+
pageSteps: 'ステップ',
|
|
227
|
+
pageStepsCount: { one: '1 ステップ', other: '{count} ステップ' },
|
|
228
|
+
pageNone: 'なし',
|
|
229
|
+
transitionKinds: {
|
|
230
|
+
fade: 'フェード',
|
|
231
|
+
slide: 'スライド',
|
|
232
|
+
zoom: 'ズーム',
|
|
233
|
+
wipe: 'ワイプ',
|
|
234
|
+
morph: 'モーフ',
|
|
235
|
+
custom: 'カスタム',
|
|
236
|
+
},
|
|
219
237
|
selectionCount: '{count} 個の要素を選択中',
|
|
220
238
|
positionLabel: '位置',
|
|
221
239
|
positionX: '水平位置',
|
|
@@ -466,6 +484,7 @@ export const ja: Locale = {
|
|
|
466
484
|
title: 'PDF を書き出し中',
|
|
467
485
|
processing: 'ページ {current} / {total} を処理中',
|
|
468
486
|
printing: '印刷ダイアログを開いています…',
|
|
487
|
+
saving: 'PDF を保存しています…',
|
|
469
488
|
done: '完了',
|
|
470
489
|
},
|
|
471
490
|
|
package/src/locale/types.ts
CHANGED
|
@@ -219,6 +219,17 @@ export type Locale = {
|
|
|
219
219
|
rotateHandle: string;
|
|
220
220
|
resizeHandle: string;
|
|
221
221
|
arrangeSection: string;
|
|
222
|
+
pageLabel: string;
|
|
223
|
+
pageBackground: string;
|
|
224
|
+
pageBackgroundTheme: string;
|
|
225
|
+
pageBackgroundShared: string;
|
|
226
|
+
pageBackgroundComplex: string;
|
|
227
|
+
pageTransition: string;
|
|
228
|
+
pageTransitionInherited: string;
|
|
229
|
+
pageSteps: string;
|
|
230
|
+
pageStepsCount: Plural;
|
|
231
|
+
pageNone: string;
|
|
232
|
+
transitionKinds: Record<'fade' | 'slide' | 'zoom' | 'wipe' | 'morph' | 'custom', string>;
|
|
222
233
|
selectionCount: string;
|
|
223
234
|
positionLabel: string;
|
|
224
235
|
positionX: string;
|
|
@@ -488,6 +499,7 @@ export type Locale = {
|
|
|
488
499
|
/** template: "Processing page {current} of {total}" */
|
|
489
500
|
processing: string;
|
|
490
501
|
printing: string;
|
|
502
|
+
saving: string;
|
|
491
503
|
done: string;
|
|
492
504
|
};
|
|
493
505
|
|