@open-slide/core 2.0.1 → 2.2.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.
Files changed (57) hide show
  1. package/dist/{build-DOgOEZZA.js → build-DTmKJyjX.js} +1 -1
  2. package/dist/cli/bin.js +4 -4
  3. package/dist/{config-hT1o6Jct.js → config-Ces2X_3T.js} +159 -17
  4. package/dist/{config-GMR1QUlM.d.ts → config-CpmGqpQi.d.ts} +1 -1
  5. package/dist/{dev-_YkLNJRt.js → dev-ldYag-pR.js} +1 -1
  6. package/dist/index.d.ts +2 -2
  7. package/dist/index.js +4 -3
  8. package/dist/locale/index.d.ts +5 -2
  9. package/dist/locale/index.js +2 -2
  10. package/dist/{preview-pABcGTQh.js → preview-GYMbZvvk.js} +1 -1
  11. package/dist/{types-BcbaKTNY.d.ts → types-CvAqFqsY.d.ts} +10 -5
  12. package/dist/{update-moCkSyvg.js → update-CPBitJQq.js} +24 -14
  13. package/dist/vite/index.d.ts +1 -1
  14. package/dist/vite/index.js +1 -1
  15. package/dist/{zh-tw-DlZoAc2-.js → zh-tw-B7_Oqv2q.js} +550 -17
  16. package/package.json +3 -3
  17. package/skills/apply-comments/SKILL.md +10 -6
  18. package/skills/create-slide/SKILL.md +2 -0
  19. package/skills/current-slide/SKILL.md +1 -0
  20. package/skills/slide-authoring/SKILL.md +31 -1
  21. package/src/app/app.tsx +2 -0
  22. package/src/app/assets/open-slide.svg +39 -0
  23. package/src/app/components/command/command-menu.tsx +1 -3
  24. package/src/app/components/history-provider.tsx +25 -3
  25. package/src/app/components/icon-switcher-indicator.tsx +1 -1
  26. package/src/app/components/inspector/comment-layer.tsx +992 -0
  27. package/src/app/components/inspector/inspect-overlay.tsx +2 -39
  28. package/src/app/components/inspector/inspector-panel.tsx +9 -92
  29. package/src/app/components/inspector/inspector-provider.tsx +299 -67
  30. package/src/app/components/panel/editor-sidebar.tsx +1 -1
  31. package/src/app/components/panel/save-card.tsx +6 -2
  32. package/src/app/components/preview-step-host.tsx +16 -0
  33. package/src/app/components/sidebar/sidebar.tsx +2 -2
  34. package/src/app/components/slide-transition-layer.tsx +1 -1
  35. package/src/app/components/style-panel/style-panel.tsx +3 -2
  36. package/src/app/components/thumbnail-rail.tsx +76 -1
  37. package/src/app/favicon.ico +0 -0
  38. package/src/app/favicon.svg +39 -0
  39. package/src/app/index.html +2 -1
  40. package/src/app/lib/inspector/freeze-motion.ts +61 -0
  41. package/src/app/lib/inspector/use-comments.ts +32 -3
  42. package/src/app/lib/keys.ts +3 -0
  43. package/src/app/lib/locale-store.ts +6 -1
  44. package/src/app/lib/print-ready.ts +9 -6
  45. package/src/app/routes/presenter.tsx +1 -16
  46. package/src/app/routes/preview.tsx +169 -0
  47. package/src/app/routes/slide.tsx +119 -70
  48. package/src/app/styles.css +64 -80
  49. package/src/locale/en.ts +7 -4
  50. package/src/locale/es.ts +550 -0
  51. package/src/locale/index.ts +1 -0
  52. package/src/locale/ja.ts +7 -5
  53. package/src/locale/types.ts +10 -5
  54. package/src/locale/zh-cn.ts +7 -4
  55. package/src/locale/zh-tw.ts +7 -4
  56. package/src/app/assets/open-slide.png +0 -0
  57. package/src/app/components/inspector/comment-widget.tsx +0 -119
@@ -197,12 +197,13 @@ export function DesignToggleButton({
197
197
  size="sm"
198
198
  variant={active ? 'default' : 'ghost'}
199
199
  onClick={onToggle}
200
+ aria-label={t.stylePanel.designToggle}
200
201
  data-design-ui
201
202
  title={t.stylePanel.designToggleTitle}
202
203
  >
203
204
  <Palette className="size-3.5" />
204
- <span className="hidden md:inline">{t.stylePanel.designToggle}</span>
205
- <kbd className="ml-1 hidden rounded-[3px] bg-foreground/10 px-1 font-mono text-[9.5px] tracking-[0.04em] md:inline">
205
+ <span className="hidden lg:inline">{t.stylePanel.designToggle}</span>
206
+ <kbd className="ml-1 hidden rounded-[3px] bg-foreground/10 px-1 font-mono text-[9.5px] tracking-[0.04em] lg:inline">
206
207
  D
207
208
  </kbd>
208
209
  </Button>
@@ -26,6 +26,7 @@ import {
26
26
  Trash2,
27
27
  } from 'lucide-react';
28
28
  import { Fragment, useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react';
29
+ import { useOptionalInspector } from '@/components/inspector/inspector-provider';
29
30
  import { Button } from '@/components/ui/button';
30
31
  import {
31
32
  ContextMenu,
@@ -36,7 +37,7 @@ import {
36
37
  } from '@/components/ui/context-menu';
37
38
  import { ScrollArea } from '@/components/ui/scroll-area';
38
39
  import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip';
39
- import { format, useLocale } from '@/lib/use-locale';
40
+ import { format, plural, useLocale } from '@/lib/use-locale';
40
41
  import { cn, pad2 } from '@/lib/utils';
41
42
  import type { DesignSystem } from '../lib/design';
42
43
  import { SlidePageProvider } from '../lib/page-context';
@@ -74,6 +75,36 @@ type Props = {
74
75
  onOverview?: () => void;
75
76
  };
76
77
 
78
+ // Per-page pending comment counts, shown on the rail only while the
79
+ // comment tool is active.
80
+ function usePageCommentCounts(): Map<number, number> | null {
81
+ const inspector = useOptionalInspector();
82
+ if (!inspector?.commentMode) return null;
83
+ const counts = new Map<number, number>();
84
+ for (const comment of inspector.comments) {
85
+ if (comment.page === undefined) continue;
86
+ counts.set(comment.page, (counts.get(comment.page) ?? 0) + 1);
87
+ }
88
+ return counts;
89
+ }
90
+
91
+ function CommentCountBadge({ count, className }: { count: number; className?: string }) {
92
+ const t = useLocale();
93
+ return (
94
+ <span
95
+ role="img"
96
+ aria-label={format(plural(count, t.inspector.commentsCount), { count })}
97
+ data-page-comments={count}
98
+ className={cn(
99
+ 'flex h-4 min-w-4 items-center justify-center rounded-full bg-brand px-1 font-mono text-[9.5px] font-semibold leading-none text-brand-foreground tabular-nums',
100
+ className,
101
+ )}
102
+ >
103
+ {count}
104
+ </span>
105
+ );
106
+ }
107
+
77
108
  const DEFAULT_VERTICAL_THUMB_WIDTH = 184;
78
109
  const VERTICAL_RAIL_CHROME = 80;
79
110
  const MIN_VERTICAL_THUMB_WIDTH = 120;
@@ -103,6 +134,7 @@ export function ThumbnailRail({
103
134
  const virtualListRef = useRef<HTMLDivElement | null>(null);
104
135
  const verticalViewportRef = useRef<HTMLElement | null>(null);
105
136
  const focusCurrentAfterScrollRef = useRef(false);
137
+ const focusAfterArrowRef = useRef(false);
106
138
  const [currentPosition, setCurrentPosition] = useState<ThumbnailOffscreenDirection>(null);
107
139
  const t = useLocale();
108
140
 
@@ -172,6 +204,32 @@ export function ThumbnailRail({
172
204
  return () => cancelAnimationFrame(frame);
173
205
  }, [currentPosition]);
174
206
 
207
+ useLayoutEffect(() => {
208
+ if (!focusAfterArrowRef.current || !activeRef.current) return;
209
+ activeRef.current.focus({ preventScroll: true });
210
+ focusAfterArrowRef.current = false;
211
+ });
212
+
213
+ const onThumbnailArrowKeyDown = useCallback(
214
+ (event: React.KeyboardEvent<HTMLButtonElement>, index: number) => {
215
+ if (event.altKey || event.ctrlKey || event.metaKey || event.nativeEvent.isComposing) return;
216
+ const direction =
217
+ event.key === 'ArrowRight' || event.key === 'ArrowDown'
218
+ ? 1
219
+ : event.key === 'ArrowLeft' || event.key === 'ArrowUp'
220
+ ? -1
221
+ : 0;
222
+ if (!direction) return;
223
+ event.preventDefault();
224
+ event.stopPropagation();
225
+ const next = Math.min(Math.max(index + direction, 0), pages.length - 1);
226
+ if (next === index) return;
227
+ focusAfterArrowRef.current = true;
228
+ onSelect(next);
229
+ },
230
+ [onSelect, pages.length],
231
+ );
232
+
175
233
  const renderThumb = useCallback(
176
234
  (PageComp: Page, i: number) => {
177
235
  const active = i === current;
@@ -195,6 +253,7 @@ export function ThumbnailRail({
195
253
  active={active}
196
254
  activeRef={active ? activeRef : undefined}
197
255
  onSelect={() => onSelect(i)}
256
+ onArrowKeyDown={(event) => onThumbnailArrowKeyDown(event, i)}
198
257
  ariaLabel={format(t.thumbnailRail.goToPageAria, { n: i + 1 })}
199
258
  >
200
259
  {inner}
@@ -204,6 +263,7 @@ export function ThumbnailRail({
204
263
  type="button"
205
264
  ref={active ? activeRef : undefined}
206
265
  onClick={() => onSelect(i)}
266
+ onKeyDown={(event) => onThumbnailArrowKeyDown(event, i)}
207
267
  aria-label={format(t.thumbnailRail.goToPageAria, { n: i + 1 })}
208
268
  aria-current={active ? 'page' : undefined}
209
269
  className={thumbButtonClass(active)}
@@ -235,6 +295,7 @@ export function ThumbnailRail({
235
295
  moduleTransition,
236
296
  onReorder,
237
297
  onSelect,
298
+ onThumbnailArrowKeyDown,
238
299
  pages.length,
239
300
  scale,
240
301
  thumbWidth,
@@ -256,6 +317,7 @@ export function ThumbnailRail({
256
317
  actions={actions}
257
318
  activeRef={activeRef}
258
319
  onSelect={onSelect}
320
+ onArrowKeyDown={onThumbnailArrowKeyDown}
259
321
  scale={scale}
260
322
  thumbWidth={horizontalWidth}
261
323
  />
@@ -411,6 +473,7 @@ function HorizontalVirtualThumbList({
411
473
  actions,
412
474
  activeRef,
413
475
  onSelect,
476
+ onArrowKeyDown,
414
477
  scale,
415
478
  thumbWidth,
416
479
  }: {
@@ -420,6 +483,7 @@ function HorizontalVirtualThumbList({
420
483
  actions?: ThumbnailActions;
421
484
  activeRef: React.MutableRefObject<HTMLButtonElement | null>;
422
485
  onSelect: (index: number) => void;
486
+ onArrowKeyDown: (event: React.KeyboardEvent<HTMLButtonElement>, index: number) => void;
423
487
  scale: number;
424
488
  thumbWidth: number;
425
489
  }) {
@@ -489,15 +553,18 @@ function HorizontalVirtualThumbList({
489
553
  }, [current, itemWidth, pages.length, thumbWidth]);
490
554
 
491
555
  const visibleRange = clampVisibleRange(range, current, pages.length);
556
+ const commentCounts = usePageCommentCounts();
492
557
  const visible = [];
493
558
  for (let i = visibleRange.start; i < visibleRange.end; i++) {
494
559
  const PageComp = pages[i];
495
560
  const active = i === current;
561
+ const commentCount = commentCounts?.get(i) ?? 0;
496
562
  const button = (
497
563
  <button
498
564
  type="button"
499
565
  ref={active ? activeRef : undefined}
500
566
  onClick={() => onSelect(i)}
567
+ onKeyDown={(event) => onArrowKeyDown(event, i)}
501
568
  aria-label={format(t.thumbnailRail.goToPageAria, { n: i + 1 })}
502
569
  aria-current={active ? 'page' : undefined}
503
570
  className={cn(
@@ -528,6 +595,9 @@ function HorizontalVirtualThumbList({
528
595
  </SlidePageProvider>
529
596
  </SlideCanvas>
530
597
  </div>
598
+ {commentCount > 0 && (
599
+ <CommentCountBadge count={commentCount} className="absolute -top-0.5 -right-1" />
600
+ )}
531
601
  </button>
532
602
  );
533
603
 
@@ -764,6 +834,7 @@ function ThumbContents({
764
834
  }, [PageComp]);
765
835
 
766
836
  const hasTransition = Boolean(PageComp.transition ?? moduleTransition);
837
+ const commentCount = usePageCommentCounts()?.get(index) ?? 0;
767
838
 
768
839
  return (
769
840
  <>
@@ -776,6 +847,7 @@ function ThumbContents({
776
847
  >
777
848
  {pad2(index + 1)}
778
849
  </span>
850
+ {commentCount > 0 && <CommentCountBadge count={commentCount} />}
779
851
  {(hasTransition || hasSteps) && (
780
852
  <div className="flex flex-col items-end gap-0.5">
781
853
  {hasTransition && (
@@ -921,6 +993,7 @@ function SortableThumb({
921
993
  active,
922
994
  activeRef,
923
995
  onSelect,
996
+ onArrowKeyDown,
924
997
  ariaLabel,
925
998
  children,
926
999
  ...rest
@@ -929,6 +1002,7 @@ function SortableThumb({
929
1002
  active: boolean;
930
1003
  activeRef: React.MutableRefObject<HTMLButtonElement | null> | undefined;
931
1004
  onSelect: () => void;
1005
+ onArrowKeyDown: React.KeyboardEventHandler<HTMLButtonElement>;
932
1006
  ariaLabel: string;
933
1007
  children: React.ReactNode;
934
1008
  } & Omit<
@@ -953,6 +1027,7 @@ function SortableThumb({
953
1027
  ref={setRef}
954
1028
  type="button"
955
1029
  onClick={onSelect}
1030
+ onKeyDownCapture={isDragging ? undefined : onArrowKeyDown}
956
1031
  aria-label={ariaLabel}
957
1032
  aria-current={active ? 'page' : undefined}
958
1033
  style={{
Binary file
@@ -0,0 +1,39 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="512" height="512" viewBox="0 0 512 512" fill="none">
2
+ <defs>
3
+ <linearGradient id="tile" x1="256" y1="16" x2="256" y2="496" gradientUnits="userSpaceOnUse">
4
+ <stop offset="0" stop-color="#FFFFFF"/>
5
+ <stop offset="1" stop-color="#EFEBE6"/>
6
+ </linearGradient>
7
+ <linearGradient id="tile-edge" x1="256" y1="16" x2="256" y2="496" gradientUnits="userSpaceOnUse">
8
+ <stop offset="0" stop-color="#FFFFFF"/>
9
+ <stop offset="0.5" stop-color="#FFFFFF" stop-opacity="0"/>
10
+ <stop offset="1" stop-color="#000000" stop-opacity="0.08"/>
11
+ </linearGradient>
12
+ <linearGradient id="slide" x1="256" y1="172" x2="256" y2="340" gradientUnits="userSpaceOnUse">
13
+ <stop offset="0" stop-color="#FF8A5E"/>
14
+ <stop offset="0.45" stop-color="#FE5226"/>
15
+ <stop offset="1" stop-color="#EE4316"/>
16
+ </linearGradient>
17
+ <linearGradient id="slide-edge" x1="256" y1="172" x2="256" y2="340" gradientUnits="userSpaceOnUse">
18
+ <stop offset="0" stop-color="#FFFFFF" stop-opacity="0.55"/>
19
+ <stop offset="0.35" stop-color="#FFFFFF" stop-opacity="0"/>
20
+ <stop offset="0.8" stop-color="#B8300C" stop-opacity="0"/>
21
+ <stop offset="1" stop-color="#B8300C" stop-opacity="0.5"/>
22
+ </linearGradient>
23
+ <radialGradient id="slide-sheen" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(196 184) rotate(32) scale(200 110)">
24
+ <stop offset="0" stop-color="#FFFFFF" stop-opacity="0.26"/>
25
+ <stop offset="1" stop-color="#FFFFFF" stop-opacity="0"/>
26
+ </radialGradient>
27
+ <filter id="lift" x="60" y="140" width="392" height="260" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
28
+ <feDropShadow dx="0" dy="18" stdDeviation="16" flood-color="#FE5226" flood-opacity="0.32"/>
29
+ <feDropShadow dx="0" dy="3" stdDeviation="3" flood-color="#8A2306" flood-opacity="0.22"/>
30
+ </filter>
31
+ </defs>
32
+ <rect x="16" y="16" width="480" height="480" rx="112" fill="url(#tile)"/>
33
+ <rect x="17.5" y="17.5" width="477" height="477" rx="110.5" stroke="url(#tile-edge)" stroke-width="3"/>
34
+ <g filter="url(#lift)">
35
+ <rect x="112" y="172" width="288" height="168" rx="34" fill="url(#slide)"/>
36
+ </g>
37
+ <rect x="112" y="172" width="288" height="168" rx="34" fill="url(#slide-sheen)"/>
38
+ <rect x="113.5" y="173.5" width="285" height="165" rx="32.5" stroke="url(#slide-edge)" stroke-width="3"/>
39
+ </svg>
@@ -2,7 +2,8 @@
2
2
  <html lang="en">
3
3
  <head>
4
4
  <meta charset="UTF-8" />
5
- <link rel="icon" href="./favicon.ico" />
5
+ <link rel="icon" href="./favicon.ico" sizes="32x32" />
6
+ <link rel="icon" href="./favicon.svg" type="image/svg+xml" />
6
7
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
8
  <title>open-slide</title>
8
9
  <style>
@@ -0,0 +1,61 @@
1
+ import { useEffect } from 'react';
2
+
3
+ export type FreezeMode = 'edit' | 'comment';
4
+
5
+ // Pauses slide animations and transitions while an overlay measures and
6
+ // hit-tests the canvas, so element rects stay put under the pointer.
7
+ export function useFreezeSlideMotion(mode: FreezeMode | null): void {
8
+ useEffect(() => {
9
+ if (!mode) return;
10
+ const root = document.querySelector<HTMLElement>('[data-inspector-root]');
11
+ if (!root) return;
12
+ const style = document.createElement('style');
13
+ style.textContent = FREEZE_CSS;
14
+ document.head.appendChild(style);
15
+ root.dataset.inspectorEditing = mode;
16
+ return () => {
17
+ style.remove();
18
+ delete root.dataset.inspectorEditing;
19
+ };
20
+ }, [mode]);
21
+ }
22
+
23
+ // A speech-bubble pin with its tip at the bottom-left corner; the hotspot
24
+ // sits on that tip so the pointer "stamps" where the comment will land.
25
+ const COMMENT_CURSOR_SVG = [
26
+ "<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'>",
27
+ "<path d='M12 3a9 9 0 0 1 9 9a9 9 0 0 1-9 9H5a2 2 0 0 1-2-2v-7a9 9 0 0 1 9-9z' ",
28
+ "fill='#fff' stroke='#111' stroke-width='1.5' stroke-linejoin='round'/></svg>",
29
+ ].join('');
30
+ const COMMENT_CURSOR = `url("data:image/svg+xml;utf8,${encodeURIComponent(COMMENT_CURSOR_SVG)}") 3 21, crosshair`;
31
+
32
+ const FREEZE_CSS = `
33
+ [data-inspector-editing] { touch-action: none; }
34
+ [data-inspector-editing] *:not([data-inspector-ui], [data-inspector-ui] *),
35
+ [data-inspector-editing] *:not([data-inspector-ui], [data-inspector-ui] *)::before,
36
+ [data-inspector-editing] *:not([data-inspector-ui], [data-inspector-ui] *)::after {
37
+ animation-duration: 1ms !important;
38
+ animation-delay: 0s !important;
39
+ animation-iteration-count: 1 !important;
40
+ animation-fill-mode: forwards !important;
41
+ transition: none !important;
42
+ view-transition-name: none !important;
43
+ user-select: none;
44
+ }
45
+ [data-inspector-editing] *:not([data-inspector-ui], [data-inspector-ui] *, [data-visual-gesture], [data-visual-gesture] *),
46
+ [data-inspector-editing] *:not([data-inspector-ui], [data-inspector-ui] *, [data-visual-gesture], [data-visual-gesture] *)::before,
47
+ [data-inspector-editing] *:not([data-inspector-ui], [data-inspector-ui] *, [data-visual-gesture], [data-visual-gesture] *)::after {
48
+ cursor: default !important;
49
+ }
50
+ [data-inspector-editing] [data-visual-gesture],
51
+ [data-inspector-editing] [data-visual-gesture] *,
52
+ [data-inspector-editing] [data-visual-gesture] *::before,
53
+ [data-inspector-editing] [data-visual-gesture] *::after {
54
+ cursor: var(--osd-gesture-cursor, default) !important;
55
+ }
56
+ [data-inspector-editing="comment"] *:not([data-inspector-ui], [data-inspector-ui] *),
57
+ [data-inspector-editing="comment"] *:not([data-inspector-ui], [data-inspector-ui] *)::before,
58
+ [data-inspector-editing="comment"] *:not([data-inspector-ui], [data-inspector-ui] *)::after {
59
+ cursor: ${COMMENT_CURSOR} !important;
60
+ }
61
+ `;
@@ -1,11 +1,24 @@
1
1
  import { useCallback, useEffect, useState } from 'react';
2
2
 
3
+ export type CommentRect = { x: number; y: number; w: number; h: number };
4
+
3
5
  export type SlideComment = {
4
6
  id: string;
5
7
  line: number;
6
8
  ts: string;
7
9
  note: string;
8
10
  hint?: string;
11
+ rect?: CommentRect;
12
+ page?: number;
13
+ target?: { line: number; column: number } | null;
14
+ };
15
+
16
+ export type AddCommentInput = {
17
+ line: number;
18
+ column: number;
19
+ text: string;
20
+ rect?: CommentRect;
21
+ page?: number;
9
22
  };
10
23
 
11
24
  type ListResponse = { comments: SlideComment[] };
@@ -31,11 +44,11 @@ export function useComments(slideId: string) {
31
44
  }, [slideId]);
32
45
 
33
46
  const add = useCallback(
34
- async (line: number, column: number, text: string) => {
47
+ async (input: AddCommentInput) => {
35
48
  const res = await fetch('/__comments/add', {
36
49
  method: 'POST',
37
50
  headers: { 'content-type': 'application/json' },
38
- body: JSON.stringify({ slideId, line, column, text }),
51
+ body: JSON.stringify({ slideId, ...input }),
39
52
  });
40
53
  if (!res.ok) {
41
54
  const body = (await res.json().catch(() => ({}))) as { error?: string };
@@ -46,6 +59,22 @@ export function useComments(slideId: string) {
46
59
  [slideId, refetch],
47
60
  );
48
61
 
62
+ const update = useCallback(
63
+ async (id: string, text: string) => {
64
+ const res = await fetch(`/__comments/${id}`, {
65
+ method: 'PUT',
66
+ headers: { 'content-type': 'application/json' },
67
+ body: JSON.stringify({ slideId, text }),
68
+ });
69
+ if (!res.ok) {
70
+ const body = (await res.json().catch(() => ({}))) as { error?: string };
71
+ throw new Error(body.error ?? `PUT /__comments/${id} → ${res.status}`);
72
+ }
73
+ await refetch();
74
+ },
75
+ [slideId, refetch],
76
+ );
77
+
49
78
  const remove = useCallback(
50
79
  async (id: string) => {
51
80
  const res = await fetch(`/__comments/${id}?slideId=${encodeURIComponent(slideId)}`, {
@@ -70,5 +99,5 @@ export function useComments(slideId: string) {
70
99
  };
71
100
  }, [refetch]);
72
101
 
73
- return { comments, error, add, remove };
102
+ return { comments, error, add, update, remove };
74
103
  }
@@ -1,3 +1,6 @@
1
+ export const IS_APPLE =
2
+ typeof navigator !== 'undefined' && /Mac|iPhone|iPad|iPod/.test(navigator.userAgent);
3
+
1
4
  export function isTypingTarget(target: EventTarget | null): boolean {
2
5
  return (
3
6
  target instanceof HTMLElement && (target.isContentEditable || target.matches('input, textarea'))
@@ -1,6 +1,7 @@
1
1
  import config from 'virtual:open-slide/config';
2
2
  import { useSyncExternalStore } from 'react';
3
3
  import { en } from '../../locale/en';
4
+ import { es } from '../../locale/es';
4
5
  import { ja } from '../../locale/ja';
5
6
  import type { Locale } from '../../locale/types';
6
7
  import { zhCN } from '../../locale/zh-cn';
@@ -13,6 +14,7 @@ const LOCALES: Record<LocaleId, Locale> = {
13
14
  'zh-TW': zhTW,
14
15
  'zh-CN': zhCN,
15
16
  ja,
17
+ es,
16
18
  };
17
19
 
18
20
  export const LOCALE_OPTIONS: ReadonlyArray<{ id: LocaleId; label: string }> = [
@@ -20,13 +22,16 @@ export const LOCALE_OPTIONS: ReadonlyArray<{ id: LocaleId; label: string }> = [
20
22
  { id: 'zh-TW', label: '繁體中文' },
21
23
  { id: 'zh-CN', label: '简体中文' },
22
24
  { id: 'ja', label: '日本語' },
25
+ { id: 'es', label: 'Español' },
23
26
  ];
24
27
 
25
28
  const STORAGE_KEY = 'open-slide:locale';
26
29
  const configLocale = config.locale as Locale | undefined;
27
30
 
28
31
  function isLocaleId(value: string | null): value is LocaleId {
29
- return value === 'en' || value === 'zh-TW' || value === 'zh-CN' || value === 'ja';
32
+ return (
33
+ value === 'en' || value === 'zh-TW' || value === 'zh-CN' || value === 'ja' || value === 'es'
34
+ );
30
35
  }
31
36
 
32
37
  function readStored(): Locale {
@@ -11,27 +11,30 @@ export async function waitForFonts(): Promise<void> {
11
11
  await document.fonts.ready;
12
12
  }
13
13
 
14
+ // Resolves false when any target was still missing at the deadline.
14
15
  export async function waitForDataWaitfor(
15
16
  root: HTMLElement,
16
17
  timeoutMs = DEFAULT_WAITFOR_TIMEOUT_MS,
17
- ): Promise<void> {
18
+ ): Promise<boolean> {
18
19
  const targets = Array.from(root.querySelectorAll<HTMLElement>('[data-waitfor]'));
19
- if (targets.length === 0) return;
20
+ if (targets.length === 0) return true;
20
21
  const deadline = performance.now() + timeoutMs;
21
- await Promise.all(
22
+ const results = await Promise.all(
22
23
  targets.map(async (el) => {
23
24
  const selector = el.getAttribute('data-waitfor');
24
- if (!selector) return;
25
+ if (!selector) return true;
25
26
  while (performance.now() < deadline) {
26
27
  try {
27
- if (el.querySelector(selector)) return;
28
+ if (el.querySelector(selector)) return true;
28
29
  } catch {
29
- return; // invalid selector — skip rather than hang
30
+ return true; // invalid selector — skip rather than hang
30
31
  }
31
32
  await nextFrame();
32
33
  }
34
+ return false;
33
35
  }),
34
36
  );
37
+ return results.every(Boolean);
35
38
  }
36
39
 
37
40
  export function isFrameAnimationSettled(frame: Element): boolean {
@@ -11,7 +11,6 @@ import {
11
11
  } from 'lucide-react';
12
12
  import {
13
13
  type KeyboardEvent as ReactKeyboardEvent,
14
- type ReactNode,
15
14
  useCallback,
16
15
  useEffect,
17
16
  useRef,
@@ -29,12 +28,12 @@ import {
29
28
  type PresenterState,
30
29
  usePresenterChannel,
31
30
  } from '../components/present/use-presenter-channel';
31
+ import { PreviewStepHost } from '../components/preview-step-host';
32
32
  import { SlideCanvas } from '../components/slide-canvas';
33
33
  import { isDeckWarmed, markDeckWarmed, SlidePreloadLayer } from '../components/slide-preload-layer';
34
34
  import { SlidePageProvider } from '../lib/page-context';
35
35
  import { CANVAS_HEIGHT, CANVAS_WIDTH, type SlideModule } from '../lib/sdk';
36
36
  import { loadSlide, slideIds } from '../lib/slides';
37
- import { type StepController, StepHost } from '../lib/step-context';
38
37
  import { useSlideModule } from '../lib/use-slide-module';
39
38
 
40
39
  export function Presenter() {
@@ -653,20 +652,6 @@ function SectionLabel({ children }: { children: React.ReactNode }) {
653
652
  return <span className="eyebrow">{children}</span>;
654
653
  }
655
654
 
656
- function PreviewStepHost({ revealed, children }: { revealed: number; children: ReactNode }) {
657
- const noopControllerRef = useRef<StepController | null>(null);
658
- return (
659
- <StepHost
660
- isActivePage={false}
661
- entryDirection="jump"
662
- controllerRef={noopControllerRef}
663
- controlledRevealed={revealed}
664
- >
665
- {children}
666
- </StepHost>
667
- );
668
- }
669
-
670
655
  function Clock() {
671
656
  const [now, setNow] = useState(() => new Date());
672
657
  const t = useLocale();