@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
@@ -1,4 +1,4 @@
1
- import { Eye, PanelRight, Pencil } from 'lucide-react';
1
+ import { Eye, MessageSquare, PanelRight, Pencil } from 'lucide-react';
2
2
  import {
3
3
  createContext,
4
4
  type ReactNode,
@@ -12,20 +12,22 @@ import {
12
12
  import { toast } from 'sonner';
13
13
  import { useHistory } from '@/components/history-provider';
14
14
  import { IconSwitcherIndicator } from '@/components/icon-switcher-indicator';
15
+ import { IconTooltip } from '@/components/icon-tooltip';
15
16
  import { Button } from '@/components/ui/button';
16
17
  import { ToggleGroup, ToggleGroupItem } from '@/components/ui/toggle-group';
18
+ import { TooltipTrigger } from '@/components/ui/tooltip';
17
19
  import { findSlideSource } from '@/lib/inspector/fiber';
18
20
  import {
19
21
  appendTextEdit,
20
22
  type TextEditOp,
21
23
  type TextEditStep,
22
24
  } from '@/lib/inspector/text-edit-timeline';
23
- import { type SlideComment, useComments } from '@/lib/inspector/use-comments';
25
+ import { type AddCommentInput, type SlideComment, useComments } from '@/lib/inspector/use-comments';
24
26
  import { type Edit, type EditOp, useEditor } from '@/lib/inspector/use-editor';
25
27
  import { useVisualEditor, type VisualEdit } from '@/lib/inspector/use-visual-editor';
26
28
  import { isShortcutControlTarget, isTypingTarget } from '@/lib/keys';
27
29
  import { textDiff } from '@/lib/text-diff';
28
- import { useLocale } from '@/lib/use-locale';
30
+ import { format, plural, useLocale } from '@/lib/use-locale';
29
31
  import { round2 } from '@/lib/utils';
30
32
  import { AssetPickerDialog } from './asset-picker-dialog';
31
33
  import { ImageCropDialog, type ImageCropRect } from './image-crop-dialog';
@@ -37,25 +39,80 @@ export type SelectedTarget = {
37
39
  canvasPath?: number[];
38
40
  };
39
41
 
40
- function rememberTarget(target: SelectedTarget): SelectedTarget {
41
- const root = target.anchor.closest('[data-osd-canvas]');
42
- if (!root) return target;
42
+ const INSTANCE_ID_ATTR = 'data-slide-instance-id';
43
+
44
+ function elementPath(root: Element, el: Element): number[] | null {
43
45
  const path: number[] = [];
44
- for (let node: Element | null = target.anchor; node && node !== root; node = node.parentElement) {
45
- const parent: Element | null = node.parentElement;
46
- if (!parent) return target;
46
+ for (let node = el; node !== root; ) {
47
+ const parent = node.parentElement;
48
+ if (!parent) return null;
47
49
  path.unshift(Array.from(parent.children).indexOf(node));
50
+ node = parent;
48
51
  }
49
- return { ...target, canvasPath: path };
52
+ return path;
50
53
  }
51
54
 
52
- function findRememberedTarget(root: HTMLElement, path?: number[]): HTMLElement | null {
53
- let node = root.querySelector('[data-osd-canvas]');
54
- if (!path) return null;
55
+ function elementAtPath(root: Element | null, path: number[]): HTMLElement | null {
56
+ let node = root;
55
57
  for (const index of path) node = node?.children[index] ?? null;
56
58
  return node instanceof HTMLElement ? node : null;
57
59
  }
58
60
 
61
+ function rememberTarget(target: SelectedTarget): SelectedTarget {
62
+ const root = target.anchor.closest('[data-osd-canvas]');
63
+ const path = root && elementPath(root, target.anchor);
64
+ return path ? { ...target, canvasPath: path } : target;
65
+ }
66
+
67
+ function findRememberedTarget(root: HTMLElement, path?: number[]): HTMLElement | null {
68
+ if (!path) return null;
69
+ return elementAtPath(root.querySelector('[data-osd-canvas]'), path);
70
+ }
71
+
72
+ // Enough to find an edited element again after its page remounts. The path is
73
+ // relative to the page layer, since an outgoing page shifts canvas-level paths.
74
+ type RevealTarget = {
75
+ line: number;
76
+ column: number;
77
+ anchor: HTMLElement;
78
+ tagName: string;
79
+ pagePath: number[] | null;
80
+ instanceId: string | null;
81
+ };
82
+
83
+ // Only the incoming layer carries it: an interrupted transition relabels and
84
+ // remounts the outgoing one, so anything found there goes stale.
85
+ const PAGE_LAYER_ATTR = 'data-osd-current-page';
86
+
87
+ function captureRevealTarget(target: SelectedTarget): RevealTarget {
88
+ const layer = target.anchor.closest(`[${PAGE_LAYER_ATTR}]`);
89
+ return {
90
+ line: target.line,
91
+ column: target.column,
92
+ anchor: target.anchor,
93
+ tagName: target.anchor.tagName,
94
+ pagePath: layer && elementPath(layer, target.anchor),
95
+ instanceId: target.anchor.getAttribute(INSTANCE_ID_ATTR),
96
+ };
97
+ }
98
+
99
+ function locateRevealTarget(layer: Element, target: RevealTarget): HTMLElement | null {
100
+ if (target.anchor.isConnected && layer.contains(target.anchor)) return target.anchor;
101
+ if (target.instanceId) {
102
+ const stamped = layer.querySelector<HTMLElement>(
103
+ `[${INSTANCE_ID_ATTR}="${target.instanceId}"]`,
104
+ );
105
+ if (stamped) return stamped;
106
+ }
107
+ const byPath = target.pagePath && elementAtPath(layer, target.pagePath);
108
+ if (byPath?.tagName === target.tagName) return byPath;
109
+ return layer.querySelector<HTMLElement>(`[data-slide-loc="${target.line}:${target.column}"]`);
110
+ }
111
+
112
+ function sameAnchors(a: SelectedTarget[], b: SelectedTarget[]): boolean {
113
+ return a.length === b.length && a.every((target, index) => target.anchor === b[index].anchor);
114
+ }
115
+
59
116
  export type InlineEditTarget = SelectedTarget & {
60
117
  point?: { x: number; y: number };
61
118
  // Double-click entry selects the word under the caret; a single-click
@@ -107,8 +164,6 @@ function createBucket(line: number, column: number): Bucket {
107
164
  };
108
165
  }
109
166
 
110
- const INSTANCE_ID_ATTR = 'data-slide-instance-id';
111
-
112
167
  export type DomTextPart = {
113
168
  node: Text | HTMLBRElement;
114
169
  current: string;
@@ -314,9 +369,17 @@ function replayDomTextEdits(el: HTMLElement, snapshot: TextDomSnapshot, steps: T
314
369
  if (el.innerHTML !== next) el.innerHTML = next;
315
370
  }
316
371
 
372
+ export type InspectorMode = 'preview' | 'edit' | 'comment';
373
+
317
374
  type InspectorCtx = {
318
375
  slideId: string;
376
+ pageIndex: number;
377
+ mode: InspectorMode;
378
+ setMode: (mode: InspectorMode) => void;
379
+ // True while the visual editor owns the canvas (`mode === 'edit'`).
319
380
  active: boolean;
381
+ commentMode: boolean;
382
+ exitCommentMode: () => void;
320
383
  toggle: () => void;
321
384
  panelOpen: boolean;
322
385
  panelHidden: boolean;
@@ -324,7 +387,8 @@ type InspectorCtx = {
324
387
  cancel: () => void;
325
388
  comments: SlideComment[];
326
389
  error: string | null;
327
- add: (line: number, column: number, text: string) => Promise<void>;
390
+ add: (input: AddCommentInput) => Promise<void>;
391
+ update: (id: string, text: string) => Promise<void>;
328
392
  remove: (id: string) => Promise<void>;
329
393
  selection: SelectedTarget[];
330
394
  setSelection: (targets: SelectedTarget[]) => void;
@@ -363,6 +427,10 @@ export function useInspector(): InspectorCtx {
363
427
  return v;
364
428
  }
365
429
 
430
+ export function useOptionalInspector(): InspectorCtx | null {
431
+ return useContext(Ctx);
432
+ }
433
+
366
434
  export function InspectorProvider({
367
435
  slideId,
368
436
  pageIndex,
@@ -376,16 +444,24 @@ export function InspectorProvider({
376
444
  onPanelOpen?: () => void;
377
445
  children: ReactNode;
378
446
  }) {
379
- const [active, setActive] = useState(import.meta.env.DEV);
447
+ const [mode, setModeState] = useState<InspectorMode>(import.meta.env.DEV ? 'edit' : 'preview');
448
+ const active = mode === 'edit';
449
+ const commentMode = mode === 'comment';
450
+ // Where Esc / toggling the comment tool off returns the user to.
451
+ const modeBeforeCommentRef = useRef<Exclude<InspectorMode, 'comment'>>('preview');
380
452
  const [panelOpen, setPanelOpen] = useState(
381
453
  () => typeof window !== 'undefined' && window.innerWidth >= 1024,
382
454
  );
383
455
  const [selection, setSelectionState] = useState<SelectedTarget[]>([]);
384
456
  const selected = selection.at(-1) ?? null;
457
+ // Targets an undo/redo should select once their page is on screen.
458
+ const pendingRevealRef = useRef<{ pageIndex: number; targets: RevealTarget[] } | null>(null);
385
459
  const setSelection = useCallback((targets: SelectedTarget[]) => {
460
+ pendingRevealRef.current = null;
386
461
  setSelectionState(targets.map(rememberTarget));
387
462
  }, []);
388
463
  const setSelected = useCallback((target: SelectedTarget | null) => {
464
+ pendingRevealRef.current = null;
389
465
  setSelectionState((previous) => {
390
466
  if (!target) return [];
391
467
  const primary = previous.at(-1);
@@ -418,7 +494,7 @@ export function InspectorProvider({
418
494
  [],
419
495
  );
420
496
  const [opsVersion, setOpsVersion] = useState(0);
421
- const { comments, error, add, remove } = useComments(slideId);
497
+ const { comments, error, add, update, remove } = useComments(slideId);
422
498
  const { applyEdit, applyEdits } = useEditor(slideId);
423
499
  const history = useHistory();
424
500
 
@@ -481,6 +557,61 @@ export function InspectorProvider({
481
557
  return root.querySelector<HTMLElement>(`[data-slide-loc="${line}:${column}"]`);
482
558
  }, []);
483
559
 
560
+ const pageIndexRef = useRef(pageIndex);
561
+ pageIndexRef.current = pageIndex;
562
+ const findTextAnchor = useCallback(
563
+ (instanceId: string, target?: SelectedTarget & { pageIndex: number }) => {
564
+ const root = document.querySelector<HTMLElement>('[data-inspector-root]');
565
+ if (!root) return null;
566
+ const stamped = root.querySelector<HTMLElement>(`[${INSTANCE_ID_ATTR}="${instanceId}"]`);
567
+ if (stamped) return stamped;
568
+ // Off-page instances must not fall back to the loc: a reused component on
569
+ // the visible page shares it, and replaying this instance's HTML there
570
+ // would clobber that page's text. Their page's remount replays the buffer.
571
+ if (!target || target.pageIndex !== pageIndexRef.current) return null;
572
+ const anchor =
573
+ findRememberedTarget(root, target.canvasPath) ??
574
+ root.querySelector<HTMLElement>(`[data-slide-loc="${target.line}:${target.column}"]`);
575
+ if (!anchor || anchor.tagName !== target.anchor.tagName) return null;
576
+ anchor.setAttribute(INSTANCE_ID_ATTR, instanceId);
577
+ return anchor;
578
+ },
579
+ [],
580
+ );
581
+
582
+ const flushReveal = useCallback((): boolean => {
583
+ const pending = pendingRevealRef.current;
584
+ if (!pending) return true;
585
+ const layer = document.querySelector(
586
+ `[data-inspector-root] [${PAGE_LAYER_ATTR}="${pending.pageIndex}"]`,
587
+ );
588
+ if (!layer) return false;
589
+ const resolved: SelectedTarget[] = [];
590
+ for (const target of pending.targets) {
591
+ const anchor = locateRevealTarget(layer, target);
592
+ const hit = anchor && findSlideSource(anchor, slideId, { hostOnly: true });
593
+ if (hit && hit.anchor === anchor && !resolved.some((t) => t.anchor === anchor)) {
594
+ resolved.push(hit);
595
+ }
596
+ }
597
+ if (resolved.length === 0) return false;
598
+ pendingRevealRef.current = null;
599
+ setSelectionState((previous) =>
600
+ sameAnchors(previous, resolved) ? previous : resolved.map(rememberTarget),
601
+ );
602
+ return true;
603
+ }, [slideId]);
604
+
605
+ // Undo/redo selects what it changed. Off-page targets wait for the page
606
+ // effect below, since the page mounts a render after `pageIndex` changes.
607
+ const revealTargets = useCallback(
608
+ (targets: RevealTarget[], targetPage: number) => {
609
+ pendingRevealRef.current = { pageIndex: targetPage, targets };
610
+ if (targetPage === pageIndexRef.current && !flushReveal()) pendingRevealRef.current = null;
611
+ },
612
+ [flushReveal],
613
+ );
614
+
484
615
  // Mutate bucket + DOM without recording history. Shared by `bufferOps`
485
616
  // (the public, history-recording entry point) and by `redo` closures.
486
617
  const applyOpsRaw = useCallback(
@@ -671,8 +802,11 @@ export function InspectorProvider({
671
802
  if (sharedAnchor?.isConnected) sharedStyle[snap.key] = orig ?? '';
672
803
  }
673
804
  } else if (snap.kind === 'text') {
674
- const textAnchor = findAnchor(line, column, snap.instanceId);
675
805
  if (snap.target) bucket.textTargets.set(snap.instanceId, snap.target);
806
+ const textAnchor = findTextAnchor(
807
+ snap.instanceId,
808
+ bucket.textTargets.get(snap.instanceId),
809
+ );
676
810
  if (snap.html !== undefined) bucket.origHtmls.set(snap.instanceId, snap.html);
677
811
  if (snap.text !== undefined) bucket.origTexts.set(snap.instanceId, { value: snap.text });
678
812
  if (snap.steps.length) bucket.textEdits.set(snap.instanceId, snap.steps);
@@ -701,7 +835,7 @@ export function InspectorProvider({
701
835
  }
702
836
  refreshCount();
703
837
  },
704
- [findAnchor, refreshCount],
838
+ [findAnchor, findTextAnchor, refreshCount],
705
839
  );
706
840
 
707
841
  const bufferOps = useCallback(
@@ -733,9 +867,14 @@ export function InspectorProvider({
733
867
  : 'text'
734
868
  : 'noop';
735
869
  const coalesceKey = `inspector:${target.line}:${target.column}:${first?.kind ?? 'noop'}:${opKey}`;
870
+ const reveal = [captureRevealTarget(target)];
736
871
  history.record({
737
872
  coalesceKey,
738
- undo: () => restoreSnapshot(target.line, target.column, snaps),
873
+ pageIndex,
874
+ undo: () => {
875
+ restoreSnapshot(target.line, target.column, snaps);
876
+ revealTargets(reveal, pageIndex);
877
+ },
739
878
  redo: () => {
740
879
  if (sharedOps.length) {
741
880
  applyOpsRaw(
@@ -746,10 +885,21 @@ export function InspectorProvider({
746
885
  );
747
886
  }
748
887
  if (textAfter.length) restoreSnapshot(target.line, target.column, textAfter, true);
888
+ revealTargets(reveal, pageIndex);
749
889
  },
750
890
  });
751
891
  },
752
- [applyOpsRaw, snapshotForOps, restoreSnapshot, findAnchor, history, ensureInstanceId, slideId],
892
+ [
893
+ applyOpsRaw,
894
+ snapshotForOps,
895
+ restoreSnapshot,
896
+ findAnchor,
897
+ history,
898
+ ensureInstanceId,
899
+ slideId,
900
+ pageIndex,
901
+ revealTargets,
902
+ ],
753
903
  );
754
904
 
755
905
  const bufferBatch = useCallback(
@@ -763,21 +913,35 @@ export function InspectorProvider({
763
913
  snapshotForOps(edit.line, edit.column, edit.anchor, edit.ops),
764
914
  );
765
915
  for (const edit of edits) applyOpsRaw(edit.line, edit.column, edit.anchor, edit.ops);
916
+ const reveal = edits.map(captureRevealTarget);
766
917
  history.record({
767
918
  coalesceKey,
919
+ pageIndex,
768
920
  undo: () => {
769
921
  for (let index = edits.length - 1; index >= 0; index--) {
770
922
  const edit = edits[index];
771
923
  restoreSnapshot(edit.line, edit.column, snapshots[index]);
772
924
  }
925
+ revealTargets(reveal, pageIndex);
773
926
  },
774
927
  redo: () => {
775
928
  for (const edit of edits)
776
929
  applyOpsRaw(edit.line, edit.column, findAnchor(edit.line, edit.column), edit.ops);
930
+ revealTargets(reveal, pageIndex);
777
931
  },
778
932
  });
779
933
  },
780
- [applyOpsRaw, snapshotForOps, restoreSnapshot, findAnchor, history, committing, slideId],
934
+ [
935
+ applyOpsRaw,
936
+ snapshotForOps,
937
+ restoreSnapshot,
938
+ findAnchor,
939
+ history,
940
+ committing,
941
+ slideId,
942
+ pageIndex,
943
+ revealTargets,
944
+ ],
781
945
  );
782
946
 
783
947
  const visual = useVisualEditor({
@@ -1056,9 +1220,22 @@ export function InspectorProvider({
1056
1220
  }, [pageIndex, slideId]);
1057
1221
 
1058
1222
  useEffect(() => {
1059
- void pageIndex;
1060
- setSelected(null);
1061
- }, [pageIndex, setSelected]);
1223
+ setSelectionState([]);
1224
+ const pending = pendingRevealRef.current;
1225
+ if (!pending) return;
1226
+ if (pending.pageIndex !== pageIndex) {
1227
+ pendingRevealRef.current = null;
1228
+ return;
1229
+ }
1230
+ if (flushReveal()) return;
1231
+ const root = document.querySelector<HTMLElement>('[data-inspector-root]');
1232
+ if (!root) return;
1233
+ const observer = new MutationObserver(() => {
1234
+ if (flushReveal()) observer.disconnect();
1235
+ });
1236
+ observer.observe(root, { childList: true, subtree: true });
1237
+ return () => observer.disconnect();
1238
+ }, [pageIndex, flushReveal]);
1062
1239
 
1063
1240
  useEffect(() => {
1064
1241
  if (!selection.length) return;
@@ -1094,19 +1271,32 @@ export function InspectorProvider({
1094
1271
  return () => observer.disconnect();
1095
1272
  }, [selection, setSelection, slideId]);
1096
1273
 
1274
+ const setMode = useCallback(
1275
+ (next: InspectorMode) => {
1276
+ if (next === mode) return;
1277
+ if (next === 'comment' && mode !== 'comment') modeBeforeCommentRef.current = mode;
1278
+ if (mode === 'edit') {
1279
+ setSelected(null);
1280
+ setInlineEdit(null);
1281
+ }
1282
+ setModeState(next);
1283
+ },
1284
+ [mode, setSelected],
1285
+ );
1286
+
1097
1287
  const toggle = useCallback(() => {
1098
- if (active) {
1099
- setSelected(null);
1100
- setInlineEdit(null);
1101
- }
1102
- setActive(!active);
1103
- }, [active, setSelected]);
1288
+ setMode(active ? 'preview' : 'edit');
1289
+ }, [active, setMode]);
1290
+
1291
+ const exitCommentMode = useCallback(() => {
1292
+ if (commentMode) setMode(modeBeforeCommentRef.current);
1293
+ }, [commentMode, setMode]);
1104
1294
 
1105
1295
  const togglePanel = useCallback(() => {
1106
1296
  setPanelOpen(!active || panelHidden || !panelOpen);
1107
- setActive(true);
1297
+ setMode('edit');
1108
1298
  onPanelOpen?.();
1109
- }, [active, panelHidden, panelOpen, onPanelOpen]);
1299
+ }, [active, panelHidden, panelOpen, onPanelOpen, setMode]);
1110
1300
 
1111
1301
  const cancel = useCallback(() => {
1112
1302
  setSelected(null);
@@ -1162,13 +1352,24 @@ export function InspectorProvider({
1162
1352
  e.altKey
1163
1353
  )
1164
1354
  return;
1165
- if (e.key !== 'i' && e.key !== 'I') return;
1166
- e.preventDefault();
1167
- togglePanel();
1355
+ if (e.key === 'i' || e.key === 'I') {
1356
+ e.preventDefault();
1357
+ togglePanel();
1358
+ } else if (e.key === 'c' || e.key === 'C') {
1359
+ e.preventDefault();
1360
+ if (commentMode) exitCommentMode();
1361
+ else setMode('comment');
1362
+ } else if (e.key === 'v' || e.key === 'V') {
1363
+ e.preventDefault();
1364
+ setMode('preview');
1365
+ } else if (e.key === 'e' || e.key === 'E') {
1366
+ e.preventDefault();
1367
+ setMode('edit');
1368
+ }
1168
1369
  };
1169
1370
  window.addEventListener('keydown', onKey);
1170
1371
  return () => window.removeEventListener('keydown', onKey);
1171
- }, [togglePanel]);
1372
+ }, [togglePanel, commentMode, exitCommentMode, setMode]);
1172
1373
 
1173
1374
  const openCrop = useCallback((anchor: HTMLImageElement) => {
1174
1375
  const loc = anchor.dataset.slideLoc;
@@ -1194,7 +1395,12 @@ export function InspectorProvider({
1194
1395
  const value = useMemo<InspectorCtx>(
1195
1396
  () => ({
1196
1397
  slideId,
1398
+ pageIndex,
1399
+ mode,
1400
+ setMode,
1197
1401
  active,
1402
+ commentMode,
1403
+ exitCommentMode,
1198
1404
  toggle,
1199
1405
  panelOpen,
1200
1406
  panelHidden,
@@ -1203,6 +1409,7 @@ export function InspectorProvider({
1203
1409
  comments,
1204
1410
  error,
1205
1411
  add,
1412
+ update,
1206
1413
  remove,
1207
1414
  selection,
1208
1415
  setSelection,
@@ -1229,7 +1436,12 @@ export function InspectorProvider({
1229
1436
  }),
1230
1437
  [
1231
1438
  slideId,
1439
+ pageIndex,
1440
+ mode,
1441
+ setMode,
1232
1442
  active,
1443
+ commentMode,
1444
+ exitCommentMode,
1233
1445
  toggle,
1234
1446
  panelOpen,
1235
1447
  panelHidden,
@@ -1238,6 +1450,7 @@ export function InspectorProvider({
1238
1450
  comments,
1239
1451
  error,
1240
1452
  add,
1453
+ update,
1241
1454
  remove,
1242
1455
  selection,
1243
1456
  setSelection,
@@ -1394,44 +1607,63 @@ function parsePercent(s: string, fallback: number): number {
1394
1607
 
1395
1608
  export function InspectModeSwitcher() {
1396
1609
  const t = useLocale();
1397
- const { active, toggle } = useInspector();
1610
+ const { mode, setMode, comments } = useInspector();
1398
1611
  if (import.meta.env.PROD) return null;
1612
+ const items: { value: InspectorMode; label: string; shortcut: string; icon: ReactNode }[] = [
1613
+ { value: 'preview', label: t.inspector.previewMode, shortcut: 'V', icon: <Eye /> },
1614
+ { value: 'edit', label: t.inspector.editMode, shortcut: 'E', icon: <Pencil /> },
1615
+ { value: 'comment', label: t.inspector.commentMode, shortcut: 'C', icon: <MessageSquare /> },
1616
+ ];
1617
+ const index = Math.max(
1618
+ 0,
1619
+ items.findIndex((item) => item.value === mode),
1620
+ );
1621
+ const pending = comments.length;
1622
+ const accessibleName = (item: (typeof items)[number]) =>
1623
+ item.value === 'comment' && pending > 0
1624
+ ? `${item.label} · ${format(plural(pending, t.inspector.commentsCount), { count: pending })}`
1625
+ : item.label;
1399
1626
  return (
1400
1627
  <ToggleGroup
1401
1628
  size="sm"
1402
1629
  spacing={1}
1403
- value={[active ? 'edit' : 'preview']}
1630
+ value={[mode]}
1404
1631
  onValueChange={(value) => {
1405
- const next = value[0];
1406
- if (next && (next === 'edit') !== active) toggle();
1632
+ const next = value[0] as InspectorMode | undefined;
1633
+ if (next && next !== mode) setMode(next);
1407
1634
  }}
1408
- aria-label={`${t.inspector.previewMode} / ${t.inspector.editMode}`}
1635
+ aria-label={`${t.inspector.previewMode} / ${t.inspector.editMode} / ${t.inspector.commentMode}`}
1409
1636
  data-inspector-ui
1410
1637
  className="relative isolate h-8 gap-0 rounded-lg border border-border/70 bg-muted/70 p-0.5"
1411
1638
  >
1412
- <IconSwitcherIndicator index={active ? 1 : 0} />
1413
- <ToggleGroupItem
1414
- value="preview"
1415
- title={t.inspector.previewMode}
1416
- aria-label={t.inspector.previewMode}
1417
- onClick={(event) => {
1418
- if (event.detail > 0) event.currentTarget.blur();
1419
- }}
1420
- className="relative z-10 h-full w-8 rounded-md px-0 text-muted-foreground hover:bg-transparent data-pressed:bg-transparent data-pressed:text-foreground data-pressed:shadow-none"
1421
- >
1422
- <Eye />
1423
- </ToggleGroupItem>
1424
- <ToggleGroupItem
1425
- value="edit"
1426
- title={t.inspector.editMode}
1427
- aria-label={t.inspector.editMode}
1428
- onClick={(event) => {
1429
- if (event.detail > 0) event.currentTarget.blur();
1430
- }}
1431
- className="relative z-10 h-full w-8 rounded-md px-0 text-muted-foreground hover:bg-transparent data-pressed:bg-transparent data-pressed:text-foreground data-pressed:shadow-none"
1432
- >
1433
- <Pencil />
1434
- </ToggleGroupItem>
1639
+ <IconSwitcherIndicator index={index} />
1640
+ {items.map((item) => (
1641
+ <IconTooltip key={item.value} label={item.label} shortcut={item.shortcut}>
1642
+ <TooltipTrigger
1643
+ render={
1644
+ <ToggleGroupItem
1645
+ value={item.value}
1646
+ aria-label={accessibleName(item)}
1647
+ data-inspector-mode={item.value}
1648
+ onClick={(event) => {
1649
+ if (event.detail > 0) event.currentTarget.blur();
1650
+ }}
1651
+ className="relative z-10 h-full w-8 rounded-md px-0 text-muted-foreground hover:bg-transparent data-pressed:bg-transparent data-pressed:text-foreground data-pressed:shadow-none"
1652
+ />
1653
+ }
1654
+ >
1655
+ {item.icon}
1656
+ {item.value === 'comment' && pending > 0 && (
1657
+ <span
1658
+ aria-hidden
1659
+ className="pointer-events-none absolute -top-1.5 -right-1.5 flex h-3.5 min-w-3.5 items-center justify-center rounded-full bg-brand px-1 font-mono text-[9px] font-semibold leading-none text-brand-foreground nums"
1660
+ >
1661
+ {pending > 99 ? '99+' : pending}
1662
+ </span>
1663
+ )}
1664
+ </TooltipTrigger>
1665
+ </IconTooltip>
1666
+ ))}
1435
1667
  </ToggleGroup>
1436
1668
  );
1437
1669
  }
@@ -1452,7 +1684,7 @@ export function InspectPanelButton() {
1452
1684
  data-inspector-ui
1453
1685
  >
1454
1686
  <PanelRight className="size-3.5" />
1455
- <span className="hidden md:inline">{t.inspector.format}</span>
1687
+ <span className="hidden lg:inline">{t.inspector.format}</span>
1456
1688
  </Button>
1457
1689
  );
1458
1690
  }
@@ -34,7 +34,7 @@ export function EditorSidebar({
34
34
  data-editor-sidebar
35
35
  inert={!open}
36
36
  aria-hidden={!open}
37
- className="flex h-full shrink-0 justify-end overflow-hidden bg-sidebar transition-[width] ease-swift motion-reduce:transition-none"
37
+ className="flex h-full max-h-1/2 shrink-0 justify-end overflow-hidden bg-sidebar transition-[width] ease-swift motion-reduce:transition-none md:max-h-none"
38
38
  style={{
39
39
  width: animVisible ? PANEL_W : 0,
40
40
  transitionDuration: `${PANEL_TRANSITION_MS}ms`,
@@ -2,9 +2,13 @@ import { Check, Loader2, Redo2, Save, Undo2 } from 'lucide-react';
2
2
  import { useEffect, useState } from 'react';
3
3
  import { usePanelMount } from '@/components/panel/panel-shell';
4
4
  import { Button } from '@/components/ui/button';
5
+ import { IS_APPLE } from '@/lib/keys';
5
6
  import { useLocale } from '@/lib/use-locale';
6
7
  import { cn } from '@/lib/utils';
7
8
 
9
+ const UNDO_SHORTCUT = IS_APPLE ? '⌘Z' : 'Ctrl Z';
10
+ const REDO_SHORTCUT = IS_APPLE ? '⇧⌘Z' : 'Ctrl Y';
11
+
8
12
  type SaveCardProps = {
9
13
  dirty: boolean;
10
14
  committing: boolean;
@@ -79,7 +83,7 @@ export function SaveCard({
79
83
  onClick={onUndo}
80
84
  disabled={committing || !canUndo}
81
85
  aria-label={t.common.undo}
82
- title={t.common.undo}
86
+ title={`${t.common.undo} (${UNDO_SHORTCUT})`}
83
87
  >
84
88
  <Undo2 className="size-3.5" />
85
89
  </Button>
@@ -90,7 +94,7 @@ export function SaveCard({
90
94
  onClick={onRedo}
91
95
  disabled={committing || !canRedo}
92
96
  aria-label={t.common.redo}
93
- title={t.common.redo}
97
+ title={`${t.common.redo} (${REDO_SHORTCUT})`}
94
98
  >
95
99
  <Redo2 className="size-3.5" />
96
100
  </Button>
@@ -0,0 +1,16 @@
1
+ import { type ReactNode, useRef } from 'react';
2
+ import { type StepController, StepHost } from '../lib/step-context';
3
+
4
+ export function PreviewStepHost({ revealed, children }: { revealed: number; children: ReactNode }) {
5
+ const noopControllerRef = useRef<StepController | null>(null);
6
+ return (
7
+ <StepHost
8
+ isActivePage={false}
9
+ entryDirection="jump"
10
+ controllerRef={noopControllerRef}
11
+ controlledRevealed={revealed}
12
+ >
13
+ {children}
14
+ </StepHost>
15
+ );
16
+ }
@@ -1,7 +1,7 @@
1
1
  import { Plus, Search } from 'lucide-react';
2
2
  import { useEffect, useRef, useState } from 'react';
3
3
  import { toast } from 'sonner';
4
- import logo from '@/assets/open-slide.png';
4
+ import logo from '@/assets/open-slide.svg';
5
5
  import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';
6
6
  import type { Folder, FolderIcon } from '@/lib/sdk';
7
7
  import { format, useLocale } from '@/lib/use-locale';
@@ -135,7 +135,7 @@ export function Sidebar({
135
135
  alt=""
136
136
  aria-hidden
137
137
  draggable={false}
138
- className="size-6 shrink-0 select-none rounded-[6px] ring-1 ring-foreground/10"
138
+ className="size-6 shrink-0 select-none"
139
139
  />
140
140
  <h1 className="font-heading text-[13.5px] font-semibold tracking-tight">
141
141
  {t.home.appTitle}
@@ -809,7 +809,7 @@ export function SlideTransitionLayer({
809
809
  </div>
810
810
  ) : null}
811
811
  {CurrentPage ? (
812
- <div ref={incomingLayerRef} className="absolute inset-0">
812
+ <div ref={incomingLayerRef} data-osd-current-page={current} className="absolute inset-0">
813
813
  <SlidePageProvider index={current} total={total}>
814
814
  <StepHost
815
815
  isActivePage