@open-document/core 0.7.0 → 0.9.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.
@@ -1,5 +1,5 @@
1
1
  import { _ as listDocIds } from "./config-4nz5NnxW.js";
2
- import { d as closeRenderSession, u as checkLayout } from "./ops-DQfckiyp.js";
2
+ import { d as closeRenderSession, u as checkLayout } from "./ops-OZZVBgsM.js";
3
3
  import { t as cliContext } from "./context-BH8C-dSW.js";
4
4
  import chalk from "chalk";
5
5
  //#region src/cli/check.ts
package/dist/cli/bin.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { a as PAGE_SIZE_NAMES, r as ORIENTATIONS } from "../sdk-DhcqZdAw.js";
2
+ import { i as ORIENTATIONS, o as PAGE_SIZE_NAMES, r as EXPORT_FORMATS } from "../sdk-CqNZzbkz.js";
3
3
  import chalk from "chalk";
4
4
  import path from "node:path";
5
5
  import * as readline from "node:readline/promises";
@@ -176,20 +176,16 @@ async function run(argv) {
176
176
  const { preview } = await import("../preview-CwCrw-i3.js");
177
177
  await preview(flags);
178
178
  });
179
- program.command("export [docIds...]").description("Render documents headlessly to PDF, HTML, or PNG").addOption(new Option("-f, --format <format>", "output format").choices([
180
- "pdf",
181
- "html",
182
- "png"
183
- ])).option("-o, --out-dir <dir>", "directory to write into (defaults to `out`)").option("--all", "export every document under docs/").action(async (docIds, flags) => {
184
- const { exportDocs } = await import("../export-BQ-GvMsb.js");
179
+ program.command("export [docIds...]").description("Render documents headlessly to PDF, HTML, PNG, or DOCX").addOption(new Option("-f, --format <format>", "output format").choices([...EXPORT_FORMATS])).option("-o, --out-dir <dir>", "directory to write into (defaults to `out`)").option("--all", "export every document under docs/").action(async (docIds, flags) => {
180
+ const { exportDocs } = await import("../export-CmVJdl9a.js");
185
181
  await exportDocs(docIds, flags);
186
182
  });
187
183
  program.command("check [docIds...]").description("Report layout faults — clipped content, blank sheets, stranded headings").option("--json", "print the full report as JSON").action(async (docIds, flags) => {
188
- const { checkDocs } = await import("../check-pEQh4jJE.js");
184
+ const { checkDocs } = await import("../check-CL0-0eB8.js");
189
185
  await checkDocs(docIds, flags);
190
186
  });
191
187
  program.command("import <file>").description("Turn a Markdown file into a document under docs/").option("--id <id>", "document id (defaults to a slug of the title)").option("--title <title>", "override the title").option("--subtitle <subtitle>", "subtitle, also used as the cover eyebrow").option("--author <author>", "author line on the cover").option("--theme <theme>", "theme id to back-link from meta.theme").addOption(new Option("--page-size <size>", "page size").choices(PAGE_SIZE_NAMES)).addOption(new Option("--orientation <orientation>", "page orientation").choices(ORIENTATIONS)).option("--no-cover", "skip the title page").option("--contents", "add a self-filling contents page").action(async (file, flags) => {
192
- const { importDoc } = await import("../import-Daat3L2J.js");
188
+ const { importDoc } = await import("../import-E6vRo7xm.js");
193
189
  await importDoc(file, flags);
194
190
  });
195
191
  program.command("sync:skills").description("Sync built-in skills from @open-document/core into this workspace").option("--dry-run", "show what would change without writing").action(async (flags) => {
@@ -1,13 +1,10 @@
1
+ import { r as EXPORT_FORMATS } from "./sdk-CqNZzbkz.js";
1
2
  import { _ as listDocIds } from "./config-4nz5NnxW.js";
2
- import { d as closeRenderSession, f as exportDocument } from "./ops-DQfckiyp.js";
3
+ import { d as closeRenderSession, f as exportDocument } from "./ops-OZZVBgsM.js";
3
4
  import { t as cliContext } from "./context-BH8C-dSW.js";
4
5
  import chalk from "chalk";
5
6
  //#region src/cli/export.ts
6
- const FORMATS = [
7
- "pdf",
8
- "html",
9
- "png"
10
- ];
7
+ const FORMATS = EXPORT_FORMATS;
11
8
  /**
12
9
  * The Download menu without a browser window — the same render pipeline, driven
13
10
  * from a script. This is what makes a document something CI can produce on a
@@ -1,4 +1,4 @@
1
- import { m as importMarkdown } from "./ops-DQfckiyp.js";
1
+ import { m as importMarkdown } from "./ops-OZZVBgsM.js";
2
2
  import { t as cliContext } from "./context-BH8C-dSW.js";
3
3
  import chalk from "chalk";
4
4
  import path from "node:path";
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { C as designToCssVars, D as useDocLabel, E as LabelVocabulary, O as useDocLabels, S as defaultDesign, T as LabelKind, _ as DesignFonts, a as DocModule, b as DesignTypeScale, c as ORIENTATIONS, d as PAGE_SIZE_NAMES, f as PageGeometry, g as resolvePageGeometry, h as isPageSizeName, i as DocMeta, l as Orientation, m as isOrientation, n as DEFAULT_PAGE_SIZE, o as DocPage, p as PageSizeName, r as DocEntry, s as FlowSection, t as DEFAULT_ORIENTATION, u as PAGE_SIZES, v as DesignPalette, w as LabelEntry, x as cssVarsToString, y as DesignSystem } from "./sdk-C9nl30dW.js";
1
+ import { A as useDocLabels, C as cssVarsToString, D as LabelKind, E as LabelEntry, O as LabelVocabulary, S as DesignTypeScale, T as designToCssVars, _ as isPageSizeName, a as DocModule, b as DesignPalette, d as Orientation, f as PAGE_SIZES, g as isOrientation, h as PageSizeName, i as DocMeta, k as useDocLabel, l as FlowSection, m as PageGeometry, n as DEFAULT_PAGE_SIZE, o as DocPage, p as PAGE_SIZE_NAMES, r as DocEntry, t as DEFAULT_ORIENTATION, u as ORIENTATIONS, v as resolvePageGeometry, w as defaultDesign, x as DesignSystem, y as DesignFonts } from "./sdk-BqU6mwD_.js";
2
2
  import { n as OpenDocConfig, t as OpenDocBuildConfig } from "./config-P61niZMf.js";
3
3
  import { CSSProperties, ComponentType, ReactNode } from "react";
4
4
  //#region src/app/lib/source-loc.d.ts
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { a as defaultDesign, i as cssVarsToString, n as DiagramSyntaxError, o as designToCssVars, r as parseDelimited, t as compileDiagram } from "./diagram-xlVDekYk.js";
2
- import { a as PAGE_SIZE_NAMES, c as resolvePageGeometry, i as PAGE_SIZES, n as DEFAULT_PAGE_SIZE, o as isOrientation, r as ORIENTATIONS, s as isPageSizeName, t as DEFAULT_ORIENTATION } from "./sdk-DhcqZdAw.js";
2
+ import { a as PAGE_SIZES, c as isPageSizeName, i as ORIENTATIONS, l as resolvePageGeometry, n as DEFAULT_PAGE_SIZE, o as PAGE_SIZE_NAMES, s as isOrientation, t as DEFAULT_ORIENTATION } from "./sdk-CqNZzbkz.js";
3
3
  import { Children, Fragment, createContext, isValidElement, useContext, useEffect, useId, useRef, useSyncExternalStore } from "react";
4
4
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
5
5
  //#region src/app/lib/source-loc.ts
@@ -145,6 +145,8 @@ function Footnote({ id, children, [LOC_PROP]: loc }) {
145
145
  }
146
146
  Footnote[FOOTNOTE_MARKER_FLAG] = true;
147
147
  const FOOTNOTE_ROW_ATTR = "data-od-footnote-row";
148
+ /** The note's id on its row, so an exporter can pair a marker with its text. */
149
+ const FOOTNOTE_ID_ATTR = "data-od-footnote-id";
148
150
  function footnoteAreaStyle() {
149
151
  return {
150
152
  borderTop: "1px solid var(--od-rule)",
@@ -160,6 +162,7 @@ function FootnoteRow({ id, content, loc }) {
160
162
  const entry = useDocLabel(id);
161
163
  return /* @__PURE__ */ jsxs("div", {
162
164
  [FOOTNOTE_ROW_ATTR]: "",
165
+ [FOOTNOTE_ID_ATTR]: id,
163
166
  style: {
164
167
  display: "flex",
165
168
  gap: 5,
@@ -337,6 +340,7 @@ function ListOf({ kind = "figure", showPageNumbers = true, style, className }) {
337
340
  ...style
338
341
  },
339
342
  children: entries.map((entry) => /* @__PURE__ */ jsxs("div", {
343
+ "data-od-list-entry": entry.id,
340
344
  style: {
341
345
  display: "flex",
342
346
  alignItems: "baseline",
@@ -1,4 +1,4 @@
1
- import { c as ORIENTATIONS, d as PAGE_SIZE_NAMES, l as Orientation, p as PageSizeName } from "../sdk-C9nl30dW.js";
1
+ import { c as ExportFormat, d as Orientation, h as PageSizeName, p as PAGE_SIZE_NAMES, s as EXPORT_FORMATS, u as ORIENTATIONS } from "../sdk-BqU6mwD_.js";
2
2
  import "vite";
3
3
  //#region src/vite/routes/context.d.ts
4
4
  type ApiContext = {
@@ -135,7 +135,6 @@ type LayoutReport = {
135
135
  warnings: number;
136
136
  findings: LayoutFinding[];
137
137
  };
138
- type ExportFormat = 'pdf' | 'html' | 'png';
139
138
  type ExportResult = {
140
139
  docId: string;
141
140
  format: ExportFormat;
@@ -291,4 +290,4 @@ declare function addComment(ctx: ApiContext, docId: string, loc: Loc, note: stri
291
290
  id: string;
292
291
  }>;
293
292
  //#endregion
294
- export { type ApiContext, type AssetSummary, type DocumentSummary, type ExportFormat, type ExportResult, type ImportMarkdownOptions, type ImportResult, type LayoutFinding, type LayoutReport, type Loc, ORIENTATIONS, OpsError, type Orientation, PAGE_SIZE_NAMES, type PageSizeName, type ThemeSummary, addComment, checkLayout, closeRenderSession, createDocument, createFolder, deleteAsset, deleteDocument, docDir, duplicateDocument, exportDocument, fileDocument, findAssetUsages, importMarkdown, listAssets, listDocIds, listDocuments, listFolders, listThemes, makeContext, readDocument, readText, readTheme, renameDocument, renderDocPage, resolveEntry, slugify, writeAsset, writeDocument, writeText, writeTexts };
293
+ export { type ApiContext, type AssetSummary, type DocumentSummary, EXPORT_FORMATS, type ExportFormat, type ExportResult, type ImportMarkdownOptions, type ImportResult, type LayoutFinding, type LayoutReport, type Loc, ORIENTATIONS, OpsError, type Orientation, PAGE_SIZE_NAMES, type PageSizeName, type ThemeSummary, addComment, checkLayout, closeRenderSession, createDocument, createFolder, deleteAsset, deleteDocument, docDir, duplicateDocument, exportDocument, fileDocument, findAssetUsages, importMarkdown, listAssets, listDocIds, listDocuments, listFolders, listThemes, makeContext, readDocument, readText, readTheme, renameDocument, renderDocPage, resolveEntry, slugify, writeAsset, writeDocument, writeText, writeTexts };
package/dist/ops/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a as PAGE_SIZE_NAMES, r as ORIENTATIONS } from "../sdk-DhcqZdAw.js";
1
+ import { i as ORIENTATIONS, o as PAGE_SIZE_NAMES, r as EXPORT_FORMATS } from "../sdk-CqNZzbkz.js";
2
2
  import { O as makeContext, S as writeDocument, _ as listDocIds, a as writeText, b as renameDocument, f as OpsError, g as duplicateDocument, h as docDir, i as readText, m as deleteDocument, o as writeTexts, p as createDocument, r as addComment, v as listDocuments, x as resolveEntry, y as readDocument } from "../config-4nz5NnxW.js";
3
- import { a as listAssets, c as readTheme, d as closeRenderSession, f as exportDocument, h as slugify, i as findAssetUsages, l as writeAsset, m as importMarkdown, n as deleteAsset, o as listFolders, p as renderDocPage, r as fileDocument, s as listThemes, t as createFolder, u as checkLayout } from "../ops-DQfckiyp.js";
4
- export { ORIENTATIONS, OpsError, PAGE_SIZE_NAMES, addComment, checkLayout, closeRenderSession, createDocument, createFolder, deleteAsset, deleteDocument, docDir, duplicateDocument, exportDocument, fileDocument, findAssetUsages, importMarkdown, listAssets, listDocIds, listDocuments, listFolders, listThemes, makeContext, readDocument, readText, readTheme, renameDocument, renderDocPage, resolveEntry, slugify, writeAsset, writeDocument, writeText, writeTexts };
3
+ import { a as listAssets, c as readTheme, d as closeRenderSession, f as exportDocument, h as slugify, i as findAssetUsages, l as writeAsset, m as importMarkdown, n as deleteAsset, o as listFolders, p as renderDocPage, r as fileDocument, s as listThemes, t as createFolder, u as checkLayout } from "../ops-OZZVBgsM.js";
4
+ export { EXPORT_FORMATS, ORIENTATIONS, OpsError, PAGE_SIZE_NAMES, addComment, checkLayout, closeRenderSession, createDocument, createFolder, deleteAsset, deleteDocument, docDir, duplicateDocument, exportDocument, fileDocument, findAssetUsages, importMarkdown, listAssets, listDocIds, listDocuments, listFolders, listThemes, makeContext, readDocument, readText, readTheme, renameDocument, renderDocPage, resolveEntry, slugify, writeAsset, writeDocument, writeText, writeTexts };
@@ -1,4 +1,4 @@
1
- import { a as PAGE_SIZE_NAMES, o as isOrientation, r as ORIENTATIONS, s as isPageSizeName } from "./sdk-DhcqZdAw.js";
1
+ import { c as isPageSizeName, i as ORIENTATIONS, o as PAGE_SIZE_NAMES, s as isOrientation } from "./sdk-CqNZzbkz.js";
2
2
  import { C as newFolderId, D as writeManifest, E as validateName, T as validateIcon, _ as listDocIds, c as countAssetUsages, d as validateAssetName, f as OpsError, k as DOC_ID_RE, l as resolveScopedAssetFile, n as parseFrontmatter$1, p as createDocument, s as assetImportPath, t as createViteConfig, u as resolveScopedAssetsDir, w as readManifest, x as resolveEntry } from "./config-4nz5NnxW.js";
3
3
  import path from "node:path";
4
4
  import fs from "node:fs/promises";
@@ -933,6 +933,7 @@ async function createRenderSession(opts) {
933
933
  }
934
934
  },
935
935
  html: () => page.evaluate("globalThis.__openDoc.htmlBundle()"),
936
+ docx: () => page.evaluate("globalThis.__openDoc.docxBundle()"),
936
937
  close: () => page.close()
937
938
  };
938
939
  },
@@ -1062,8 +1063,8 @@ async function exportDocument(ctx, docId, opts = {}) {
1062
1063
  written.push(path.relative(ctx.userCwd, file));
1063
1064
  };
1064
1065
  if (format === "pdf") await write(`${docId}.pdf`, await renderer.pdf());
1065
- else if (format === "html") {
1066
- const bundle = await renderer.html();
1066
+ else if (format === "html" || format === "docx") {
1067
+ const bundle = format === "html" ? await renderer.html() : await renderer.docx();
1067
1068
  if (!bundle) throw new OpsError(422, `document has no pages: ${docId}`);
1068
1069
  await write(bundle.filename, Buffer.from(bundle.base64, "base64"));
1069
1070
  } else {
@@ -106,6 +106,13 @@ type FlowSection = {
106
106
  };
107
107
  /** What a document's default export may contain: fixed pages, flow sections, or both. */
108
108
  type DocEntry = DocPage | FlowSection;
109
+ /**
110
+ * Every format `open-doc export` can write. The CLI's `--format`, the MCP
111
+ * `export_document` schema and `ops/layout.ts` all read this tuple, so adding a
112
+ * format is one edit here and its branch in `exportDocument`.
113
+ */
114
+ declare const EXPORT_FORMATS: readonly ["pdf", "html", "png", "docx"];
115
+ type ExportFormat = (typeof EXPORT_FORMATS)[number];
109
116
  type DocMeta = {
110
117
  title?: string;
111
118
  subtitle?: string;
@@ -126,4 +133,4 @@ type DocModule = {
126
133
  };
127
134
  declare function resolvePageGeometry(meta?: DocMeta): PageGeometry;
128
135
  //#endregion
129
- export { designToCssVars as C, useDocLabel as D, LabelVocabulary as E, useDocLabels as O, defaultDesign as S, LabelKind as T, DesignFonts as _, DocModule as a, DesignTypeScale as b, ORIENTATIONS as c, PAGE_SIZE_NAMES as d, PageGeometry as f, resolvePageGeometry as g, isPageSizeName as h, DocMeta as i, Orientation as l, isOrientation as m, DEFAULT_PAGE_SIZE as n, DocPage as o, PageSizeName as p, DocEntry as r, FlowSection as s, DEFAULT_ORIENTATION as t, PAGE_SIZES as u, DesignPalette as v, LabelEntry as w, cssVarsToString as x, DesignSystem as y };
136
+ export { useDocLabels as A, cssVarsToString as C, LabelKind as D, LabelEntry as E, LabelVocabulary as O, DesignTypeScale as S, designToCssVars as T, isPageSizeName as _, DocModule as a, DesignPalette as b, ExportFormat as c, Orientation as d, PAGE_SIZES as f, isOrientation as g, PageSizeName as h, DocMeta as i, useDocLabel as k, FlowSection as l, PageGeometry as m, DEFAULT_PAGE_SIZE as n, DocPage as o, PAGE_SIZE_NAMES as p, DocEntry as r, EXPORT_FORMATS as s, DEFAULT_ORIENTATION as t, ORIENTATIONS as u, resolvePageGeometry as v, defaultDesign as w, DesignSystem as x, DesignFonts as y };
@@ -36,6 +36,17 @@ function isPageSizeName(value) {
36
36
  function isOrientation(value) {
37
37
  return value === "portrait" || value === "landscape";
38
38
  }
39
+ /**
40
+ * Every format `open-doc export` can write. The CLI's `--format`, the MCP
41
+ * `export_document` schema and `ops/layout.ts` all read this tuple, so adding a
42
+ * format is one edit here and its branch in `exportDocument`.
43
+ */
44
+ const EXPORT_FORMATS = [
45
+ "pdf",
46
+ "html",
47
+ "png",
48
+ "docx"
49
+ ];
39
50
  function resolvePageGeometry(meta) {
40
51
  const size = PAGE_SIZES[meta?.pageSize ?? "A4"] ?? PAGE_SIZES["A4"];
41
52
  const landscape = meta?.orientation === "landscape";
@@ -47,4 +58,4 @@ function resolvePageGeometry(meta) {
47
58
  };
48
59
  }
49
60
  //#endregion
50
- export { PAGE_SIZE_NAMES as a, resolvePageGeometry as c, PAGE_SIZES as i, DEFAULT_PAGE_SIZE as n, isOrientation as o, ORIENTATIONS as r, isPageSizeName as s, DEFAULT_ORIENTATION as t };
61
+ export { PAGE_SIZES as a, isPageSizeName as c, ORIENTATIONS as i, resolvePageGeometry as l, DEFAULT_PAGE_SIZE as n, PAGE_SIZE_NAMES as o, EXPORT_FORMATS as r, isOrientation as s, DEFAULT_ORIENTATION as t };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-document/core",
3
- "version": "0.7.0",
3
+ "version": "0.9.0",
4
4
  "description": "Runtime and CLI for open-doc — write documents in docs/, we handle the pages, print layout, and export.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -358,7 +358,8 @@ A document is not a slide deck. Long-form copy is the point — but it still has
358
358
  - **Assets panel** (`/assets` in the dev UI): upload, rename, and delete files in the global `assets/` folder or any document's `assets/` folder, with an "unused" badge and a copy-ready import line. Files you reference in source are what it scans, so an import you write by hand shows up there immediately.
359
359
  - **Inspect mode** (the "Inspect" button, dev only): click any element on a page to edit its text in place — the change is written straight back into `docs/<id>/index.tsx` — or leave a note for the agent, which is stored as a `@doc-comment` marker and processed by the `apply-comments` skill.
360
360
  - **Download menu** — PDF (true page size) and self-contained HTML.
361
- - **Headless render** — `open-doc export <id> --format pdf|html|png` produces the same output from a script, and `open-doc check <id>` reports layout faults. Both drive the real viewer in a headless browser, so what they produce is what the Download menu produces.
361
+ - **Headless render** — `open-doc export <id> --format pdf|html|png|docx` produces the same output from a script, and `open-doc check <id>` reports layout faults. Both drive the real viewer in a headless browser, so what they produce is what the Download menu produces.
362
+ - **Word (DOCX)** — for review that runs in Word. It carries structure, not page breaks: headings become Word heading styles, `<TableOfContents />` a TOC field, `<Footnote>` real footnotes, a `flow()` footer a Word footer with page-number fields, and the theme's CJK font the East Asian font. Write headings as real `h1`–`h3` and tables as `<table>`/`<DataTable>` so they arrive as structure; anything drawn with boxes (a chart made of `div`s) arrives as a picture, and absolutely positioned layouts on fixed pages flow as plain paragraphs.
362
363
  - **Design panel** (the "Design" button in the document view, dev only): live-tweaks the `design` const — palette, fonts, type scale, margin, leading, radius — previewing on the real pages and writing the values back into `docs/<id>/index.tsx` on save.
363
364
 
364
365
  ### Writing for the inspector
@@ -154,6 +154,8 @@ export type FootnotesProps = {
154
154
  export const FOOTNOTE_AREA_MARGIN_TOP = 12;
155
155
 
156
156
  export const FOOTNOTE_ROW_ATTR = 'data-od-footnote-row';
157
+ /** The note's id on its row, so an exporter can pair a marker with its text. */
158
+ export const FOOTNOTE_ID_ATTR = 'data-od-footnote-id';
157
159
 
158
160
  export function footnoteAreaStyle(): CSSProperties {
159
161
  return {
@@ -170,7 +172,10 @@ export function footnoteAreaStyle(): CSSProperties {
170
172
  export function FootnoteRow({ id, content, loc }: CollectedNote) {
171
173
  const entry = useDocLabel(id);
172
174
  return (
173
- <div {...{ [FOOTNOTE_ROW_ATTR]: '' }} style={{ display: 'flex', gap: 5, marginBottom: 3 }}>
175
+ <div
176
+ {...{ [FOOTNOTE_ROW_ATTR]: '', [FOOTNOTE_ID_ATTR]: id }}
177
+ style={{ display: 'flex', gap: 5, marginBottom: 3 }}
178
+ >
174
179
  <span
175
180
  style={{
176
181
  flex: 'none',
@@ -1043,8 +1043,11 @@ export function Inspector({
1043
1043
  setStatus(null);
1044
1044
  setNote('');
1045
1045
  };
1046
+ // On the window, not the pane: the first click opens the element panel,
1047
+ // and in two-up or grid a sheet near the right edge can have the panel
1048
+ // open right under the pointer — the second click then lands on it, and a
1049
+ // listener on the pane would never hear the double-click at all.
1046
1050
  const onDblClick = (e: MouseEvent) => {
1047
- if (insideChrome(e.target)) return;
1048
1051
  const first = firstClickRef.current;
1049
1052
  firstClickRef.current = null;
1050
1053
  if (first && Date.now() - first.time < DOUBLE_CLICK_MS) {
@@ -1052,6 +1055,7 @@ export function Inspector({
1052
1055
  setWantEdit({ anchor: first.anchor, at: first.at, selectWord: true });
1053
1056
  return;
1054
1057
  }
1058
+ if (!container.contains(e.target as Node) || insideChrome(e.target)) return;
1055
1059
  if (entryAt(e.target)) return;
1056
1060
  const target = targetFrom(e.target as Element);
1057
1061
  if (!target?.anchor.contains(e.target as Node)) return;
@@ -1099,13 +1103,13 @@ export function Inspector({
1099
1103
 
1100
1104
  container.addEventListener('pointermove', onMove, true);
1101
1105
  container.addEventListener('click', onClick, true);
1102
- container.addEventListener('dblclick', onDblClick, true);
1106
+ window.addEventListener('dblclick', onDblClick, true);
1103
1107
  window.addEventListener('pointerdown', onPointerDown, true);
1104
1108
  window.addEventListener('keydown', onKey, true);
1105
1109
  return () => {
1106
1110
  container.removeEventListener('pointermove', onMove, true);
1107
1111
  container.removeEventListener('click', onClick, true);
1108
- container.removeEventListener('dblclick', onDblClick, true);
1112
+ window.removeEventListener('dblclick', onDblClick, true);
1109
1113
  window.removeEventListener('pointerdown', onPointerDown, true);
1110
1114
  window.removeEventListener('keydown', onKey, true);
1111
1115
  };
@@ -186,6 +186,7 @@ export function ListOf({ kind = 'figure', showPageNumbers = true, style, classNa
186
186
  {entries.map((entry) => (
187
187
  <div
188
188
  key={entry.id}
189
+ data-od-list-entry={entry.id}
189
190
  style={{ display: 'flex', alignItems: 'baseline', gap: 8, marginBottom: 6 }}
190
191
  >
191
192
  <span style={{ flex: 'none', color: 'var(--od-muted)' }}>
@@ -1,5 +1,6 @@
1
1
  import { useEffect, useRef } from 'react';
2
2
  import { diagnosePages, type LayoutFinding } from './diagnostics';
3
+ import { buildDocDocx } from './export-docx';
3
4
  import { buildDocHtmlBundle } from './export-html';
4
5
  import { mountPrintCopy } from './export-pdf';
5
6
  import type { DocModule, PageGeometry } from './sdk';
@@ -29,6 +30,7 @@ export type OpenDocBridge = {
29
30
  preparePrint(): Promise<{ pageCount: number }>;
30
31
  releasePrint(): void;
31
32
  htmlBundle(): Promise<BridgeBundle | null>;
33
+ docxBundle(): Promise<BridgeBundle | null>;
32
34
  };
33
35
 
34
36
  type BridgeInput = {
@@ -118,6 +120,17 @@ export function useAgentBridge(input: BridgeInput): void {
118
120
  base64: toBase64(bundle.bytes),
119
121
  };
120
122
  },
123
+ async docxBundle() {
124
+ const { docId, doc, pages } = latest.current;
125
+ if (!doc || pages.length === 0) return null;
126
+ const bundle = await buildDocDocx(doc, docId, pages);
127
+ if (!bundle) return null;
128
+ return {
129
+ filename: bundle.filename,
130
+ mimeType: bundle.mimeType,
131
+ base64: toBase64(bundle.bytes),
132
+ };
133
+ },
121
134
  };
122
135
 
123
136
  return () => {