@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.
Files changed (88) hide show
  1. package/dist/build-Bzy-qlGc.js +19 -0
  2. package/dist/cli/bin.d.ts +1 -1
  3. package/dist/cli/bin.js +331 -25
  4. package/dist/{config-CDHB8Oow.d.ts → config-AtA2Bqtn.d.ts} +4 -4
  5. package/dist/{config-GA6NMgs_.js → config-nbSvY7z_.js} +547 -778
  6. package/dist/{design-cpzS8aud.js → design-Cpqx7SJs.js} +1 -2
  7. package/dist/{dev-D57ui2yV.js → dev-MXa5Tod4.js} +39 -16
  8. package/dist/index.d.ts +7 -37
  9. package/dist/index.js +51 -54
  10. package/dist/locale/index.d.ts +2 -8
  11. package/dist/locale/index.js +13 -3
  12. package/dist/preview-DEpQcKz3.js +24 -0
  13. package/dist/{types-8HghULIe.d.ts → types-BzPSOxe-.d.ts} +5 -9
  14. package/dist/vite/index.d.ts +1 -4
  15. package/dist/vite/index.js +2 -4
  16. package/dist/{format-74A3B6zu.js → zh-tw-BxZ_pYqe.js} +13 -49
  17. package/package.json +12 -12
  18. package/skills/create-slide/SKILL.md +4 -1
  19. package/skills/slide-authoring/SKILL.md +25 -2
  20. package/src/app/app.tsx +1 -3
  21. package/src/app/assets/open-slide.png +0 -0
  22. package/src/app/components/asset-view.tsx +8 -16
  23. package/src/app/components/command/home-command-menu.tsx +6 -6
  24. package/src/app/components/export-progress-toast.tsx +80 -0
  25. package/src/app/components/history-provider.tsx +1 -5
  26. package/src/app/components/image-placeholder.tsx +4 -12
  27. package/src/app/components/inspector/asset-picker-dialog.tsx +6 -16
  28. package/src/app/components/inspector/image-crop-dialog.tsx +1 -4
  29. package/src/app/components/inspector/inline-text-editor.tsx +798 -0
  30. package/src/app/components/inspector/inspect-overlay.tsx +30 -72
  31. package/src/app/components/inspector/inspector-panel.tsx +17 -49
  32. package/src/app/components/inspector/inspector-provider.tsx +53 -36
  33. package/src/app/components/notes-drawer.tsx +2 -5
  34. package/src/app/components/overview-grid.tsx +5 -4
  35. package/src/app/components/panel/panel-shell.tsx +1 -3
  36. package/src/app/components/player.tsx +5 -6
  37. package/src/app/components/present/control-bar.tsx +4 -4
  38. package/src/app/components/present/jump-input.tsx +3 -2
  39. package/src/app/components/present/use-presenter-channel.ts +0 -1
  40. package/src/app/components/sidebar/folder-item.tsx +39 -16
  41. package/src/app/components/sidebar/sidebar-footer.tsx +7 -1
  42. package/src/app/components/sidebar/sidebar.tsx +91 -64
  43. package/src/app/components/slide-canvas.tsx +2 -6
  44. package/src/app/components/slide-transition-layer.tsx +48 -76
  45. package/src/app/components/style-panel/design-provider.tsx +1 -14
  46. package/src/app/components/style-panel/use-design.ts +1 -28
  47. package/src/app/components/themes/theme-detail.tsx +4 -4
  48. package/src/app/components/themes/themes-gallery.tsx +11 -6
  49. package/src/app/components/thumbnail-rail.tsx +7 -12
  50. package/src/app/lib/assets.ts +6 -7
  51. package/src/app/lib/dom.ts +42 -0
  52. package/src/app/lib/export-html.ts +10 -25
  53. package/src/app/lib/export-pdf.ts +11 -28
  54. package/src/app/lib/export-pptx.ts +6 -36
  55. package/src/app/lib/folders.ts +51 -46
  56. package/src/app/lib/inspector/inline-text.ts +31 -0
  57. package/src/app/lib/inspector/pick-target.ts +38 -0
  58. package/src/app/lib/inspector/use-comments.ts +1 -1
  59. package/src/app/lib/keys.ts +18 -0
  60. package/src/app/lib/last-home-location.ts +18 -0
  61. package/src/app/lib/print-ready.ts +2 -4
  62. package/src/app/lib/slides.ts +7 -4
  63. package/src/app/lib/text-diff.ts +19 -0
  64. package/src/app/lib/use-click-page-navigation.ts +2 -6
  65. package/src/app/lib/use-is-mobile.ts +2 -14
  66. package/src/app/lib/use-media-query.ts +20 -0
  67. package/src/app/lib/use-prefers-reduced-motion.ts +5 -13
  68. package/src/app/lib/use-slide-module.ts +1 -1
  69. package/src/app/lib/use-wheel-page-navigation.ts +1 -1
  70. package/src/app/lib/utils.test.ts +25 -1
  71. package/src/app/lib/utils.ts +8 -0
  72. package/src/app/routes/home-shell.tsx +71 -64
  73. package/src/app/routes/home.tsx +41 -52
  74. package/src/app/routes/presenter.tsx +10 -20
  75. package/src/app/routes/slide.tsx +84 -71
  76. package/src/app/routes/themes.tsx +7 -8
  77. package/src/app/styles.css +33 -44
  78. package/src/locale/en.ts +2 -7
  79. package/src/locale/ja.ts +2 -7
  80. package/src/locale/types.ts +2 -7
  81. package/src/locale/zh-cn.ts +2 -7
  82. package/src/locale/zh-tw.ts +2 -7
  83. package/dist/build-CaV_vhIw.js +0 -17
  84. package/dist/preview-D40Zw_o0.js +0 -18
  85. package/dist/sync-BCJDRIqo.js +0 -139
  86. package/dist/sync-j9_QPovT.js +0 -3
  87. package/src/app/components/pdf-progress-toast.tsx +0 -36
  88. package/src/app/components/pptx-progress-toast.tsx +0 -36
@@ -31,12 +31,12 @@ import {
31
31
  DropdownMenuTrigger,
32
32
  } from '@/components/ui/dropdown-menu';
33
33
  import { format, useLocale } from '@/lib/use-locale';
34
- import { cn } from '@/lib/utils';
35
- import { FolderIconChip, SLIDE_DND_MIME } from '../components/sidebar/folder-item';
34
+ import { cn, pad2 } from '@/lib/utils';
35
+ import { FolderIconChip, SLIDE_DND_MIME, SystemViewIcon } from '../components/sidebar/folder-item';
36
36
  import { ALL_SLIDES_ID, DRAFT_ID } from '../components/sidebar/sidebar';
37
37
  import { SlideCanvas } from '../components/slide-canvas';
38
38
  import { SlidePageProvider } from '../lib/page-context';
39
- import type { Folder, FolderIcon, SlideModule } from '../lib/sdk';
39
+ import type { Folder, SlideModule } from '../lib/sdk';
40
40
  import { loadSlide, slideCreatedAt, slideIds } from '../lib/slides';
41
41
  import type { HomeOutletContext } from './home-shell';
42
42
 
@@ -97,10 +97,6 @@ export function Home() {
97
97
  : (slidesByFolder[selectedId] ?? []);
98
98
 
99
99
  const title = selectedFolder?.name ?? (isAll ? t.home.slides : t.home.draft);
100
- const headerIcon = selectedFolder?.icon ?? {
101
- type: 'emoji' as const,
102
- value: isAll ? '🎞️' : '📝',
103
- };
104
100
 
105
101
  const [query, setQuery] = useState('');
106
102
  const [sortKey, setSortKey] = useSortPref();
@@ -136,10 +132,14 @@ export function Home() {
136
132
 
137
133
  return (
138
134
  <>
139
- <header className="mb-8 md:mb-12">
140
- <div className="flex flex-wrap items-center gap-3">
141
- <FolderIconChip icon={headerIcon} className="size-7 text-2xl" />
142
- <h1 className="font-heading text-[32px] font-semibold leading-[1.05] tracking-[-0.025em] md:text-[44px]">
135
+ <header className="mb-6 md:mb-8">
136
+ <div className="flex flex-wrap items-center gap-2.5">
137
+ {selectedFolder ? (
138
+ <FolderIconChip icon={selectedFolder.icon} className="size-5 text-[16px]" />
139
+ ) : (
140
+ <SystemViewIcon kind={isAll ? 'all' : 'draft'} className="text-muted-foreground" />
141
+ )}
142
+ <h1 className="font-heading text-[19px] font-semibold leading-none tracking-[-0.015em] md:text-[21px]">
143
143
  {title}
144
144
  </h1>
145
145
  <DropdownMenu>
@@ -148,7 +148,7 @@ export function Home() {
148
148
  <button
149
149
  type="button"
150
150
  aria-label={t.home.folders}
151
- className="flex size-7 items-center justify-center rounded-[6px] border border-border bg-card text-muted-foreground hover:text-foreground aria-expanded:border-foreground/40 aria-expanded:text-foreground md:hidden"
151
+ className="flex size-7 items-center justify-center rounded-[6px] border border-border bg-card text-muted-foreground outline-none transition-[background-color,color,scale] duration-100 hover:bg-muted hover:text-foreground active:scale-95 focus-visible:ring-2 focus-visible:ring-ring/30 aria-expanded:border-foreground/40 aria-expanded:text-foreground md:hidden"
152
152
  >
153
153
  <ChevronDown className="size-4" />
154
154
  </button>
@@ -159,17 +159,17 @@ export function Home() {
159
159
  onClick={() => selectFolder(ALL_SLIDES_ID)}
160
160
  className={cn(isAll && 'bg-muted text-foreground')}
161
161
  >
162
- <FolderIconChip icon={{ type: 'emoji', value: '🎞️' }} />
162
+ <SystemViewIcon kind="all" className="text-muted-foreground" />
163
163
  <span className="flex-1 truncate">{t.home.slides}</span>
164
- <span className="folio">{slideIds.length.toString().padStart(2, '0')}</span>
164
+ <span className="folio">{pad2(slideIds.length)}</span>
165
165
  </DropdownMenuItem>
166
166
  <DropdownMenuItem
167
167
  onClick={() => selectFolder(DRAFT_ID)}
168
168
  className={cn(isDraft && 'bg-muted text-foreground')}
169
169
  >
170
- <FolderIconChip icon={{ type: 'emoji', value: '📝' }} />
170
+ <SystemViewIcon kind="draft" className="text-muted-foreground" />
171
171
  <span className="flex-1 truncate">{t.home.draft}</span>
172
- <span className="folio">{draftSlides.length.toString().padStart(2, '0')}</span>
172
+ <span className="folio">{pad2(draftSlides.length)}</span>
173
173
  </DropdownMenuItem>
174
174
  {manifest.folders.map((f) => (
175
175
  <DropdownMenuItem
@@ -179,23 +179,15 @@ export function Home() {
179
179
  >
180
180
  <FolderIconChip icon={f.icon} />
181
181
  <span className="flex-1 truncate">{f.name}</span>
182
- <span className="folio">
183
- {(slidesByFolder[f.id]?.length ?? 0).toString().padStart(2, '0')}
184
- </span>
182
+ <span className="folio">{pad2(slidesByFolder[f.id]?.length ?? 0)}</span>
185
183
  </DropdownMenuItem>
186
184
  ))}
187
185
  </DropdownMenuContent>
188
186
  </DropdownMenu>
189
187
  {!loading && (
190
- <span className="folio ml-1 self-end pb-2">
191
- {(isSearching ? filteredSlides.length : visibleSlides.length)
192
- .toString()
193
- .padStart(2, '0')}
194
- {isSearching && (
195
- <span className="opacity-40">
196
- /{visibleSlides.length.toString().padStart(2, '0')}
197
- </span>
198
- )}
188
+ <span className="folio ml-0.5">
189
+ {pad2(isSearching ? filteredSlides.length : visibleSlides.length)}
190
+ {isSearching && <span className="opacity-40">/{pad2(visibleSlides.length)}</span>}
199
191
  </span>
200
192
  )}
201
193
  <div className="ml-auto flex w-full items-center gap-2 md:w-auto">
@@ -213,8 +205,12 @@ export function Home() {
213
205
  <NoResultsState query={query} onClear={() => setQuery('')} />
214
206
  ) : (
215
207
  <ul className="grid grid-cols-[repeat(auto-fill,minmax(240px,1fr))] gap-x-6 gap-y-9 md:grid-cols-[repeat(auto-fill,minmax(300px,1fr))]">
216
- {sortedSlides.map((id) => (
217
- <li key={id}>
208
+ {sortedSlides.map((id, i) => (
209
+ <li
210
+ key={id}
211
+ className="rise-in"
212
+ style={{ animationDelay: `${Math.min(i, 11) * 30}ms` }}
213
+ >
218
214
  <SlideCard
219
215
  id={id}
220
216
  folders={manifest.folders}
@@ -343,12 +339,10 @@ function HomeLoading() {
343
339
  function NoResultsState({ query, onClear }: { query: string; onClear: () => void }) {
344
340
  const t = useLocale();
345
341
  return (
346
- <div className="rounded-[10px] border border-dashed border-border bg-card/60 px-8 py-20">
342
+ <div className="rounded-[8px] border border-dashed border-border px-8 py-20">
347
343
  <div className="mx-auto flex max-w-md flex-col items-center text-center">
348
- <div className="flex size-12 items-center justify-center rounded-full border border-hairline bg-card text-muted-foreground">
349
- <Search className="size-5" />
350
- </div>
351
- <p className="mt-4 font-heading text-[15px] font-semibold tracking-tight">
344
+ <Search className="size-5 text-muted-foreground/60" aria-hidden />
345
+ <p className="mt-4 font-heading text-[14px] font-semibold tracking-tight">
352
346
  {t.home.noMatches}
353
347
  </p>
354
348
  <p className="mt-1.5 text-[13px] leading-relaxed text-muted-foreground">
@@ -371,14 +365,12 @@ function EmptyState({ isDraft, folderName }: { isDraft: boolean; folderName?: st
371
365
  folderName ?? t.home.folderEmptyTitle,
372
366
  );
373
367
  return (
374
- <div className="rounded-[10px] border border-dashed border-border bg-card/60 px-8 py-20">
368
+ <div className="rounded-[8px] border border-dashed border-border px-8 py-20">
375
369
  <div className="mx-auto flex max-w-md flex-col items-center text-center">
376
- <div className="flex size-12 items-center justify-center rounded-full border border-hairline bg-card text-muted-foreground">
377
- <FolderPlus className="size-5" />
378
- </div>
370
+ <FolderPlus className="size-5 text-muted-foreground/60" aria-hidden />
379
371
  {isDraft ? (
380
372
  <>
381
- <p className="mt-4 font-heading text-[15px] font-semibold tracking-tight">
373
+ <p className="mt-4 font-heading text-[14px] font-semibold tracking-tight">
382
374
  {t.home.noSlidesYet}
383
375
  </p>
384
376
  <p className="mt-1.5 text-[13px] leading-relaxed text-muted-foreground">
@@ -391,7 +383,7 @@ function EmptyState({ isDraft, folderName }: { isDraft: boolean; folderName?: st
391
383
  </>
392
384
  ) : (
393
385
  <>
394
- <p className="mt-4 font-heading text-[15px] font-semibold tracking-tight">
386
+ <p className="mt-4 font-heading text-[14px] font-semibold tracking-tight">
395
387
  {folderEmptyTitle}
396
388
  </p>
397
389
  <p className="mt-1.5 text-[13px] leading-relaxed text-muted-foreground">
@@ -517,7 +509,7 @@ function SlideCard({
517
509
  {/* Slide thumb — tight border, grey baseboard, no shadcn rounded-xl */}
518
510
  <div className="relative aspect-video overflow-hidden rounded-[6px] border border-hairline bg-card shadow-edge ring-1 ring-foreground/[0.04] group-hover:shadow-floating group-hover:ring-foreground/20 motion-safe:transition-[box-shadow,--tw-ring-color,scale] motion-safe:duration-200 group-active:scale-[0.99]">
519
511
  {FirstPage ? (
520
- <div className="h-full w-full ease-swift motion-safe:transition-transform motion-safe:duration-200 motion-safe:group-hover:scale-[1.03]">
512
+ <div className="h-full w-full">
521
513
  <SlideCanvas flat freezeMotion design={slide?.design}>
522
514
  <SlidePageProvider index={0} total={slide?.default.length ?? 1}>
523
515
  <FirstPage />
@@ -549,16 +541,13 @@ function SlideCard({
549
541
  </div>
550
542
 
551
543
  {import.meta.env.DEV && (
552
- <div className="absolute right-2 top-2">
544
+ <div className="absolute right-2 top-2 z-20">
553
545
  <DropdownMenu>
554
546
  <DropdownMenuTrigger
555
547
  render={
556
548
  <button
557
549
  type="button"
558
- onClick={(e) => {
559
- e.stopPropagation();
560
- e.preventDefault();
561
- }}
550
+ onClick={(e) => e.stopPropagation()}
562
551
  className="flex size-7 items-center justify-center rounded-[5px] bg-card/90 text-foreground shadow-edge ring-1 ring-border opacity-0 outline-none backdrop-blur 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"
563
552
  aria-label={tCard.home.slideActions}
564
553
  >
@@ -752,7 +741,7 @@ function MoveDialog({
752
741
  </DialogHeader>
753
742
  <div className="max-h-[320px] overflow-y-auto rounded-[6px] border border-border bg-background">
754
743
  <FolderOption
755
- icon={{ type: 'emoji', value: '📝' }}
744
+ chip={<SystemViewIcon kind="draft" className="text-muted-foreground" />}
756
745
  label={t.home.draft}
757
746
  active={selected === null}
758
747
  onClick={() => setSelected(null)}
@@ -760,7 +749,7 @@ function MoveDialog({
760
749
  {folders.map((f) => (
761
750
  <FolderOption
762
751
  key={f.id}
763
- icon={f.icon}
752
+ chip={<FolderIconChip icon={f.icon} />}
764
753
  label={f.name}
765
754
  active={selected === f.id}
766
755
  onClick={() => setSelected(f.id)}
@@ -781,12 +770,12 @@ function MoveDialog({
781
770
  }
782
771
 
783
772
  function FolderOption({
784
- icon,
773
+ chip,
785
774
  label,
786
775
  active,
787
776
  onClick,
788
777
  }: {
789
- icon: FolderIcon;
778
+ chip: React.ReactNode;
790
779
  label: string;
791
780
  active: boolean;
792
781
  onClick: () => void;
@@ -801,7 +790,7 @@ function FolderOption({
801
790
  active ? 'bg-muted text-foreground' : 'hover:bg-muted/60',
802
791
  )}
803
792
  >
804
- <FolderIconChip icon={icon} />
793
+ {chip}
805
794
  <span className="truncate">{label}</span>
806
795
  {active && (
807
796
  <span className="ml-auto inline-flex items-center gap-1 text-[10.5px] text-brand">
@@ -20,8 +20,9 @@ import {
20
20
  import { useNavigate, useParams } from 'react-router-dom';
21
21
  import { Button } from '@/components/ui/button';
22
22
  import { Dialog, DialogContent, DialogTitle, DialogTrigger } from '@/components/ui/dialog';
23
+ import { hasModifier, isBackwardKey, isForwardKey, isTypingTarget } from '@/lib/keys';
23
24
  import { format, useLocale } from '@/lib/use-locale';
24
- import { cn } from '@/lib/utils';
25
+ import { cn, pad2 } from '@/lib/utils';
25
26
  import {
26
27
  type PresenterState,
27
28
  usePresenterChannel,
@@ -78,9 +79,6 @@ export function Presenter() {
78
79
  if (!channel.available || requestedRef.current) return;
79
80
  requestedRef.current = true;
80
81
  channel.send({ type: 'request-state' });
81
- // If nothing answers within a beat, surface the "no projection" hint.
82
- const t = setTimeout(() => setHasProjection((v) => v), 600);
83
- return () => clearTimeout(t);
84
82
  }, [channel, slideId]);
85
83
 
86
84
  const navigate = useNavigate();
@@ -105,17 +103,12 @@ export function Presenter() {
105
103
  const onKey = (e: KeyboardEvent) => {
106
104
  // The deck-switcher menu owns its own arrow-key navigation.
107
105
  if (e.defaultPrevented) return;
108
- if (e.target instanceof HTMLElement && e.target.matches('input, textarea')) return;
109
- if (e.altKey || e.ctrlKey || e.metaKey) return;
110
- if (
111
- e.key === 'ArrowRight' ||
112
- e.key === 'ArrowDown' ||
113
- e.key === ' ' ||
114
- e.key === 'PageDown'
115
- ) {
106
+ if (isTypingTarget(e.target)) return;
107
+ if (hasModifier(e)) return;
108
+ if (isForwardKey(e)) {
116
109
  e.preventDefault();
117
110
  goNext();
118
- } else if (e.key === 'ArrowLeft' || e.key === 'ArrowUp' || e.key === 'PageUp') {
111
+ } else if (isBackwardKey(e)) {
119
112
  e.preventDefault();
120
113
  goPrev();
121
114
  } else if (e.key === 'b' || e.key === 'B') {
@@ -324,9 +317,9 @@ function PresenterTopBar({
324
317
  <Clock />
325
318
  <ElapsedClock startedAt={startedAt} />
326
319
  <div className="font-mono text-[18px] tabular-nums">
327
- <span className="text-foreground">{(index + 1).toString().padStart(2, '0')}</span>
320
+ <span className="text-foreground">{pad2(index + 1)}</span>
328
321
  <span className="text-foreground/30"> / </span>
329
- <span className="text-muted-foreground">{total.toString().padStart(2, '0')}</span>
322
+ <span className="text-muted-foreground">{pad2(total)}</span>
330
323
  </div>
331
324
  </div>
332
325
  </header>
@@ -481,7 +474,7 @@ function DeckSwitcher({
481
474
  </div>
482
475
  <div className="mt-0.5 truncate font-mono text-[10.5px] tabular-nums text-muted-foreground">
483
476
  {id}
484
- {mod && ` · ${mod.default.length.toString().padStart(2, '0')}`}
477
+ {mod && ` · ${pad2(mod.default.length)}`}
485
478
  </div>
486
479
  </div>
487
480
  {id === slideId && <Check className="size-3.5 shrink-0 text-muted-foreground" />}
@@ -699,10 +692,7 @@ function ElapsedClock({ startedAt }: { startedAt: number }) {
699
692
  const h = Math.floor(elapsed / 3600);
700
693
  const m = Math.floor((elapsed % 3600) / 60);
701
694
  const s = elapsed % 60;
702
- const text =
703
- h > 0
704
- ? `${h}:${m.toString().padStart(2, '0')}:${s.toString().padStart(2, '0')}`
705
- : `${m.toString().padStart(2, '0')}:${s.toString().padStart(2, '0')}`;
695
+ const text = h > 0 ? `${h}:${pad2(m)}:${pad2(s)}` : `${pad2(m)}:${pad2(s)}`;
706
696
  return (
707
697
  <time
708
698
  title={t.presenter.elapsed}
@@ -16,12 +16,21 @@ import {
16
16
  Presentation,
17
17
  Terminal,
18
18
  } from 'lucide-react';
19
- import { type RefObject, useCallback, useEffect, useMemo, useRef, useState } from 'react';
19
+ import {
20
+ type ReactElement,
21
+ type RefObject,
22
+ useCallback,
23
+ useEffect,
24
+ useMemo,
25
+ useRef,
26
+ useState,
27
+ } from 'react';
20
28
  import { Link, useNavigate, useParams, useSearchParams } from 'react-router-dom';
21
29
  import { toast } from 'sonner';
22
30
  import { AssetView } from '@/components/asset-view';
23
31
  import { HistoryProvider } from '@/components/history-provider';
24
32
  import { CommentWidget } from '@/components/inspector/comment-widget';
33
+ import { InlineEditLayer } from '@/components/inspector/inline-text-editor';
25
34
  import { InspectOverlay } from '@/components/inspector/inspect-overlay';
26
35
  import { InspectorPanel } from '@/components/inspector/inspector-panel';
27
36
  import {
@@ -44,6 +53,8 @@ import {
44
53
  import { Tabs, TabsList, TabsTrigger } from '@/components/ui/tabs';
45
54
  import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip';
46
55
  import { useFolders } from '@/lib/folders';
56
+ import { hasModifier, isBackwardKey, isForwardKey, isTypingTarget } from '@/lib/keys';
57
+ import { readLastHomeLocation } from '@/lib/last-home-location';
47
58
  import { useAgentSocketConnected } from '@/lib/use-agent-socket';
48
59
  import { useClickPageNavigation } from '@/lib/use-click-page-navigation';
49
60
  import { useIsMobile } from '@/lib/use-is-mobile';
@@ -51,18 +62,17 @@ import { format, useLocale } from '@/lib/use-locale';
51
62
  import { useWheelPageNavigation } from '@/lib/use-wheel-page-navigation';
52
63
  import { cn } from '@/lib/utils';
53
64
  import { SlideCommandMenu } from '../components/command/slide-command-menu';
65
+ import { PdfProgressToast, PptxProgressToast } from '../components/export-progress-toast';
54
66
  import { NotesDrawer } from '../components/notes-drawer';
55
67
  import { OverviewGrid } from '../components/overview-grid';
56
- import { PdfProgressToast } from '../components/pdf-progress-toast';
57
68
  import { openPresenterWindow, Player } from '../components/player';
58
- import { PptxProgressToast } from '../components/pptx-progress-toast';
59
69
  import { SlideCanvas } from '../components/slide-canvas';
60
70
  import { isDeckWarmed, markDeckWarmed, SlidePreloadLayer } from '../components/slide-preload-layer';
61
71
  import { SlideTransitionLayer } from '../components/slide-transition-layer';
62
72
  import { type ThumbnailActions, ThumbnailRail } from '../components/thumbnail-rail';
63
73
  import { exportSlideAsHtml } from '../lib/export-html';
64
- import { exportSlideAsPdf, isSafari } from '../lib/export-pdf';
65
- import { exportSlideAsImagePptx } from '../lib/export-pptx';
74
+ import { exportSlideAsPdf, isSafari, type PdfExportProgress } from '../lib/export-pdf';
75
+ import { exportSlideAsImagePptx, type PptxExportProgress } from '../lib/export-pptx';
66
76
  import { remapNotesSessionCacheAfterReorder } from '../lib/inspector/use-notes';
67
77
  import type { SlideModule } from '../lib/sdk';
68
78
  import { usePrefersReducedMotion } from '../lib/use-prefers-reduced-motion';
@@ -76,6 +86,16 @@ export function Slide() {
76
86
  const { slideId = '' } = useParams();
77
87
  const [searchParams, setSearchParams] = useSearchParams();
78
88
  const navigate = useNavigate();
89
+ // react-router records its entry index in history.state; going back is only
90
+ // safe when we actually pushed an entry, otherwise land on the last home view.
91
+ const goBack = useCallback(() => {
92
+ const idx = (window.history.state as { idx?: number } | null)?.idx ?? 0;
93
+ if (idx > 0) {
94
+ navigate(-1);
95
+ } else {
96
+ navigate(readLastHomeLocation(), { replace: true });
97
+ }
98
+ }, [navigate]);
79
99
  const { slide, error } = useSlideModule(slideId);
80
100
  const [playMode, setPlayMode] = useState<'window' | 'fullscreen' | null>(null);
81
101
  // Last deck the Player showed. During a presenter-driven deck switch the
@@ -272,9 +292,9 @@ export function Slide() {
272
292
  // page-nav handler too would race it and skip <Steps> reveals, so bail out.
273
293
  if (playMode || !showSlideUi) return;
274
294
  const onKey = (e: KeyboardEvent) => {
275
- if (e.target instanceof HTMLElement && e.target.matches('input, textarea')) return;
295
+ if (isTypingTarget(e.target)) return;
276
296
  // Letter shortcuts only fire bare so browser combos (Cmd/Ctrl-P, ⌘F…) stay intact.
277
- if (e.altKey || e.ctrlKey || e.metaKey) return;
297
+ if (hasModifier(e)) return;
278
298
  // Toggle overview from either state — the overview's own capture-phase
279
299
  // handler doesn't consume O, so this stays consistent open ↔ closed.
280
300
  if (e.key === 'o' || e.key === 'O') {
@@ -285,17 +305,12 @@ export function Slide() {
285
305
  // Once overview owns focus, swallow everything else here — its
286
306
  // capture-phase listener drives the focused thumbnail.
287
307
  if (overviewOpen) return;
288
- if (
289
- e.key === 'ArrowRight' ||
290
- e.key === 'ArrowDown' ||
291
- e.key === ' ' ||
292
- e.key === 'PageDown'
293
- ) {
308
+ if (isForwardKey(e)) {
294
309
  e.preventDefault();
295
310
  goTo(index + 1);
296
311
  return;
297
312
  }
298
- if (e.key === 'ArrowLeft' || e.key === 'ArrowUp' || e.key === 'PageUp') {
313
+ if (isBackwardKey(e)) {
299
314
  e.preventDefault();
300
315
  goTo(index - 1);
301
316
  return;
@@ -487,58 +502,56 @@ export function Slide() {
487
502
  }
488
503
  };
489
504
 
490
- const exportPdf = async () => {
491
- if (!slide || exporting) return;
492
- if (isSafari()) {
493
- toast.error(t.slide.pdfExportSafariUnsupported, { duration: 5000 });
494
- return;
495
- }
505
+ // One toast id drives the whole export: the same id is re-rendered on every
506
+ // progress tick, swapped for the error toast on failure, then dismissed.
507
+ const runProgressExport = async <P,>(opts: {
508
+ kind: string;
509
+ initial: P;
510
+ failedMessage: string;
511
+ renderToast: (progress: P) => ReactElement;
512
+ run: (onProgress: (progress: P) => void) => Promise<void>;
513
+ }) => {
496
514
  setExporting(true);
497
- const toastId = `pdf-export-${slideId}`;
498
- toast.custom(
499
- () => (
500
- <PdfProgressToast
501
- progress={{ phase: 'processing', current: 0, total: pages.length, percent: 0 }}
502
- />
503
- ),
504
- { id: toastId, duration: Infinity },
505
- );
515
+ const toastId = `${opts.kind}-export-${slideId}`;
516
+ const show = (progress: P) =>
517
+ toast.custom(() => opts.renderToast(progress), { id: toastId, duration: Infinity });
518
+ show(opts.initial);
506
519
  try {
507
- await exportSlideAsPdf(slide, slideId, (p) => {
508
- toast.custom(() => <PdfProgressToast progress={p} />, { id: toastId, duration: Infinity });
509
- });
520
+ await opts.run(show);
521
+ toast.dismiss(toastId);
510
522
  } catch (err) {
511
- console.error('[open-slide] pdf export failed', err);
512
- toast.error(t.slide.pdfExportFailed, { id: toastId, duration: 4000 });
523
+ console.error(`[open-slide] ${opts.kind} export failed`, err);
524
+ // Reuses the progress toast's id, so it must outlive this handler.
525
+ toast.error(opts.failedMessage, { id: toastId, duration: 4000 });
513
526
  } finally {
514
527
  setExporting(false);
515
- toast.dismiss(toastId);
516
528
  }
517
529
  };
518
530
 
519
- const exportImagePptx = async () => {
531
+ const exportPdf = async () => {
520
532
  if (!slide || exporting) return;
521
- setExporting(true);
522
- const toastId = `pptx-export-${slideId}`;
523
- toast.custom(
524
- () => (
525
- <PptxProgressToast
526
- progress={{ phase: 'processing', current: 0, total: pages.length, percent: 0 }}
527
- />
528
- ),
529
- { id: toastId, duration: Infinity },
530
- );
531
- try {
532
- await exportSlideAsImagePptx(slide, slideId, (p) => {
533
- toast.custom(() => <PptxProgressToast progress={p} />, { id: toastId, duration: Infinity });
534
- });
535
- } catch (err) {
536
- console.error('[open-slide] image pptx export failed', err);
537
- toast.error(t.slide.imagePptxExportFailed, { id: toastId, duration: 4000 });
538
- } finally {
539
- setExporting(false);
540
- toast.dismiss(toastId);
533
+ if (isSafari()) {
534
+ toast.error(t.slide.pdfExportSafariUnsupported, { duration: 5000 });
535
+ return;
541
536
  }
537
+ await runProgressExport<PdfExportProgress>({
538
+ kind: 'pdf',
539
+ initial: { phase: 'processing', current: 0, total: pages.length, percent: 0 },
540
+ failedMessage: t.slide.pdfExportFailed,
541
+ renderToast: (progress) => <PdfProgressToast progress={progress} />,
542
+ run: (onProgress) => exportSlideAsPdf(slide, slideId, onProgress),
543
+ });
544
+ };
545
+
546
+ const exportImagePptx = async () => {
547
+ if (!slide || exporting) return;
548
+ await runProgressExport<PptxExportProgress>({
549
+ kind: 'pptx',
550
+ initial: { phase: 'processing', current: 0, total: pages.length, percent: 0 },
551
+ failedMessage: t.slide.imagePptxExportFailed,
552
+ renderToast: (progress) => <PptxProgressToast progress={progress} />,
553
+ run: (onProgress) => exportSlideAsImagePptx(slide, slideId, onProgress),
554
+ });
542
555
  };
543
556
 
544
557
  const exportMenuItems = (
@@ -589,19 +602,20 @@ export function Slide() {
589
602
  <HistoryProvider>
590
603
  <InspectorProvider slideId={slideId} pageIndex={index}>
591
604
  <SelectionReporter />
592
- <div className="flex h-dvh flex-col overflow-hidden bg-background text-foreground">
593
- {/* Editorial toolbar — three zones, hairline separators, mono-folio center */}
594
- <header className="relative flex h-12 shrink-0 items-center gap-2 border-b border-hairline bg-sidebar/85 px-2 backdrop-blur-md md:px-3">
605
+ <div className="flex h-dvh flex-col overflow-hidden bg-sidebar text-foreground">
606
+ {/* Toolbar sits directly on the chrome ground — three zones, mono-folio center */}
607
+ <header className="relative flex h-12 shrink-0 items-center gap-2 px-2 md:px-3">
595
608
  <div className="flex flex-1 items-center gap-1.5 md:flex-none md:gap-2">
596
609
  {showSlideBrowser && (
597
- <Link
598
- to="/"
610
+ <button
611
+ type="button"
612
+ onClick={goBack}
599
613
  aria-label={t.slide.backToHome}
600
614
  title={t.slide.home}
601
615
  className={buttonVariants({ variant: 'ghost', size: 'icon-sm' })}
602
616
  >
603
617
  <ChevronLeft className="size-4" />
604
- </Link>
618
+ </button>
605
619
  )}
606
620
  <span aria-hidden className="mx-0.5 hidden h-5 w-px bg-hairline md:block" />
607
621
  {import.meta.env.DEV && (
@@ -735,9 +749,6 @@ export function Slide() {
735
749
  >
736
750
  <Play className="size-3.5 fill-current" />
737
751
  <span className="hidden md:inline">{t.slide.present}</span>
738
- <kbd className="ml-1 hidden rounded-[3px] bg-brand-foreground/15 px-1 font-mono text-[9.5px] tracking-[0.04em] md:inline">
739
- F
740
- </kbd>
741
752
  </Button>
742
753
  <DropdownMenu>
743
754
  <DropdownMenuTrigger
@@ -780,7 +791,7 @@ export function Slide() {
780
791
  </header>
781
792
 
782
793
  {view === 'assets' ? (
783
- <div className="min-h-0 flex-1">
794
+ <div className="min-h-0 flex-1 overflow-hidden md:mx-2 md:mb-2 md:rounded-[10px] md:bg-background md:shadow-edge md:ring-1 md:ring-foreground/[0.06]">
784
795
  <AssetView slideId={slideId} />
785
796
  </div>
786
797
  ) : (
@@ -801,7 +812,7 @@ export function Slide() {
801
812
  ref={slideViewportRef}
802
813
  data-inspector-root
803
814
  data-slide-id={slideId}
804
- className="relative min-h-0 min-w-0 flex-1 bg-canvas p-2 md:p-10"
815
+ className="relative min-h-0 min-w-0 flex-1 bg-background p-2 md:mx-2 md:mb-2 md:rounded-[10px] md:p-10 md:shadow-edge md:ring-1 md:ring-foreground/[0.06]"
805
816
  >
806
817
  <SlideViewportNavigation
807
818
  targetRef={slideViewportRef}
@@ -820,6 +831,7 @@ export function Slide() {
820
831
  />
821
832
  </SlideCanvas>
822
833
  <InspectOverlay />
834
+ <InlineEditLayer />
823
835
  <SaveBar />
824
836
  {import.meta.env.DEV && <CommentWidget />}
825
837
  </main>
@@ -1080,18 +1092,19 @@ function SlideViewportNavigation({
1080
1092
  canPrev,
1081
1093
  canNext,
1082
1094
  }: {
1083
- targetRef: RefObject<HTMLElement>;
1095
+ targetRef: RefObject<HTMLElement | null>;
1084
1096
  onPrev: () => void;
1085
1097
  onNext: () => void;
1086
1098
  canPrev: boolean;
1087
1099
  canNext: boolean;
1088
1100
  }) {
1089
- const { active } = useInspector();
1101
+ const { active, inlineEdit } = useInspector();
1090
1102
  const isMobile = useIsMobile();
1103
+ const editing = !!inlineEdit;
1091
1104
 
1092
1105
  useWheelPageNavigation({
1093
1106
  ref: targetRef,
1094
- enabled: !active,
1107
+ enabled: !active && !editing,
1095
1108
  canPrev,
1096
1109
  canNext,
1097
1110
  onPrev,
@@ -1103,7 +1116,7 @@ function SlideViewportNavigation({
1103
1116
  // zones). Interactive slide content keeps its tap via the hook's passthrough.
1104
1117
  useClickPageNavigation({
1105
1118
  ref: targetRef,
1106
- enabled: isMobile && !active,
1119
+ enabled: isMobile && !active && !editing,
1107
1120
  edgeRatio: 0.18,
1108
1121
  canPrev,
1109
1122
  canNext,
@@ -1,6 +1,7 @@
1
1
  import { useNavigate, useParams } from 'react-router-dom';
2
2
  import { useLocale } from '@/lib/use-locale';
3
- import { FolderIconChip } from '../components/sidebar/folder-item';
3
+ import { pad2 } from '@/lib/utils';
4
+ import { SystemViewIcon } from '../components/sidebar/folder-item';
4
5
  import { ThemeDetail } from '../components/themes/theme-detail';
5
6
  import { ThemesGallery } from '../components/themes/themes-gallery';
6
7
  import { themes as themeRegistry } from '../lib/themes';
@@ -10,15 +11,13 @@ export function ThemesGalleryPage() {
10
11
  const t = useLocale();
11
12
  return (
12
13
  <>
13
- <header className="mb-8 md:mb-12">
14
- <div className="flex flex-wrap items-center gap-3">
15
- <FolderIconChip icon={{ type: 'emoji', value: '🎨' }} className="size-7 text-2xl" />
16
- <h1 className="font-heading text-[32px] font-semibold leading-[1.05] tracking-[-0.025em] md:text-[44px]">
14
+ <header className="mb-6 md:mb-8">
15
+ <div className="flex flex-wrap items-center gap-2.5">
16
+ <SystemViewIcon kind="themes" className="text-muted-foreground" />
17
+ <h1 className="font-heading text-[19px] font-semibold leading-none tracking-[-0.015em] md:text-[21px]">
17
18
  {t.themes.title}
18
19
  </h1>
19
- <span className="folio ml-1 self-end pb-2">
20
- {themeRegistry.length.toString().padStart(2, '0')}
21
- </span>
20
+ <span className="folio ml-0.5">{pad2(themeRegistry.length)}</span>
22
21
  </div>
23
22
  </header>
24
23
  <ThemesGallery onOpen={(id) => navigate(`/themes/${encodeURIComponent(id)}`)} />