@open-slide/core 1.12.0 → 1.13.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 (34) hide show
  1. package/README.md +2 -0
  2. package/dist/{build-L2yL1hTo.js → build-OAZ8maw5.js} +1 -1
  3. package/dist/cli/bin.js +3 -3
  4. package/dist/{config-OT4T-im0.js → config-CU_NISD6.js} +49 -4
  5. package/dist/{config-C2C3cut3.d.ts → config-x493taft.d.ts} +1 -1
  6. package/dist/{dev-DJUpPCGT.js → dev-C78J1TLR.js} +1 -1
  7. package/dist/{format-zplQGJPI.js → format-7j0EzhuV.js} +4 -0
  8. package/dist/index.d.ts +31 -9
  9. package/dist/index.js +22 -2
  10. package/dist/locale/index.d.ts +1 -1
  11. package/dist/locale/index.js +1 -1
  12. package/dist/{preview-Bf8up6-P.js → preview-DZLZ3L9v.js} +1 -1
  13. package/dist/{types-uNHQlioH.d.ts → types-CHmFPIG_.d.ts} +1 -0
  14. package/dist/vite/index.d.ts +2 -2
  15. package/dist/vite/index.js +1 -1
  16. package/package.json +5 -5
  17. package/src/app/components/inspector/inspect-overlay.tsx +39 -18
  18. package/src/app/components/inspector/inspector-panel.tsx +5 -1
  19. package/src/app/components/inspector/inspector-provider.tsx +54 -6
  20. package/src/app/components/overview-grid.tsx +200 -69
  21. package/src/app/components/player.tsx +66 -3
  22. package/src/app/components/present/control-bar.tsx +99 -7
  23. package/src/app/components/shared-element.tsx +48 -0
  24. package/src/app/components/slide-canvas.tsx +24 -14
  25. package/src/app/components/slide-transition-layer.tsx +506 -4
  26. package/src/app/lib/export-html.ts +1 -1
  27. package/src/app/lib/transition.ts +7 -0
  28. package/src/app/lib/use-click-page-navigation.ts +10 -2
  29. package/src/app/routes/slide.tsx +175 -143
  30. package/src/locale/en.ts +1 -0
  31. package/src/locale/ja.ts +1 -0
  32. package/src/locale/types.ts +1 -0
  33. package/src/locale/zh-cn.ts +1 -0
  34. package/src/locale/zh-tw.ts +1 -0
package/README.md CHANGED
@@ -78,9 +78,11 @@ export const meta = { title: 'Hello' };
78
78
  import {
79
79
  CANVAS_WIDTH, // 1920
80
80
  CANVAS_HEIGHT, // 1080
81
+ unstable_SharedElement, // match or fade objects across pages for shared element transitions
81
82
  type Page,
82
83
  type SlideMeta,
83
84
  type SlideModule,
85
+ type SlideTransition,
84
86
  type OpenSlideConfig,
85
87
  } from '@open-slide/core';
86
88
  ```
@@ -1,5 +1,5 @@
1
1
  import "./design-cpzS8aud.js";
2
- import { createViteConfig } from "./config-OT4T-im0.js";
2
+ import { createViteConfig } from "./config-CU_NISD6.js";
3
3
  import path from "node:path";
4
4
  import { build as build$1, mergeConfig } from "vite";
5
5
 
package/dist/cli/bin.js CHANGED
@@ -57,15 +57,15 @@ async function run(argv) {
57
57
  program.name("open-slide").description("Author slides — we handle the Vite/React stack.").version(version, "-v, --version", "print version").helpOption("-h, --help", "show help").showHelpAfterError(chalk.dim("(run `open-slide --help` for usage)"));
58
58
  program.command("dev").description("Start the dev server").addOption(new Option("-p, --port <port>", "port to listen on").argParser(parsePort)).addOption(new Option("--host [host]", "expose on the network (optional host)")).option("--open", "open the browser on start").option("--no-skills-check", "skip the built-in skills drift check").action(async (flags) => {
59
59
  if (flags.skillsCheck !== false) await runSkillsDriftCheck(resolveBuiltinSkillsDir());
60
- const { dev } = await import("../dev-DJUpPCGT.js");
60
+ const { dev } = await import("../dev-C78J1TLR.js");
61
61
  await dev(flags);
62
62
  });
63
63
  program.command("build").description("Build a static site").option("--out-dir <dir>", "output directory (defaults to `dist`)").action(async (flags) => {
64
- const { build } = await import("../build-L2yL1hTo.js");
64
+ const { build } = await import("../build-OAZ8maw5.js");
65
65
  await build(flags);
66
66
  });
67
67
  program.command("preview").description("Preview the production build").addOption(new Option("-p, --port <port>", "port to listen on").argParser(parsePort)).addOption(new Option("--host [host]", "expose on the network (optional host)")).option("--open", "open the browser on start").action(async (flags) => {
68
- const { preview } = await import("../preview-Bf8up6-P.js");
68
+ const { preview } = await import("../preview-DZLZ3L9v.js");
69
69
  await preview(flags);
70
70
  });
71
71
  program.command("sync:skills").description("Sync built-in skills from @open-slide/core into this workspace").option("--dry-run", "show what would change without writing").action(async (flags) => {
@@ -1642,9 +1642,52 @@ function reorderNotesArrayInSource(source, order) {
1642
1642
  if (found === null) return source;
1643
1643
  const { arrayStart, arrayEnd, elementTexts } = found;
1644
1644
  const pick = (i) => i >= 0 && i < elementTexts.length ? elementTexts[i] : "undefined";
1645
- const reordered = order.map(pick);
1646
- while (reordered.length > 0 && reordered[reordered.length - 1] === "undefined") reordered.pop();
1647
- const replacement = reordered.length === 0 ? "[]" : `[\n${reordered.map((s) => ` ${s},`).join("\n")}\n]`;
1645
+ return rebuildNotesArray(source, arrayStart, arrayEnd, order.map(pick));
1646
+ }
1647
+ /**
1648
+ * Remove the note aligned with the page at `index` so the `notes` export stays
1649
+ * index-aligned with `export default [...]` after a page deletion. Mirrors
1650
+ * {@link removePageFromDefaultExportInSource}.
1651
+ *
1652
+ * Returns the rewritten source, the original source if no `notes` export exists
1653
+ * or the index falls past the recorded notes, or `null` if the `notes` export's
1654
+ * shape is too surprising to touch safely.
1655
+ */
1656
+ function removeNotesElementInSource(source, index) {
1657
+ if (!Number.isInteger(index) || index < 0) return null;
1658
+ const found = findNotesArray(source);
1659
+ if (found === "invalid") return null;
1660
+ if (found === null) return source;
1661
+ const { arrayStart, arrayEnd, elementTexts } = found;
1662
+ if (index >= elementTexts.length) return source;
1663
+ const next = elementTexts.slice();
1664
+ next.splice(index, 1);
1665
+ return rebuildNotesArray(source, arrayStart, arrayEnd, next);
1666
+ }
1667
+ /**
1668
+ * Duplicate the note aligned with the page at `index`, inserting the copy right
1669
+ * after it so the `notes` export stays index-aligned with `export default [...]`
1670
+ * after a page duplication. Mirrors {@link duplicatePageInDefaultExportInSource}.
1671
+ *
1672
+ * Returns the rewritten source, the original source if no `notes` export exists
1673
+ * or the index falls past the recorded notes (the new slot and everything after
1674
+ * it are absent, so nothing shifts), or `null` if the shape is too surprising.
1675
+ */
1676
+ function duplicateNotesElementInSource(source, index) {
1677
+ if (!Number.isInteger(index) || index < 0) return null;
1678
+ const found = findNotesArray(source);
1679
+ if (found === "invalid") return null;
1680
+ if (found === null) return source;
1681
+ const { arrayStart, arrayEnd, elementTexts } = found;
1682
+ if (index >= elementTexts.length) return source;
1683
+ const next = elementTexts.slice();
1684
+ next.splice(index + 1, 0, next[index]);
1685
+ return rebuildNotesArray(source, arrayStart, arrayEnd, next);
1686
+ }
1687
+ function rebuildNotesArray(source, arrayStart, arrayEnd, elements) {
1688
+ const trimmed = elements.slice();
1689
+ while (trimmed.length > 0 && trimmed[trimmed.length - 1] === "undefined") trimmed.pop();
1690
+ const replacement = trimmed.length === 0 ? "[]" : `[\n${trimmed.map((s) => ` ${s},`).join("\n")}\n]`;
1648
1691
  if (replacement === source.slice(arrayStart, arrayEnd)) return source;
1649
1692
  return source.slice(0, arrayStart) + replacement + source.slice(arrayEnd);
1650
1693
  }
@@ -2647,7 +2690,9 @@ function registerSlideRoutes(server, ctx) {
2647
2690
  }
2648
2691
  const updated = isDelete ? removePageFromDefaultExportInSource(source, pageIndex) : duplicatePageInDefaultExportInSource(source, pageIndex);
2649
2692
  if (updated === null) return json(res, 422, { error: isDelete ? "could not delete page — index out of range or default export is not an array" : "could not duplicate page — index out of range or default export is not an array" });
2650
- if (updated !== source) await fs.writeFile(entry, updated, "utf8");
2693
+ const withNotes = isDelete ? removeNotesElementInSource(updated, pageIndex) : duplicateNotesElementInSource(updated, pageIndex);
2694
+ if (withNotes === null) return json(res, 422, { error: isDelete ? "could not delete page — `notes` export has an unexpected shape" : "could not duplicate page — `notes` export has an unexpected shape" });
2695
+ if (withNotes !== source) await fs.writeFile(entry, withNotes, "utf8");
2651
2696
  return json(res, 200, {
2652
2697
  ok: true,
2653
2698
  slideId: slideId$1,
@@ -1,4 +1,4 @@
1
- import { Locale } from "./types-uNHQlioH.js";
1
+ import { Locale } from "./types-CHmFPIG_.js";
2
2
 
3
3
  //#region src/config.d.ts
4
4
  type OpenSlideBuildConfig = {
@@ -1,5 +1,5 @@
1
1
  import "./design-cpzS8aud.js";
2
- import { createViteConfig } from "./config-OT4T-im0.js";
2
+ import { createViteConfig } from "./config-CU_NISD6.js";
3
3
  import { createServer, mergeConfig } from "vite";
4
4
 
5
5
  //#region src/cli/dev.ts
@@ -99,6 +99,7 @@ const en = {
99
99
  agentDisconnectedTooltip: "Lost connection to the dev server, so your agent can no longer see the current slide or inspector selection. Restart the dev server to restore the connection.",
100
100
  download: "Download",
101
101
  copyLink: "Copy link",
102
+ moreActions: "More actions",
102
103
  toastCopyLinkSuccess: "Link copied to clipboard",
103
104
  toastCopyLinkFailed: "Failed to copy link",
104
105
  exportAsHtml: "Export as HTML",
@@ -496,6 +497,7 @@ const ja = {
496
497
  backToHome: "ホームへ戻る",
497
498
  download: "ダウンロード",
498
499
  copyLink: "リンクをコピー",
500
+ moreActions: "その他の操作",
499
501
  toastCopyLinkSuccess: "リンクをクリップボードにコピーしました",
500
502
  toastCopyLinkFailed: "リンクのコピーに失敗しました",
501
503
  exportAsHtml: "HTML として書き出し",
@@ -893,6 +895,7 @@ const zhCN = {
893
895
  backToHome: "返回首页",
894
896
  download: "下载",
895
897
  copyLink: "复制链接",
898
+ moreActions: "更多操作",
896
899
  toastCopyLinkSuccess: "已复制链接到剪贴板",
897
900
  toastCopyLinkFailed: "复制链接失败",
898
901
  exportAsHtml: "导出为 HTML",
@@ -1290,6 +1293,7 @@ const zhTW = {
1290
1293
  backToHome: "返回首頁",
1291
1294
  download: "下載",
1292
1295
  copyLink: "複製連結",
1296
+ moreActions: "更多動作",
1293
1297
  toastCopyLinkSuccess: "已複製連結到剪貼簿",
1294
1298
  toastCopyLinkFailed: "複製連結失敗",
1295
1299
  exportAsHtml: "匯出為 HTML",
package/dist/index.d.ts CHANGED
@@ -1,9 +1,10 @@
1
- import { Locale, Plural } from "./types-uNHQlioH.js";
2
- import { OpenSlideConfig } from "./config-C2C3cut3.js";
3
- import { CSSProperties, ComponentType, HTMLAttributes, PropsWithChildren } from "react";
4
- import * as react_jsx_runtime0 from "react/jsx-runtime";
5
- import * as react_jsx_runtime3 from "react/jsx-runtime";
1
+ import { Locale, Plural } from "./types-CHmFPIG_.js";
2
+ import { OpenSlideConfig } from "./config-x493taft.js";
3
+ import { CSSProperties, ComponentType, HTMLAttributes, PropsWithChildren, ReactNode } from "react";
6
4
  import * as react_jsx_runtime4 from "react/jsx-runtime";
5
+ import * as react_jsx_runtime3 from "react/jsx-runtime";
6
+ import * as react_jsx_runtime1 from "react/jsx-runtime";
7
+ import * as react_jsx_runtime2 from "react/jsx-runtime";
7
8
 
8
9
  //#region src/app/components/image-placeholder.d.ts
9
10
  type ImagePlaceholderProps = {
@@ -20,7 +21,22 @@ declare function ImagePlaceholder({
20
21
  style,
21
22
  className,
22
23
  ...rest
23
- }: ImagePlaceholderProps): react_jsx_runtime0.JSX.Element;
24
+ }: ImagePlaceholderProps): react_jsx_runtime4.JSX.Element;
25
+
26
+ //#endregion
27
+ //#region src/app/components/shared-element.d.ts
28
+ type unstable_SharedElementProps = {
29
+ id: string;
30
+ children: ReactNode;
31
+ className?: string;
32
+ style?: CSSProperties;
33
+ };
34
+ declare function unstable_SharedElement({
35
+ id,
36
+ children,
37
+ className,
38
+ style
39
+ }: unstable_SharedElementProps): react_jsx_runtime3.JSX.Element;
24
40
 
25
41
  //#endregion
26
42
  //#region src/app/lib/design.d.ts
@@ -67,6 +83,12 @@ type SlideTransition = {
67
83
  easing?: string;
68
84
  enter?: TransitionPhase;
69
85
  exit?: TransitionPhase;
86
+ sharedElements?: boolean | SharedElementTransition;
87
+ };
88
+ type SharedElementTransition = {
89
+ duration?: number;
90
+ easing?: string;
91
+ delay?: number;
70
92
  };
71
93
 
72
94
  //#endregion
@@ -95,7 +117,7 @@ declare const CANVAS_HEIGHT = 1080;
95
117
  type StepsProps = PropsWithChildren;
96
118
  declare function Steps({
97
119
  children
98
- }: StepsProps): react_jsx_runtime3.JSX.Element;
120
+ }: StepsProps): react_jsx_runtime1.JSX.Element;
99
121
  type StepProps = PropsWithChildren<{
100
122
  duration?: number;
101
123
  }>;
@@ -106,7 +128,7 @@ declare function Step({
106
128
  children,
107
129
  duration,
108
130
  _revealed
109
- }: InternalStepProps): react_jsx_runtime4.JSX.Element;
131
+ }: InternalStepProps): react_jsx_runtime2.JSX.Element;
110
132
 
111
133
  //#endregion
112
- export { CANVAS_HEIGHT, CANVAS_WIDTH, DesignFonts, DesignPalette, DesignSystem, DesignTypeScale, ImagePlaceholder, ImagePlaceholderProps, Locale, OpenSlideConfig, Page, Plural, SlideMeta, SlideModule, SlideTransition, Step, StepProps, Steps, StepsProps, TransitionPhase, cssVarsToString, defaultDesign, designToCssVars, useSlidePageNumber };
134
+ export { CANVAS_HEIGHT, CANVAS_WIDTH, DesignFonts, DesignPalette, DesignSystem, DesignTypeScale, ImagePlaceholder, ImagePlaceholderProps, Locale, OpenSlideConfig, Page, Plural, SharedElementTransition, SlideMeta, SlideModule, SlideTransition, Step, StepProps, Steps, StepsProps, TransitionPhase, cssVarsToString, defaultDesign, designToCssVars, unstable_SharedElement, unstable_SharedElementProps, useSlidePageNumber };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { en, ja, zhCN, zhTW } from "./format-zplQGJPI.js";
1
+ import { en, ja, zhCN, zhTW } from "./format-7j0EzhuV.js";
2
2
  import { cssVarsToString, defaultDesign, designToCssVars } from "./design-cpzS8aud.js";
3
3
  import { Children, cloneElement, createContext, isValidElement, useCallback, useContext, useEffect, useLayoutEffect, useRef, useState, useSyncExternalStore } from "react";
4
4
  import { toast } from "sonner";
@@ -331,6 +331,26 @@ function PlaceholderIcon() {
331
331
  });
332
332
  }
333
333
 
334
+ //#endregion
335
+ //#region src/app/components/shared-element.tsx
336
+ function unstable_SharedElement({ id, children, className, style }) {
337
+ const child = Children.toArray(children)[0] ?? null;
338
+ if (Children.count(children) === 1 && isValidElement(child) && typeof child.type === "string") return cloneElement(child, {
339
+ "data-osd-shared-element": id,
340
+ className: [child.props.className, className].filter(Boolean).join(" ") || void 0,
341
+ style: style ? {
342
+ ...child.props.style,
343
+ ...style
344
+ } : child.props.style
345
+ });
346
+ return /* @__PURE__ */ jsx("div", {
347
+ className,
348
+ style,
349
+ "data-osd-shared-element": id,
350
+ children
351
+ });
352
+ }
353
+
334
354
  //#endregion
335
355
  //#region src/app/lib/page-context.tsx
336
356
  const GLOBAL_KEY$1 = "__open_slide_page_context__";
@@ -444,4 +464,4 @@ function Step({ children, duration = 180, _revealed }) {
444
464
  }
445
465
 
446
466
  //#endregion
447
- export { CANVAS_HEIGHT, CANVAS_WIDTH, ImagePlaceholder, Step, Steps, cssVarsToString, defaultDesign, designToCssVars, useSlidePageNumber };
467
+ export { CANVAS_HEIGHT, CANVAS_WIDTH, ImagePlaceholder, Step, Steps, cssVarsToString, defaultDesign, designToCssVars, unstable_SharedElement, useSlidePageNumber };
@@ -1,4 +1,4 @@
1
- import { Locale, Plural } from "../types-uNHQlioH.js";
1
+ import { Locale, Plural } from "../types-CHmFPIG_.js";
2
2
 
3
3
  //#region src/locale/en.d.ts
4
4
  declare const en: Locale;
@@ -1,3 +1,3 @@
1
- import { en, format, ja, plural, zhCN, zhTW } from "../format-zplQGJPI.js";
1
+ import { en, format, ja, plural, zhCN, zhTW } from "../format-7j0EzhuV.js";
2
2
 
3
3
  export { en, format, ja, plural, zhCN, zhTW };
@@ -1,5 +1,5 @@
1
1
  import "./design-cpzS8aud.js";
2
- import { createViteConfig } from "./config-OT4T-im0.js";
2
+ import { createViteConfig } from "./config-CU_NISD6.js";
3
3
  import { mergeConfig, preview as preview$1 } from "vite";
4
4
 
5
5
  //#region src/cli/preview.ts
@@ -107,6 +107,7 @@ type Locale = {
107
107
  agentDisconnectedTooltip: string;
108
108
  download: string;
109
109
  copyLink: string;
110
+ moreActions: string;
110
111
  toastCopyLinkSuccess: string;
111
112
  toastCopyLinkFailed: string;
112
113
  exportAsHtml: string;
@@ -1,5 +1,5 @@
1
- import "../types-uNHQlioH.js";
2
- import { OpenSlideConfig } from "../config-C2C3cut3.js";
1
+ import "../types-CHmFPIG_.js";
2
+ import { OpenSlideConfig } from "../config-x493taft.js";
3
3
  import { InlineConfig } from "vite";
4
4
 
5
5
  //#region src/vite/config.d.ts
@@ -1,4 +1,4 @@
1
1
  import "../design-cpzS8aud.js";
2
- import { createViteConfig } from "../config-OT4T-im0.js";
2
+ import { createViteConfig } from "../config-CU_NISD6.js";
3
3
 
4
4
  export { createViteConfig };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-slide/core",
3
- "version": "1.12.0",
3
+ "version": "1.13.0",
4
4
  "description": "Runtime and CLI for open-slide — write slides in slides/, we handle the rest.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -70,8 +70,8 @@
70
70
  "chalk": "^5.3.0",
71
71
  "class-variance-authority": "^0.7.1",
72
72
  "clsx": "^2.1.1",
73
- "commander": "^12.1.0",
74
- "emoji-picker-react": "^4.18.0",
73
+ "commander": "^15.0.0",
74
+ "emoji-picker-react": "^4.19.1",
75
75
  "fast-glob": "^3.3.2",
76
76
  "fflate": "^0.8.2",
77
77
  "html-to-image": "^1.11.13",
@@ -81,8 +81,8 @@
81
81
  "react": "^18.3.1",
82
82
  "react-dom": "^18.3.1",
83
83
  "react-image-crop": "^11.0.10",
84
- "react-router-dom": "^6.26.2",
85
- "shadcn": "^4.3.0",
84
+ "react-router-dom": "^7.18.0",
85
+ "shadcn": "^4.11.0",
86
86
  "sonner": "^2.0.7",
87
87
  "tailwind-merge": "^3.5.0",
88
88
  "tailwindcss": "^4.2.2",
@@ -16,17 +16,13 @@ const FRAME_MORPH_MS = 180;
16
16
  const LAYOUT_TRACK_MS = PANEL_TRANSITION_MS + FRAME_MORPH_MS;
17
17
 
18
18
  export function InspectOverlay() {
19
- const { active, slideId, selected, setSelected, cancel, openCrop } = useInspector();
19
+ const { active, activate, slideId, selected, setSelected, cancel, openCrop } = useInspector();
20
20
  const overlayRef = useRef<HTMLDivElement>(null);
21
21
  const [hover, setHover] = useState<Highlight | null>(null);
22
22
 
23
23
  useEffect(() => {
24
- if (!active) {
25
- setHover(null);
26
- return;
27
- }
28
-
29
24
  const onKey = (e: KeyboardEvent) => {
25
+ if (!active) return;
30
26
  if (e.key === 'Escape') {
31
27
  e.preventDefault();
32
28
  e.stopPropagation();
@@ -35,52 +31,66 @@ export function InspectOverlay() {
35
31
  };
36
32
 
37
33
  const onMove = (e: PointerEvent) => {
34
+ if (!active) return;
38
35
  if (e.target instanceof Element && e.target.closest('[data-inspector-ui]')) {
39
36
  return setHover(null);
40
37
  }
41
- const el = pickInspectorTarget(pickElement(e.clientX, e.clientY));
42
- if (!el) return setHover(null);
43
- const hit = findSlideSource(el, slideId, { hostOnly: true });
38
+ const hit = findInspectorHitAtPoint(e.clientX, e.clientY, slideId);
44
39
  if (!hit) return setHover(null);
45
40
  setHover({ hit });
46
41
  };
47
42
 
43
+ const onMouseDown = (e: MouseEvent) => {
44
+ if (!active && e.detail < 2) return;
45
+ if (e.target instanceof Element && e.target.closest('[data-inspector-ui]')) return;
46
+ const hit = findInspectorHitAtPoint(e.clientX, e.clientY, slideId);
47
+ if (!hit) return;
48
+ e.preventDefault();
49
+ };
50
+
48
51
  const onClick = (e: MouseEvent) => {
52
+ if (!active) return;
49
53
  if (e.target instanceof Element && e.target.closest('[data-inspector-ui]')) return;
50
- const el = pickInspectorTarget(pickElement(e.clientX, e.clientY));
51
- if (!el) return;
52
- const hit = findSlideSource(el, slideId, { hostOnly: true });
54
+ const hit = findInspectorHitAtPoint(e.clientX, e.clientY, slideId);
53
55
  if (!hit) return;
54
56
  e.preventDefault();
55
57
  e.stopPropagation();
58
+ clearTextSelection();
59
+ activate();
56
60
  setSelected({ line: hit.line, column: hit.column, anchor: hit.anchor });
57
61
  setHover({ hit });
58
62
  };
59
63
 
60
64
  const onDblClick = (e: MouseEvent) => {
61
65
  if (e.target instanceof Element && e.target.closest('[data-inspector-ui]')) return;
62
- const el = pickInspectorTarget(pickElement(e.clientX, e.clientY));
63
- if (!el) return;
64
- const hit = findSlideSource(el, slideId, { hostOnly: true });
66
+ const hit = findInspectorHitAtPoint(e.clientX, e.clientY, slideId);
65
67
  if (!hit) return;
66
- if (!(hit.anchor instanceof HTMLImageElement)) return;
67
68
  e.preventDefault();
68
69
  e.stopPropagation();
70
+ clearTextSelection();
71
+ if (!active) activate();
69
72
  setSelected({ line: hit.line, column: hit.column, anchor: hit.anchor });
70
- openCrop(hit.anchor);
73
+ setHover({ hit });
74
+ if (active && hit.anchor instanceof HTMLImageElement) openCrop(hit.anchor);
71
75
  };
72
76
 
73
77
  window.addEventListener('pointermove', onMove, true);
78
+ window.addEventListener('mousedown', onMouseDown, true);
74
79
  window.addEventListener('click', onClick, true);
75
80
  window.addEventListener('dblclick', onDblClick, true);
76
81
  window.addEventListener('keydown', onKey, true);
77
82
  return () => {
78
83
  window.removeEventListener('pointermove', onMove, true);
84
+ window.removeEventListener('mousedown', onMouseDown, true);
79
85
  window.removeEventListener('click', onClick, true);
80
86
  window.removeEventListener('dblclick', onDblClick, true);
81
87
  window.removeEventListener('keydown', onKey, true);
82
88
  };
83
- }, [active, slideId, setSelected, cancel, openCrop]);
89
+ }, [active, activate, slideId, setSelected, cancel, openCrop]);
90
+
91
+ useEffect(() => {
92
+ if (!active) setHover(null);
93
+ }, [active]);
84
94
 
85
95
  const hoverAnchor = hover?.hit.anchor.isConnected ? hover.hit.anchor : null;
86
96
  const selectedAnchor = selected?.anchor.isConnected ? selected.anchor : null;
@@ -319,6 +329,17 @@ function pickElement(x: number, y: number): HTMLElement | null {
319
329
  return null;
320
330
  }
321
331
 
332
+ function findInspectorHitAtPoint(x: number, y: number, slideId: string): SlideSourceHit | null {
333
+ const el = pickInspectorTarget(pickElement(x, y));
334
+ if (!el) return null;
335
+ return findSlideSource(el, slideId, { hostOnly: true });
336
+ }
337
+
338
+ function clearTextSelection() {
339
+ const selection = window.getSelection();
340
+ if (selection && !selection.isCollapsed) selection.removeAllRanges();
341
+ }
342
+
322
343
  const INLINE_TEXT_TAGS = new Set([
323
344
  'B',
324
345
  'CODE',
@@ -862,7 +862,11 @@ function AgentWatchingBadge() {
862
862
  {connected ? t.inspector.agentWatching : t.inspector.agentNotWatching}
863
863
  </button>
864
864
  </TooltipTrigger>
865
- <TooltipContent side="bottom" align="end" className="max-w-[260px] leading-relaxed">
865
+ <TooltipContent
866
+ side="bottom"
867
+ align="end"
868
+ className="w-max max-w-[min(520px,calc(100vw-2rem))] text-center leading-relaxed"
869
+ >
866
870
  {connected ? t.inspector.agentWatchingTooltip : t.inspector.agentNotWatchingTooltip}
867
871
  </TooltipContent>
868
872
  </Tooltip>
@@ -244,6 +244,7 @@ function replayDomTextRangeStyles(el: HTMLElement, html: string, ops: TextRangeS
244
244
  type InspectorCtx = {
245
245
  slideId: string;
246
246
  active: boolean;
247
+ activate: () => void;
247
248
  toggle: () => void;
248
249
  cancel: () => void;
249
250
  comments: SlideComment[];
@@ -284,11 +285,14 @@ export function InspectorProvider({
284
285
  pageIndex: number;
285
286
  children: ReactNode;
286
287
  }) {
287
- const [active, setActive] = useState(false);
288
+ const [manualActive, setManualActive] = useState(false);
289
+ const [heldActive, setHeldActive] = useState(false);
288
290
  const [selected, setSelected] = useState<SelectedTarget | null>(null);
289
291
  const { comments, error, refetch, add, remove } = useComments(slideId);
290
292
  const { applyEdit, applyEdits } = useEditor(slideId);
291
293
  const history = useHistory();
294
+ const active = manualActive || heldActive;
295
+ const manualActiveRef = useRef(manualActive);
292
296
 
293
297
  const pendingRef = useRef<Map<string, Bucket>>(new Map());
294
298
  const instanceCounterRef = useRef(0);
@@ -915,15 +919,24 @@ export function InspectorProvider({
915
919
  return () => observer.disconnect();
916
920
  }, [selected]);
917
921
 
922
+ const activate = useCallback(() => {
923
+ manualActiveRef.current = true;
924
+ setManualActive(true);
925
+ }, []);
926
+
918
927
  const toggle = useCallback(() => {
919
- setActive((a) => {
920
- if (a) setSelected(null);
921
- return !a;
928
+ setManualActive((a) => {
929
+ if (a && !heldActive) setSelected(null);
930
+ const next = !a;
931
+ manualActiveRef.current = next;
932
+ return next;
922
933
  });
923
- }, []);
934
+ }, [heldActive]);
924
935
 
925
936
  const cancel = useCallback(() => {
926
- setActive(false);
937
+ manualActiveRef.current = false;
938
+ setManualActive(false);
939
+ setHeldActive(false);
927
940
  setSelected(null);
928
941
  }, []);
929
942
 
@@ -948,6 +961,39 @@ export function InspectorProvider({
948
961
  return () => window.removeEventListener('keydown', onKey);
949
962
  }, [toggle]);
950
963
 
964
+ useEffect(() => {
965
+ if (import.meta.env.PROD) return;
966
+
967
+ const isApplePlatform = /Mac|iPhone|iPad|iPod/.test(
968
+ `${navigator.platform} ${navigator.userAgent}`,
969
+ );
970
+ const holdKey = isApplePlatform ? 'Meta' : 'Control';
971
+
972
+ const onKeyDown = (e: KeyboardEvent) => {
973
+ if (e.repeat) return;
974
+ if (e.target instanceof HTMLElement && e.target.matches('input, textarea')) return;
975
+ if (e.key !== holdKey) return;
976
+ setHeldActive(true);
977
+ };
978
+
979
+ const releaseHeld = (e?: KeyboardEvent) => {
980
+ if (e && e.key !== holdKey) return;
981
+ setHeldActive(false);
982
+ if (!manualActiveRef.current) setSelected(null);
983
+ };
984
+
985
+ const onBlur = () => releaseHeld();
986
+
987
+ window.addEventListener('keydown', onKeyDown, true);
988
+ window.addEventListener('keyup', releaseHeld, true);
989
+ window.addEventListener('blur', onBlur, true);
990
+ return () => {
991
+ window.removeEventListener('keydown', onKeyDown, true);
992
+ window.removeEventListener('keyup', releaseHeld, true);
993
+ window.removeEventListener('blur', onBlur, true);
994
+ };
995
+ }, []);
996
+
951
997
  const openCrop = useCallback((anchor: HTMLImageElement) => {
952
998
  const loc = anchor.dataset.slideLoc;
953
999
  if (!loc) return;
@@ -973,6 +1019,7 @@ export function InspectorProvider({
973
1019
  () => ({
974
1020
  slideId,
975
1021
  active,
1022
+ activate,
976
1023
  toggle,
977
1024
  cancel,
978
1025
  comments,
@@ -995,6 +1042,7 @@ export function InspectorProvider({
995
1042
  [
996
1043
  slideId,
997
1044
  active,
1045
+ activate,
998
1046
  toggle,
999
1047
  cancel,
1000
1048
  comments,