@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
|
@@ -4,10 +4,11 @@ import { buttonVariants } from '@/components/ui/button';
|
|
|
4
4
|
import {
|
|
5
5
|
DropdownMenu,
|
|
6
6
|
DropdownMenuContent,
|
|
7
|
-
|
|
7
|
+
DropdownMenuRadioGroup,
|
|
8
|
+
DropdownMenuRadioItem,
|
|
8
9
|
DropdownMenuTrigger,
|
|
9
10
|
} from '@/components/ui/dropdown-menu';
|
|
10
|
-
import { LOCALE_OPTIONS, setLocale } from '@/lib/locale-store';
|
|
11
|
+
import { LOCALE_OPTIONS, type LocaleId, setLocale } from '@/lib/locale-store';
|
|
11
12
|
import { useLocale } from '@/lib/use-locale';
|
|
12
13
|
import { cn } from '@/lib/utils';
|
|
13
14
|
|
|
@@ -30,15 +31,16 @@ export function LanguageToggle() {
|
|
|
30
31
|
</DropdownMenuTrigger>
|
|
31
32
|
</IconTooltip>
|
|
32
33
|
<DropdownMenuContent align="end" className="min-w-[140px]">
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
34
|
+
<DropdownMenuRadioGroup
|
|
35
|
+
value={t.id}
|
|
36
|
+
onValueChange={(value) => setLocale(value as LocaleId)}
|
|
37
|
+
>
|
|
38
|
+
{LOCALE_OPTIONS.map((option) => (
|
|
39
|
+
<DropdownMenuRadioItem key={option.id} value={option.id} closeOnClick>
|
|
40
|
+
{option.label}
|
|
41
|
+
</DropdownMenuRadioItem>
|
|
42
|
+
))}
|
|
43
|
+
</DropdownMenuRadioGroup>
|
|
42
44
|
</DropdownMenuContent>
|
|
43
45
|
</DropdownMenu>
|
|
44
46
|
);
|
|
@@ -112,7 +112,7 @@ export function OverviewGrid({
|
|
|
112
112
|
aria-modal="true"
|
|
113
113
|
aria-label={t.present.overviewDialogAria}
|
|
114
114
|
className={cn(
|
|
115
|
-
'absolute inset-0 z-50 flex flex-col backdrop-blur-
|
|
115
|
+
'absolute inset-0 z-50 flex flex-col backdrop-blur-2xl backdrop-saturate-150',
|
|
116
116
|
'motion-safe:animate-in motion-safe:fade-in-0 motion-safe:duration-150',
|
|
117
117
|
styles.surface,
|
|
118
118
|
)}
|
|
@@ -335,7 +335,7 @@ type OverviewStyles = {
|
|
|
335
335
|
};
|
|
336
336
|
|
|
337
337
|
const presentStyles = {
|
|
338
|
-
surface: 'bg-black/
|
|
338
|
+
surface: 'bg-black/80',
|
|
339
339
|
eyebrow: 'text-white/55',
|
|
340
340
|
thumbFocused: 'bg-white/10',
|
|
341
341
|
thumbHover: 'hover:bg-white/5',
|
|
@@ -349,7 +349,7 @@ const presentStyles = {
|
|
|
349
349
|
} as const;
|
|
350
350
|
|
|
351
351
|
const editorStyles = {
|
|
352
|
-
surface: 'bg-background/
|
|
352
|
+
surface: 'bg-background/80',
|
|
353
353
|
eyebrow: 'text-muted-foreground',
|
|
354
354
|
thumbFocused: 'bg-muted',
|
|
355
355
|
thumbHover: 'hover:bg-muted/60',
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { type ReactNode, useState } from 'react';
|
|
1
|
+
import { type CSSProperties, type ReactNode, useEffect, useState } from 'react';
|
|
2
2
|
import { AGENT_DOCK_W } from '@/components/agent/agent-dock';
|
|
3
3
|
import { InspectorPanel } from '@/components/inspector/inspector-panel';
|
|
4
4
|
import { useInspector } from '@/components/inspector/inspector-provider';
|
|
5
|
+
import type { PageInfo } from '@/components/inspector/page-panel';
|
|
5
6
|
import { useDesignPanelState } from '@/components/style-panel/design-provider';
|
|
6
7
|
import { DesignPanel } from '@/components/style-panel/style-panel';
|
|
7
8
|
import { useLocale } from '@/lib/use-locale';
|
|
9
|
+
import { cn } from '@/lib/utils';
|
|
8
10
|
import { PANEL_TRANSITION_MS, PANEL_W, usePanelMount } from './panel-shell';
|
|
9
11
|
import { ResizeHandle, useStoredWidth } from './resize-handle';
|
|
10
12
|
|
|
@@ -22,11 +24,13 @@ export function EditorSidebar({
|
|
|
22
24
|
onCloseDesign,
|
|
23
25
|
agentOpen = false,
|
|
24
26
|
agent,
|
|
27
|
+
page,
|
|
25
28
|
}: {
|
|
26
29
|
designOpen: boolean;
|
|
27
30
|
onCloseDesign: () => void;
|
|
28
31
|
agentOpen?: boolean;
|
|
29
32
|
agent?: ReactNode;
|
|
33
|
+
page?: PageInfo;
|
|
30
34
|
}) {
|
|
31
35
|
const t = useLocale();
|
|
32
36
|
const { active, panelOpen } = useInspector();
|
|
@@ -64,7 +68,9 @@ export function EditorSidebar({
|
|
|
64
68
|
const [agentMounted, setAgentMounted] = useState(false);
|
|
65
69
|
if (isAgent && !agentMounted) setAgentMounted(true);
|
|
66
70
|
const open = mode !== null;
|
|
67
|
-
const { mounted, animVisible } = usePanelMount(open);
|
|
71
|
+
const { mounted, animVisible } = usePanelMount(open, { animateInitial: false });
|
|
72
|
+
const [firstRender, setFirstRender] = useState(true);
|
|
73
|
+
useEffect(() => setFirstRender(false), []);
|
|
68
74
|
|
|
69
75
|
if (!mounted) return null;
|
|
70
76
|
|
|
@@ -97,23 +103,52 @@ export function EditorSidebar({
|
|
|
97
103
|
/>
|
|
98
104
|
)}
|
|
99
105
|
{agentMounted && (
|
|
100
|
-
<
|
|
101
|
-
|
|
106
|
+
<SwapPane
|
|
107
|
+
animate={!firstRender}
|
|
108
|
+
className="h-full shrink-0"
|
|
102
109
|
style={{ width: agentWidth }}
|
|
103
110
|
hidden={!isAgent}
|
|
104
111
|
>
|
|
105
112
|
{agent}
|
|
106
|
-
</
|
|
113
|
+
</SwapPane>
|
|
107
114
|
)}
|
|
108
115
|
{!isAgent && (
|
|
109
|
-
<
|
|
116
|
+
<SwapPane
|
|
117
|
+
animate={!firstRender}
|
|
118
|
+
className="flex h-full shrink-0"
|
|
119
|
+
style={{ width: editorWidth }}
|
|
120
|
+
>
|
|
110
121
|
{lastEditor === 'design' ? (
|
|
111
122
|
<DesignPanel onClose={onCloseDesign} />
|
|
112
123
|
) : (
|
|
113
|
-
<InspectorPanel preferredTab={preferredTab} onTabChange={setPreferredTab} />
|
|
124
|
+
<InspectorPanel preferredTab={preferredTab} onTabChange={setPreferredTab} page={page} />
|
|
114
125
|
)}
|
|
115
|
-
</
|
|
126
|
+
</SwapPane>
|
|
116
127
|
)}
|
|
117
128
|
</div>
|
|
118
129
|
);
|
|
119
130
|
}
|
|
131
|
+
|
|
132
|
+
// Fixed at mount, since toggling the fade on a showing pane would replay it; a
|
|
133
|
+
// hidden pane can pick it up, as it only plays once shown again.
|
|
134
|
+
function SwapPane({
|
|
135
|
+
animate,
|
|
136
|
+
hidden = false,
|
|
137
|
+
className,
|
|
138
|
+
style,
|
|
139
|
+
children,
|
|
140
|
+
}: {
|
|
141
|
+
animate: boolean;
|
|
142
|
+
hidden?: boolean;
|
|
143
|
+
className?: string;
|
|
144
|
+
style?: CSSProperties;
|
|
145
|
+
children: ReactNode;
|
|
146
|
+
}) {
|
|
147
|
+
const [fade, setFade] = useState(animate);
|
|
148
|
+
if (hidden && !fade) setFade(true);
|
|
149
|
+
return (
|
|
150
|
+
<div className={cn(fade && 'sidebar-swap', className)} style={style} hidden={hidden}>
|
|
151
|
+
{children}
|
|
152
|
+
</div>
|
|
153
|
+
);
|
|
154
|
+
}
|
|
@@ -6,8 +6,8 @@ export const PANEL_TRANSITION_MS = 240;
|
|
|
6
6
|
|
|
7
7
|
// Defer the width expansion to the next frame so the browser paints once
|
|
8
8
|
// at width=0 first; otherwise the transition has no starting frame.
|
|
9
|
-
export function useAnimatedOpen(open: boolean): boolean {
|
|
10
|
-
const [animVisible, setAnimVisible] = useState(
|
|
9
|
+
export function useAnimatedOpen(open: boolean, initial = false): boolean {
|
|
10
|
+
const [animVisible, setAnimVisible] = useState(initial);
|
|
11
11
|
useEffect(() => {
|
|
12
12
|
if (open) {
|
|
13
13
|
const id = requestAnimationFrame(() => setAnimVisible(true));
|
|
@@ -20,8 +20,12 @@ export function useAnimatedOpen(open: boolean): boolean {
|
|
|
20
20
|
|
|
21
21
|
// Stay mounted through the close-out width transition so the panel
|
|
22
22
|
// visibly collapses instead of vanishing.
|
|
23
|
-
export function usePanelMount(
|
|
24
|
-
|
|
23
|
+
export function usePanelMount(
|
|
24
|
+
open: boolean,
|
|
25
|
+
{ animateInitial = true }: { animateInitial?: boolean } = {},
|
|
26
|
+
): { mounted: boolean; animVisible: boolean } {
|
|
27
|
+
const [startOpen] = useState(() => open && !animateInitial);
|
|
28
|
+
const [mounted, setMounted] = useState(startOpen);
|
|
25
29
|
useEffect(() => {
|
|
26
30
|
if (open) {
|
|
27
31
|
setMounted(true);
|
|
@@ -30,7 +34,7 @@ export function usePanelMount(open: boolean): { mounted: boolean; animVisible: b
|
|
|
30
34
|
const t = setTimeout(() => setMounted(false), PANEL_TRANSITION_MS);
|
|
31
35
|
return () => clearTimeout(t);
|
|
32
36
|
}, [open]);
|
|
33
|
-
const animVisible = useAnimatedOpen(open && mounted);
|
|
37
|
+
const animVisible = useAnimatedOpen(open && mounted, startOpen);
|
|
34
38
|
return { mounted, animVisible };
|
|
35
39
|
}
|
|
36
40
|
|
|
@@ -73,7 +73,7 @@ export function SaveCard({
|
|
|
73
73
|
: 'translate-y-2 scale-[0.98] opacity-0',
|
|
74
74
|
)}
|
|
75
75
|
>
|
|
76
|
-
<div className="pointer-events-auto flex h-9 items-center gap-1 rounded-[8px] border border-border bg-
|
|
76
|
+
<div className="pointer-events-auto flex h-9 items-center gap-1 rounded-[8px] border border-border bg-material py-0.5 pr-0.5 pl-1 shadow-overlay backdrop-blur-xl backdrop-saturate-150">
|
|
77
77
|
{showHistory && (
|
|
78
78
|
<div className="flex items-center">
|
|
79
79
|
<Button
|
|
@@ -3,6 +3,9 @@ import { hasModifier, isBackwardKey, isForwardKey, isTypingTarget } from '@/lib/
|
|
|
3
3
|
import { useClickPageNavigation } from '@/lib/use-click-page-navigation';
|
|
4
4
|
import { useWheelPageNavigation } from '@/lib/use-wheel-page-navigation';
|
|
5
5
|
import { cn } from '@/lib/utils';
|
|
6
|
+
import { requestPresentFullscreen } from '../lemonriver/present/dual-screen';
|
|
7
|
+
import { PresenterBlockedHint } from '../lemonriver/present/presenter-blocked-hint';
|
|
8
|
+
import { useScreenWakeLock } from '../lemonriver/present/wake-lock';
|
|
6
9
|
import type { DesignSystem } from '../lib/design';
|
|
7
10
|
import type { Page } from '../lib/sdk';
|
|
8
11
|
import type { EntryDirection, StepAggregate, StepController } from '../lib/step-context';
|
|
@@ -75,6 +78,7 @@ export function Player({
|
|
|
75
78
|
}: Props) {
|
|
76
79
|
const isMobile = useIsMobile();
|
|
77
80
|
const prefersReducedMotion = usePrefersReducedMotion();
|
|
81
|
+
useScreenWakeLock(controls);
|
|
78
82
|
const fade = curtain && !prefersReducedMotion;
|
|
79
83
|
const [curtainOpaque, setCurtainOpaque] = useState(fade);
|
|
80
84
|
const exitingRef = useRef(false);
|
|
@@ -261,7 +265,7 @@ export function Player({
|
|
|
261
265
|
const el = rootRef.current;
|
|
262
266
|
if (!el) return;
|
|
263
267
|
if (document.fullscreenElement !== el) {
|
|
264
|
-
el
|
|
268
|
+
requestPresentFullscreen(el);
|
|
265
269
|
}
|
|
266
270
|
return () => {
|
|
267
271
|
if (document.fullscreenElement) document.exitFullscreen?.().catch(() => {});
|
|
@@ -538,6 +542,7 @@ export function Player({
|
|
|
538
542
|
tooltipContainer={rootEl}
|
|
539
543
|
/>
|
|
540
544
|
<PresentHelpOverlay open={helpOpen} onOpenChange={setHelpOpen} container={rootEl} />
|
|
545
|
+
{slideId && <PresenterBlockedHint slideId={slideId} />}
|
|
541
546
|
</div>
|
|
542
547
|
)}
|
|
543
548
|
|
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
DropdownMenuTrigger,
|
|
17
17
|
} from '@/components/ui/dropdown-menu';
|
|
18
18
|
import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';
|
|
19
|
+
import { haptic } from '@/lib/desktop';
|
|
19
20
|
import type { Folder, FolderIcon } from '@/lib/sdk';
|
|
20
21
|
import { useLocale } from '@/lib/use-locale';
|
|
21
22
|
import { cn, pad2 } from '@/lib/utils';
|
|
@@ -131,7 +132,9 @@ export function FolderItem({
|
|
|
131
132
|
const handleDragEnter = (e: React.DragEvent) => {
|
|
132
133
|
if (!isSlideDrag(e)) return;
|
|
133
134
|
dragDepth.current += 1;
|
|
134
|
-
if (dragDepth.current
|
|
135
|
+
if (dragDepth.current !== 1) return;
|
|
136
|
+
setDragOver(true);
|
|
137
|
+
haptic('generic');
|
|
135
138
|
};
|
|
136
139
|
const handleDragOver = (e: React.DragEvent) => {
|
|
137
140
|
if (!isSlideDrag(e)) return;
|
|
@@ -2,6 +2,7 @@ import { Plus, Search } from 'lucide-react';
|
|
|
2
2
|
import { useEffect, useRef, useState } from 'react';
|
|
3
3
|
import { toast } from 'sonner';
|
|
4
4
|
import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';
|
|
5
|
+
import { haptic } from '@/lib/desktop';
|
|
5
6
|
import type { Folder, FolderIcon } from '@/lib/sdk';
|
|
6
7
|
import { format, useLocale } from '@/lib/use-locale';
|
|
7
8
|
import { cn } from '@/lib/utils';
|
|
@@ -53,6 +54,8 @@ export function Sidebar({
|
|
|
53
54
|
}) {
|
|
54
55
|
const [dragId, setDragId] = useState<string | null>(null);
|
|
55
56
|
const [dropTarget, setDropTarget] = useState<{ id: string; before: boolean } | null>(null);
|
|
57
|
+
// Survives the dragleave that clears dropTarget between rows, so each new slot ticks once.
|
|
58
|
+
const lastDropSlot = useRef<string | null>(null);
|
|
56
59
|
|
|
57
60
|
const finishReorder = (toId: string, before: boolean) => {
|
|
58
61
|
const fromId = dragId;
|
|
@@ -129,14 +132,8 @@ export function Sidebar({
|
|
|
129
132
|
|
|
130
133
|
return (
|
|
131
134
|
<aside className="group/side relative flex h-full w-[16.5rem] shrink-0 flex-col bg-sidebar text-sidebar-foreground">
|
|
132
|
-
<div className="flex items-center gap-2.5 px-4 pt-4 pb-3">
|
|
133
|
-
<img
|
|
134
|
-
src={logo}
|
|
135
|
-
alt=""
|
|
136
|
-
aria-hidden
|
|
137
|
-
draggable={false}
|
|
138
|
-
className="size-6 shrink-0 select-none"
|
|
139
|
-
/>
|
|
135
|
+
<div className="flex select-none items-center gap-2.5 px-4 pt-4 pb-3">
|
|
136
|
+
<img src={logo} alt="" aria-hidden draggable={false} className="size-6 shrink-0" />
|
|
140
137
|
<h1 className="font-heading text-[13.5px] font-semibold tracking-tight">
|
|
141
138
|
{t.home.appTitle}
|
|
142
139
|
</h1>
|
|
@@ -240,6 +237,7 @@ export function Sidebar({
|
|
|
240
237
|
e.dataTransfer.setData(FOLDER_DND_MIME, folder.id);
|
|
241
238
|
e.dataTransfer.effectAllowed = 'move';
|
|
242
239
|
setDragId(folder.id);
|
|
240
|
+
lastDropSlot.current = null;
|
|
243
241
|
}}
|
|
244
242
|
onDragEnd={() => {
|
|
245
243
|
setDragId(null);
|
|
@@ -251,6 +249,11 @@ export function Sidebar({
|
|
|
251
249
|
e.dataTransfer.dropEffect = 'move';
|
|
252
250
|
const rect = e.currentTarget.getBoundingClientRect();
|
|
253
251
|
const isBefore = e.clientY < rect.top + rect.height / 2;
|
|
252
|
+
const slot = `${folder.id}:${isBefore}`;
|
|
253
|
+
if (lastDropSlot.current !== null && lastDropSlot.current !== slot) {
|
|
254
|
+
haptic('levelChange');
|
|
255
|
+
}
|
|
256
|
+
lastDropSlot.current = slot;
|
|
254
257
|
if (!dropTarget || dropTarget.id !== folder.id || dropTarget.before !== isBefore) {
|
|
255
258
|
setDropTarget({ id: folder.id, before: isBefore });
|
|
256
259
|
}
|
|
@@ -51,7 +51,7 @@ export function SlideCanvas({
|
|
|
51
51
|
<div ref={containerRef} className={cn('relative h-full w-full', flat && 'overflow-hidden')}>
|
|
52
52
|
<div
|
|
53
53
|
className={cn(
|
|
54
|
-
'overflow-hidden bg-white text-black',
|
|
54
|
+
'overflow-hidden bg-white text-start text-black',
|
|
55
55
|
!flat && 'rounded-[6px] shadow-floating',
|
|
56
56
|
)}
|
|
57
57
|
style={
|
|
@@ -12,6 +12,7 @@ import { toast } from 'sonner';
|
|
|
12
12
|
import { useHistory } from '@/components/history-provider';
|
|
13
13
|
import { type DesignSystem, designToCssVars } from '../../lib/design';
|
|
14
14
|
import { shuffleDesign } from '../../lib/design-presets';
|
|
15
|
+
import { createSaveQueue, useUnsavedSource } from '../../lib/unsaved';
|
|
15
16
|
import { useDesign as useDesignFetch } from './use-design';
|
|
16
17
|
|
|
17
18
|
type DesignCtx = {
|
|
@@ -42,16 +43,20 @@ function clone<T>(d: T): T {
|
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
export function DesignProvider({ slideId, children }: { slideId: string; children: ReactNode }) {
|
|
45
|
-
const { design, exists, warning, loaded, save } = useDesignFetch(slideId);
|
|
46
|
+
const { design, savedFrom, exists, warning, loaded, save } = useDesignFetch(slideId);
|
|
46
47
|
const [draft, setDraft] = useState<DesignSystem | null>(null);
|
|
47
48
|
const [committing, setCommitting] = useState(false);
|
|
48
49
|
const history = useHistory();
|
|
49
50
|
const draftRef = useRef<DesignSystem | null>(null);
|
|
50
51
|
draftRef.current = draft;
|
|
51
|
-
|
|
52
|
+
// A save or discard only reaches `dirty` on the next render; this answers in between.
|
|
53
|
+
const settledDraftRef = useRef<DesignSystem | null>(null);
|
|
54
|
+
const [saveQueue] = useState(createSaveQueue);
|
|
55
|
+
// When a save's response arrives as the new design, edits made since it was sent stay.
|
|
52
56
|
useEffect(() => {
|
|
53
|
-
if (design
|
|
54
|
-
|
|
57
|
+
if (!design || (savedFrom && draftRef.current !== savedFrom)) return;
|
|
58
|
+
setDraft(clone(design));
|
|
59
|
+
}, [design, savedFrom]);
|
|
55
60
|
|
|
56
61
|
const dirty = useMemo(() => {
|
|
57
62
|
if (!draft || !design) return false;
|
|
@@ -74,20 +79,52 @@ export function DesignProvider({ slideId, children }: { slideId: string; childre
|
|
|
74
79
|
[history],
|
|
75
80
|
);
|
|
76
81
|
|
|
77
|
-
|
|
78
|
-
|
|
82
|
+
// Each save sends the draft as it stands when its turn comes: two in flight
|
|
83
|
+
// could answer out of order and put an older design back over the draft.
|
|
84
|
+
const write = useCallback((): Promise<string | null> => {
|
|
85
|
+
if (!draftRef.current) return Promise.resolve(null);
|
|
79
86
|
setCommitting(true);
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
87
|
+
return saveQueue.run(
|
|
88
|
+
async () => {
|
|
89
|
+
const saving = draftRef.current;
|
|
90
|
+
if (!saving || saving === settledDraftRef.current) return null;
|
|
91
|
+
const r = await save(saving);
|
|
92
|
+
if (r.ok) {
|
|
93
|
+
if (draftRef.current === saving) history.clear();
|
|
94
|
+
settledDraftRef.current = saving;
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
const error = r.error ?? 'Failed to save';
|
|
98
|
+
toast.error(error);
|
|
99
|
+
return error;
|
|
100
|
+
},
|
|
101
|
+
() => setCommitting(false),
|
|
102
|
+
);
|
|
103
|
+
}, [saveQueue, save, history]);
|
|
104
|
+
|
|
105
|
+
const commit = useCallback(async () => {
|
|
106
|
+
await write();
|
|
107
|
+
}, [write]);
|
|
85
108
|
|
|
86
109
|
const discard = useCallback(() => {
|
|
110
|
+
settledDraftRef.current = draftRef.current;
|
|
87
111
|
if (design) setDraft(clone(design));
|
|
88
112
|
history.clear();
|
|
89
113
|
}, [design, history]);
|
|
90
114
|
|
|
115
|
+
const dirtyRef = useRef(dirty);
|
|
116
|
+
dirtyRef.current = dirty;
|
|
117
|
+
useUnsavedSource({
|
|
118
|
+
kind: 'draft',
|
|
119
|
+
dirty: () =>
|
|
120
|
+
saveQueue.busy() || (dirtyRef.current && draftRef.current !== settledDraftRef.current),
|
|
121
|
+
save: async () => {
|
|
122
|
+
const error = await write();
|
|
123
|
+
if (error) throw new Error(error);
|
|
124
|
+
},
|
|
125
|
+
discard,
|
|
126
|
+
});
|
|
127
|
+
|
|
91
128
|
const shuffle = useCallback(() => {
|
|
92
129
|
const prev = draftRef.current;
|
|
93
130
|
const next = clone(shuffleDesign(prev));
|
|
@@ -3,6 +3,8 @@ import type { DesignSystem } from '../../lib/design';
|
|
|
3
3
|
|
|
4
4
|
type FetchedState = {
|
|
5
5
|
design: DesignSystem | null;
|
|
6
|
+
// The draft whose save returned `design`, or null when it was fetched.
|
|
7
|
+
savedFrom: Partial<DesignSystem> | null;
|
|
6
8
|
exists: boolean;
|
|
7
9
|
warning: string | null;
|
|
8
10
|
loaded: boolean;
|
|
@@ -15,6 +17,7 @@ export type UseDesignReturn = FetchedState & {
|
|
|
15
17
|
export function useDesign(slideId: string): UseDesignReturn {
|
|
16
18
|
const [state, setState] = useState<FetchedState>({
|
|
17
19
|
design: null,
|
|
20
|
+
savedFrom: null,
|
|
18
21
|
exists: false,
|
|
19
22
|
warning: null,
|
|
20
23
|
loaded: false,
|
|
@@ -35,6 +38,7 @@ export function useDesign(slideId: string): UseDesignReturn {
|
|
|
35
38
|
};
|
|
36
39
|
setState({
|
|
37
40
|
design: body.design,
|
|
41
|
+
savedFrom: null,
|
|
38
42
|
exists: body.exists,
|
|
39
43
|
warning: body.warning,
|
|
40
44
|
loaded: true,
|
|
@@ -45,7 +49,7 @@ export function useDesign(slideId: string): UseDesignReturn {
|
|
|
45
49
|
}, []);
|
|
46
50
|
|
|
47
51
|
useEffect(() => {
|
|
48
|
-
setState({ design: null, exists: false, warning: null, loaded: false });
|
|
52
|
+
setState({ design: null, savedFrom: null, exists: false, warning: null, loaded: false });
|
|
49
53
|
void refresh();
|
|
50
54
|
}, [refresh]);
|
|
51
55
|
|
|
@@ -71,6 +75,7 @@ export function useDesign(slideId: string): UseDesignReturn {
|
|
|
71
75
|
setState((s) => ({
|
|
72
76
|
...s,
|
|
73
77
|
design: body.design ?? s.design,
|
|
78
|
+
savedFrom: patch,
|
|
74
79
|
exists: true,
|
|
75
80
|
warning: null,
|
|
76
81
|
}));
|
|
@@ -6,7 +6,8 @@ import { buttonVariants } from '@/components/ui/button';
|
|
|
6
6
|
import {
|
|
7
7
|
DropdownMenu,
|
|
8
8
|
DropdownMenuContent,
|
|
9
|
-
|
|
9
|
+
DropdownMenuRadioGroup,
|
|
10
|
+
DropdownMenuRadioItem,
|
|
10
11
|
DropdownMenuTrigger,
|
|
11
12
|
} from '@/components/ui/dropdown-menu';
|
|
12
13
|
import { useLocale } from '@/lib/use-locale';
|
|
@@ -38,27 +39,20 @@ export function ThemeToggle() {
|
|
|
38
39
|
</DropdownMenuTrigger>
|
|
39
40
|
</IconTooltip>
|
|
40
41
|
<DropdownMenuContent align="end" className="min-w-[140px]">
|
|
41
|
-
<
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
</
|
|
55
|
-
<DropdownMenuItem
|
|
56
|
-
onClick={() => setTheme('system')}
|
|
57
|
-
data-active={mounted && theme === 'system'}
|
|
58
|
-
>
|
|
59
|
-
<Monitor />
|
|
60
|
-
{t.themeToggle.system}
|
|
61
|
-
</DropdownMenuItem>
|
|
42
|
+
<DropdownMenuRadioGroup value={mounted ? theme : undefined} onValueChange={setTheme}>
|
|
43
|
+
<DropdownMenuRadioItem value="light" closeOnClick>
|
|
44
|
+
<Sun />
|
|
45
|
+
{t.themeToggle.light}
|
|
46
|
+
</DropdownMenuRadioItem>
|
|
47
|
+
<DropdownMenuRadioItem value="dark" closeOnClick>
|
|
48
|
+
<Moon />
|
|
49
|
+
{t.themeToggle.dark}
|
|
50
|
+
</DropdownMenuRadioItem>
|
|
51
|
+
<DropdownMenuRadioItem value="system" closeOnClick>
|
|
52
|
+
<Monitor />
|
|
53
|
+
{t.themeToggle.system}
|
|
54
|
+
</DropdownMenuRadioItem>
|
|
55
|
+
</DropdownMenuRadioGroup>
|
|
62
56
|
</DropdownMenuContent>
|
|
63
57
|
</DropdownMenu>
|
|
64
58
|
);
|