@open-slide/core 1.19.0 → 2.0.0-beta.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 (100) hide show
  1. package/dist/{build-CaV_vhIw.js → build-CfAxF6Dm.js} +2 -5
  2. package/dist/cli/bin.d.ts +1 -1
  3. package/dist/cli/bin.js +139 -13
  4. package/dist/{config-CDHB8Oow.d.ts → config-AtA2Bqtn.d.ts} +4 -4
  5. package/dist/{config-GA6NMgs_.js → config-C_VI2EpT.js} +545 -776
  6. package/dist/{design-cpzS8aud.js → design-Cpqx7SJs.js} +1 -2
  7. package/dist/{dev-D57ui2yV.js → dev-BChELmc-.js} +4 -7
  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-D40Zw_o0.js → preview-CcCQa268.js} +3 -7
  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 +18 -15
  21. package/src/app/assets/open-slide.png +0 -0
  22. package/src/app/components/asset-view.tsx +46 -39
  23. package/src/app/components/command/command-menu.tsx +5 -1
  24. package/src/app/components/command/command.tsx +4 -2
  25. package/src/app/components/command/home-command-menu.tsx +6 -6
  26. package/src/app/components/export-progress-toast.tsx +80 -0
  27. package/src/app/components/history-provider.tsx +1 -5
  28. package/src/app/components/icon-tooltip.tsx +24 -15
  29. package/src/app/components/image-placeholder.tsx +4 -12
  30. package/src/app/components/inspector/asset-picker-dialog.tsx +24 -32
  31. package/src/app/components/inspector/comment-widget.tsx +33 -7
  32. package/src/app/components/inspector/image-crop-dialog.tsx +9 -6
  33. package/src/app/components/inspector/inline-text-editor.tsx +798 -0
  34. package/src/app/components/inspector/inspect-overlay.tsx +35 -76
  35. package/src/app/components/inspector/inspector-panel.tsx +31 -53
  36. package/src/app/components/inspector/inspector-provider.tsx +53 -36
  37. package/src/app/components/language-toggle.tsx +2 -3
  38. package/src/app/components/notes-drawer.tsx +4 -7
  39. package/src/app/components/overview-grid.tsx +15 -8
  40. package/src/app/components/panel/panel-shell.tsx +1 -3
  41. package/src/app/components/panel/save-card.tsx +12 -3
  42. package/src/app/components/player.tsx +5 -6
  43. package/src/app/components/present/blackout-overlay.tsx +16 -3
  44. package/src/app/components/present/control-bar.tsx +21 -13
  45. package/src/app/components/present/jump-input.tsx +27 -5
  46. package/src/app/components/present/laser-pointer.tsx +34 -11
  47. package/src/app/components/present/progress-bar.tsx +1 -1
  48. package/src/app/components/present/use-presenter-channel.ts +0 -1
  49. package/src/app/components/present/use-touch-swipe.ts +9 -2
  50. package/src/app/components/sidebar/folder-item.tsx +48 -21
  51. package/src/app/components/sidebar/icon-picker.tsx +1 -1
  52. package/src/app/components/sidebar/sidebar-footer.tsx +20 -7
  53. package/src/app/components/sidebar/sidebar.tsx +91 -64
  54. package/src/app/components/slide-canvas.tsx +2 -6
  55. package/src/app/components/slide-transition-layer.tsx +48 -76
  56. package/src/app/components/style-panel/design-provider.tsx +1 -14
  57. package/src/app/components/style-panel/style-panel.tsx +16 -12
  58. package/src/app/components/style-panel/use-design.ts +1 -28
  59. package/src/app/components/theme-toggle.tsx +4 -5
  60. package/src/app/components/themes/theme-detail.tsx +11 -8
  61. package/src/app/components/themes/themes-gallery.tsx +13 -8
  62. package/src/app/components/thumbnail-rail.tsx +14 -15
  63. package/src/app/index.html +21 -0
  64. package/src/app/lib/assets.ts +6 -7
  65. package/src/app/lib/dom.ts +42 -0
  66. package/src/app/lib/export-html.ts +10 -25
  67. package/src/app/lib/export-pdf.ts +11 -28
  68. package/src/app/lib/export-pptx.ts +6 -36
  69. package/src/app/lib/folders.ts +51 -46
  70. package/src/app/lib/inspector/inline-text.ts +31 -0
  71. package/src/app/lib/inspector/pick-target.ts +38 -0
  72. package/src/app/lib/inspector/use-comments.ts +1 -1
  73. package/src/app/lib/keys.ts +18 -0
  74. package/src/app/lib/last-home-location.ts +18 -0
  75. package/src/app/lib/print-ready.ts +2 -4
  76. package/src/app/lib/slides.ts +7 -4
  77. package/src/app/lib/text-diff.ts +19 -0
  78. package/src/app/lib/use-click-page-navigation.ts +2 -6
  79. package/src/app/lib/use-is-mobile.ts +2 -14
  80. package/src/app/lib/use-media-query.ts +20 -0
  81. package/src/app/lib/use-prefers-reduced-motion.ts +5 -13
  82. package/src/app/lib/use-slide-module.ts +1 -1
  83. package/src/app/lib/use-wheel-page-navigation.ts +1 -1
  84. package/src/app/lib/utils.test.ts +25 -1
  85. package/src/app/lib/utils.ts +8 -0
  86. package/src/app/routes/home-shell.tsx +71 -64
  87. package/src/app/routes/home.tsx +50 -58
  88. package/src/app/routes/presenter.tsx +14 -23
  89. package/src/app/routes/slide.tsx +90 -77
  90. package/src/app/routes/themes.tsx +7 -8
  91. package/src/app/styles.css +40 -44
  92. package/src/locale/en.ts +2 -7
  93. package/src/locale/ja.ts +2 -7
  94. package/src/locale/types.ts +2 -7
  95. package/src/locale/zh-cn.ts +2 -7
  96. package/src/locale/zh-tw.ts +2 -7
  97. package/dist/sync-BCJDRIqo.js +0 -139
  98. package/dist/sync-j9_QPovT.js +0 -3
  99. package/src/app/components/pdf-progress-toast.tsx +0 -32
  100. package/src/app/components/pptx-progress-toast.tsx +0 -32
@@ -3,6 +3,11 @@ import { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react
3
3
  import { PANEL_TRANSITION_MS } from '@/components/panel/panel-shell';
4
4
  import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip';
5
5
  import { findSlideSource, type SlideSourceHit } from '@/lib/inspector/fiber';
6
+ import {
7
+ isInspectableEventTarget,
8
+ pickElement,
9
+ pickInspectorTarget,
10
+ } from '@/lib/inspector/pick-target';
6
11
  import { useLocale } from '@/lib/use-locale';
7
12
  import { cn } from '@/lib/utils';
8
13
  import { useInspector } from './inspector-provider';
@@ -16,7 +21,7 @@ const FRAME_MORPH_MS = 180;
16
21
  const LAYOUT_TRACK_MS = PANEL_TRANSITION_MS + FRAME_MORPH_MS;
17
22
 
18
23
  export function InspectOverlay() {
19
- const { active, slideId, selected, setSelected, cancel, openCrop } = useInspector();
24
+ const { active, slideId, selected, setSelected, cancel, openCrop, inlineEdit } = useInspector();
20
25
  const overlayRef = useRef<HTMLDivElement>(null);
21
26
  const [hover, setHover] = useState<Highlight | null>(null);
22
27
 
@@ -28,6 +33,8 @@ export function InspectOverlay() {
28
33
 
29
34
  const onKey = (e: KeyboardEvent) => {
30
35
  if (e.key === 'Escape') {
36
+ // The inline edit layer owns Escape while a text run is being edited.
37
+ if (inlineEdit) return;
31
38
  e.preventDefault();
32
39
  e.stopPropagation();
33
40
  cancel();
@@ -36,6 +43,7 @@ export function InspectOverlay() {
36
43
 
37
44
  const onMove = (e: PointerEvent) => {
38
45
  if (!isInspectableEventTarget(e.target)) return setHover(null);
46
+ if (inlineEdit?.anchor.contains(e.target as Node)) return setHover(null);
39
47
  const el = pickInspectorTarget(pickElement(e.clientX, e.clientY));
40
48
  if (!el) return setHover(null);
41
49
  const hit = findSlideSource(el, slideId, { hostOnly: true });
@@ -45,6 +53,8 @@ export function InspectOverlay() {
45
53
 
46
54
  const onClick = (e: MouseEvent) => {
47
55
  if (!isInspectableEventTarget(e.target)) return;
56
+ // Clicks inside the inline-editing element move the caret natively.
57
+ if (inlineEdit?.anchor.contains(e.target as Node)) return;
48
58
  const el = pickInspectorTarget(pickElement(e.clientX, e.clientY));
49
59
  if (!el) return;
50
60
  const hit = findSlideSource(el, slideId, { hostOnly: true });
@@ -57,6 +67,7 @@ export function InspectOverlay() {
57
67
 
58
68
  const onDblClick = (e: MouseEvent) => {
59
69
  if (!isInspectableEventTarget(e.target)) return;
70
+ if (inlineEdit?.anchor.contains(e.target as Node)) return;
60
71
  const el = pickInspectorTarget(pickElement(e.clientX, e.clientY));
61
72
  if (!el) return;
62
73
  const hit = findSlideSource(el, slideId, { hostOnly: true });
@@ -78,7 +89,7 @@ export function InspectOverlay() {
78
89
  window.removeEventListener('dblclick', onDblClick, true);
79
90
  window.removeEventListener('keydown', onKey, true);
80
91
  };
81
- }, [active, slideId, setSelected, cancel, openCrop]);
92
+ }, [active, slideId, setSelected, cancel, openCrop, inlineEdit]);
82
93
 
83
94
  const hoverAnchor = hover?.hit.anchor.isConnected ? hover.hit.anchor : null;
84
95
  const selectedAnchor = selected?.anchor.isConnected ? selected.anchor : null;
@@ -87,7 +98,13 @@ export function InspectOverlay() {
87
98
  if (!active) return null;
88
99
  return (
89
100
  <div ref={overlayRef} data-inspector-ui className="pointer-events-none absolute inset-0 z-30">
90
- <Frame anchor={selectedAnchor} overlayRef={overlayRef} variant="selected" showImageActions />
101
+ <Frame
102
+ anchor={selectedAnchor}
103
+ overlayRef={overlayRef}
104
+ variant="selected"
105
+ showImageActions
106
+ editing={!!inlineEdit && inlineEdit.anchor === selectedAnchor}
107
+ />
91
108
  <Frame anchor={dedupedHover} overlayRef={overlayRef} variant="hover" />
92
109
  </div>
93
110
  );
@@ -105,11 +122,13 @@ function Frame({
105
122
  overlayRef,
106
123
  variant,
107
124
  showImageActions = false,
125
+ editing = false,
108
126
  }: {
109
127
  anchor: HTMLElement | null;
110
- overlayRef: React.RefObject<HTMLDivElement>;
128
+ overlayRef: React.RefObject<HTMLDivElement | null>;
111
129
  variant: FrameVariant;
112
130
  showImageActions?: boolean;
131
+ editing?: boolean;
113
132
  }) {
114
133
  const [rect, setRect] = useState<RelRect | null>(null);
115
134
  const [hasTarget, setHasTarget] = useState(false);
@@ -190,15 +209,22 @@ function Frame({
190
209
  }, [visible]);
191
210
 
192
211
  if (!rect) return null;
212
+ const morphEase = 'var(--ease-swift)';
193
213
  const transition = morph
194
- ? `left ${FRAME_MORPH_MS}ms ease-out, top ${FRAME_MORPH_MS}ms ease-out, ` +
195
- `width ${FRAME_MORPH_MS}ms ease-out, height ${FRAME_MORPH_MS}ms ease-out, ` +
214
+ ? `left ${FRAME_MORPH_MS}ms ${morphEase}, top ${FRAME_MORPH_MS}ms ${morphEase}, ` +
215
+ `width ${FRAME_MORPH_MS}ms ${morphEase}, height ${FRAME_MORPH_MS}ms ${morphEase}, ` +
196
216
  `opacity ${FRAME_FADE_MS}ms ease-out`
197
217
  : `opacity ${FRAME_FADE_MS}ms ease-out`;
198
218
 
199
219
  const imageAnchor = anchor instanceof HTMLImageElement ? anchor : null;
200
220
  const actionsVisible = showImageActions && visible && !!imageAnchor;
201
221
 
222
+ // While a text run is being edited inline, drop the tint so the text
223
+ // underneath stays fully readable.
224
+ const frameStyle = editing
225
+ ? { ...FRAME_STYLES[variant], background: 'transparent' }
226
+ : FRAME_STYLES[variant];
227
+
202
228
  return (
203
229
  <>
204
230
  <div
@@ -210,7 +236,7 @@ function Frame({
210
236
  height: rect.height,
211
237
  opacity: visible ? 1 : 0,
212
238
  transition,
213
- ...FRAME_STYLES[variant],
239
+ ...frameStyle,
214
240
  }}
215
241
  />
216
242
  {showImageActions && imageAnchor && (
@@ -265,7 +291,7 @@ function ImageActionPanel({
265
291
  e.stopPropagation();
266
292
  openReplace(anchor);
267
293
  }}
268
- className="inline-flex size-7 items-center justify-center rounded-[5px] text-foreground/85 transition-colors hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40"
294
+ className="inline-flex size-7 items-center justify-center rounded-[5px] text-foreground/85 transition-[background-color,color,scale] duration-150 hover:bg-muted hover:text-foreground active:scale-[0.94] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40"
269
295
  >
270
296
  <ImageIcon className="size-3.5" />
271
297
  </button>
@@ -285,7 +311,7 @@ function ImageActionPanel({
285
311
  e.stopPropagation();
286
312
  openCrop(anchor as HTMLImageElement);
287
313
  }}
288
- className="inline-flex size-7 items-center justify-center rounded-[5px] text-foreground/85 transition-colors hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40"
314
+ className="inline-flex size-7 items-center justify-center rounded-[5px] text-foreground/85 transition-[background-color,color,scale] duration-150 hover:bg-muted hover:text-foreground active:scale-[0.94] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40"
289
315
  >
290
316
  <Crop className="size-3.5" />
291
317
  </button>
@@ -309,70 +335,3 @@ function sameRect(a: RelRect | null, b: RelRect): boolean {
309
335
  Math.abs(a.height - b.height) < 0.5
310
336
  );
311
337
  }
312
-
313
- // Only inspect events that originate inside the slide root. Portaled UI
314
- // (dialogs, tooltips, toasts) mounts on `document.body`, outside the root;
315
- // without this guard the capture-phase window listeners swallow clicks
316
- // meant for a dialog and select the slide element behind it instead.
317
- function isInspectableEventTarget(target: EventTarget | null): boolean {
318
- if (!(target instanceof Element)) return false;
319
- if (target.closest('[data-inspector-ui]')) return false;
320
- return !!target.closest('[data-inspector-root]');
321
- }
322
-
323
- function pickElement(x: number, y: number): HTMLElement | null {
324
- const stack = document.elementsFromPoint(x, y);
325
- for (const el of stack) {
326
- if (!(el instanceof HTMLElement)) continue;
327
- if (el.closest('[data-inspector-ui]')) continue;
328
- if (!el.closest('[data-inspector-root]')) continue;
329
- return el;
330
- }
331
- return null;
332
- }
333
-
334
- const INLINE_TEXT_TAGS = new Set([
335
- 'B',
336
- 'CODE',
337
- 'DEL',
338
- 'EM',
339
- 'I',
340
- 'INS',
341
- 'MARK',
342
- 'S',
343
- 'SMALL',
344
- 'SPAN',
345
- 'STRONG',
346
- 'SUB',
347
- 'SUP',
348
- 'U',
349
- ]);
350
-
351
- function pickInspectorTarget(el: HTMLElement | null): HTMLElement | null {
352
- if (!el) return null;
353
- const root = el.closest('[data-inspector-root]');
354
- const startedOnInlineText = INLINE_TEXT_TAGS.has(el.tagName);
355
- for (let cur: HTMLElement | null = el; cur && root?.contains(cur); cur = cur.parentElement) {
356
- if (startedOnInlineText && INLINE_TEXT_TAGS.has(cur.tagName)) continue;
357
- if (isEditableTextContainer(cur)) return cur;
358
- }
359
- return el;
360
- }
361
-
362
- function isEditableTextContainer(el: HTMLElement): boolean {
363
- if (!el.textContent?.trim()) return false;
364
- return hasOnlyInlineTextChildren(el);
365
- }
366
-
367
- function hasOnlyInlineTextChildren(el: HTMLElement): boolean {
368
- for (const child of Array.from(el.childNodes)) {
369
- if (child.nodeType === Node.TEXT_NODE) {
370
- continue;
371
- } else if (child instanceof HTMLElement) {
372
- if (child.tagName === 'BR') continue;
373
- if (INLINE_TEXT_TAGS.has(child.tagName) && hasOnlyInlineTextChildren(child)) continue;
374
- }
375
- return false;
376
- }
377
- return true;
378
- }
@@ -29,9 +29,11 @@ import { Toggle } from '@/components/ui/toggle';
29
29
  import { ToggleGroup, ToggleGroupItem } from '@/components/ui/toggle-group';
30
30
  import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip';
31
31
  import { findSlideSource } from '@/lib/inspector/fiber';
32
+ import { hasOnlyInlineTextChildren } from '@/lib/inspector/inline-text';
32
33
  import type { EditOp } from '@/lib/inspector/use-editor';
33
34
  import { useAgentSocketConnected } from '@/lib/use-agent-socket';
34
35
  import { useLocale } from '@/lib/use-locale';
36
+ import { cn, round2 } from '@/lib/utils';
35
37
  import type { Locale } from '../../../locale/types';
36
38
  import { AssetPickerDialog } from './asset-picker-dialog';
37
39
  import { type SelectedTarget, useInspector } from './inspector-provider';
@@ -71,8 +73,17 @@ function resolveSelectedTarget(target: SelectedTarget, slideId: string): Selecte
71
73
  }
72
74
 
73
75
  export function InspectorPanel() {
74
- const { active, slideId, selected, setSelected, bufferOps, pendingCount, add, applyEdit } =
75
- useInspector();
76
+ const {
77
+ active,
78
+ slideId,
79
+ selected,
80
+ setSelected,
81
+ bufferOps,
82
+ pendingCount,
83
+ opsVersion,
84
+ add,
85
+ applyEdit,
86
+ } = useInspector();
76
87
  const [snapshot, setSnapshot] = useState<ElementSnapshot | null>(null);
77
88
  const [contentSelection, setContentSelection] = useState<ContentSelection | null>(null);
78
89
  const [rangeStylePreview, setRangeStylePreview] = useState<RangeStylePreview | null>(null);
@@ -88,6 +99,7 @@ export function InspectorPanel() {
88
99
  useEffect(() => {
89
100
  void reloadCounter;
90
101
  void pendingCount;
102
+ void opsVersion;
91
103
  if (!selected) {
92
104
  setSnapshot(null);
93
105
  return;
@@ -103,7 +115,7 @@ export function InspectorPanel() {
103
115
  }
104
116
  }
105
117
  setSnapshot(readSnapshot(anchor));
106
- }, [selected, setSelected, slideId, reloadCounter, pendingCount]);
118
+ }, [selected, setSelected, slideId, reloadCounter, pendingCount, opsVersion]);
107
119
 
108
120
  // Freeze slide animations while editing so commits don't replay motion.
109
121
  useEffect(() => {
@@ -170,7 +182,7 @@ export function InspectorPanel() {
170
182
  rangeStylePreview.start === contentRange.start &&
171
183
  rangeStylePreview.end === contentRange.end;
172
184
  const typographySnapshot = rangePreviewApplies
173
- ? withStylePreview(pinSnapshot, rangeStylePreview.values)
185
+ ? { ...pinSnapshot, ...rangeStylePreview.values }
174
186
  : pinSnapshot;
175
187
  const applyTextStyle = (ops: EditOp[]) => {
176
188
  const styleOps = ops.flatMap((op) => (op.kind === 'set-style' ? [op] : []));
@@ -369,10 +381,6 @@ function stylePreviewFromOps(ops: Array<Extract<EditOp, { kind: 'set-style' }>>)
369
381
  return preview;
370
382
  }
371
383
 
372
- function withStylePreview(snapshot: ElementSnapshot, preview: StylePreview): ElementSnapshot {
373
- return { ...snapshot, ...preview };
374
- }
375
-
376
384
  function ContentField({
377
385
  snapshot,
378
386
  apply,
@@ -688,7 +696,7 @@ function ColorField({
688
696
 
689
697
  return (
690
698
  <Field label={label}>
691
- <label className="relative inline-flex size-8 shrink-0 cursor-pointer items-center justify-center overflow-hidden rounded-md border bg-background shadow-xs">
699
+ <label className="relative inline-flex size-8 shrink-0 cursor-pointer items-center justify-center overflow-hidden rounded-md border bg-background shadow-xs transition-[border-color,scale] duration-150 hover:border-foreground/20 active:scale-[0.96] has-[:focus-visible]:ring-2 has-[:focus-visible]:ring-ring/40">
692
700
  <span
693
701
  className="size-5 rounded-sm"
694
702
  style={{
@@ -717,7 +725,7 @@ function ColorField({
717
725
  setDraft(e.target.value);
718
726
  commitHex(e.target.value);
719
727
  }}
720
- className="h-8 flex-1 font-mono text-[11px] uppercase"
728
+ className="nums h-8 flex-1 font-mono text-[11px] uppercase"
721
729
  spellCheck={false}
722
730
  />
723
731
  {clearable && onClear && (
@@ -851,12 +859,12 @@ function AgentWatchingBadge() {
851
859
  render={
852
860
  <button
853
861
  type="button"
854
- className="flex shrink-0 cursor-help items-center gap-1.5 rounded-[3px] border border-hairline bg-card px-1.5 py-px text-[10.5px] text-foreground/85 outline-none focus-visible:ring-2 focus-visible:ring-ring/30"
862
+ className="flex shrink-0 cursor-help items-center gap-1.5 rounded-[3px] border border-hairline bg-card px-1.5 py-px text-[10.5px] text-foreground/85 outline-none transition-colors duration-150 hover:bg-muted/50 focus-visible:ring-2 focus-visible:ring-ring/30"
855
863
  >
856
864
  <span aria-hidden className="relative flex size-1.5 items-center justify-center">
857
865
  {connected ? (
858
866
  <>
859
- <span className="absolute inline-flex size-full animate-ping rounded-full bg-emerald-500 opacity-60" />
867
+ <span className="absolute inline-flex size-full rounded-full bg-emerald-500 opacity-60 motion-safe:animate-ping" />
860
868
  <span className="relative inline-flex size-1.5 rounded-full bg-emerald-500" />
861
869
  </>
862
870
  ) : (
@@ -879,6 +887,10 @@ function AgentWatchingBadge() {
879
887
  );
880
888
  }
881
889
 
890
+ // The cue animation re-mounts with every element selection; without this
891
+ // guard it replays each time instead of once per inspector session.
892
+ let commentCuePlayed = false;
893
+
882
894
  function CommentsSection({
883
895
  selected,
884
896
  onAdd,
@@ -888,9 +900,14 @@ function CommentsSection({
888
900
  }) {
889
901
  const [draft, setDraft] = useState('');
890
902
  const [submitting, setSubmitting] = useState(false);
903
+ const [showCue] = useState(() => !commentCuePlayed);
891
904
  const wrapRef = useRef<HTMLDivElement>(null);
892
905
  const t = useLocale();
893
906
 
907
+ useEffect(() => {
908
+ commentCuePlayed = true;
909
+ }, []);
910
+
894
911
  useEffect(() => {
895
912
  const onKey = (e: KeyboardEvent) => {
896
913
  if (e.key !== '/') return;
@@ -920,7 +937,7 @@ function CommentsSection({
920
937
  return (
921
938
  <Section title={t.inspector.leaveComment}>
922
939
  <div className="flex flex-col gap-2">
923
- <div ref={wrapRef} className="comment-cue rounded-[6px]">
940
+ <div ref={wrapRef} className={cn('rounded-[6px]', showCue && 'comment-cue')}>
924
941
  <Textarea
925
942
  value={draft}
926
943
  onChange={(e) => setDraft(e.target.value)}
@@ -949,7 +966,7 @@ function CommentsSection({
949
966
 
950
967
  function readSnapshot(el: HTMLElement): ElementSnapshot {
951
968
  const cs = getComputedStyle(el);
952
- const text = isSimpleTextElement(el) ? readEditableText(el) : null;
969
+ const text = hasOnlyInlineTextChildren(el) ? readEditableText(el) : null;
953
970
  const imageSrc =
954
971
  el.tagName === 'IMG'
955
972
  ? (el as HTMLImageElement).currentSrc || (el as HTMLImageElement).src || null
@@ -979,41 +996,6 @@ function readSnapshot(el: HTMLElement): ElementSnapshot {
979
996
  };
980
997
  }
981
998
 
982
- function isSimpleTextElement(el: HTMLElement): boolean {
983
- if (el.childNodes.length === 0) return true;
984
- return hasOnlyInlineTextChildren(el);
985
- }
986
-
987
- const INLINE_TEXT_TAGS = new Set([
988
- 'B',
989
- 'CODE',
990
- 'DEL',
991
- 'EM',
992
- 'I',
993
- 'INS',
994
- 'MARK',
995
- 'S',
996
- 'SMALL',
997
- 'SPAN',
998
- 'STRONG',
999
- 'SUB',
1000
- 'SUP',
1001
- 'U',
1002
- ]);
1003
-
1004
- function hasOnlyInlineTextChildren(el: HTMLElement): boolean {
1005
- for (const child of Array.from(el.childNodes)) {
1006
- if (child.nodeType === Node.TEXT_NODE) {
1007
- continue;
1008
- } else if (child instanceof HTMLElement) {
1009
- if (child.tagName === 'BR') continue;
1010
- if (INLINE_TEXT_TAGS.has(child.tagName) && hasOnlyInlineTextChildren(child)) continue;
1011
- }
1012
- return false;
1013
- }
1014
- return true;
1015
- }
1016
-
1017
999
  function readEditableText(el: HTMLElement): string {
1018
1000
  const parts: string[] = [];
1019
1001
  for (const child of Array.from(el.childNodes)) {
@@ -1089,10 +1071,6 @@ function parseLetterSpacing(value: string): number {
1089
1071
  return Number.isFinite(n) ? round2(n) : 0;
1090
1072
  }
1091
1073
 
1092
- function round2(n: number): number {
1093
- return Math.round(n * 100) / 100;
1094
- }
1095
-
1096
1074
  function findElementByLine(slideId: string, line: number, column: number): HTMLElement | null {
1097
1075
  const root = document.querySelector('[data-inspector-root]');
1098
1076
  if (!root) return null;
@@ -13,8 +13,11 @@ import { toast } from 'sonner';
13
13
  import { useHistory } from '@/components/history-provider';
14
14
  import { Button } from '@/components/ui/button';
15
15
  import { type SlideComment, useComments } from '@/lib/inspector/use-comments';
16
- import { type Edit, type EditOp, type EditResult, useEditor } from '@/lib/inspector/use-editor';
16
+ import { type Edit, type EditOp, useEditor } from '@/lib/inspector/use-editor';
17
+ import { isTypingTarget } from '@/lib/keys';
18
+ import { textDiff } from '@/lib/text-diff';
17
19
  import { useLocale } from '@/lib/use-locale';
20
+ import { round2 } from '@/lib/utils';
18
21
  import { AssetPickerDialog } from './asset-picker-dialog';
19
22
  import { ImageCropDialog, type ImageCropRect } from './image-crop-dialog';
20
23
 
@@ -24,6 +27,16 @@ export type SelectedTarget = {
24
27
  anchor: HTMLElement;
25
28
  };
26
29
 
30
+ export type InlineEditTarget = SelectedTarget & {
31
+ point?: { x: number; y: number };
32
+ // Double-click entry selects the word under the caret; a single-click
33
+ // switch from another editing session just places the caret.
34
+ selectWord?: boolean;
35
+ // Distinguishes sessions on the same source loc (reused components render
36
+ // several DOM instances of one loc), so each switch remounts the editor.
37
+ session?: number;
38
+ };
39
+
27
40
  type AssetAttrOp = { assetPath: string; previewUrl: string };
28
41
  type Sequenced<T> = T & { seq: number };
29
42
  type StyleOp = { value: string | null; prevText?: string };
@@ -61,15 +74,15 @@ function readInstanceId(el: HTMLElement): string | null {
61
74
  return el.getAttribute(INSTANCE_ID_ATTR);
62
75
  }
63
76
 
64
- type DomTextPart = { node: Text | HTMLBRElement; current: string };
77
+ export type DomTextPart = { node: Text | HTMLBRElement; current: string };
65
78
 
66
- function readEditableText(el: HTMLElement): string {
79
+ export function readEditableText(el: HTMLElement): string {
67
80
  const parts: DomTextPart[] = [];
68
81
  collectDomTextParts(el, parts);
69
82
  return parts.map((part) => part.current).join('');
70
83
  }
71
84
 
72
- function collectDomTextParts(node: Node, out: DomTextPart[]): void {
85
+ export function collectDomTextParts(node: Node, out: DomTextPart[]): void {
73
86
  const parts: DomTextPart[] = [];
74
87
  collectDomTextPartsRaw(node, parts);
75
88
  out.push(...normalizeDomTextParts(parts));
@@ -106,26 +119,6 @@ function renderedTextNodeValue(node: Text): string {
106
119
  return node.data.replace(/\s+/g, ' ');
107
120
  }
108
121
 
109
- function textDiff(prevText: string, nextText: string) {
110
- let start = 0;
111
- while (
112
- start < prevText.length &&
113
- start < nextText.length &&
114
- prevText[start] === nextText[start]
115
- ) {
116
- start += 1;
117
- }
118
-
119
- let prevEnd = prevText.length;
120
- let nextEnd = nextText.length;
121
- while (prevEnd > start && nextEnd > start && prevText[prevEnd - 1] === nextText[nextEnd - 1]) {
122
- prevEnd -= 1;
123
- nextEnd -= 1;
124
- }
125
-
126
- return { start, end: prevEnd, value: nextText.slice(start, nextEnd) };
127
- }
128
-
129
122
  function textFragment(value: string): DocumentFragment {
130
123
  const fragment = document.createDocumentFragment();
131
124
  const lines = value.split('\n');
@@ -248,13 +241,17 @@ type InspectorCtx = {
248
241
  cancel: () => void;
249
242
  comments: SlideComment[];
250
243
  error: string | null;
251
- refetch: () => Promise<void>;
252
244
  add: (line: number, column: number, text: string) => Promise<void>;
253
245
  remove: (id: string) => Promise<void>;
254
246
  selected: SelectedTarget | null;
255
247
  setSelected: (s: SelectedTarget | null) => void;
248
+ inlineEdit: InlineEditTarget | null;
249
+ startInlineEdit: (target: InlineEditTarget) => void;
250
+ stopInlineEdit: () => void;
251
+ // Bumped on every buffered-op mutation (including undo/redo restores) so
252
+ // panels can re-read DOM snapshots without polling.
253
+ opsVersion: number;
256
254
  applyEdit: (line: number, column: number, ops: EditOp[]) => Promise<void>;
257
- applyEdits: (edits: Edit[]) => Promise<EditResult[]>;
258
255
  // Mutate the DOM optimistically, snapshot the pre-edit values, and
259
256
  // remember the ops. `commitEdits` (manual Save or auto-flush on
260
257
  // close) is what actually writes to disk; `cancelEdits` reverts.
@@ -286,7 +283,9 @@ export function InspectorProvider({
286
283
  }) {
287
284
  const [active, setActive] = useState(false);
288
285
  const [selected, setSelected] = useState<SelectedTarget | null>(null);
289
- const { comments, error, refetch, add, remove } = useComments(slideId);
286
+ const [inlineEdit, setInlineEdit] = useState<InlineEditTarget | null>(null);
287
+ const [opsVersion, setOpsVersion] = useState(0);
288
+ const { comments, error, add, remove } = useComments(slideId);
290
289
  const { applyEdit, applyEdits } = useEditor(slideId);
291
290
  const history = useHistory();
292
291
 
@@ -334,6 +333,7 @@ export function InspectorProvider({
334
333
  }
335
334
  }
336
335
  setPendingCount(n);
336
+ setOpsVersion((v) => v + 1);
337
337
  }, []);
338
338
 
339
339
  // Find the live anchor for a buffered loc. Used by history undo/redo
@@ -927,6 +927,23 @@ export function InspectorProvider({
927
927
  setSelected(null);
928
928
  }, []);
929
929
 
930
+ const inlineEditSessionRef = useRef(0);
931
+ const startInlineEdit = useCallback((target: InlineEditTarget) => {
932
+ setSelected({ line: target.line, column: target.column, anchor: target.anchor });
933
+ setInlineEdit({ ...target, session: ++inlineEditSessionRef.current });
934
+ }, []);
935
+
936
+ const stopInlineEdit = useCallback(() => {
937
+ setInlineEdit(null);
938
+ }, []);
939
+
940
+ // Deselecting, selecting another element, or an HMR anchor swap all end
941
+ // the inline session — the contenteditable node is gone or no longer the
942
+ // selection's anchor.
943
+ useEffect(() => {
944
+ if (inlineEdit && selected?.anchor !== inlineEdit.anchor) setInlineEdit(null);
945
+ }, [selected, inlineEdit]);
946
+
930
947
  const openReplace = useCallback((anchor: HTMLElement) => {
931
948
  const loc = anchor.dataset.slideLoc;
932
949
  if (!loc) return;
@@ -940,7 +957,7 @@ export function InspectorProvider({
940
957
  useEffect(() => {
941
958
  if (import.meta.env.PROD) return;
942
959
  const onKey = (e: KeyboardEvent) => {
943
- if (e.target instanceof HTMLElement && e.target.matches('input, textarea')) return;
960
+ if (isTypingTarget(e.target)) return;
944
961
  if (e.key !== 'i' && e.key !== 'I') return;
945
962
  toggle();
946
963
  };
@@ -977,13 +994,15 @@ export function InspectorProvider({
977
994
  cancel,
978
995
  comments,
979
996
  error,
980
- refetch,
981
997
  add,
982
998
  remove,
983
999
  selected,
984
1000
  setSelected,
1001
+ inlineEdit,
1002
+ startInlineEdit,
1003
+ stopInlineEdit,
1004
+ opsVersion,
985
1005
  applyEdit,
986
- applyEdits,
987
1006
  bufferOps,
988
1007
  pendingCount,
989
1008
  commitEdits,
@@ -999,12 +1018,14 @@ export function InspectorProvider({
999
1018
  cancel,
1000
1019
  comments,
1001
1020
  error,
1002
- refetch,
1003
1021
  add,
1004
1022
  remove,
1005
1023
  selected,
1024
+ inlineEdit,
1025
+ startInlineEdit,
1026
+ stopInlineEdit,
1027
+ opsVersion,
1006
1028
  applyEdit,
1007
- applyEdits,
1008
1029
  bufferOps,
1009
1030
  pendingCount,
1010
1031
  commitEdits,
@@ -1089,10 +1110,6 @@ export function InspectorProvider({
1089
1110
  );
1090
1111
  }
1091
1112
 
1092
- function round2(n: number): number {
1093
- return Math.round(n * 100) / 100;
1094
- }
1095
-
1096
1113
  function parseObjectViewBox(value: string): ImageCropRect | null {
1097
1114
  const v = value?.trim();
1098
1115
  if (!v || v === 'none') return null;
@@ -1,5 +1,5 @@
1
1
  import { Languages } from 'lucide-react';
2
- import { IconTooltip } from '@/components/icon-tooltip';
2
+ import { IconTooltip, MenuTooltipTrigger } from '@/components/icon-tooltip';
3
3
  import { buttonVariants } from '@/components/ui/button';
4
4
  import {
5
5
  DropdownMenu,
@@ -7,7 +7,6 @@ import {
7
7
  DropdownMenuItem,
8
8
  DropdownMenuTrigger,
9
9
  } from '@/components/ui/dropdown-menu';
10
- import { TooltipTrigger } from '@/components/ui/tooltip';
11
10
  import { LOCALE_OPTIONS, setLocale } from '@/lib/locale-store';
12
11
  import { useLocale } from '@/lib/use-locale';
13
12
  import { cn } from '@/lib/utils';
@@ -20,7 +19,7 @@ export function LanguageToggle() {
20
19
  <IconTooltip label={t.languageToggle.title}>
21
20
  <DropdownMenuTrigger
22
21
  render={
23
- <TooltipTrigger
22
+ <MenuTooltipTrigger
24
23
  type="button"
25
24
  aria-label={t.languageToggle.toggleAria}
26
25
  className={cn(buttonVariants({ variant: 'ghost', size: 'icon-sm' }))}
@@ -44,10 +44,7 @@ export function NotesDrawer({ slideId, index, total, initial }: Props) {
44
44
  })();
45
45
 
46
46
  return (
47
- <aside
48
- data-notes-drawer
49
- className="hidden shrink-0 border-t border-hairline bg-sidebar/85 backdrop-blur md:block"
50
- >
47
+ <aside data-notes-drawer className="hidden shrink-0 bg-sidebar md:block">
51
48
  <button
52
49
  type="button"
53
50
  onClick={() => {
@@ -56,12 +53,12 @@ export function NotesDrawer({ slideId, index, total, initial }: Props) {
56
53
  return !o;
57
54
  });
58
55
  }}
59
- className="flex h-9 w-full items-center gap-2 px-3 text-[12px] text-foreground/80 hover:bg-muted/40"
56
+ className="flex h-9 w-full items-center gap-2 px-3 text-[12px] text-foreground/80 transition-colors duration-150 hover:bg-muted/40 active:bg-muted/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring/30"
60
57
  aria-expanded={open}
61
58
  >
62
59
  <NotebookPen className="size-3.5 text-muted-foreground" />
63
60
  <span className="font-medium">{t.notesDrawer.toggle}</span>
64
- <span className="font-mono text-[11px] text-muted-foreground">
61
+ <span className="font-mono text-[11px] tabular-nums text-muted-foreground">
65
62
  {format(t.notesDrawer.pageLabel, { n: index + 1, total })}
66
63
  </span>
67
64
  <span
@@ -81,7 +78,7 @@ export function NotesDrawer({ slideId, index, total, initial }: Props) {
81
78
  </button>
82
79
  {mounted && (
83
80
  <div
84
- className="overflow-hidden border-t border-hairline transition-[height] ease-out"
81
+ className="overflow-hidden transition-[height] ease-swift motion-reduce:transition-none"
85
82
  style={{
86
83
  height: animVisible ? DRAWER_CONTENT_H : 0,
87
84
  transitionDuration: `${PANEL_TRANSITION_MS}ms`,