@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
@@ -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);
@@ -200,6 +219,12 @@ function Frame({
200
219
  const imageAnchor = anchor instanceof HTMLImageElement ? anchor : null;
201
220
  const actionsVisible = showImageActions && visible && !!imageAnchor;
202
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
+
203
228
  return (
204
229
  <>
205
230
  <div
@@ -211,7 +236,7 @@ function Frame({
211
236
  height: rect.height,
212
237
  opacity: visible ? 1 : 0,
213
238
  transition,
214
- ...FRAME_STYLES[variant],
239
+ ...frameStyle,
215
240
  }}
216
241
  />
217
242
  {showImageActions && imageAnchor && (
@@ -310,70 +335,3 @@ function sameRect(a: RelRect | null, b: RelRect): boolean {
310
335
  Math.abs(a.height - b.height) < 0.5
311
336
  );
312
337
  }
313
-
314
- // Only inspect events that originate inside the slide root. Portaled UI
315
- // (dialogs, tooltips, toasts) mounts on `document.body`, outside the root;
316
- // without this guard the capture-phase window listeners swallow clicks
317
- // meant for a dialog and select the slide element behind it instead.
318
- function isInspectableEventTarget(target: EventTarget | null): boolean {
319
- if (!(target instanceof Element)) return false;
320
- if (target.closest('[data-inspector-ui]')) return false;
321
- return !!target.closest('[data-inspector-root]');
322
- }
323
-
324
- function pickElement(x: number, y: number): HTMLElement | null {
325
- const stack = document.elementsFromPoint(x, y);
326
- for (const el of stack) {
327
- if (!(el instanceof HTMLElement)) continue;
328
- if (el.closest('[data-inspector-ui]')) continue;
329
- if (!el.closest('[data-inspector-root]')) continue;
330
- return el;
331
- }
332
- return null;
333
- }
334
-
335
- const INLINE_TEXT_TAGS = new Set([
336
- 'B',
337
- 'CODE',
338
- 'DEL',
339
- 'EM',
340
- 'I',
341
- 'INS',
342
- 'MARK',
343
- 'S',
344
- 'SMALL',
345
- 'SPAN',
346
- 'STRONG',
347
- 'SUB',
348
- 'SUP',
349
- 'U',
350
- ]);
351
-
352
- function pickInspectorTarget(el: HTMLElement | null): HTMLElement | null {
353
- if (!el) return null;
354
- const root = el.closest('[data-inspector-root]');
355
- const startedOnInlineText = INLINE_TEXT_TAGS.has(el.tagName);
356
- for (let cur: HTMLElement | null = el; cur && root?.contains(cur); cur = cur.parentElement) {
357
- if (startedOnInlineText && INLINE_TEXT_TAGS.has(cur.tagName)) continue;
358
- if (isEditableTextContainer(cur)) return cur;
359
- }
360
- return el;
361
- }
362
-
363
- function isEditableTextContainer(el: HTMLElement): boolean {
364
- if (!el.textContent?.trim()) return false;
365
- return hasOnlyInlineTextChildren(el);
366
- }
367
-
368
- function hasOnlyInlineTextChildren(el: HTMLElement): boolean {
369
- for (const child of Array.from(el.childNodes)) {
370
- if (child.nodeType === Node.TEXT_NODE) {
371
- continue;
372
- } else if (child instanceof HTMLElement) {
373
- if (child.tagName === 'BR') continue;
374
- if (INLINE_TEXT_TAGS.has(child.tagName) && hasOnlyInlineTextChildren(child)) continue;
375
- }
376
- return false;
377
- }
378
- return true;
379
- }
@@ -29,10 +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';
35
- import { cn } from '@/lib/utils';
36
+ import { cn, round2 } from '@/lib/utils';
36
37
  import type { Locale } from '../../../locale/types';
37
38
  import { AssetPickerDialog } from './asset-picker-dialog';
38
39
  import { type SelectedTarget, useInspector } from './inspector-provider';
@@ -72,8 +73,17 @@ function resolveSelectedTarget(target: SelectedTarget, slideId: string): Selecte
72
73
  }
73
74
 
74
75
  export function InspectorPanel() {
75
- const { active, slideId, selected, setSelected, bufferOps, pendingCount, add, applyEdit } =
76
- useInspector();
76
+ const {
77
+ active,
78
+ slideId,
79
+ selected,
80
+ setSelected,
81
+ bufferOps,
82
+ pendingCount,
83
+ opsVersion,
84
+ add,
85
+ applyEdit,
86
+ } = useInspector();
77
87
  const [snapshot, setSnapshot] = useState<ElementSnapshot | null>(null);
78
88
  const [contentSelection, setContentSelection] = useState<ContentSelection | null>(null);
79
89
  const [rangeStylePreview, setRangeStylePreview] = useState<RangeStylePreview | null>(null);
@@ -89,6 +99,7 @@ export function InspectorPanel() {
89
99
  useEffect(() => {
90
100
  void reloadCounter;
91
101
  void pendingCount;
102
+ void opsVersion;
92
103
  if (!selected) {
93
104
  setSnapshot(null);
94
105
  return;
@@ -104,7 +115,7 @@ export function InspectorPanel() {
104
115
  }
105
116
  }
106
117
  setSnapshot(readSnapshot(anchor));
107
- }, [selected, setSelected, slideId, reloadCounter, pendingCount]);
118
+ }, [selected, setSelected, slideId, reloadCounter, pendingCount, opsVersion]);
108
119
 
109
120
  // Freeze slide animations while editing so commits don't replay motion.
110
121
  useEffect(() => {
@@ -171,7 +182,7 @@ export function InspectorPanel() {
171
182
  rangeStylePreview.start === contentRange.start &&
172
183
  rangeStylePreview.end === contentRange.end;
173
184
  const typographySnapshot = rangePreviewApplies
174
- ? withStylePreview(pinSnapshot, rangeStylePreview.values)
185
+ ? { ...pinSnapshot, ...rangeStylePreview.values }
175
186
  : pinSnapshot;
176
187
  const applyTextStyle = (ops: EditOp[]) => {
177
188
  const styleOps = ops.flatMap((op) => (op.kind === 'set-style' ? [op] : []));
@@ -370,10 +381,6 @@ function stylePreviewFromOps(ops: Array<Extract<EditOp, { kind: 'set-style' }>>)
370
381
  return preview;
371
382
  }
372
383
 
373
- function withStylePreview(snapshot: ElementSnapshot, preview: StylePreview): ElementSnapshot {
374
- return { ...snapshot, ...preview };
375
- }
376
-
377
384
  function ContentField({
378
385
  snapshot,
379
386
  apply,
@@ -959,7 +966,7 @@ function CommentsSection({
959
966
 
960
967
  function readSnapshot(el: HTMLElement): ElementSnapshot {
961
968
  const cs = getComputedStyle(el);
962
- const text = isSimpleTextElement(el) ? readEditableText(el) : null;
969
+ const text = hasOnlyInlineTextChildren(el) ? readEditableText(el) : null;
963
970
  const imageSrc =
964
971
  el.tagName === 'IMG'
965
972
  ? (el as HTMLImageElement).currentSrc || (el as HTMLImageElement).src || null
@@ -989,41 +996,6 @@ function readSnapshot(el: HTMLElement): ElementSnapshot {
989
996
  };
990
997
  }
991
998
 
992
- function isSimpleTextElement(el: HTMLElement): boolean {
993
- if (el.childNodes.length === 0) return true;
994
- return hasOnlyInlineTextChildren(el);
995
- }
996
-
997
- const INLINE_TEXT_TAGS = new Set([
998
- 'B',
999
- 'CODE',
1000
- 'DEL',
1001
- 'EM',
1002
- 'I',
1003
- 'INS',
1004
- 'MARK',
1005
- 'S',
1006
- 'SMALL',
1007
- 'SPAN',
1008
- 'STRONG',
1009
- 'SUB',
1010
- 'SUP',
1011
- 'U',
1012
- ]);
1013
-
1014
- function hasOnlyInlineTextChildren(el: HTMLElement): boolean {
1015
- for (const child of Array.from(el.childNodes)) {
1016
- if (child.nodeType === Node.TEXT_NODE) {
1017
- continue;
1018
- } else if (child instanceof HTMLElement) {
1019
- if (child.tagName === 'BR') continue;
1020
- if (INLINE_TEXT_TAGS.has(child.tagName) && hasOnlyInlineTextChildren(child)) continue;
1021
- }
1022
- return false;
1023
- }
1024
- return true;
1025
- }
1026
-
1027
999
  function readEditableText(el: HTMLElement): string {
1028
1000
  const parts: string[] = [];
1029
1001
  for (const child of Array.from(el.childNodes)) {
@@ -1099,10 +1071,6 @@ function parseLetterSpacing(value: string): number {
1099
1071
  return Number.isFinite(n) ? round2(n) : 0;
1100
1072
  }
1101
1073
 
1102
- function round2(n: number): number {
1103
- return Math.round(n * 100) / 100;
1104
- }
1105
-
1106
1074
  function findElementByLine(slideId: string, line: number, column: number): HTMLElement | null {
1107
1075
  const root = document.querySelector('[data-inspector-root]');
1108
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;
@@ -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={() => {
@@ -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-swift motion-reduce:transition-none"
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`,
@@ -1,8 +1,9 @@
1
1
  import { ListOrdered, type LucideIcon, Sparkles, X } from 'lucide-react';
2
2
  import { type Ref, useEffect, useRef, useState } from 'react';
3
3
  import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip';
4
+ import { isTypingTarget } from '@/lib/keys';
4
5
  import { format, useLocale } from '@/lib/use-locale';
5
- import { cn } from '@/lib/utils';
6
+ import { cn, pad2 } from '@/lib/utils';
6
7
  import type { DesignSystem } from '../lib/design';
7
8
  import { SlidePageProvider } from '../lib/page-context';
8
9
  import type { Page } from '../lib/sdk';
@@ -60,7 +61,7 @@ export function OverviewGrid({
60
61
  useEffect(() => {
61
62
  if (!open) return;
62
63
  const onKey = (e: KeyboardEvent) => {
63
- if (e.target instanceof HTMLElement && e.target.matches('input, textarea')) return;
64
+ if (isTypingTarget(e.target)) return;
64
65
  const cols = computeCols(gridRef.current);
65
66
  if (e.key === 'ArrowRight') {
66
67
  e.preventDefault();
@@ -120,7 +121,7 @@ export function OverviewGrid({
120
121
  <span className={cn('eyebrow', styles.eyebrow)}>{t.present.overviewEyebrow}</span>
121
122
  <div className="flex items-center gap-3">
122
123
  <span className={cn('font-mono text-[11px] tabular-nums', styles.eyebrow)}>
123
- {(focused + 1).toString().padStart(2, '0')} · {pages.length.toString().padStart(2, '0')}
124
+ {pad2(focused + 1)} · {pad2(pages.length)}
124
125
  </span>
125
126
  <button
126
127
  type="button"
@@ -262,7 +263,7 @@ function OverviewThumb({
262
263
  isFocused || isCurrent ? styles.labelActive : styles.labelMuted,
263
264
  )}
264
265
  >
265
- {(index + 1).toString().padStart(2, '0')}
266
+ {pad2(index + 1)}
266
267
  </span>
267
268
  {(hasTransition || hasSteps) && (
268
269
  <span className="flex items-center gap-1">
@@ -55,11 +55,9 @@ export function PanelShell({
55
55
  return (
56
56
  <aside
57
57
  {...dataAttrs}
58
- className="flex h-full shrink-0 justify-end overflow-hidden bg-sidebar transition-[width,border-left-width] ease-swift motion-reduce:transition-none"
58
+ className="flex h-full shrink-0 justify-end overflow-hidden bg-sidebar transition-[width] ease-swift motion-reduce:transition-none"
59
59
  style={{
60
60
  width: animVisible ? PANEL_W : 0,
61
- borderLeftWidth: animVisible ? 1 : 0,
62
- borderLeftColor: 'var(--hairline)',
63
61
  transitionDuration: `${PANEL_TRANSITION_MS}ms`,
64
62
  }}
65
63
  >
@@ -1,4 +1,5 @@
1
1
  import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
2
+ import { hasModifier, isBackwardKey, isForwardKey, isTypingTarget } from '@/lib/keys';
2
3
  import { useClickPageNavigation } from '@/lib/use-click-page-navigation';
3
4
  import { useWheelPageNavigation } from '@/lib/use-wheel-page-navigation';
4
5
  import { cn } from '@/lib/utils';
@@ -271,8 +272,7 @@ export function Player({
271
272
 
272
273
  useEffect(() => {
273
274
  const onKey = (e: KeyboardEvent) => {
274
- const tgt = e.target;
275
- if (tgt instanceof HTMLElement && tgt.matches('input, textarea')) return;
275
+ if (isTypingTarget(e.target)) return;
276
276
 
277
277
  // While an overlay is open, only Esc and the toggle that owns it
278
278
  // should reach the Player. Overview installs its own capture-phase
@@ -300,9 +300,8 @@ export function Player({
300
300
  return;
301
301
  }
302
302
 
303
- const isNext =
304
- e.key === 'ArrowRight' || e.key === 'ArrowDown' || e.key === ' ' || e.key === 'PageDown';
305
- const isPrev = e.key === 'ArrowLeft' || e.key === 'ArrowUp' || e.key === 'PageUp';
303
+ const isNext = isForwardKey(e);
304
+ const isPrev = isBackwardKey(e);
306
305
 
307
306
  if (isNext || isPrev) {
308
307
  if (controls && blackout) setBlackout(null);
@@ -334,7 +333,7 @@ export function Player({
334
333
  if (!controls) return;
335
334
  // Single-letter shortcuts only fire when no modifier is held — keeps
336
335
  // browser shortcuts (Cmd/Ctrl-something) from being hijacked.
337
- if (e.altKey || e.ctrlKey || e.metaKey) return;
336
+ if (hasModifier(e)) return;
338
337
 
339
338
  if (e.key === 'b' || e.key === 'B') {
340
339
  e.preventDefault();
@@ -14,7 +14,7 @@ import {
14
14
  import { createContext, useContext, useEffect, useState } from 'react';
15
15
  import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip';
16
16
  import { useLocale } from '@/lib/use-locale';
17
- import { cn } from '@/lib/utils';
17
+ import { cn, pad2 } from '@/lib/utils';
18
18
 
19
19
  const TooltipContainerCtx = createContext<HTMLElement | null>(null);
20
20
 
@@ -107,9 +107,9 @@ export function PresentControlBar({
107
107
  <Divider />
108
108
 
109
109
  <span className="px-2 font-mono text-[11.5px] tracking-[0.08em] tabular-nums uppercase select-none text-white/85">
110
- <span className="text-white">{(index + 1).toString().padStart(2, '0')}</span>
110
+ <span className="text-white">{pad2(index + 1)}</span>
111
111
  <span className="text-white/35"> / </span>
112
- <span>{total.toString().padStart(2, '0')}</span>
112
+ <span>{pad2(total)}</span>
113
113
  </span>
114
114
 
115
115
  <Divider />
@@ -320,7 +320,7 @@ function ElapsedClock({ startedAt }: { startedAt: number }) {
320
320
  title={t.present.elapsedTime}
321
321
  className="px-2 font-mono text-[11.5px] tracking-[0.08em] tabular-nums uppercase select-none text-white/70"
322
322
  >
323
- {m.toString().padStart(2, '0')}:{s.toString().padStart(2, '0')}
323
+ {pad2(m)}:{pad2(s)}
324
324
  </time>
325
325
  );
326
326
  }
@@ -1,4 +1,5 @@
1
1
  import { useEffect, useRef, useState } from 'react';
2
+ import { hasModifier, isTypingTarget } from '@/lib/keys';
2
3
  import { cn } from '@/lib/utils';
3
4
 
4
5
  const FLUSH_DELAY_MS = 1200;
@@ -45,8 +46,8 @@ export function PresentJumpInput({ pageCount, onJump }: Props) {
45
46
  };
46
47
 
47
48
  const onKey = (e: KeyboardEvent) => {
48
- if (e.target instanceof HTMLElement && e.target.matches('input, textarea')) return;
49
- if (e.altKey || e.ctrlKey || e.metaKey) return;
49
+ if (isTypingTarget(e.target)) return;
50
+ if (hasModifier(e)) return;
50
51
 
51
52
  if (/^[0-9]$/.test(e.key)) {
52
53
  e.preventDefault();
@@ -15,7 +15,6 @@ export type PresenterCommand =
15
15
  | { type: 'next' }
16
16
  | { type: 'prev' }
17
17
  | { type: 'request-state' }
18
- | { type: 'restart-timer' }
19
18
  | { type: 'toggle-blackout'; mode: 'black' | 'white' }
20
19
  | { type: 'switch-slide'; slideId: string };
21
20