@arbidocs/blocks 0.4.110 → 0.4.112

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 (123) hide show
  1. package/dist/{NativeDocxEditor-WODZAURG.cjs → NativeDocxEditor-AQZSUGET.cjs} +8 -8
  2. package/dist/{NativeDocxEditor-WODZAURG.cjs.map → NativeDocxEditor-AQZSUGET.cjs.map} +1 -1
  3. package/dist/{NativeDocxEditor-4PY4YZYC.js → NativeDocxEditor-MBCBXYDZ.js} +4 -4
  4. package/dist/{NativeDocxEditor-4PY4YZYC.js.map → NativeDocxEditor-MBCBXYDZ.js.map} +1 -1
  5. package/dist/agents/index.cjs +208 -208
  6. package/dist/agents/index.js +3 -3
  7. package/dist/calendar/EventEditor.d.ts +1 -1
  8. package/dist/calendar/draft.d.ts +7 -1
  9. package/dist/calendar/index.cjs +58 -10
  10. package/dist/calendar/index.cjs.map +1 -1
  11. package/dist/calendar/index.d.ts +1 -1
  12. package/dist/calendar/index.js +56 -11
  13. package/dist/calendar/index.js.map +1 -1
  14. package/dist/calendar/types.d.ts +20 -0
  15. package/dist/calls/CallSidePanel.d.ts +16 -1
  16. package/dist/calls/ControlBar.d.ts +25 -3
  17. package/dist/calls/PreJoin.d.ts +6 -2
  18. package/dist/calls/cards.d.ts +6 -2
  19. package/dist/calls/index.cjs +1078 -47
  20. package/dist/calls/index.cjs.map +1 -1
  21. package/dist/calls/index.d.ts +4 -3
  22. package/dist/calls/index.js +1067 -51
  23. package/dist/calls/index.js.map +1 -1
  24. package/dist/calls/panels.d.ts +11 -0
  25. package/dist/calls/webinar/ChatPermissionSetting.d.ts +18 -0
  26. package/dist/calls/webinar/OnStageCheck.d.ts +23 -0
  27. package/dist/calls/webinar/QAPanel.d.ts +56 -0
  28. package/dist/calls/webinar/RaiseHandButton.d.ts +14 -0
  29. package/dist/calls/webinar/WebinarAudiencePanel.d.ts +23 -0
  30. package/dist/calls/webinar/WebinarViewer.d.ts +39 -0
  31. package/dist/calls/webinar/WebinarWaiting.d.ts +19 -0
  32. package/dist/calls/webinar/hooks.d.ts +13 -0
  33. package/dist/calls/webinar/index.d.ts +14 -0
  34. package/dist/calls/webinar/live.d.ts +43 -0
  35. package/dist/calls/webinar/types.d.ts +49 -0
  36. package/dist/{chunk-GKDWQLVU.js → chunk-3OT37I24.js} +165 -381
  37. package/dist/chunk-3OT37I24.js.map +1 -0
  38. package/dist/{chunk-2NIL2ASF.cjs → chunk-ETBB5KMN.cjs} +196 -400
  39. package/dist/chunk-ETBB5KMN.cjs.map +1 -0
  40. package/dist/{chunk-SQNAJPNR.js → chunk-GFYGYME3.js} +3 -3
  41. package/dist/{chunk-SQNAJPNR.js.map → chunk-GFYGYME3.js.map} +1 -1
  42. package/dist/{chunk-PEHLUB52.js → chunk-GIBRZ54P.js} +3 -3
  43. package/dist/{chunk-PEHLUB52.js.map → chunk-GIBRZ54P.js.map} +1 -1
  44. package/dist/chunk-GICUGQNN.cjs +76 -0
  45. package/dist/chunk-GICUGQNN.cjs.map +1 -0
  46. package/dist/{chunk-54WBIVHV.cjs → chunk-HF4PAYBM.cjs} +5 -5
  47. package/dist/{chunk-54WBIVHV.cjs.map → chunk-HF4PAYBM.cjs.map} +1 -1
  48. package/dist/chunk-I2QSDQQV.cjs +126 -0
  49. package/dist/chunk-I2QSDQQV.cjs.map +1 -0
  50. package/dist/chunk-JJLMCV3T.js +73 -0
  51. package/dist/chunk-JJLMCV3T.js.map +1 -0
  52. package/dist/{chunk-W7ZDBPJ3.cjs → chunk-OR4CO743.cjs} +3 -3
  53. package/dist/{chunk-W7ZDBPJ3.cjs.map → chunk-OR4CO743.cjs.map} +1 -1
  54. package/dist/chunk-QXMR5YHC.js +80 -0
  55. package/dist/chunk-QXMR5YHC.js.map +1 -0
  56. package/dist/{chunk-ELDUWTRR.cjs → chunk-RUFNJRLW.cjs} +4 -4
  57. package/dist/{chunk-ELDUWTRR.cjs.map → chunk-RUFNJRLW.cjs.map} +1 -1
  58. package/dist/{chunk-JB32KYAH.js → chunk-TKJSCHSX.js} +3 -3
  59. package/dist/{chunk-JB32KYAH.js.map → chunk-TKJSCHSX.js.map} +1 -1
  60. package/dist/{chunk-WPVIOGDG.cjs → chunk-US5ASM4G.cjs} +22 -22
  61. package/dist/{chunk-WPVIOGDG.cjs.map → chunk-US5ASM4G.cjs.map} +1 -1
  62. package/dist/{chunk-CECWAIHL.js → chunk-XFZ7HNPG.js} +3 -3
  63. package/dist/{chunk-CECWAIHL.js.map → chunk-XFZ7HNPG.js.map} +1 -1
  64. package/dist/{chunk-VZKBI2KJ.cjs → chunk-Z2NSU7D5.cjs} +4 -4
  65. package/dist/{chunk-VZKBI2KJ.cjs.map → chunk-Z2NSU7D5.cjs.map} +1 -1
  66. package/dist/{chunk-A35KT2II.js → chunk-ZP4IFW2E.js} +4 -4
  67. package/dist/{chunk-A35KT2II.js.map → chunk-ZP4IFW2E.js.map} +1 -1
  68. package/dist/collaboration/index.cjs +1 -1
  69. package/dist/collaboration/index.js +1 -1
  70. package/dist/connect/docx.cjs +7 -7
  71. package/dist/connect/docx.js +5 -5
  72. package/dist/connect/index.cjs +38 -38
  73. package/dist/connect/index.js +8 -8
  74. package/dist/docx/AgentUndo.d.ts +4 -0
  75. package/dist/docx/definitions/commands.d.ts +3 -52
  76. package/dist/docx/definitions/fragment.d.ts +5 -31
  77. package/dist/docx/definitions/port.d.ts +2 -22
  78. package/dist/docx/index.cjs +47 -47
  79. package/dist/docx/index.js +4 -4
  80. package/dist/docx/references/commands.d.ts +3 -89
  81. package/dist/docx/references/port.d.ts +2 -11
  82. package/dist/facts/index.cjs +1 -1
  83. package/dist/facts/index.js +1 -1
  84. package/dist/files/index.cjs +1 -1
  85. package/dist/files/index.js +1 -1
  86. package/dist/index.cjs +278 -278
  87. package/dist/index.js +8 -8
  88. package/dist/settings/index.cjs +47 -101
  89. package/dist/settings/index.cjs.map +1 -1
  90. package/dist/settings/index.js +9 -69
  91. package/dist/settings/index.js.map +1 -1
  92. package/dist/shell/index.cjs +9 -9
  93. package/dist/shell/index.js +1 -1
  94. package/dist/tags/definitions.d.ts +4 -25
  95. package/dist/tags/ooxml.d.ts +1 -19
  96. package/dist/workflow-canvas/index.cjs +10 -10
  97. package/dist/workflow-canvas/index.js +3 -3
  98. package/node_modules/@arbidocs/coedit/dist/commands.cjs +866 -9
  99. package/node_modules/@arbidocs/coedit/dist/commands.cjs.map +1 -1
  100. package/node_modules/@arbidocs/coedit/dist/commands.d.cts +342 -156
  101. package/node_modules/@arbidocs/coedit/dist/commands.d.ts +342 -156
  102. package/node_modules/@arbidocs/coedit/dist/commands.js +817 -11
  103. package/node_modules/@arbidocs/coedit/dist/commands.js.map +1 -1
  104. package/node_modules/@arbidocs/coedit/dist/port-ip7WByvH.d.cts +188 -0
  105. package/node_modules/@arbidocs/coedit/dist/port-ip7WByvH.d.ts +188 -0
  106. package/node_modules/@arbidocs/coedit/dist/server.cjs +731 -65
  107. package/node_modules/@arbidocs/coedit/dist/server.cjs.map +1 -1
  108. package/node_modules/@arbidocs/coedit/dist/server.d.cts +40 -1
  109. package/node_modules/@arbidocs/coedit/dist/server.d.ts +40 -1
  110. package/node_modules/@arbidocs/coedit/dist/server.js +730 -66
  111. package/node_modules/@arbidocs/coedit/dist/server.js.map +1 -1
  112. package/node_modules/@arbidocs/coedit/dist/template.d.cts +3 -17
  113. package/node_modules/@arbidocs/coedit/dist/template.d.ts +3 -17
  114. package/node_modules/@arbidocs/coedit/dist/track-eYC94jTp.d.cts +17 -0
  115. package/node_modules/@arbidocs/coedit/dist/track-eYC94jTp.d.ts +17 -0
  116. package/node_modules/@arbidocs/coedit/package.json +1 -1
  117. package/package.json +4 -4
  118. package/dist/chunk-2A4MDHJR.cjs +0 -198
  119. package/dist/chunk-2A4MDHJR.cjs.map +0 -1
  120. package/dist/chunk-2NIL2ASF.cjs.map +0 -1
  121. package/dist/chunk-EPHGD4YV.js +0 -174
  122. package/dist/chunk-EPHGD4YV.js.map +0 -1
  123. package/dist/chunk-GKDWQLVU.js.map +0 -1
@@ -1,12 +1,12 @@
1
1
  "use client";
2
2
  import { FactPassageItem } from './chunk-HFZ45FD3.js';
3
- import { stylesXml, definitionBookmark, groupDefinitions, definitionLabels, filterTermGroups, esc, hyperlinkRelationship, docxPackage, documentXml, definitionIdOfBookmark, compareTerms, parseDefinition } from './chunk-EPHGD4YV.js';
3
+ import { stylesXml, groupDefinitions, definitionLabels, filterTermGroups, docxPackage, documentXml, esc } from './chunk-QXMR5YHC.js';
4
4
  import { filterMentionCandidates, MentionMenu, findMentionQuery, listOptionId, extractMentions, useListKeyNav } from './chunk-AA3PT6KR.js';
5
5
  import { unzipSync, strFromU8, strToU8, zipSync } from 'fflate';
6
6
  import { renderToStaticMarkup } from 'react-dom/server';
7
7
  import { AiMarkdown, Dialog, DialogContent, DialogHeader, DialogTitle, cn, DialogDescription, Button, DialogFooter, Tabs, TabsList, TabsTrigger, TabsContent, Input, splitMarkdownBlocks } from '@arbidocs/react/ui';
8
8
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
9
- import React4, { createContext, useContext, useState, useRef, useCallback, useEffect, useLayoutEffect, useMemo, useSyncExternalStore } from 'react';
9
+ import React4, { createContext, useContext, useState, useRef, useCallback, useEffect, useLayoutEffect, useMemo, useSyncExternalStore, useReducer } from 'react';
10
10
  import { createPortal } from 'react-dom';
11
11
  import { collectReviewItems, revisionItemsOf } from '@docx-editor.dev/core/store';
12
12
  import { useDocxEditor, ReviewRailContext, useEditorSnapshot, useEditorState, useChromeTranslate, DocxEditor, useParagraphStyle, normalizeImageBytes, usePageSetup, useEditorCommand } from '@docx-editor.dev/react';
@@ -14,9 +14,9 @@ import { MessageSquarePlus, MessageSquare, PencilLine, ChevronLeft, ChevronRight
14
14
  import * as Y from 'yjs';
15
15
  import { DOCUMENT_COLLABORATION_VERSIONS, collaborationModule } from '@arbidocs/coedit';
16
16
  import { createHocuspocusCollaboration } from '@arbidocs/coedit/hocuspocus';
17
+ import { documentStyleIds, stylesUsed, readParagraphs, insertDefinedTerm, definitionOfAnchor, documentNumbering, paragraphRunsXml, listTargets, refreshCrossReferences, REF_BOOKMARK_PREFIX, insertDocumentReference, refResult, markCrossReferenceTarget, insertCrossReferenceField, filterTargets, paragraphNumber, fragmentPackage, AGENT_UNDO_MAP, undoOps } from '@arbidocs/coedit/commands';
18
+ export { findDefinitionsSection, insertCrossReference, insertDefinedTerm, insertDocumentReference, listTargets, paragraphNumber } from '@arbidocs/coedit/commands';
17
19
  import { defaultLegalTemplate, listBuildingBlocks, attachedTemplateOf, linkedLevelStyles, styleDivergence, buildingBlockFragment, fragmentClipboardHtml, trackInsertion, newFromTemplate } from '@arbidocs/coedit/template';
18
- import { readParagraphs, documentNumbering, listTargets, REF_BOOKMARK_PREFIX, filterTargets, paragraphNumber, FIELD_ATOM, staleCrossReferences, brokenCrossReferences, BROKEN_CROSS_REFERENCE_STYLE, CROSS_REFERENCE_STYLE, DEFINED_TERM_STYLE } from '@arbidocs/coedit/commands';
19
- export { listTargets, paragraphNumber } from '@arbidocs/coedit/commands';
20
20
  import { executeImageCommand } from '@docx-editor.dev/core/editor';
21
21
 
22
22
  function normalizeDocxExport(data) {
@@ -986,7 +986,7 @@ function DocxCommentActivity() {
986
986
  const thread = review.items.filter(
987
987
  (entry) => entry.kind === "comment" && (entry.item.id === commentId || entry.parentId === commentId)
988
988
  );
989
- const statuses = Object.entries(activity).filter(([, run2]) => run2.commentId === commentId);
989
+ const statuses = Object.entries(activity).filter(([, run]) => run.commentId === commentId);
990
990
  const labels = {
991
991
  delivering: "Delivering mention\u2026",
992
992
  queued: "Queued\u2026",
@@ -998,18 +998,18 @@ function DocxCommentActivity() {
998
998
  unknown: "Status unavailable"
999
999
  };
1000
1000
  return /* @__PURE__ */ jsxs("div", { className: "native-docx-comment-extra", "data-review-selectable": "", children: [
1001
- statuses.map(([id, run2]) => /* @__PURE__ */ jsxs(
1001
+ statuses.map(([id, run]) => /* @__PURE__ */ jsxs(
1002
1002
  "div",
1003
1003
  {
1004
1004
  role: "status",
1005
1005
  "data-testid": "docx-comment-agent-status",
1006
- "data-status": run2.status,
1006
+ "data-status": run.status,
1007
1007
  className: "native-docx-comment-activity",
1008
1008
  children: [
1009
- ["delivering", "queued", "in_progress"].includes(run2.status) && /* @__PURE__ */ jsx("span", { className: "native-docx-agent-spinner", "aria-hidden": "true" }),
1010
- run2.label,
1009
+ ["delivering", "queued", "in_progress"].includes(run.status) && /* @__PURE__ */ jsx("span", { className: "native-docx-agent-spinner", "aria-hidden": "true" }),
1010
+ run.label,
1011
1011
  ": ",
1012
- labels[run2.status]
1012
+ labels[run.status]
1013
1013
  ]
1014
1014
  },
1015
1015
  id
@@ -1037,10 +1037,10 @@ function DocxCommentActivity() {
1037
1037
  /* @__PURE__ */ jsx("p", { className: "text-sm font-medium", children: entry.author || "Reviewer" }),
1038
1038
  /* @__PURE__ */ jsx("div", { "data-testid": "docx-full-comment-text", children: /* @__PURE__ */ jsx(AiMarkdown, { allowHtml: false, children: commentText(entry) }) })
1039
1039
  ] }, entry.key)),
1040
- statuses.map(([id, run2]) => /* @__PURE__ */ jsxs("p", { role: "status", className: "text-sm", children: [
1041
- run2.label,
1040
+ statuses.map(([id, run]) => /* @__PURE__ */ jsxs("p", { role: "status", className: "text-sm", children: [
1041
+ run.label,
1042
1042
  ": ",
1043
- labels[run2.status]
1043
+ labels[run.status]
1044
1044
  ] }, id))
1045
1045
  ]
1046
1046
  }
@@ -1351,243 +1351,14 @@ function DocxMentions({
1351
1351
  }
1352
1352
  ) });
1353
1353
  }
1354
- var CHARACTER_STYLES = {
1355
- [DEFINED_TERM_STYLE]: `<w:style w:type="character" w:customStyle="1" w:styleId="${DEFINED_TERM_STYLE}"><w:name w:val="Defined Term"/><w:rPr><w:u w:val="dotted" w:color="7F7F7F"/></w:rPr></w:style>`,
1356
- [CROSS_REFERENCE_STYLE]: `<w:style w:type="character" w:customStyle="1" w:styleId="${CROSS_REFERENCE_STYLE}"><w:name w:val="Cross Reference"/><w:rPr><w:color w:val="1F4E79"/><w:u w:val="dotted" w:color="8EA9C1"/></w:rPr></w:style>`,
1357
- [BROKEN_CROSS_REFERENCE_STYLE]: `<w:style w:type="character" w:customStyle="1" w:styleId="${BROKEN_CROSS_REFERENCE_STYLE}"><w:name w:val="Cross Reference Broken"/><w:basedOn w:val="${CROSS_REFERENCE_STYLE}"/><w:rPr><w:color w:val="C00000"/><w:u w:val="wave" w:color="C00000"/></w:rPr></w:style>`
1358
- };
1359
- function stylesUsed(body) {
1360
- return [...new Set([...body.matchAll(/<w:rStyle w:val="([^"]+)"/g)].map((m) => m[1]))];
1361
- }
1362
- var fragmentStyles = (ids) => stylesXml(
1363
- "",
1364
- `<w:style w:type="paragraph" w:default="1" w:styleId="Normal"><w:name w:val="Normal"/><w:qFormat/></w:style>${ids.map((id) => CHARACTER_STYLES[id] ?? "").join("")}`
1365
- );
1366
- var textRun = (text, props = "") => `<w:r>${props ? `<w:rPr>${props}</w:rPr>` : ""}<w:t xml:space="preserve">${esc(text)}</w:t></w:r>`;
1367
- function definitionTooltip(definition) {
1368
- const line = `\u201C${definition.term}\u201D${definition.rest}`.replace(/\s+/g, " ").trim();
1369
- return line.length > 255 ? `${line.slice(0, 254)}\u2026` : line;
1370
- }
1371
- function definitionParagraphXml(definition, bookmark, id = 0) {
1372
- return `<w:p><w:bookmarkStart w:id="${id}" w:name="${esc(bookmark)}"/>${textRun("\u201C")}${textRun(
1373
- definition.term,
1374
- "<w:b/>"
1375
- )}${textRun("\u201D")}<w:bookmarkEnd w:id="${id}"/>${textRun(definition.rest)}</w:p>`;
1376
- }
1377
- function headingParagraphXml(text, styleId) {
1378
- return styleId ? `<w:p><w:pPr><w:pStyle w:val="${esc(styleId)}"/></w:pPr>${textRun(text)}</w:p>` : `<w:p><w:pPr><w:keepNext/></w:pPr>${textRun(text, "<w:b/>")}</w:p>`;
1379
- }
1380
- function termLinkXml(term, bookmark, tooltip) {
1381
- return `<w:p><w:hyperlink w:anchor="${esc(bookmark)}" w:tooltip="${esc(tooltip)}" w:history="1">${textRun(
1382
- term,
1383
- `<w:rStyle w:val="${DEFINED_TERM_STYLE}"/>`
1384
- )}</w:hyperlink></w:p>`;
1385
- }
1386
1354
  function base64(bytes) {
1387
1355
  let binary = "";
1388
1356
  for (let i = 0; i < bytes.length; i += 32768)
1389
1357
  binary += String.fromCharCode(...bytes.subarray(i, i + 32768));
1390
1358
  return btoa(binary);
1391
1359
  }
1392
- function fragmentHtml(body, covered2, {
1393
- revision,
1394
- relationships,
1395
- styles = stylesUsed(body)
1396
- } = {}) {
1397
- const untracked = docxPackage({
1398
- document: documentXml(body),
1399
- styles: fragmentStyles(styles),
1400
- title: "Defined terms",
1401
- relationships
1402
- });
1403
- const bytes = revision ? trackInsertion(untracked, revision, covered2) : untracked;
1404
- return `<div data-docx-fragment="${base64(bytes)}" data-docx-fragment-end="${covered2 ? "covered" : "open"}"></div>`;
1405
- }
1406
-
1407
- // src/docx/definitions/commands.ts
1408
- var DEFINITIONS_HEADING = "Definitions";
1409
- var SECTION_TITLE = /^(definitions?(\s*(and|&)\s*interpretations?)?|interpretations?(\s*(and|&)\s*definitions?)?|defined\s+terms|glossary)$/i;
1410
- var NUMBERING = /^(?:(?:clause|section|article|schedule|part)\s+)?(?:[0-9]+(?:\.[0-9]+)*|[A-Z]|[ivxlc]+)[.):]?\s+(?:[-–—]\s*)?/i;
1411
- function isDefinitionsTitle(paragraph) {
1412
- if (!paragraph.topLevel) return false;
1413
- const title = paragraph.text.trim().replace(NUMBERING, "").replace(/[.:]+$/, "").trim();
1414
- return SECTION_TITLE.test(title) && (paragraph.heading || title.length <= 40);
1415
- }
1416
- function findDefinitionsSection(paragraphs) {
1417
- const title = paragraphs.findIndex(isDefinitionsTitle);
1418
- if (title < 0) return null;
1419
- let end = title + 1;
1420
- while (end < paragraphs.length && paragraphs[end].topLevel && !paragraphs[end].heading) end++;
1421
- return { title, start: title + 1, end };
1422
- }
1423
- var termOf = (paragraph) => parseDefinition(paragraph.text)?.term ?? null;
1424
- function insertionIndex(paragraphs, section, term, skip = /* @__PURE__ */ new Set()) {
1425
- let afterLast = section.start;
1426
- for (let i = section.start; i < section.end; i++) {
1427
- if (skip.has(paragraphs[i].id)) continue;
1428
- const other = termOf(paragraphs[i]);
1429
- if (other === null) continue;
1430
- if (compareTerms(other, term) > 0) return i;
1431
- afterLast = i + 1;
1432
- }
1433
- return afterLast;
1434
- }
1435
- var headingStyle = (paragraphs) => paragraphs.find((p) => p.topLevel && p.heading && p.styleId)?.styleId;
1436
- function insertParagraphs(port, index, body, count, keep) {
1437
- const before = port.paragraphs();
1438
- const kept = keep ? before.findIndex((p) => p.id === keep.paragraphId) : -1;
1439
- if (index < before.length) {
1440
- port.setCaret({ paragraphId: before[index].id, offset: 0 });
1441
- } else {
1442
- const last = before[before.length - 1];
1443
- port.setCaret({ paragraphId: last.id, offset: last.text.length });
1444
- port.splitParagraph();
1445
- const opened = port.paragraphs();
1446
- port.setCaret({ paragraphId: opened[opened.length - 1].id, offset: 0 });
1447
- }
1448
- if (!port.paste(body, "", true)) throw new Error("The definition could not be added.");
1449
- if (!keep || kept < 0) return keep;
1450
- const after = port.paragraphs();
1451
- const moved = index <= kept ? kept + count : kept;
1452
- return { paragraphId: after[moved]?.id ?? keep.paragraphId, offset: keep.offset };
1453
- }
1454
- function addDefinition(port, definition, keep) {
1455
- const paragraphs = port.paragraphs();
1456
- const section = findDefinitionsSection(paragraphs);
1457
- const paragraph = definitionParagraphXml(definition, definitionBookmark(definition.id));
1458
- if (section)
1459
- return insertParagraphs(
1460
- port,
1461
- insertionIndex(paragraphs, section, definition.term),
1462
- paragraph,
1463
- 1,
1464
- keep
1465
- );
1466
- return insertParagraphs(
1467
- port,
1468
- paragraphs.length,
1469
- headingParagraphXml(DEFINITIONS_HEADING, headingStyle(paragraphs)) + paragraph,
1470
- 2,
1471
- keep
1472
- );
1473
- }
1474
- var hasBookmark = (paragraphs, name) => paragraphs.some((p) => p.bookmarks.includes(name));
1475
- function insertDefinedTerm(port, definition, options = {}) {
1476
- const start = port.caret();
1477
- if (!start) throw new Error("Place the cursor where the term should go.");
1478
- let caret = start;
1479
- if (options.replace) {
1480
- caret = { paragraphId: start.paragraphId, offset: Math.max(0, start.offset - options.replace) };
1481
- port.deleteRange(caret, start);
1482
- }
1483
- const bookmark = definitionBookmark(definition.id);
1484
- const addedDefinition = !hasBookmark(port.paragraphs(), bookmark);
1485
- if (addedDefinition) caret = addDefinition(port, definition, caret) ?? caret;
1486
- port.setCaret(caret);
1487
- if (!port.paste(
1488
- termLinkXml(definition.term, bookmark, definitionTooltip(definition)),
1489
- definition.term,
1490
- false
1491
- ))
1492
- throw new Error("The term could not be inserted.");
1493
- port.setCaret({ paragraphId: caret.paragraphId, offset: caret.offset + definition.term.length });
1494
- return { addedDefinition };
1495
- }
1496
- function definitionOfAnchor(anchor, definitions) {
1497
- const id = definitionIdOfBookmark(anchor.replace(/^#/, ""));
1498
- return id ? definitions.get(id) : void 0;
1499
- }
1500
- function LinkHoverCard({
1501
- root,
1502
- matches,
1503
- resolve,
1504
- onFirstHover,
1505
- testId
1506
- }) {
1507
- const [card, setCard] = useState(null);
1508
- const hovered = useRef(false);
1509
- const latest = useRef({ matches, onFirstHover });
1510
- latest.current = { matches, onFirstHover };
1511
- useEffect(() => {
1512
- if (!root) return;
1513
- const over = (event) => {
1514
- const link = event.target?.closest?.(
1515
- "a.docx-hyperlink"
1516
- );
1517
- const href = link?.getAttribute("href") ?? "";
1518
- if (!link || !href || !latest.current.matches(href, link)) return;
1519
- if (!hovered.current) {
1520
- hovered.current = true;
1521
- latest.current.onFirstHover?.();
1522
- }
1523
- const title = link.getAttribute("title");
1524
- if (title) {
1525
- link.dataset.hoverTitle = title;
1526
- link.removeAttribute("title");
1527
- }
1528
- const rect = link.getBoundingClientRect();
1529
- setCard({
1530
- left: rect.left,
1531
- top: rect.bottom + 6,
1532
- href,
1533
- fallback: link.dataset.hoverTitle ?? ""
1534
- });
1535
- };
1536
- const out = (event) => {
1537
- const link = event.target?.closest?.("a.docx-hyperlink");
1538
- if (link && !link.contains(event.relatedTarget)) setCard(null);
1539
- };
1540
- const hide = () => setCard(null);
1541
- root.addEventListener("mouseover", over);
1542
- root.addEventListener("mouseout", out);
1543
- window.addEventListener("keydown", hide, true);
1544
- window.addEventListener("pointerdown", hide, true);
1545
- window.addEventListener("scroll", hide, true);
1546
- return () => {
1547
- root.removeEventListener("mouseover", over);
1548
- root.removeEventListener("mouseout", out);
1549
- window.removeEventListener("keydown", hide, true);
1550
- window.removeEventListener("pointerdown", hide, true);
1551
- window.removeEventListener("scroll", hide, true);
1552
- };
1553
- }, [root]);
1554
- if (!card) return null;
1555
- const content = resolve(card.href);
1556
- if (!content && !card.fallback) return null;
1557
- return createPortal(
1558
- /* @__PURE__ */ jsx(
1559
- "div",
1560
- {
1561
- role: "tooltip",
1562
- className: "native-docx-link-card rounded-md border border-border bg-popover p-3 text-sm text-popover-foreground shadow-lg",
1563
- style: {
1564
- position: "fixed",
1565
- left: Math.max(8, Math.min(card.left, window.innerWidth - 348)),
1566
- top: card.top,
1567
- width: 340,
1568
- zIndex: 1e3,
1569
- pointerEvents: "none"
1570
- },
1571
- "data-testid": testId,
1572
- children: content ? /* @__PURE__ */ jsxs(Fragment, { children: [
1573
- content.title && /* @__PURE__ */ jsx("p", { className: "font-medium", children: content.title }),
1574
- /* @__PURE__ */ jsx("p", { className: content.title ? "mt-1 text-muted-foreground" : void 0, children: content.body }),
1575
- content.footer && /* @__PURE__ */ jsx("p", { className: "mt-2 text-xs text-muted-foreground", children: content.footer })
1576
- ] }) : /* @__PURE__ */ jsx("p", { children: card.fallback })
1577
- }
1578
- ),
1579
- document.body
1580
- );
1581
- }
1582
- var attr = (node, name) => node.attributes?.find((a) => a.localName === name)?.value;
1583
- function documentStyleIds(root) {
1584
- const ids = /* @__PURE__ */ new Set();
1585
- for (const style of root?.children ?? [])
1586
- if (style.localName === "style") {
1587
- const id = attr(style, "styleId");
1588
- if (id) ids.add(id);
1589
- }
1590
- return ids;
1360
+ function fragmentHtml(body, covered2, options = {}) {
1361
+ return `<div data-docx-fragment="${base64(fragmentPackage(body, covered2, options))}" data-docx-fragment-end="${covered2 ? "covered" : "open"}"></div>`;
1591
1362
  }
1592
1363
  function editorPort(editor, revision) {
1593
1364
  const surface = () => {
@@ -1694,6 +1465,136 @@ function preservingCaret(editor, fn) {
1694
1465
  }
1695
1466
  return result;
1696
1467
  }
1468
+ var AgentUndoRoom = createContext(null);
1469
+ function AgentUndo() {
1470
+ const item = useReviewItem();
1471
+ const review = useReview();
1472
+ const editor = useDocxEditor();
1473
+ const room = useContext(AgentUndoRoom);
1474
+ const records = room?.getMap(AGENT_UNDO_MAP);
1475
+ const [, changed] = useReducer((n) => n + 1, 0);
1476
+ const [error, setError] = useState("");
1477
+ useEffect(() => {
1478
+ if (!records) return;
1479
+ records.observe(changed);
1480
+ return () => records.unobserve(changed);
1481
+ }, [records]);
1482
+ if (!item || item.kind !== "comment" || item.parentId || !records) return null;
1483
+ const id = item.item.id;
1484
+ const record = records.get(id);
1485
+ if (!record) return null;
1486
+ const undo = () => {
1487
+ const surface = editor?.surface;
1488
+ if (!editor || !surface) return;
1489
+ const ops = undoOps(surface.session.part().root, record);
1490
+ if (!ops) return setError("What this changed is no longer in the document.");
1491
+ let applied = false;
1492
+ try {
1493
+ applied = withDirectEditing(editor, () => surface.applyAutomationOps(() => ops)).committed;
1494
+ } catch {
1495
+ }
1496
+ if (!applied) return setError("This change could not be undone.");
1497
+ records.delete(id);
1498
+ review.resolve(item, true);
1499
+ };
1500
+ return /* @__PURE__ */ jsxs("div", { className: "native-docx-comment-extra", "data-review-selectable": "", children: [
1501
+ /* @__PURE__ */ jsx(
1502
+ "button",
1503
+ {
1504
+ type: "button",
1505
+ "data-testid": "docx-agent-undo",
1506
+ onClick: (event) => {
1507
+ event.stopPropagation();
1508
+ undo();
1509
+ },
1510
+ children: "Undo"
1511
+ }
1512
+ ),
1513
+ error && /* @__PURE__ */ jsx("p", { role: "status", className: "native-docx-comment-activity", children: error })
1514
+ ] });
1515
+ }
1516
+ function LinkHoverCard({
1517
+ root,
1518
+ matches,
1519
+ resolve,
1520
+ onFirstHover,
1521
+ testId
1522
+ }) {
1523
+ const [card, setCard] = useState(null);
1524
+ const hovered = useRef(false);
1525
+ const latest = useRef({ matches, onFirstHover });
1526
+ latest.current = { matches, onFirstHover };
1527
+ useEffect(() => {
1528
+ if (!root) return;
1529
+ const over = (event) => {
1530
+ const link = event.target?.closest?.(
1531
+ "a.docx-hyperlink"
1532
+ );
1533
+ const href = link?.getAttribute("href") ?? "";
1534
+ if (!link || !href || !latest.current.matches(href, link)) return;
1535
+ if (!hovered.current) {
1536
+ hovered.current = true;
1537
+ latest.current.onFirstHover?.();
1538
+ }
1539
+ const title = link.getAttribute("title");
1540
+ if (title) {
1541
+ link.dataset.hoverTitle = title;
1542
+ link.removeAttribute("title");
1543
+ }
1544
+ const rect = link.getBoundingClientRect();
1545
+ setCard({
1546
+ left: rect.left,
1547
+ top: rect.bottom + 6,
1548
+ href,
1549
+ fallback: link.dataset.hoverTitle ?? ""
1550
+ });
1551
+ };
1552
+ const out = (event) => {
1553
+ const link = event.target?.closest?.("a.docx-hyperlink");
1554
+ if (link && !link.contains(event.relatedTarget)) setCard(null);
1555
+ };
1556
+ const hide = () => setCard(null);
1557
+ root.addEventListener("mouseover", over);
1558
+ root.addEventListener("mouseout", out);
1559
+ window.addEventListener("keydown", hide, true);
1560
+ window.addEventListener("pointerdown", hide, true);
1561
+ window.addEventListener("scroll", hide, true);
1562
+ return () => {
1563
+ root.removeEventListener("mouseover", over);
1564
+ root.removeEventListener("mouseout", out);
1565
+ window.removeEventListener("keydown", hide, true);
1566
+ window.removeEventListener("pointerdown", hide, true);
1567
+ window.removeEventListener("scroll", hide, true);
1568
+ };
1569
+ }, [root]);
1570
+ if (!card) return null;
1571
+ const content = resolve(card.href);
1572
+ if (!content && !card.fallback) return null;
1573
+ return createPortal(
1574
+ /* @__PURE__ */ jsx(
1575
+ "div",
1576
+ {
1577
+ role: "tooltip",
1578
+ className: "native-docx-link-card rounded-md border border-border bg-popover p-3 text-sm text-popover-foreground shadow-lg",
1579
+ style: {
1580
+ position: "fixed",
1581
+ left: Math.max(8, Math.min(card.left, window.innerWidth - 348)),
1582
+ top: card.top,
1583
+ width: 340,
1584
+ zIndex: 1e3,
1585
+ pointerEvents: "none"
1586
+ },
1587
+ "data-testid": testId,
1588
+ children: content ? /* @__PURE__ */ jsxs(Fragment, { children: [
1589
+ content.title && /* @__PURE__ */ jsx("p", { className: "font-medium", children: content.title }),
1590
+ /* @__PURE__ */ jsx("p", { className: content.title ? "mt-1 text-muted-foreground" : void 0, children: content.body }),
1591
+ content.footer && /* @__PURE__ */ jsx("p", { className: "mt-2 text-xs text-muted-foreground", children: content.footer })
1592
+ ] }) : /* @__PURE__ */ jsx("p", { children: card.fallback })
1593
+ }
1594
+ ),
1595
+ document.body
1596
+ );
1597
+ }
1697
1598
 
1698
1599
  // src/docx/structural/trackedOrNoted.ts
1699
1600
  var revisionDate = (at = /* @__PURE__ */ new Date()) => at.toISOString().replace(/\.\d{3}Z$/, "Z");
@@ -1717,7 +1618,7 @@ function trackedOrNoted(port, { label, author, insert, inserted = Boolean }) {
1717
1618
  if (before && after && port.comment(before, after, label)) return { result, how: "noted" };
1718
1619
  return { result, how: "direct" };
1719
1620
  }
1720
- var attr2 = (node, name) => node.attributes?.find((a) => a.localName === name)?.value;
1621
+ var attr = (node, name) => node.attributes?.find((a) => a.localName === name)?.value;
1721
1622
  function structuralPort(editor) {
1722
1623
  return {
1723
1624
  mode: () => editor.getEditingMode(),
@@ -1732,7 +1633,7 @@ function structuralPort(editor) {
1732
1633
  const root = editor.surface?.session.part().root;
1733
1634
  let count = 0;
1734
1635
  const visit = (node) => {
1735
- if (node.localName === "ins" && attr2(node, "author") === author && attr2(node, "date") === date)
1636
+ if (node.localName === "ins" && attr(node, "author") === author && attr(node, "date") === date)
1736
1637
  count++;
1737
1638
  node.children?.forEach(visit);
1738
1639
  };
@@ -1858,7 +1759,7 @@ function DefinedTermsProvider({
1858
1759
  },
1859
1760
  [notify]
1860
1761
  );
1861
- const run2 = useCallback(
1762
+ const run = useCallback(
1862
1763
  (fn) => editor ? attempt(() => withDirectEditing(editor, fn)) : void 0,
1863
1764
  [editor, attempt]
1864
1765
  );
@@ -1873,7 +1774,7 @@ function DefinedTermsProvider({
1873
1774
  (row) => {
1874
1775
  if (!editor || !picker || !row) return;
1875
1776
  const port = editorPort(editor);
1876
- const placed = run2(() => {
1777
+ const placed = run(() => {
1877
1778
  if (picker.mode === "search" && picker.caret) port.setCaret(picker.caret);
1878
1779
  const caret = port.caret();
1879
1780
  if (!caret) throw new Error("Place the cursor where the term should go.");
@@ -1893,7 +1794,7 @@ function DefinedTermsProvider({
1893
1794
  if (result?.addedDefinition)
1894
1795
  notify?.(`\u201C${row.definition.term}\u201D added to the Definitions section.`, "success");
1895
1796
  },
1896
- [editor, picker, run2, attempt, track, notify]
1797
+ [editor, picker, run, attempt, track, notify]
1897
1798
  );
1898
1799
  const openPicker = useCallback(
1899
1800
  (anchor) => {
@@ -2856,107 +2757,6 @@ function runBeforeSave(editor) {
2856
2757
  } catch {
2857
2758
  }
2858
2759
  }
2859
- function newRefBookmark(taken, random = Math.random) {
2860
- for (; ; ) {
2861
- const name = `${REF_BOOKMARK_PREFIX}${String(Math.floor(random() * 9e8) + 1e8)}`;
2862
- if (!taken.has(name)) return name;
2863
- }
2864
- }
2865
- var styled = (style) => style ? `<w:rPr><w:rStyle w:val="${style}"/></w:rPr>` : "";
2866
- var run = (text, style) => `<w:r>${styled(style)}<w:t xml:space="preserve">${esc(text)}</w:t></w:r>`;
2867
- function refFieldXml(instruction, cached) {
2868
- const r = (inner) => `<w:r>${styled(CROSS_REFERENCE_STYLE)}${inner}</w:r>`;
2869
- return `${r('<w:fldChar w:fldCharType="begin"/>')}${r(
2870
- `<w:instrText xml:space="preserve"> ${esc(instruction)} </w:instrText>`
2871
- )}${r('<w:fldChar w:fldCharType="separate"/>')}${run(cached, CROSS_REFERENCE_STYLE)}${r(
2872
- '<w:fldChar w:fldCharType="end"/>'
2873
- )}`;
2874
- }
2875
- var refTooltip = (value, mode) => mode === "number" ? `Cross-reference to clause ${value}` : `Cross-reference to \u201C${value}\u201D`;
2876
- function crossReferenceXml(bookmark, mode, value) {
2877
- return `<w:hyperlink w:anchor="${esc(bookmark)}" w:tooltip="${esc(
2878
- refTooltip(value, mode)
2879
- )}" w:history="1">${refFieldXml(refInstruction(bookmark, mode), value)}</w:hyperlink>`;
2880
- }
2881
- var refInstruction = (bookmark, mode) => mode === "number" ? `REF ${bookmark} \\r \\h` : `REF ${bookmark} \\h`;
2882
- var refResult = (target, mode) => mode === "number" && target.number ? target.number : target.text;
2883
- var allBookmarks = (port) => new Set(port.paragraphs().flatMap((p) => p.bookmarks));
2884
- function ensureTargetBookmark(port, target, mode) {
2885
- const paragraph = port.paragraphs().find((p) => p.id === target.paragraphId);
2886
- if (!paragraph) throw new Error("That clause is no longer in the document.");
2887
- const existing = paragraph.bookmarks.find((b) => b.startsWith(REF_BOOKMARK_PREFIX));
2888
- if (existing && mode === "number") return existing;
2889
- const name = newRefBookmark(allBookmarks(port));
2890
- const start = `<w:bookmarkStart w:id="0" w:name="${name}"/>`;
2891
- const end = '<w:bookmarkEnd w:id="0"/>';
2892
- if (mode === "number") {
2893
- port.setCaret({ paragraphId: paragraph.id, offset: 0 });
2894
- if (!port.paste(`<w:p>${start}${end}</w:p>`, "", false))
2895
- throw new Error("The cross-reference target could not be marked.");
2896
- return name;
2897
- }
2898
- const runs = port.runsXml(paragraph.id);
2899
- if (!runs) throw new Error("This heading cannot be referred to by its text; use its number.");
2900
- port.deleteRange(
2901
- { paragraphId: paragraph.id, offset: 0 },
2902
- { paragraphId: paragraph.id, offset: paragraph.text.length }
2903
- );
2904
- if (!port.paste(`<w:p>${start}${runs}${end}</w:p>`, paragraph.text, false))
2905
- throw new Error("The cross-reference target could not be marked.");
2906
- return name;
2907
- }
2908
- function pastePoint(port, caret) {
2909
- const paragraph = port.paragraphs().find((p) => p.id === caret.paragraphId);
2910
- if (paragraph?.text[caret.offset - 1] !== FIELD_ATOM) return caret;
2911
- port.setCaret(caret);
2912
- port.typeText(" ");
2913
- return { paragraphId: caret.paragraphId, offset: caret.offset + 1 };
2914
- }
2915
- function markCrossReferenceTarget(port, target, mode) {
2916
- if (mode === "number" && !target.number) mode = "text";
2917
- const bookmark = ensureTargetBookmark(port, target, mode);
2918
- return { bookmark, mode, value: refResult(target, mode) };
2919
- }
2920
- function insertCrossReferenceField(port, { bookmark, mode, value }, caret) {
2921
- caret = pastePoint(port, caret);
2922
- port.setCaret(caret);
2923
- if (!port.paste(`<w:p>${crossReferenceXml(bookmark, mode, value)}</w:p>`, value, false))
2924
- throw new Error("The cross-reference could not be inserted.");
2925
- port.setCaret({ paragraphId: caret.paragraphId, offset: caret.offset + 1 });
2926
- return { bookmark };
2927
- }
2928
- function insertCrossReference(port, target, mode, caret) {
2929
- return insertCrossReferenceField(port, markCrossReferenceTarget(port, target, mode), caret);
2930
- }
2931
- var documentReferenceTooltip = (text, appName = "ARBI") => `Cross-reference: ${text} \u2014 opens in ${appName}`;
2932
- function insertDocumentReference(port, reference, caret) {
2933
- const text = reference.text.trim();
2934
- if (!text) throw new Error("Enter the reference text.");
2935
- const tooltip = documentReferenceTooltip(text, reference.appName).slice(0, 255);
2936
- caret = pastePoint(port, caret);
2937
- port.setCaret(caret);
2938
- const link = `<w:p><w:hyperlink r:id="rIdRef1"${tooltip ? ` w:tooltip="${esc(tooltip)}"` : ""} w:history="1">${run(text, CROSS_REFERENCE_STYLE)}</w:hyperlink></w:p>`;
2939
- if (!port.paste(link, text, false, hyperlinkRelationship("rIdRef1", reference.url)))
2940
- throw new Error("The reference could not be inserted.");
2941
- port.setCaret({ paragraphId: caret.paragraphId, offset: caret.offset + text.length });
2942
- }
2943
- function refreshCrossReferences(port) {
2944
- const stale = staleCrossReferences(port).sort(
2945
- (a, b) => a.paragraphId === b.paragraphId ? b.offset - a.offset : 0
2946
- );
2947
- let refreshed = 0;
2948
- for (const ref of stale) {
2949
- const paragraph = port.paragraphs().find((p) => p.id === ref.paragraphId);
2950
- if (!paragraph || paragraph.text[ref.offset - 1] === FIELD_ATOM) continue;
2951
- const at = { paragraphId: ref.paragraphId, offset: ref.offset };
2952
- port.deleteRange(at, { paragraphId: ref.paragraphId, offset: ref.offset + 1 });
2953
- port.setCaret(at);
2954
- const text = ref.value ?? (ref.cached.trim() || ref.bookmark);
2955
- const body = ref.value === null ? run(text, BROKEN_CROSS_REFERENCE_STYLE) : crossReferenceXml(ref.bookmark, ref.mode, ref.value);
2956
- if (port.paste(`<w:p>${body}</w:p>`, text, false) && ref.value !== null) refreshed++;
2957
- }
2958
- return { refreshed, broken: brokenCrossReferences(port) };
2959
- }
2960
2760
 
2961
2761
  // src/docx/references/passages.ts
2962
2762
  function shortTitle(title) {
@@ -2986,25 +2786,6 @@ function filterPassages(passages, query) {
2986
2786
  const q = query.trim().toLowerCase();
2987
2787
  return q ? passages.filter((p) => p.text.toLowerCase().includes(q)) : [...passages];
2988
2788
  }
2989
- var RUN_PARTS = /* @__PURE__ */ new Set(["rPr", "t", "tab", "br", "lastRenderedPageBreak"]);
2990
- var SKIPPED = /* @__PURE__ */ new Set(["pPr", "bookmarkStart", "bookmarkEnd", "proofErr", "permStart", "permEnd"]);
2991
- function serialize(node) {
2992
- if (node.kind === "textValue") return esc(node.value ?? "");
2993
- const name = `${node.prefix ?? "w"}:${node.localName}`;
2994
- const attrs = (node.attributes ?? []).map((a) => ` ${a.prefix ? `${a.prefix}:` : ""}${a.localName}="${esc(a.value)}"`).join("");
2995
- const children = (node.children ?? []).map((c) => serialize(c)).join("");
2996
- return children ? `<${name}${attrs}>${children}</${name}>` : `<${name}${attrs}/>`;
2997
- }
2998
- function paragraphRunsXml(paragraph) {
2999
- const runs = [];
3000
- for (const child of paragraph.children ?? []) {
3001
- if (child.localName && SKIPPED.has(child.localName)) continue;
3002
- if (child.localName !== "r") return null;
3003
- if ((child.children ?? []).some((c) => !c.localName || !RUN_PARTS.has(c.localName))) return null;
3004
- runs.push(serialize(child));
3005
- }
3006
- return runs.length ? runs.join("") : null;
3007
- }
3008
2789
  function findNode2(node, id) {
3009
2790
  if (node.id === id) return node;
3010
2791
  for (const child of node.children ?? []) {
@@ -3098,7 +2879,7 @@ function CrossReferencesProvider({
3098
2879
  notify?.(error instanceof Error ? error.message : "Could not read the document.", "error");
3099
2880
  }
3100
2881
  }, [editor, editable, notify]);
3101
- const run2 = useCallback(
2882
+ const run = useCallback(
3102
2883
  (label, prepare, insert) => {
3103
2884
  if (!editor) return;
3104
2885
  try {
@@ -3251,12 +3032,12 @@ function CrossReferencesProvider({
3251
3032
  labels: l,
3252
3033
  onCancel: () => setDialog(null),
3253
3034
  onClosed: () => editor?.surface?.focus(),
3254
- onInsertTarget: (target, mode) => run2(
3035
+ onInsertTarget: (target, mode) => run(
3255
3036
  `Inserted cross-reference: ${refResult(target, mode)}`,
3256
3037
  () => markCrossReferenceTarget(referencesPort(editor), target, mode),
3257
3038
  (marked, revision) => insertCrossReferenceField(referencesPort(editor, revision), marked, dialog.caret)
3258
3039
  ),
3259
- onInsertPassage: (target, text) => run2(
3040
+ onInsertPassage: (target, text) => run(
3260
3041
  `Inserted cross-reference: ${text}`,
3261
3042
  () => void 0,
3262
3043
  (_, revision) => insertDocumentReference(
@@ -4021,9 +3802,9 @@ function countSeqFields(root, label, throughId) {
4021
3802
  return count;
4022
3803
  }
4023
3804
  function captionParagraphXml(label, number, text) {
4024
- const run2 = (value) => `<w:r><w:t xml:space="preserve">${esc(value)}</w:t></w:r>`;
3805
+ const run = (value) => `<w:r><w:t xml:space="preserve">${esc(value)}</w:t></w:r>`;
4025
3806
  const rest = text.trim() ? `: ${text.trim()}` : "";
4026
- return `<w:p><w:pPr><w:pStyle w:val="Caption"/></w:pPr>${run2(`${label} `)}<w:fldSimple w:instr=" SEQ ${esc(label)} \\* ARABIC "><w:r><w:t>${number}</w:t></w:r></w:fldSimple>${rest ? run2(rest) : ""}</w:p>`;
3807
+ return `<w:p><w:pPr><w:pStyle w:val="Caption"/></w:pPr>${run(`${label} `)}<w:fldSimple w:instr=" SEQ ${esc(label)} \\* ARABIC "><w:r><w:t>${number}</w:t></w:r></w:fldSimple>${rest ? run(rest) : ""}</w:p>`;
4027
3808
  }
4028
3809
  function base642(bytes) {
4029
3810
  let binary = "";
@@ -4273,7 +4054,7 @@ function GenerateImageButton({ generation }) {
4273
4054
  });
4274
4055
  const editable = useEditorState((snapshot) => snapshot.editable);
4275
4056
  const generating = useSyncExternalStore(subscribe, () => running > 0);
4276
- async function run2() {
4057
+ async function run() {
4277
4058
  if (!editor || !prompt.trim() || busy) return;
4278
4059
  const caret = rememberCaret(editor);
4279
4060
  const controller = new AbortController();
@@ -4319,7 +4100,7 @@ function GenerateImageButton({ generation }) {
4319
4100
  className: "native-docx-form native-docx-generate-image",
4320
4101
  onSubmit: (event) => {
4321
4102
  event.preventDefault();
4322
- void run2();
4103
+ void run();
4323
4104
  },
4324
4105
  children: [
4325
4106
  /* @__PURE__ */ jsxs("label", { children: [
@@ -4335,7 +4116,7 @@ function GenerateImageButton({ generation }) {
4335
4116
  "data-testid": "docx-generate-image-prompt",
4336
4117
  onChange: (event) => setPrompt(event.target.value),
4337
4118
  onKeyDown: (event) => {
4338
- if (event.key === "Enter" && (event.metaKey || event.ctrlKey)) void run2();
4119
+ if (event.key === "Enter" && (event.metaKey || event.ctrlKey)) void run();
4339
4120
  }
4340
4121
  }
4341
4122
  )
@@ -5097,7 +4878,10 @@ function NativeDocxEditor({
5097
4878
  notify: adapter.notify,
5098
4879
  getAgentStatus: adapter.getAgentStatus,
5099
4880
  requestAgent: adapter.requestAgent ? (request) => adapter.requestAgent(documentId, request) : void 0,
5100
- children: /* @__PURE__ */ jsx(DocxEditorReview, { children: () => /* @__PURE__ */ jsx(DocxEditorReview.Card, { children: /* @__PURE__ */ jsx(DocxCommentActivity, {}) }) })
4881
+ children: /* @__PURE__ */ jsx(AgentUndoRoom.Provider, { value: ready.room?.ydoc ?? null, children: /* @__PURE__ */ jsx(DocxEditorReview, { children: () => /* @__PURE__ */ jsxs(DocxEditorReview.Card, { children: [
4882
+ /* @__PURE__ */ jsx(DocxCommentActivity, {}),
4883
+ /* @__PURE__ */ jsx(AgentUndo, {})
4884
+ ] }) }) })
5101
4885
  }
5102
4886
  ),
5103
4887
  !compact && /* @__PURE__ */ jsx(DocxEditor.HeaderFooterChrome, {}),
@@ -5156,6 +4940,6 @@ function NativeDocxEditor({
5156
4940
  );
5157
4941
  }
5158
4942
 
5159
- export { BUILTIN_TEMPLATE_NAME, CrossReferenceDialog, CrossReferencesProvider, DEFAULT_CROSS_REFERENCES_LABELS, DEFAULT_DEFINED_TERMS_LABELS, DEFINED_TERM_TRIGGER, DefinedTermsProvider, DocxAuthorContext, DocxCommentActivity, DocxEditorReview, DocxMentions, DocxParticipants, DocxRibbon, GenerateImageButton, HouseTemplateProvider, LinkHoverCard, NativeDocxEditor, builtinHouseTemplate, contentPath, editorPort, findDefinitionsSection, insertCrossReference, insertDefinedTerm, insertDocumentReference, normalizeDocxExport, referenceText, referencesPort, resolveHouseTemplate, reviewModule, shortTitle, structuralPort, templateFileName, trackedOrNoted, useCrossReferences, useDefinedTerms, useHouseTemplate, useReview, useReviewItem, useTrackedOrNoted, withDirectEditing };
5160
- //# sourceMappingURL=chunk-GKDWQLVU.js.map
5161
- //# sourceMappingURL=chunk-GKDWQLVU.js.map
4943
+ export { BUILTIN_TEMPLATE_NAME, CrossReferenceDialog, CrossReferencesProvider, DEFAULT_CROSS_REFERENCES_LABELS, DEFAULT_DEFINED_TERMS_LABELS, DEFINED_TERM_TRIGGER, DefinedTermsProvider, DocxAuthorContext, DocxCommentActivity, DocxEditorReview, DocxMentions, DocxParticipants, DocxRibbon, GenerateImageButton, HouseTemplateProvider, LinkHoverCard, NativeDocxEditor, builtinHouseTemplate, contentPath, editorPort, normalizeDocxExport, referenceText, referencesPort, resolveHouseTemplate, reviewModule, shortTitle, structuralPort, templateFileName, trackedOrNoted, useCrossReferences, useDefinedTerms, useHouseTemplate, useReview, useReviewItem, useTrackedOrNoted, withDirectEditing };
4944
+ //# sourceMappingURL=chunk-3OT37I24.js.map
4945
+ //# sourceMappingURL=chunk-3OT37I24.js.map