@open-slide/core 1.19.1 → 2.0.0-beta.1
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-Bzy-qlGc.js +19 -0
- package/dist/cli/bin.d.ts +1 -1
- package/dist/cli/bin.js +331 -25
- package/dist/{config-CDHB8Oow.d.ts → config-AtA2Bqtn.d.ts} +4 -4
- package/dist/{config-GA6NMgs_.js → config-nbSvY7z_.js} +547 -778
- package/dist/{design-cpzS8aud.js → design-Cpqx7SJs.js} +1 -2
- package/dist/{dev-D57ui2yV.js → dev-MXa5Tod4.js} +39 -16
- package/dist/index.d.ts +7 -37
- package/dist/index.js +51 -54
- package/dist/locale/index.d.ts +2 -8
- package/dist/locale/index.js +13 -3
- package/dist/preview-DEpQcKz3.js +24 -0
- package/dist/{types-8HghULIe.d.ts → types-BzPSOxe-.d.ts} +5 -9
- package/dist/vite/index.d.ts +1 -4
- package/dist/vite/index.js +2 -4
- package/dist/{format-74A3B6zu.js → zh-tw-BxZ_pYqe.js} +13 -49
- package/package.json +12 -12
- package/skills/create-slide/SKILL.md +4 -1
- package/skills/slide-authoring/SKILL.md +25 -2
- package/src/app/app.tsx +1 -3
- package/src/app/assets/open-slide.png +0 -0
- package/src/app/components/asset-view.tsx +8 -16
- package/src/app/components/command/home-command-menu.tsx +6 -6
- package/src/app/components/export-progress-toast.tsx +80 -0
- package/src/app/components/history-provider.tsx +1 -5
- package/src/app/components/image-placeholder.tsx +4 -12
- package/src/app/components/inspector/asset-picker-dialog.tsx +6 -16
- package/src/app/components/inspector/image-crop-dialog.tsx +1 -4
- package/src/app/components/inspector/inline-text-editor.tsx +798 -0
- package/src/app/components/inspector/inspect-overlay.tsx +30 -72
- package/src/app/components/inspector/inspector-panel.tsx +17 -49
- package/src/app/components/inspector/inspector-provider.tsx +53 -36
- package/src/app/components/notes-drawer.tsx +2 -5
- package/src/app/components/overview-grid.tsx +5 -4
- package/src/app/components/panel/panel-shell.tsx +1 -3
- package/src/app/components/player.tsx +5 -6
- package/src/app/components/present/control-bar.tsx +4 -4
- package/src/app/components/present/jump-input.tsx +3 -2
- package/src/app/components/present/use-presenter-channel.ts +0 -1
- package/src/app/components/sidebar/folder-item.tsx +39 -16
- package/src/app/components/sidebar/sidebar-footer.tsx +7 -1
- package/src/app/components/sidebar/sidebar.tsx +91 -64
- package/src/app/components/slide-canvas.tsx +2 -6
- package/src/app/components/slide-transition-layer.tsx +48 -76
- package/src/app/components/style-panel/design-provider.tsx +1 -14
- package/src/app/components/style-panel/use-design.ts +1 -28
- package/src/app/components/themes/theme-detail.tsx +4 -4
- package/src/app/components/themes/themes-gallery.tsx +11 -6
- package/src/app/components/thumbnail-rail.tsx +7 -12
- package/src/app/lib/assets.ts +6 -7
- package/src/app/lib/dom.ts +42 -0
- package/src/app/lib/export-html.ts +10 -25
- package/src/app/lib/export-pdf.ts +11 -28
- package/src/app/lib/export-pptx.ts +6 -36
- package/src/app/lib/folders.ts +51 -46
- package/src/app/lib/inspector/inline-text.ts +31 -0
- package/src/app/lib/inspector/pick-target.ts +38 -0
- package/src/app/lib/inspector/use-comments.ts +1 -1
- package/src/app/lib/keys.ts +18 -0
- package/src/app/lib/last-home-location.ts +18 -0
- package/src/app/lib/print-ready.ts +2 -4
- package/src/app/lib/slides.ts +7 -4
- package/src/app/lib/text-diff.ts +19 -0
- package/src/app/lib/use-click-page-navigation.ts +2 -6
- package/src/app/lib/use-is-mobile.ts +2 -14
- package/src/app/lib/use-media-query.ts +20 -0
- package/src/app/lib/use-prefers-reduced-motion.ts +5 -13
- package/src/app/lib/use-slide-module.ts +1 -1
- package/src/app/lib/use-wheel-page-navigation.ts +1 -1
- package/src/app/lib/utils.test.ts +25 -1
- package/src/app/lib/utils.ts +8 -0
- package/src/app/routes/home-shell.tsx +71 -64
- package/src/app/routes/home.tsx +41 -52
- package/src/app/routes/presenter.tsx +10 -20
- package/src/app/routes/slide.tsx +84 -71
- package/src/app/routes/themes.tsx +7 -8
- package/src/app/styles.css +33 -44
- package/src/locale/en.ts +2 -7
- package/src/locale/ja.ts +2 -7
- package/src/locale/types.ts +2 -7
- package/src/locale/zh-cn.ts +2 -7
- package/src/locale/zh-tw.ts +2 -7
- package/dist/build-CaV_vhIw.js +0 -17
- package/dist/preview-D40Zw_o0.js +0 -18
- package/dist/sync-BCJDRIqo.js +0 -139
- package/dist/sync-j9_QPovT.js +0 -3
- package/src/app/components/pdf-progress-toast.tsx +0 -36
- package/src/app/components/pptx-progress-toast.tsx +0 -36
|
@@ -1,4 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
FolderOpen,
|
|
3
|
+
LayoutGrid,
|
|
4
|
+
type LucideIcon,
|
|
5
|
+
MoreHorizontal,
|
|
6
|
+
Palette,
|
|
7
|
+
Pencil,
|
|
8
|
+
PenLine,
|
|
9
|
+
Trash2,
|
|
10
|
+
} from 'lucide-react';
|
|
2
11
|
import { useEffect, useRef, useState } from 'react';
|
|
3
12
|
import {
|
|
4
13
|
DropdownMenu,
|
|
@@ -9,7 +18,7 @@ import {
|
|
|
9
18
|
import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';
|
|
10
19
|
import type { Folder, FolderIcon } from '@/lib/sdk';
|
|
11
20
|
import { useLocale } from '@/lib/use-locale';
|
|
12
|
-
import { cn } from '@/lib/utils';
|
|
21
|
+
import { cn, pad2 } from '@/lib/utils';
|
|
13
22
|
import { IconPicker } from './icon-picker';
|
|
14
23
|
|
|
15
24
|
export const SLIDE_DND_MIME = 'application/x-slide-id';
|
|
@@ -33,6 +42,24 @@ function useSlideDragActive() {
|
|
|
33
42
|
return active;
|
|
34
43
|
}
|
|
35
44
|
|
|
45
|
+
export type SystemViewKind = 'all' | 'draft' | 'themes' | 'assets';
|
|
46
|
+
|
|
47
|
+
const SYSTEM_VIEW_ICONS: Record<SystemViewKind, LucideIcon> = {
|
|
48
|
+
all: LayoutGrid,
|
|
49
|
+
draft: PenLine,
|
|
50
|
+
themes: Palette,
|
|
51
|
+
assets: FolderOpen,
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export function SystemViewIcon({ kind, className }: { kind: SystemViewKind; className?: string }) {
|
|
55
|
+
const Icon = SYSTEM_VIEW_ICONS[kind];
|
|
56
|
+
return (
|
|
57
|
+
<span aria-hidden className={cn('flex size-5 shrink-0 items-center justify-center', className)}>
|
|
58
|
+
<Icon className="size-4" strokeWidth={1.75} />
|
|
59
|
+
</span>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
36
63
|
export function FolderIconChip({ icon, className }: { icon: FolderIcon; className?: string }) {
|
|
37
64
|
if (icon.type === 'emoji') {
|
|
38
65
|
return (
|
|
@@ -126,16 +153,12 @@ export function FolderItem({
|
|
|
126
153
|
onDropSlide(slideId);
|
|
127
154
|
};
|
|
128
155
|
|
|
129
|
-
const
|
|
130
|
-
row.kind === '
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
? { type: 'emoji', value: '🎨' }
|
|
136
|
-
: row.kind === 'assets'
|
|
137
|
-
? { type: 'emoji', value: '🗂️' }
|
|
138
|
-
: row.folder.icon;
|
|
156
|
+
const chip =
|
|
157
|
+
row.kind === 'folder' ? (
|
|
158
|
+
<FolderIconChip icon={row.folder.icon} />
|
|
159
|
+
) : (
|
|
160
|
+
<SystemViewIcon kind={row.kind} className={cn(!selected && 'text-muted-foreground')} />
|
|
161
|
+
);
|
|
139
162
|
const label =
|
|
140
163
|
row.kind === 'all'
|
|
141
164
|
? t.home.slides
|
|
@@ -160,7 +183,7 @@ export function FolderItem({
|
|
|
160
183
|
className={cn(
|
|
161
184
|
'group relative flex items-center gap-2.5 rounded-[5px] px-2 py-[5px] text-[12.5px] transition-[background-color,color,scale] duration-150',
|
|
162
185
|
selected
|
|
163
|
-
? 'bg-
|
|
186
|
+
? 'bg-background font-medium text-foreground shadow-edge ring-1 ring-foreground/[0.06]'
|
|
164
187
|
: 'text-foreground/70 hover:bg-muted/60 hover:text-foreground',
|
|
165
188
|
slideDragActive && acceptsSlideDrop && !dragOver && 'ring-1 ring-foreground/10',
|
|
166
189
|
dragOver &&
|
|
@@ -181,7 +204,7 @@ export function FolderItem({
|
|
|
181
204
|
aria-label={t.home.changeIcon}
|
|
182
205
|
onClick={(e) => e.stopPropagation()}
|
|
183
206
|
>
|
|
184
|
-
|
|
207
|
+
{chip}
|
|
185
208
|
</button>
|
|
186
209
|
}
|
|
187
210
|
/>
|
|
@@ -196,7 +219,7 @@ export function FolderItem({
|
|
|
196
219
|
aria-label={label}
|
|
197
220
|
className="flex size-5 shrink-0 items-center justify-center"
|
|
198
221
|
>
|
|
199
|
-
|
|
222
|
+
{chip}
|
|
200
223
|
</button>
|
|
201
224
|
)}
|
|
202
225
|
|
|
@@ -234,7 +257,7 @@ export function FolderItem({
|
|
|
234
257
|
'group-hover:opacity-0 group-has-[[aria-expanded=true]]:opacity-0',
|
|
235
258
|
)}
|
|
236
259
|
>
|
|
237
|
-
{count
|
|
260
|
+
{pad2(count)}
|
|
238
261
|
</span>
|
|
239
262
|
|
|
240
263
|
{row.kind === 'folder' && import.meta.env.DEV && (
|
|
@@ -2,6 +2,8 @@ import config from 'virtual:open-slide/config';
|
|
|
2
2
|
import { Loader2, RefreshCw, RotateCw } from 'lucide-react';
|
|
3
3
|
import { useEffect, useState } from 'react';
|
|
4
4
|
import { toast } from 'sonner';
|
|
5
|
+
import { LanguageToggle } from '@/components/language-toggle';
|
|
6
|
+
import { ThemeToggle } from '@/components/theme-toggle';
|
|
5
7
|
import { Button } from '@/components/ui/button';
|
|
6
8
|
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip';
|
|
7
9
|
import { format, useLocale } from '@/lib/use-locale';
|
|
@@ -68,7 +70,7 @@ export function SidebarFooter() {
|
|
|
68
70
|
);
|
|
69
71
|
|
|
70
72
|
return (
|
|
71
|
-
<div className="
|
|
73
|
+
<div className="flex items-center justify-between gap-2 py-1.5 pr-2 pl-4 text-[11px] text-muted-foreground/70 tabular-nums">
|
|
72
74
|
{update?.latest ? (
|
|
73
75
|
<TooltipProvider delay={200}>
|
|
74
76
|
<Tooltip
|
|
@@ -141,6 +143,10 @@ export function SidebarFooter() {
|
|
|
141
143
|
) : (
|
|
142
144
|
versionRow
|
|
143
145
|
)}
|
|
146
|
+
<div className="flex shrink-0 items-center">
|
|
147
|
+
<LanguageToggle />
|
|
148
|
+
<ThemeToggle />
|
|
149
|
+
</div>
|
|
144
150
|
</div>
|
|
145
151
|
);
|
|
146
152
|
}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { Plus } from 'lucide-react';
|
|
1
|
+
import { Plus, Search } from 'lucide-react';
|
|
2
2
|
import { useEffect, useRef, useState } from 'react';
|
|
3
3
|
import { toast } from 'sonner';
|
|
4
|
-
import
|
|
5
|
-
import { ThemeToggle } from '@/components/theme-toggle';
|
|
4
|
+
import logo from '@/assets/open-slide.png';
|
|
6
5
|
import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';
|
|
7
6
|
import type { Folder, FolderIcon } from '@/lib/sdk';
|
|
8
7
|
import { format, useLocale } from '@/lib/use-locale';
|
|
9
8
|
import { cn } from '@/lib/utils';
|
|
10
|
-
import {
|
|
9
|
+
import { COMMAND_MENU_SHORTCUT } from '../command/command-menu';
|
|
11
10
|
import { FolderIconChip, FolderItem } from './folder-item';
|
|
12
11
|
import { IconPicker, PRESET_COLORS } from './icon-picker';
|
|
13
12
|
import { SidebarFooter } from './sidebar-footer';
|
|
@@ -129,17 +128,42 @@ export function Sidebar({
|
|
|
129
128
|
}, [creating]);
|
|
130
129
|
|
|
131
130
|
return (
|
|
132
|
-
<aside className="relative flex h-full w-[16.5rem] shrink-0 flex-col
|
|
133
|
-
<div className="flex items-center
|
|
134
|
-
<
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
131
|
+
<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 rounded-[6px] ring-1 ring-foreground/10"
|
|
139
|
+
/>
|
|
140
|
+
<h1 className="font-heading text-[13.5px] font-semibold tracking-tight">
|
|
141
|
+
{t.home.appTitle}
|
|
142
|
+
</h1>
|
|
143
|
+
</div>
|
|
144
|
+
|
|
145
|
+
<div className="px-2 pb-3">
|
|
146
|
+
<button
|
|
147
|
+
type="button"
|
|
148
|
+
onClick={onOpenCommandMenu}
|
|
149
|
+
aria-label={t.commandMenu.triggerAria}
|
|
150
|
+
aria-haspopup="dialog"
|
|
151
|
+
className={cn(
|
|
152
|
+
'flex h-8 w-full items-center gap-2 rounded-[6px] border border-border bg-card px-2.5 text-[12.5px] text-muted-foreground shadow-edge outline-none',
|
|
153
|
+
'transition-[border-color,color,background-color] duration-100',
|
|
154
|
+
'hover:border-foreground/20 hover:text-foreground',
|
|
155
|
+
'focus-visible:border-foreground/30 focus-visible:ring-2 focus-visible:ring-ring/30',
|
|
156
|
+
)}
|
|
157
|
+
>
|
|
158
|
+
<Search className="size-3.5 shrink-0" aria-hidden />
|
|
159
|
+
<span className="flex-1 truncate text-left">{t.commandMenu.triggerTooltip}</span>
|
|
160
|
+
<kbd className="rounded-[4px] border border-hairline bg-muted/60 px-1 py-px font-mono text-[9.5px] leading-none tracking-[0.04em] text-muted-foreground">
|
|
161
|
+
{COMMAND_MENU_SHORTCUT}
|
|
162
|
+
</kbd>
|
|
163
|
+
</button>
|
|
140
164
|
</div>
|
|
141
165
|
|
|
142
|
-
<div className="px-2">
|
|
166
|
+
<div className="space-y-0.5 px-2">
|
|
143
167
|
<FolderItem
|
|
144
168
|
row={{ kind: 'all' }}
|
|
145
169
|
count={allCount}
|
|
@@ -165,12 +189,27 @@ export function Sidebar({
|
|
|
165
189
|
)}
|
|
166
190
|
</div>
|
|
167
191
|
|
|
168
|
-
<div className="mt-5 flex items-center
|
|
192
|
+
<div className="mt-5 flex h-6 items-center justify-between pr-2.5 pl-4 pb-0.5">
|
|
169
193
|
<span className="eyebrow">{t.home.folders}</span>
|
|
170
|
-
|
|
194
|
+
{import.meta.env.DEV && (
|
|
195
|
+
<button
|
|
196
|
+
type="button"
|
|
197
|
+
onClick={startCreating}
|
|
198
|
+
aria-label={t.home.newFolder}
|
|
199
|
+
title={t.home.newFolder}
|
|
200
|
+
className={cn(
|
|
201
|
+
'flex size-5 items-center justify-center rounded-[4px] text-muted-foreground/70 opacity-0 outline-none',
|
|
202
|
+
'transition-[opacity,background-color,color,scale] duration-100',
|
|
203
|
+
'hover:bg-muted hover:text-foreground active:scale-90',
|
|
204
|
+
'group-hover/side:opacity-100 focus-visible:opacity-100 focus-visible:ring-1 focus-visible:ring-brand',
|
|
205
|
+
)}
|
|
206
|
+
>
|
|
207
|
+
<Plus className="size-3.5" />
|
|
208
|
+
</button>
|
|
209
|
+
)}
|
|
171
210
|
</div>
|
|
172
211
|
|
|
173
|
-
<div className="flex-1 overflow-y-auto px-2 pb-2">
|
|
212
|
+
<div className="flex-1 space-y-0.5 overflow-y-auto px-2 pb-2">
|
|
174
213
|
<FolderItem
|
|
175
214
|
row={{ kind: 'draft' }}
|
|
176
215
|
count={countFor(null)}
|
|
@@ -246,57 +285,45 @@ export function Sidebar({
|
|
|
246
285
|
);
|
|
247
286
|
})}
|
|
248
287
|
|
|
249
|
-
{import.meta.env.DEV &&
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
>
|
|
255
|
-
<
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
}
|
|
266
|
-
/>
|
|
267
|
-
<PopoverContent side="right" align="start" className="w-auto p-2">
|
|
268
|
-
<IconPicker value={newIcon} onChange={setNewIcon} />
|
|
269
|
-
</PopoverContent>
|
|
270
|
-
</Popover>
|
|
271
|
-
<input
|
|
272
|
-
ref={inputRef}
|
|
273
|
-
value={newName}
|
|
274
|
-
onChange={(e) => setNewName(e.target.value)}
|
|
275
|
-
onKeyDown={(e) => {
|
|
276
|
-
if (e.nativeEvent.isComposing) return;
|
|
277
|
-
if (e.key === 'Enter') commitCreate();
|
|
278
|
-
if (e.key === 'Escape') exitCreate();
|
|
279
|
-
}}
|
|
280
|
-
placeholder={t.home.folderName}
|
|
281
|
-
maxLength={40}
|
|
282
|
-
className="min-w-0 flex-1 bg-transparent text-[12.5px] outline-none placeholder:text-muted-foreground/60"
|
|
288
|
+
{import.meta.env.DEV && creating && (
|
|
289
|
+
<div
|
|
290
|
+
data-folder-create
|
|
291
|
+
className="mt-1 flex items-center gap-2.5 rounded-[5px] border border-dashed border-foreground/30 bg-card px-2 py-[5px]"
|
|
292
|
+
>
|
|
293
|
+
<Popover open={iconOpen} onOpenChange={setIconOpen}>
|
|
294
|
+
<PopoverTrigger
|
|
295
|
+
render={
|
|
296
|
+
<button
|
|
297
|
+
type="button"
|
|
298
|
+
className="flex size-5 shrink-0 items-center justify-center rounded outline-none motion-safe:transition-transform motion-safe:duration-150 hover:scale-110 active:scale-95 focus-visible:ring-1 focus-visible:ring-brand"
|
|
299
|
+
aria-label={t.home.pickIcon}
|
|
300
|
+
>
|
|
301
|
+
<FolderIconChip icon={newIcon} />
|
|
302
|
+
</button>
|
|
303
|
+
}
|
|
283
304
|
/>
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
305
|
+
<PopoverContent side="right" align="start" className="w-auto p-2">
|
|
306
|
+
<IconPicker value={newIcon} onChange={setNewIcon} />
|
|
307
|
+
</PopoverContent>
|
|
308
|
+
</Popover>
|
|
309
|
+
<input
|
|
310
|
+
ref={inputRef}
|
|
311
|
+
value={newName}
|
|
312
|
+
onChange={(e) => setNewName(e.target.value)}
|
|
313
|
+
onKeyDown={(e) => {
|
|
314
|
+
if (e.nativeEvent.isComposing) return;
|
|
315
|
+
if (e.key === 'Enter') commitCreate();
|
|
316
|
+
if (e.key === 'Escape') exitCreate();
|
|
317
|
+
}}
|
|
318
|
+
placeholder={t.home.folderName}
|
|
319
|
+
maxLength={40}
|
|
320
|
+
className="min-w-0 flex-1 bg-transparent text-[12.5px] outline-none placeholder:text-muted-foreground/60"
|
|
321
|
+
/>
|
|
322
|
+
</div>
|
|
323
|
+
)}
|
|
295
324
|
</div>
|
|
296
325
|
|
|
297
|
-
<
|
|
298
|
-
<SidebarFooter />
|
|
299
|
-
</div>
|
|
326
|
+
<SidebarFooter />
|
|
300
327
|
</aside>
|
|
301
328
|
);
|
|
302
329
|
}
|
|
@@ -10,7 +10,6 @@ type Props = {
|
|
|
10
10
|
center?: boolean;
|
|
11
11
|
flat?: boolean;
|
|
12
12
|
freezeMotion?: boolean;
|
|
13
|
-
className?: string;
|
|
14
13
|
design?: DesignSystem;
|
|
15
14
|
};
|
|
16
15
|
|
|
@@ -20,7 +19,6 @@ export function SlideCanvas({
|
|
|
20
19
|
center = true,
|
|
21
20
|
flat = false,
|
|
22
21
|
freezeMotion = false,
|
|
23
|
-
className,
|
|
24
22
|
design,
|
|
25
23
|
}: Props) {
|
|
26
24
|
const containerRef = useRef<HTMLDivElement>(null);
|
|
@@ -50,13 +48,11 @@ export function SlideCanvas({
|
|
|
50
48
|
const designVars = design ? designToCssVars(design) : undefined;
|
|
51
49
|
|
|
52
50
|
return (
|
|
53
|
-
<div ref={containerRef} className={cn('relative h-full w-full overflow-hidden'
|
|
51
|
+
<div ref={containerRef} className={cn('relative h-full w-full', flat && 'overflow-hidden')}>
|
|
54
52
|
<div
|
|
55
53
|
className={cn(
|
|
56
54
|
'overflow-hidden bg-white text-black',
|
|
57
|
-
|
|
58
|
-
// can't be clipped by the parent's overflow-hidden.
|
|
59
|
-
!flat && 'rounded-[6px] shadow-[inset_0_0_0_1px_oklch(0_0_0/0.08)]',
|
|
55
|
+
!flat && 'rounded-[6px] shadow-floating',
|
|
60
56
|
)}
|
|
61
57
|
style={
|
|
62
58
|
{
|
|
@@ -180,7 +180,7 @@ function shouldSkipCopiedStyle(
|
|
|
180
180
|
prop: string,
|
|
181
181
|
preserveInheritedVisualStyle: boolean,
|
|
182
182
|
): boolean {
|
|
183
|
-
if (prop === TEXT_FILL_COLOR_PROPERTY &&
|
|
183
|
+
if (prop === TEXT_FILL_COLOR_PROPERTY && styles.getPropertyValue(prop) === styles.color) {
|
|
184
184
|
return true;
|
|
185
185
|
}
|
|
186
186
|
|
|
@@ -190,7 +190,7 @@ function shouldSkipCopiedStyle(
|
|
|
190
190
|
if (!parent) return false;
|
|
191
191
|
|
|
192
192
|
const parentStyles = getComputedStyle(parent);
|
|
193
|
-
return
|
|
193
|
+
return styles.getPropertyValue(prop) === parentStyles.getPropertyValue(prop);
|
|
194
194
|
}
|
|
195
195
|
|
|
196
196
|
function copyComputedStyles(
|
|
@@ -261,10 +261,6 @@ function morphTranslateTransform(rect: LocalRect, local: string): string {
|
|
|
261
261
|
return [`translate(${rect.left}px, ${rect.top}px)`, local].filter(Boolean).join(' ');
|
|
262
262
|
}
|
|
263
263
|
|
|
264
|
-
function getStyleProperty(styles: CSSStyleDeclaration, css: string): string {
|
|
265
|
-
return styles.getPropertyValue(css);
|
|
266
|
-
}
|
|
267
|
-
|
|
268
264
|
// element.animate() silently drops kebab-case keys; keyframe properties must
|
|
269
265
|
// use their IDL camelCase names.
|
|
270
266
|
function keyframeProperty(css: string): string {
|
|
@@ -284,7 +280,7 @@ function visualStyleKeyframe(
|
|
|
284
280
|
) {
|
|
285
281
|
continue;
|
|
286
282
|
}
|
|
287
|
-
const value =
|
|
283
|
+
const value = styles.getPropertyValue(prop);
|
|
288
284
|
if (prop === TEXT_FILL_COLOR_PROPERTY && value === styles.color) continue;
|
|
289
285
|
if (value) frame[keyframeProperty(prop)] = value;
|
|
290
286
|
}
|
|
@@ -302,8 +298,8 @@ function isVisibleBorderSide(
|
|
|
302
298
|
styles: CSSStyleDeclaration,
|
|
303
299
|
side: (typeof BORDER_SIDE_PROPERTIES)[number],
|
|
304
300
|
): boolean {
|
|
305
|
-
const width = parsePx(
|
|
306
|
-
const borderStyle =
|
|
301
|
+
const width = parsePx(styles.getPropertyValue(side.cssWidth)) ?? 0;
|
|
302
|
+
const borderStyle = styles.getPropertyValue(side.cssStyle);
|
|
307
303
|
return width > 0 && borderStyle !== 'none' && borderStyle !== 'hidden';
|
|
308
304
|
}
|
|
309
305
|
|
|
@@ -325,8 +321,8 @@ function borderFrameKeyframe(
|
|
|
325
321
|
};
|
|
326
322
|
|
|
327
323
|
for (const side of BORDER_SIDE_PROPERTIES) {
|
|
328
|
-
frame[side.width] =
|
|
329
|
-
frame[side.color] =
|
|
324
|
+
frame[side.width] = styles.getPropertyValue(side.cssWidth);
|
|
325
|
+
frame[side.color] = styles.getPropertyValue(side.cssColor);
|
|
330
326
|
}
|
|
331
327
|
|
|
332
328
|
return frame;
|
|
@@ -357,9 +353,9 @@ function appendBorderFrame(
|
|
|
357
353
|
|
|
358
354
|
for (const side of BORDER_SIDE_PROPERTIES) {
|
|
359
355
|
const styles = isVisibleBorderSide(sourceStyles, side) ? sourceStyles : targetStyles;
|
|
360
|
-
frame.style[side.style] =
|
|
361
|
-
frame.style[side.width] =
|
|
362
|
-
frame.style[side.color] =
|
|
356
|
+
frame.style[side.style] = styles.getPropertyValue(side.cssStyle);
|
|
357
|
+
frame.style[side.width] = sourceStyles.getPropertyValue(side.cssWidth);
|
|
358
|
+
frame.style[side.color] = sourceStyles.getPropertyValue(side.cssColor);
|
|
363
359
|
}
|
|
364
360
|
|
|
365
361
|
overlay.appendChild(frame);
|
|
@@ -368,7 +364,7 @@ function appendBorderFrame(
|
|
|
368
364
|
|
|
369
365
|
function hasVisualStyleChange(from: CSSStyleDeclaration, to: CSSStyleDeclaration): boolean {
|
|
370
366
|
for (const prop of MORPH_VISUAL_PROPERTIES) {
|
|
371
|
-
if (
|
|
367
|
+
if (from.getPropertyValue(prop) !== to.getPropertyValue(prop)) return true;
|
|
372
368
|
}
|
|
373
369
|
return false;
|
|
374
370
|
}
|
|
@@ -508,7 +504,38 @@ function runMorphTransition(
|
|
|
508
504
|
const animations: Animation[] = [];
|
|
509
505
|
const restore: Array<() => void> = [];
|
|
510
506
|
const outgoing = collectMorphElements(outgoingLayer);
|
|
511
|
-
|
|
507
|
+
|
|
508
|
+
// An element with no counterpart (or no usable rect on one side) can't
|
|
509
|
+
// travel, so it fades in place instead of morphing.
|
|
510
|
+
const fadeOutSource = (source: HTMLElement, from: LocalRect) => {
|
|
511
|
+
const clone = appendPositionedClone(wrapper, overlay, source, from);
|
|
512
|
+
restore.push(hideOriginal(source));
|
|
513
|
+
animations.push(
|
|
514
|
+
runStationaryMorphAnimation(
|
|
515
|
+
clone,
|
|
516
|
+
from,
|
|
517
|
+
getComputedStyle(source),
|
|
518
|
+
effectiveOpacity(source, outgoingLayer),
|
|
519
|
+
'0',
|
|
520
|
+
phase,
|
|
521
|
+
),
|
|
522
|
+
);
|
|
523
|
+
};
|
|
524
|
+
|
|
525
|
+
const fadeInTarget = (target: HTMLElement, to: LocalRect) => {
|
|
526
|
+
const clone = appendPositionedClone(wrapper, overlay, target, to);
|
|
527
|
+
restore.push(hideOriginal(target));
|
|
528
|
+
animations.push(
|
|
529
|
+
runStationaryMorphAnimation(
|
|
530
|
+
clone,
|
|
531
|
+
to,
|
|
532
|
+
getComputedStyle(target),
|
|
533
|
+
'0',
|
|
534
|
+
effectiveOpacity(target, incomingLayer),
|
|
535
|
+
phase,
|
|
536
|
+
),
|
|
537
|
+
);
|
|
538
|
+
};
|
|
512
539
|
|
|
513
540
|
for (const [id, source] of outgoing) {
|
|
514
541
|
const target = incoming.get(id);
|
|
@@ -517,65 +544,23 @@ function runMorphTransition(
|
|
|
517
544
|
if (target) {
|
|
518
545
|
const to = measureLocalRect(target, wrapper, wrapperRect);
|
|
519
546
|
if (hasUsableRect(to)) {
|
|
520
|
-
|
|
521
|
-
const clone = appendPositionedClone(wrapper, overlay, target, to);
|
|
522
|
-
restore.push(hideOriginal(target));
|
|
523
|
-
|
|
524
|
-
const targetStyles = getComputedStyle(target);
|
|
525
|
-
animations.push(
|
|
526
|
-
runStationaryMorphAnimation(
|
|
527
|
-
clone,
|
|
528
|
-
to,
|
|
529
|
-
targetStyles,
|
|
530
|
-
'0',
|
|
531
|
-
effectiveOpacity(target, incomingLayer),
|
|
532
|
-
phase,
|
|
533
|
-
),
|
|
534
|
-
);
|
|
547
|
+
fadeInTarget(target, to);
|
|
535
548
|
}
|
|
536
549
|
}
|
|
537
550
|
continue;
|
|
538
551
|
}
|
|
539
552
|
|
|
540
553
|
if (!target) {
|
|
541
|
-
|
|
542
|
-
restore.push(hideOriginal(source));
|
|
543
|
-
|
|
544
|
-
const sourceStyles = getComputedStyle(source);
|
|
545
|
-
animations.push(
|
|
546
|
-
runStationaryMorphAnimation(
|
|
547
|
-
clone,
|
|
548
|
-
from,
|
|
549
|
-
sourceStyles,
|
|
550
|
-
effectiveOpacity(source, outgoingLayer),
|
|
551
|
-
'0',
|
|
552
|
-
phase,
|
|
553
|
-
),
|
|
554
|
-
);
|
|
554
|
+
fadeOutSource(source, from);
|
|
555
555
|
continue;
|
|
556
556
|
}
|
|
557
557
|
|
|
558
558
|
const to = measureLocalRect(target, wrapper, wrapperRect);
|
|
559
559
|
if (!hasUsableRect(to)) {
|
|
560
|
-
|
|
561
|
-
restore.push(hideOriginal(source));
|
|
562
|
-
|
|
563
|
-
const sourceStyles = getComputedStyle(source);
|
|
564
|
-
animations.push(
|
|
565
|
-
runStationaryMorphAnimation(
|
|
566
|
-
clone,
|
|
567
|
-
from,
|
|
568
|
-
sourceStyles,
|
|
569
|
-
effectiveOpacity(source, outgoingLayer),
|
|
570
|
-
'0',
|
|
571
|
-
phase,
|
|
572
|
-
),
|
|
573
|
-
);
|
|
560
|
+
fadeOutSource(source, from);
|
|
574
561
|
continue;
|
|
575
562
|
}
|
|
576
563
|
|
|
577
|
-
handledIncoming.add(id);
|
|
578
|
-
|
|
579
564
|
const clone = appendPositionedClone(wrapper, overlay, source, from);
|
|
580
565
|
restore.push(hideOriginal(source), hideOriginal(target));
|
|
581
566
|
|
|
@@ -628,25 +613,12 @@ function runMorphTransition(
|
|
|
628
613
|
}
|
|
629
614
|
|
|
630
615
|
for (const [id, target] of incoming) {
|
|
631
|
-
if (
|
|
616
|
+
if (outgoing.has(id)) continue;
|
|
632
617
|
|
|
633
618
|
const to = measureLocalRect(target, wrapper, wrapperRect);
|
|
634
619
|
if (!hasUsableRect(to)) continue;
|
|
635
620
|
|
|
636
|
-
|
|
637
|
-
restore.push(hideOriginal(target));
|
|
638
|
-
|
|
639
|
-
const targetStyles = getComputedStyle(target);
|
|
640
|
-
animations.push(
|
|
641
|
-
runStationaryMorphAnimation(
|
|
642
|
-
clone,
|
|
643
|
-
to,
|
|
644
|
-
targetStyles,
|
|
645
|
-
'0',
|
|
646
|
-
effectiveOpacity(target, incomingLayer),
|
|
647
|
-
phase,
|
|
648
|
-
),
|
|
649
|
-
);
|
|
621
|
+
fadeInTarget(target, to);
|
|
650
622
|
}
|
|
651
623
|
|
|
652
624
|
if (animations.length === 0) overlay.remove();
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
} from 'react';
|
|
11
11
|
import { toast } from 'sonner';
|
|
12
12
|
import { useHistory } from '@/components/history-provider';
|
|
13
|
-
import { type DesignSystem,
|
|
13
|
+
import { type DesignSystem, designToCssVars } from '../../lib/design';
|
|
14
14
|
import { shuffleDesign } from '../../lib/design-presets';
|
|
15
15
|
import { useDesign as useDesignFetch } from './use-design';
|
|
16
16
|
|
|
@@ -26,7 +26,6 @@ type DesignCtx = {
|
|
|
26
26
|
update: (mut: (next: DesignSystem) => void, coalesceKey?: string) => void;
|
|
27
27
|
commit: () => Promise<void>;
|
|
28
28
|
discard: () => void;
|
|
29
|
-
resetToDefaults: () => void;
|
|
30
29
|
shuffle: () => void;
|
|
31
30
|
};
|
|
32
31
|
|
|
@@ -89,17 +88,6 @@ export function DesignProvider({ slideId, children }: { slideId: string; childre
|
|
|
89
88
|
history.clear();
|
|
90
89
|
}, [design, history]);
|
|
91
90
|
|
|
92
|
-
const resetToDefaults = useCallback(() => {
|
|
93
|
-
const prev = draftRef.current;
|
|
94
|
-
const next = clone(defaultDesign);
|
|
95
|
-
setDraft(next);
|
|
96
|
-
history.record({
|
|
97
|
-
coalesceKey: 'design:reset',
|
|
98
|
-
undo: () => setDraft(prev),
|
|
99
|
-
redo: () => setDraft(next),
|
|
100
|
-
});
|
|
101
|
-
}, [history]);
|
|
102
|
-
|
|
103
91
|
const shuffle = useCallback(() => {
|
|
104
92
|
const prev = draftRef.current;
|
|
105
93
|
const next = clone(shuffleDesign(prev));
|
|
@@ -132,7 +120,6 @@ export function DesignProvider({ slideId, children }: { slideId: string; childre
|
|
|
132
120
|
update,
|
|
133
121
|
commit,
|
|
134
122
|
discard,
|
|
135
|
-
resetToDefaults,
|
|
136
123
|
shuffle,
|
|
137
124
|
};
|
|
138
125
|
|
|
@@ -9,9 +9,7 @@ type FetchedState = {
|
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
export type UseDesignReturn = FetchedState & {
|
|
12
|
-
refresh: () => Promise<void>;
|
|
13
12
|
save: (patch: Partial<DesignSystem>) => Promise<{ ok: boolean; error?: string }>;
|
|
14
|
-
reset: () => Promise<{ ok: boolean; error?: string }>;
|
|
15
13
|
};
|
|
16
14
|
|
|
17
15
|
export function useDesign(slideId: string): UseDesignReturn {
|
|
@@ -83,30 +81,5 @@ export function useDesign(slideId: string): UseDesignReturn {
|
|
|
83
81
|
}
|
|
84
82
|
}, []);
|
|
85
83
|
|
|
86
|
-
|
|
87
|
-
const id = slideIdRef.current;
|
|
88
|
-
if (!id) return { ok: false, error: 'no slide id' };
|
|
89
|
-
try {
|
|
90
|
-
const res = await fetch(`/__design/reset?slideId=${encodeURIComponent(id)}`, {
|
|
91
|
-
method: 'POST',
|
|
92
|
-
});
|
|
93
|
-
const body = (await res.json()) as { ok?: boolean; error?: string; design?: DesignSystem };
|
|
94
|
-
if (!res.ok || !body.ok) {
|
|
95
|
-
return { ok: false, error: body.error ?? `HTTP ${res.status}` };
|
|
96
|
-
}
|
|
97
|
-
if (body.design) {
|
|
98
|
-
setState((s) => ({
|
|
99
|
-
...s,
|
|
100
|
-
design: body.design ?? s.design,
|
|
101
|
-
exists: true,
|
|
102
|
-
warning: null,
|
|
103
|
-
}));
|
|
104
|
-
}
|
|
105
|
-
return { ok: true };
|
|
106
|
-
} catch (err) {
|
|
107
|
-
return { ok: false, error: String((err as Error).message) };
|
|
108
|
-
}
|
|
109
|
-
}, []);
|
|
110
|
-
|
|
111
|
-
return { ...state, refresh, save, reset };
|
|
84
|
+
return { ...state, save };
|
|
112
85
|
}
|