@lemonriver/core 1.2.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 +34 -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/player.tsx +6 -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/present/dual-screen.ts +154 -0
- package/src/app/lemonriver/present/presenter-blocked-hint.tsx +28 -0
- package/src/app/lemonriver/present/wake-lock.ts +74 -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 +594 -452
- package/src/app/lemonriver/text/es.ts +404 -270
- package/src/app/lemonriver/text/ja.ts +405 -273
- package/src/app/lemonriver/text/platform.ts +7 -0
- package/src/app/lemonriver/text/types.ts +122 -1
- package/src/app/lemonriver/text/zh-cn.ts +645 -507
- package/src/app/lemonriver/text/zh-tw.ts +681 -544
- 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/presenter.tsx +2 -0
- package/src/app/routes/slide.tsx +130 -74
- 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" />
|
|
@@ -31,6 +31,7 @@ import {
|
|
|
31
31
|
import { PreviewStepHost } from '../components/preview-step-host';
|
|
32
32
|
import { SlideCanvas } from '../components/slide-canvas';
|
|
33
33
|
import { isDeckWarmed, markDeckWarmed, SlidePreloadLayer } from '../components/slide-preload-layer';
|
|
34
|
+
import { useScreenWakeLock } from '../lemonriver/present/wake-lock';
|
|
34
35
|
import { SlidePageProvider } from '../lib/page-context';
|
|
35
36
|
import { CANVAS_HEIGHT, CANVAS_WIDTH, type SlideModule } from '../lib/sdk';
|
|
36
37
|
import { loadSlide, slideIds } from '../lib/slides';
|
|
@@ -40,6 +41,7 @@ export function Presenter() {
|
|
|
40
41
|
const { slideId = '' } = useParams();
|
|
41
42
|
const { slide, error } = useSlideModule(slideId);
|
|
42
43
|
useDocumentTitle(slide?.meta?.title);
|
|
44
|
+
useScreenWakeLock(true);
|
|
43
45
|
|
|
44
46
|
// Presenter view is a passive mirror of the projection window. It only
|
|
45
47
|
// tracks the index it last heard about; navigation buttons send commands
|
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,
|
|
@@ -96,6 +102,10 @@ import { isDeckWarmed, markDeckWarmed, SlidePreloadLayer } from '../components/s
|
|
|
96
102
|
import { SlideTransitionLayer } from '../components/slide-transition-layer';
|
|
97
103
|
import { type ThumbnailActions, ThumbnailRail } from '../components/thumbnail-rail';
|
|
98
104
|
import { exportFailedHint } from '../lemonriver/feedback/export';
|
|
105
|
+
import {
|
|
106
|
+
clearAudiencePresentation,
|
|
107
|
+
startAudiencePresentation,
|
|
108
|
+
} from '../lemonriver/present/dual-screen';
|
|
99
109
|
import { ShareMenuEntry } from '../lemonriver/share/editor-share';
|
|
100
110
|
import { SlideExtensions } from '../lemonriver/slide-extensions';
|
|
101
111
|
import { exportSlideAsHtml } from '../lib/export-html';
|
|
@@ -105,7 +115,7 @@ import {
|
|
|
105
115
|
exportSlideAsPptx,
|
|
106
116
|
type PptxExportProgress,
|
|
107
117
|
} from '../lib/export-pptx';
|
|
108
|
-
import {
|
|
118
|
+
import { changeNotesPages } from '../lib/inspector/use-notes';
|
|
109
119
|
import type { SlideModule } from '../lib/sdk';
|
|
110
120
|
import { usePrefersReducedMotion } from '../lib/use-prefers-reduced-motion';
|
|
111
121
|
import { useSlideModule } from '../lib/use-slide-module';
|
|
@@ -114,6 +124,12 @@ const { showSlideUi, showSlideBrowser, allowHtmlDownload } = config.build;
|
|
|
114
124
|
|
|
115
125
|
const noop = () => {};
|
|
116
126
|
|
|
127
|
+
type PagePlan = {
|
|
128
|
+
order: number[];
|
|
129
|
+
request: string;
|
|
130
|
+
init: RequestInit;
|
|
131
|
+
};
|
|
132
|
+
|
|
117
133
|
export function Slide() {
|
|
118
134
|
const { slideId = '' } = useParams();
|
|
119
135
|
const [searchParams, setSearchParams] = useSearchParams();
|
|
@@ -121,6 +137,9 @@ export function Slide() {
|
|
|
121
137
|
// Back always leads to the home view the editor was opened from, so the
|
|
122
138
|
// board and the pages opened from it never stack up in the history.
|
|
123
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;
|
|
124
143
|
navigate(readLastHomeLocation(), { replace: true });
|
|
125
144
|
}, [navigate]);
|
|
126
145
|
const { slide, error } = useSlideModule(slideId);
|
|
@@ -141,6 +160,7 @@ export function Slide() {
|
|
|
141
160
|
const [overviewOpen, setOverviewOpen] = useState(false);
|
|
142
161
|
const [commandOpen, setCommandOpen] = useState(false);
|
|
143
162
|
const { open: agentOpen, toggle: toggleAgent } = useAgentDock();
|
|
163
|
+
useSessionHandoff(slideId);
|
|
144
164
|
useLayoutEffect(() => {
|
|
145
165
|
if (agentOpen) setDesignOpen(false);
|
|
146
166
|
}, [agentOpen]);
|
|
@@ -171,7 +191,7 @@ export function Slide() {
|
|
|
171
191
|
},
|
|
172
192
|
[],
|
|
173
193
|
);
|
|
174
|
-
const
|
|
194
|
+
const enterPresentation = useCallback(
|
|
175
195
|
(mode: 'window' | 'fullscreen') => {
|
|
176
196
|
if (prefersReducedMotion) {
|
|
177
197
|
setPlayMode(mode);
|
|
@@ -189,7 +209,16 @@ export function Slide() {
|
|
|
189
209
|
},
|
|
190
210
|
[prefersReducedMotion],
|
|
191
211
|
);
|
|
212
|
+
const present = useCallback(
|
|
213
|
+
(mode: 'window' | 'fullscreen') => {
|
|
214
|
+
if (mode === 'fullscreen')
|
|
215
|
+
void startAudiencePresentation(slideId, () => enterPresentation('fullscreen'));
|
|
216
|
+
else enterPresentation(mode);
|
|
217
|
+
},
|
|
218
|
+
[enterPresentation, slideId],
|
|
219
|
+
);
|
|
192
220
|
const exitPresent = useCallback(() => {
|
|
221
|
+
clearAudiencePresentation();
|
|
193
222
|
setPlayMode(null);
|
|
194
223
|
if (!prefersReducedMotion) setCurtain('leaving');
|
|
195
224
|
}, [prefersReducedMotion]);
|
|
@@ -210,11 +239,16 @@ export function Slide() {
|
|
|
210
239
|
};
|
|
211
240
|
}, [curtain, playMode]);
|
|
212
241
|
|
|
242
|
+
const routedRef = useRef(slideId);
|
|
243
|
+
routedRef.current = slideId;
|
|
213
244
|
const modulePages = useMemo(() => slide?.default ?? [], [slide]);
|
|
214
|
-
|
|
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 });
|
|
215
248
|
useEffect(() => {
|
|
216
|
-
|
|
249
|
+
setDeck({ slideId: routedRef.current, pages: modulePages });
|
|
217
250
|
}, [modulePages]);
|
|
251
|
+
const pages = deck.pages;
|
|
218
252
|
const pageCount = pages.length;
|
|
219
253
|
const rawIndex = Number(searchParams.get('p') ?? '1') - 1;
|
|
220
254
|
const index = Number.isFinite(rawIndex) ? Math.max(0, Math.min(pageCount - 1, rawIndex)) : 0;
|
|
@@ -239,19 +273,23 @@ export function Slide() {
|
|
|
239
273
|
[navigate],
|
|
240
274
|
);
|
|
241
275
|
|
|
242
|
-
const
|
|
276
|
+
const showPage = useCallback(
|
|
243
277
|
(i: number) => {
|
|
244
|
-
const clamped = Math.max(0, Math.min(pageCount - 1, i));
|
|
245
278
|
setSearchParams(
|
|
246
279
|
(prev) => {
|
|
247
280
|
const next = new URLSearchParams(prev);
|
|
248
|
-
next.set('p', String(
|
|
281
|
+
next.set('p', String(i + 1));
|
|
249
282
|
return next;
|
|
250
283
|
},
|
|
251
284
|
{ replace: true },
|
|
252
285
|
);
|
|
253
286
|
},
|
|
254
|
-
[
|
|
287
|
+
[setSearchParams],
|
|
288
|
+
);
|
|
289
|
+
|
|
290
|
+
const goTo = useCallback(
|
|
291
|
+
(i: number) => showPage(Math.max(0, Math.min(pageCount - 1, i))),
|
|
292
|
+
[pageCount, showPage],
|
|
255
293
|
);
|
|
256
294
|
|
|
257
295
|
// While an agent writes this deck page by page, jump to each page as it
|
|
@@ -264,104 +302,114 @@ export function Slide() {
|
|
|
264
302
|
seenPageCount.current = pageCount;
|
|
265
303
|
}, [agentWriting, pageCount, goTo]);
|
|
266
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
|
+
|
|
267
346
|
const reorderPage = useCallback(
|
|
268
347
|
async (from: number, to: number) => {
|
|
269
348
|
if (from === to) return;
|
|
270
|
-
const before = pages;
|
|
271
|
-
const nextPages = [...before];
|
|
272
|
-
const [moved] = nextPages.splice(from, 1);
|
|
273
|
-
nextPages.splice(to, 0, moved);
|
|
274
|
-
setPages(nextPages);
|
|
275
|
-
|
|
276
|
-
const order = before.map((_, i) => i);
|
|
277
|
-
const [movedIdx] = order.splice(from, 1);
|
|
278
|
-
order.splice(to, 0, movedIdx);
|
|
279
|
-
|
|
280
|
-
remapNotesSessionCacheAfterReorder(slideId, order);
|
|
281
|
-
|
|
282
|
-
// Keep the user looking at the same page they were on before the drag.
|
|
283
|
-
let nextIndex = index;
|
|
284
|
-
if (index === from) nextIndex = to;
|
|
285
|
-
else if (from < index && to >= index) nextIndex = index - 1;
|
|
286
|
-
else if (from > index && to <= index) nextIndex = index + 1;
|
|
287
|
-
if (nextIndex !== index) goTo(nextIndex);
|
|
288
|
-
|
|
289
349
|
try {
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
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
|
+
};
|
|
294
363
|
});
|
|
295
|
-
if (!res.ok) {
|
|
296
|
-
const detail = await res.json().catch(() => ({ error: res.statusText }));
|
|
297
|
-
throw new Error(detail.error ?? `HTTP ${res.status}`);
|
|
298
|
-
}
|
|
299
364
|
} catch (err) {
|
|
300
|
-
setPages(before);
|
|
301
|
-
const inverse = order.map((_, i) => order.indexOf(i));
|
|
302
|
-
remapNotesSessionCacheAfterReorder(slideId, inverse);
|
|
303
365
|
toast.error(`Reorder failed: ${String((err as Error).message ?? err)}`);
|
|
304
366
|
}
|
|
305
367
|
},
|
|
306
|
-
[
|
|
368
|
+
[slideId, changePages],
|
|
307
369
|
);
|
|
308
370
|
|
|
309
371
|
const duplicatePage = useCallback(
|
|
310
372
|
async (i: number) => {
|
|
311
|
-
const before = pages;
|
|
312
|
-
if (i < 0 || i >= before.length) return;
|
|
313
|
-
const nextPages = [...before];
|
|
314
|
-
nextPages.splice(i + 1, 0, before[i]);
|
|
315
|
-
setPages(nextPages);
|
|
316
|
-
if (index > i) goTo(index + 1);
|
|
317
|
-
|
|
318
373
|
try {
|
|
319
|
-
const
|
|
320
|
-
|
|
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
|
+
};
|
|
321
382
|
});
|
|
322
|
-
if (
|
|
323
|
-
const detail = await res.json().catch(() => ({ error: res.statusText }));
|
|
324
|
-
throw new Error(detail.error ?? `HTTP ${res.status}`);
|
|
325
|
-
}
|
|
326
|
-
toast.success(format(t.thumbnailRail.toastDuplicated, { n: i + 1 }));
|
|
383
|
+
if (changed) toast.success(format(t.thumbnailRail.toastDuplicated, { n: i + 1 }));
|
|
327
384
|
} catch (err) {
|
|
328
|
-
setPages(before);
|
|
329
385
|
toast.error(
|
|
330
386
|
`${t.thumbnailRail.toastDuplicateFailed}: ${String((err as Error).message ?? err)}`,
|
|
331
387
|
);
|
|
332
388
|
}
|
|
333
389
|
},
|
|
334
|
-
[
|
|
390
|
+
[slideId, changePages, t.thumbnailRail],
|
|
335
391
|
);
|
|
336
392
|
|
|
337
393
|
const deletePage = useCallback(
|
|
338
394
|
async (i: number) => {
|
|
339
|
-
const before = pages;
|
|
340
|
-
if (i < 0 || i >= before.length || before.length <= 1) return;
|
|
341
|
-
const nextPages = before.slice(0, i).concat(before.slice(i + 1));
|
|
342
|
-
setPages(nextPages);
|
|
343
|
-
if (index >= i && index > 0) {
|
|
344
|
-
const target = index === i ? Math.min(index, nextPages.length - 1) : index - 1;
|
|
345
|
-
goTo(target);
|
|
346
|
-
}
|
|
347
|
-
|
|
348
395
|
try {
|
|
349
|
-
const
|
|
350
|
-
|
|
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
|
+
};
|
|
351
404
|
});
|
|
352
|
-
if (
|
|
353
|
-
const detail = await res.json().catch(() => ({ error: res.statusText }));
|
|
354
|
-
throw new Error(detail.error ?? `HTTP ${res.status}`);
|
|
355
|
-
}
|
|
356
|
-
toast.success(format(t.thumbnailRail.toastDeleted, { n: i + 1 }));
|
|
405
|
+
if (changed) toast.success(format(t.thumbnailRail.toastDeleted, { n: i + 1 }));
|
|
357
406
|
} catch (err) {
|
|
358
|
-
setPages(before);
|
|
359
407
|
toast.error(
|
|
360
408
|
`${t.thumbnailRail.toastDeleteFailed}: ${String((err as Error).message ?? err)}`,
|
|
361
409
|
);
|
|
362
410
|
}
|
|
363
411
|
},
|
|
364
|
-
[
|
|
412
|
+
[slideId, changePages, t.thumbnailRail],
|
|
365
413
|
);
|
|
366
414
|
|
|
367
415
|
const thumbnailActions = useMemo<ThumbnailActions | undefined>(
|
|
@@ -928,6 +976,14 @@ export function Slide() {
|
|
|
928
976
|
designOpen={designOpen}
|
|
929
977
|
onCloseDesign={() => setDesignOpen(false)}
|
|
930
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
|
+
}}
|
|
931
987
|
agent={
|
|
932
988
|
import.meta.env.DEV && (
|
|
933
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
|
|