@beyondwork/docx-react-component 1.0.120 → 1.0.122

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 (116) hide show
  1. package/README.md +1 -0
  2. package/dist/api/public-types.cjs +1713 -55
  3. package/dist/api/public-types.d.cts +2 -2
  4. package/dist/api/public-types.d.ts +2 -2
  5. package/dist/api/public-types.js +6 -6
  6. package/dist/api/v3.cjs +4958 -406
  7. package/dist/api/v3.d.cts +3 -3
  8. package/dist/api/v3.d.ts +3 -3
  9. package/dist/api/v3.js +14 -14
  10. package/dist/{canonical-document-fNawStsc.d.cts → canonical-document-ByIqTd4s.d.cts} +9 -1
  11. package/dist/{canonical-document-fNawStsc.d.ts → canonical-document-ByIqTd4s.d.ts} +9 -1
  12. package/dist/{chunk-5RNMPLXU.js → chunk-37SEJQ3G.js} +4 -4
  13. package/dist/{chunk-FXGQM2JB.js → chunk-3OFSP2IX.js} +11 -5
  14. package/dist/{chunk-U5BSQXF4.js → chunk-3OHVK2D6.js} +70 -12
  15. package/dist/{chunk-AUQDC5BD.js → chunk-3TUQCHYT.js} +101 -2
  16. package/dist/{chunk-SJSMYEMU.js → chunk-B4YHWFE3.js} +3 -3
  17. package/dist/{chunk-XC56YLIS.js → chunk-C2LWJ4CZ.js} +4 -0
  18. package/dist/{chunk-VDIUVT46.js → chunk-CX42VC67.js} +1 -1
  19. package/dist/{chunk-KCHEAX4Z.js → chunk-EMDH4IQN.js} +148 -70
  20. package/dist/{chunk-TMQGWF7R.js → chunk-G3B2OBCZ.js} +352 -17
  21. package/dist/{chunk-VCL5MJMZ.js → chunk-GON2DNTE.js} +149 -28
  22. package/dist/{chunk-WVZX4NYG.js → chunk-GZW2ERUO.js} +601 -47
  23. package/dist/{chunk-WDNEPRFW.js → chunk-ICX54W4U.js} +1 -1
  24. package/dist/{chunk-FIGWJ43K.js → chunk-IT2DK3A7.js} +1883 -90
  25. package/dist/{chunk-2ZWFQ74R.js → chunk-OBCP6VTG.js} +1 -1
  26. package/dist/{chunk-FLNQY74K.js → chunk-OYGMRRR7.js} +1 -1
  27. package/dist/{chunk-MPYYBRVN.js → chunk-PCXTMEGY.js} +782 -124
  28. package/dist/{chunk-4JNUMMM7.js → chunk-PGGPPZ65.js} +17 -2
  29. package/dist/{chunk-KHZNNBTN.js → chunk-QFU7ZOAD.js} +43 -39
  30. package/dist/{chunk-4ZNQFWFM.js → chunk-QIO6V46H.js} +84 -4
  31. package/dist/{chunk-IQ2VJEF6.js → chunk-QNGJRZ2D.js} +1 -1
  32. package/dist/{chunk-BM5NSDII.js → chunk-S4ANOS2M.js} +2 -2
  33. package/dist/{chunk-AQA7OZ2R.js → chunk-TFSXOIAI.js} +959 -43
  34. package/dist/{chunk-NQZUGMLW.js → chunk-TMU7JMXX.js} +184 -32
  35. package/dist/{chunk-KD5K5XIA.js → chunk-UHQOUTAX.js} +568 -88
  36. package/dist/{chunk-327AIUXL.js → chunk-UWDWGQH5.js} +11 -4
  37. package/dist/{chunk-BBB4GSDB.js → chunk-XVFENXLK.js} +2 -2
  38. package/dist/{chunk-MUEN2WOG.js → chunk-ZKSDVHGH.js} +6 -3
  39. package/dist/compare.cjs +17 -2
  40. package/dist/compare.d.cts +1 -1
  41. package/dist/compare.d.ts +1 -1
  42. package/dist/compare.js +3 -3
  43. package/dist/core/commands/formatting-commands.d.cts +2 -2
  44. package/dist/core/commands/formatting-commands.d.ts +2 -2
  45. package/dist/core/commands/image-commands.cjs +814 -45
  46. package/dist/core/commands/image-commands.d.cts +2 -2
  47. package/dist/core/commands/image-commands.d.ts +2 -2
  48. package/dist/core/commands/image-commands.js +8 -8
  49. package/dist/core/commands/section-layout-commands.d.cts +2 -2
  50. package/dist/core/commands/section-layout-commands.d.ts +2 -2
  51. package/dist/core/commands/style-commands.d.cts +2 -2
  52. package/dist/core/commands/style-commands.d.ts +2 -2
  53. package/dist/core/commands/table-structure-commands.cjs +750 -42
  54. package/dist/core/commands/table-structure-commands.d.cts +2 -2
  55. package/dist/core/commands/table-structure-commands.d.ts +2 -2
  56. package/dist/core/commands/table-structure-commands.js +6 -6
  57. package/dist/core/commands/text-commands.cjs +910 -57
  58. package/dist/core/commands/text-commands.d.cts +2 -2
  59. package/dist/core/commands/text-commands.d.ts +2 -2
  60. package/dist/core/commands/text-commands.js +8 -8
  61. package/dist/core/selection/mapping.d.cts +2 -2
  62. package/dist/core/selection/mapping.d.ts +2 -2
  63. package/dist/core/state/editor-state.cjs +17 -2
  64. package/dist/core/state/editor-state.d.cts +2 -2
  65. package/dist/core/state/editor-state.d.ts +2 -2
  66. package/dist/core/state/editor-state.js +2 -2
  67. package/dist/index.cjs +6203 -625
  68. package/dist/index.d.cts +5 -5
  69. package/dist/index.d.ts +5 -5
  70. package/dist/index.js +299 -67
  71. package/dist/io/docx-session.cjs +354 -102
  72. package/dist/io/docx-session.d.cts +4 -4
  73. package/dist/io/docx-session.d.ts +4 -4
  74. package/dist/io/docx-session.js +5 -5
  75. package/dist/legal.cjs +183 -31
  76. package/dist/legal.d.cts +1 -1
  77. package/dist/legal.d.ts +1 -1
  78. package/dist/legal.js +3 -3
  79. package/dist/{loader-CaohrhNl.d.ts → loader-BF8ju_LK.d.ts} +22 -4
  80. package/dist/{loader-BpCyGnZl.d.cts → loader-g54WRvj1.d.cts} +22 -4
  81. package/dist/{public-types-Dpch9JG0.d.cts → public-types-D_y4Ptcj.d.cts} +747 -21
  82. package/dist/{public-types-C948HNVF.d.ts → public-types-Dl1jiWjk.d.ts} +747 -21
  83. package/dist/public-types.cjs +1713 -55
  84. package/dist/public-types.d.cts +2 -2
  85. package/dist/public-types.d.ts +2 -2
  86. package/dist/public-types.js +6 -6
  87. package/dist/runtime/collab.cjs +4 -0
  88. package/dist/runtime/collab.d.cts +3 -3
  89. package/dist/runtime/collab.d.ts +3 -3
  90. package/dist/runtime/collab.js +2 -2
  91. package/dist/runtime/document-runtime.cjs +3699 -507
  92. package/dist/runtime/document-runtime.d.cts +2 -2
  93. package/dist/runtime/document-runtime.d.ts +2 -2
  94. package/dist/runtime/document-runtime.js +18 -18
  95. package/dist/{session-Dqg17V3s.d.ts → session-C1EPAkcI.d.ts} +3 -3
  96. package/dist/{session-BlXE5zxz.d.cts → session-D15QOO0Q.d.cts} +3 -3
  97. package/dist/session.cjs +951 -104
  98. package/dist/session.d.cts +5 -5
  99. package/dist/session.d.ts +5 -5
  100. package/dist/session.js +10 -8
  101. package/dist/tailwind.cjs +1752 -91
  102. package/dist/tailwind.d.cts +2 -2
  103. package/dist/tailwind.d.ts +2 -2
  104. package/dist/tailwind.js +10 -10
  105. package/dist/{types-C9vZVpKy.d.cts → types-BoSRp2Vg.d.cts} +2 -2
  106. package/dist/{types-B1tlF1bq.d.ts → types-DEvRwq9C.d.ts} +2 -2
  107. package/dist/ui-tailwind/editor-surface/search-plugin.d.cts +3 -3
  108. package/dist/ui-tailwind/editor-surface/search-plugin.d.ts +3 -3
  109. package/dist/ui-tailwind/editor-surface/search-plugin.js +7 -7
  110. package/dist/ui-tailwind/theme/editor-theme.css +5 -5
  111. package/dist/ui-tailwind.cjs +1752 -91
  112. package/dist/ui-tailwind.d.cts +8 -8
  113. package/dist/ui-tailwind.d.ts +8 -8
  114. package/dist/ui-tailwind.js +10 -10
  115. package/package.json +17 -5
  116. package/dist/ui-tailwind/theme/tokens.css +0 -382
@@ -1,7 +1,7 @@
1
- export { a as LoadDocxEditorSessionAsyncOptions, b as LoadDocxEditorSessionOptions, L as LoadedDocxEditorSession, l as loadDocxEditorSessionAsync } from '../loader-BpCyGnZl.cjs';
2
- import { R as RevisionStoryTargetRecord, O as OpaqueFragmentRecord } from '../canonical-document-fNawStsc.cjs';
3
- import { a$ as EditorAnchorProjection } from '../public-types-Dpch9JG0.cjs';
4
- import '../types-C9vZVpKy.cjs';
1
+ export { b as LoadDocxEditorSessionAsyncOptions, c as LoadDocxEditorSessionOptions, L as LoadedDocxEditorSession, l as loadDocxEditorSessionAsync } from '../loader-g54WRvj1.cjs';
2
+ import { R as RevisionStoryTargetRecord, O as OpaqueFragmentRecord } from '../canonical-document-ByIqTd4s.cjs';
3
+ import { a$ as EditorAnchorProjection } from '../public-types-D_y4Ptcj.cjs';
4
+ import '../types-BoSRp2Vg.cjs';
5
5
  import 'react';
6
6
  import 'yjs';
7
7
  import 'y-protocols/awareness';
@@ -1,7 +1,7 @@
1
- export { a as LoadDocxEditorSessionAsyncOptions, b as LoadDocxEditorSessionOptions, L as LoadedDocxEditorSession, l as loadDocxEditorSessionAsync } from '../loader-CaohrhNl.js';
2
- import { R as RevisionStoryTargetRecord, O as OpaqueFragmentRecord } from '../canonical-document-fNawStsc.js';
3
- import { a$ as EditorAnchorProjection } from '../public-types-C948HNVF.js';
4
- import '../types-B1tlF1bq.js';
1
+ export { b as LoadDocxEditorSessionAsyncOptions, c as LoadDocxEditorSessionOptions, L as LoadedDocxEditorSession, l as loadDocxEditorSessionAsync } from '../loader-BF8ju_LK.js';
2
+ import { R as RevisionStoryTargetRecord, O as OpaqueFragmentRecord } from '../canonical-document-ByIqTd4s.js';
3
+ import { a$ as EditorAnchorProjection } from '../public-types-Dl1jiWjk.js';
4
+ import '../types-DEvRwq9C.js';
5
5
  import 'react';
6
6
  import 'yjs';
7
7
  import 'y-protocols/awareness';
@@ -2,18 +2,18 @@ import {
2
2
  loadDocxSessionAsync,
3
3
  normalizeImportedCommentThreads,
4
4
  stripCommentMarkup
5
- } from "../chunk-KCHEAX4Z.js";
6
- import "../chunk-327AIUXL.js";
7
- import "../chunk-NQZUGMLW.js";
5
+ } from "../chunk-EMDH4IQN.js";
6
+ import "../chunk-UWDWGQH5.js";
7
+ import "../chunk-TMU7JMXX.js";
8
8
  import "../chunk-4BJ6K26R.js";
9
- import "../chunk-AQA7OZ2R.js";
9
+ import "../chunk-TFSXOIAI.js";
10
10
  import "../chunk-OL2UEHRP.js";
11
11
  import "../chunk-EB6M3GE6.js";
12
12
  import "../chunk-IHE7YOAY.js";
13
13
  import "../chunk-MT37IIGN.js";
14
14
  import "../chunk-UTL65BUI.js";
15
15
  import "../chunk-UFVDIR2C.js";
16
- import "../chunk-4JNUMMM7.js";
16
+ import "../chunk-PGGPPZ65.js";
17
17
  import "../chunk-DNXYUIIS.js";
18
18
  import "../chunk-M2HUK3KF.js";
19
19
  export {
package/dist/legal.cjs CHANGED
@@ -1017,6 +1017,7 @@ var SCOPE_MARKER_BOOKMARK_PREFIX = "bw:scope:";
1017
1017
  // src/io/ooxml/parse-bookmark-references.ts
1018
1018
  var HYPERLINK_ANCHOR_RE = /<(?:\w+:)?hyperlink\b[^>]*\bw:anchor\s*=\s*"([^"]*)"/gi;
1019
1019
  var INSTR_TEXT_RE = /<(?:\w+:)?instrText\b[^>]*>([\s\S]*?)<\/(?:\w+:)?instrText>/gi;
1020
+ var SIMPLE_FIELD_INSTR_RE = /<(?:\w+:)?fldSimple\b[^>]*\bw:instr\s*=\s*"([^"]*)"/gi;
1020
1021
  var TOC_FIELD_RE = /\bTOC\b/;
1021
1022
  var REFLIKE_FIELD_RE = /\b(?:HYPERLINK|REF|PAGEREF|NOTEREF)\s+([A-Za-z0-9_:.\-]+)/g;
1022
1023
  var DATA_BINDING_RE = /<(?:\w+:)?dataBinding\b/i;
@@ -1035,12 +1036,14 @@ function scanBookmarkReferences(documentXml, callerAllowlist = []) {
1035
1036
  }
1036
1037
  INSTR_TEXT_RE.lastIndex = 0;
1037
1038
  while ((m = INSTR_TEXT_RE.exec(documentXml)) !== null) {
1038
- const instrText = m[1] ?? "";
1039
- if (TOC_FIELD_RE.test(instrText)) retainAllToc = true;
1040
- REFLIKE_FIELD_RE.lastIndex = 0;
1041
- let r;
1042
- while ((r = REFLIKE_FIELD_RE.exec(instrText)) !== null) {
1043
- if (r[1]) retained.add(r[1]);
1039
+ if (scanInstructionForRetainedBookmarks(m[1] ?? "", retained)) {
1040
+ retainAllToc = true;
1041
+ }
1042
+ }
1043
+ SIMPLE_FIELD_INSTR_RE.lastIndex = 0;
1044
+ while ((m = SIMPLE_FIELD_INSTR_RE.exec(documentXml)) !== null) {
1045
+ if (scanInstructionForRetainedBookmarks(m[1] ?? "", retained)) {
1046
+ retainAllToc = true;
1044
1047
  }
1045
1048
  }
1046
1049
  retainRevisionBoundedBookmarks(documentXml, retained);
@@ -1050,6 +1053,15 @@ function scanBookmarkReferences(documentXml, callerAllowlist = []) {
1050
1053
  retainAll
1051
1054
  };
1052
1055
  }
1056
+ function scanInstructionForRetainedBookmarks(instruction, retained) {
1057
+ const hasTocField = TOC_FIELD_RE.test(instruction);
1058
+ REFLIKE_FIELD_RE.lastIndex = 0;
1059
+ let r;
1060
+ while ((r = REFLIKE_FIELD_RE.exec(instruction)) !== null) {
1061
+ if (r[1]) retained.add(r[1]);
1062
+ }
1063
+ return hasTocField;
1064
+ }
1053
1065
  function retainRevisionBoundedBookmarks(documentXml, retained) {
1054
1066
  const starts = /* @__PURE__ */ new Map();
1055
1067
  BOOKMARK_START_RE.lastIndex = 0;
@@ -3851,7 +3863,7 @@ var SAFE_TABLE_FIELD_FAMILIES = /* @__PURE__ */ new Set([
3851
3863
  "FORMULA"
3852
3864
  ]);
3853
3865
  var RISKY_TABLE_MARKUP_RE = /<w:(ins|del|moveFrom|moveTo|rPrChange|pPrChange|tblPrChange|trPrChange|tcPrChange|sectPrChange|cellIns|cellDel|cellMerge|smartTag)\b/;
3854
- var SIMPLE_FIELD_INSTR_RE = /\bw:instr="([^"]*)"/g;
3866
+ var SIMPLE_FIELD_INSTR_RE2 = /\bw:instr="([^"]*)"/g;
3855
3867
  var COMPLEX_FIELD_TOKEN_RE = /<(?:\w+:)?fldChar\b[^>]*?(?:\w+:)?fldCharType="(begin|separate|end)"[^>]*?(?:\/>|>[\s\S]*?<\/(?:\w+:)?fldChar>)|<(?:\w+:)?instrText\b[^>]*>([\s\S]*?)<\/(?:\w+:)?instrText>/gu;
3856
3868
  function decodeXmlEntities2(text) {
3857
3869
  return text.replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&apos;/g, "'").replace(/&amp;/g, "&");
@@ -3892,7 +3904,7 @@ function isSafeTableFieldInstruction(instruction) {
3892
3904
  }
3893
3905
  function tableRequiresOpaquePreservation(rawXml) {
3894
3906
  if (RISKY_TABLE_MARKUP_RE.test(rawXml)) return true;
3895
- const simpleInstructions = [...rawXml.matchAll(SIMPLE_FIELD_INSTR_RE)].map(
3907
+ const simpleInstructions = [...rawXml.matchAll(SIMPLE_FIELD_INSTR_RE2)].map(
3896
3908
  (match) => match[1] ?? ""
3897
3909
  );
3898
3910
  const complexInstructions = extractComplexFieldInstructionsFromRaw(rawXml);
@@ -4572,7 +4584,11 @@ function parseMainDocumentXmlInner(xml, relationships, mediaParts, sourcePartPat
4572
4584
  const documentElement = findChildElement(root, "document");
4573
4585
  const bodyElement = findChildElement(documentElement, "body");
4574
4586
  const relationshipMap = new Map(relationships.map((relationship) => [relationship.id, relationship]));
4575
- const allBlocks = bodyElement.children.filter((node) => node.type === "element").map((node) => parseBodyChild(node, xml, relationshipMap, relationships, mediaParts, sourcePartPath)).filter((block) => !(block.type === "opaque_block" && block.rawXml === ""));
4587
+ const allBlocks = mapElementChildrenWithXmlPath(
4588
+ bodyElement,
4589
+ "/document[1]/body[1]",
4590
+ (node, xmlPath) => parseBodyChild(node, xml, relationshipMap, relationships, mediaParts, sourcePartPath, 0, xmlPath)
4591
+ ).filter((block) => !(block.type === "opaque_block" && block.rawXml === ""));
4576
4592
  let finalSectionProperties;
4577
4593
  const blocks = [];
4578
4594
  for (let i = 0; i < allBlocks.length; i++) {
@@ -4662,22 +4678,25 @@ function parseBlockStreamFromXml(xml, ctx) {
4662
4678
  const priorDepth = activeTxbxBlockStreamDepth;
4663
4679
  activeTxbxBlockStreamDepth = depth;
4664
4680
  try {
4665
- return wrapper.children.filter((n) => n.type === "element").map(
4666
- (n) => parseBodyChild(
4681
+ return mapElementChildrenWithXmlPath(
4682
+ wrapper,
4683
+ `/${localName(wrapper.name)}[1]`,
4684
+ (n, xmlPath) => parseBodyChild(
4667
4685
  n,
4668
4686
  xml,
4669
4687
  relationshipMap,
4670
4688
  ctx.relationships,
4671
4689
  ctx.mediaParts,
4672
4690
  ctx.sourcePartPath,
4673
- depth
4691
+ depth,
4692
+ xmlPath
4674
4693
  )
4675
4694
  );
4676
4695
  } finally {
4677
4696
  activeTxbxBlockStreamDepth = priorDepth;
4678
4697
  }
4679
4698
  }
4680
- function parseBodyChild(node, sourceXml, relationshipMap, relationships, mediaParts, sourcePartPath, _depth = 0) {
4699
+ function parseBodyChild(node, sourceXml, relationshipMap, relationships, mediaParts, sourcePartPath, _depth = 0, sourceXmlPath = `/${localName(node.name)}[1]`) {
4681
4700
  const nodeType = localName(node.name);
4682
4701
  if (nodeType === "tbl") {
4683
4702
  const rawTableXml = sourceXml.slice(node.start, node.end);
@@ -4688,7 +4707,15 @@ function parseBodyChild(node, sourceXml, relationshipMap, relationships, mediaPa
4688
4707
  };
4689
4708
  }
4690
4709
  try {
4691
- return parseTableElement(node, sourceXml, relationshipMap, relationships, mediaParts, sourcePartPath);
4710
+ return parseTableElement(
4711
+ node,
4712
+ sourceXml,
4713
+ relationshipMap,
4714
+ relationships,
4715
+ mediaParts,
4716
+ sourcePartPath,
4717
+ sourceXmlPath
4718
+ );
4692
4719
  } catch {
4693
4720
  return {
4694
4721
  type: "opaque_block",
@@ -4697,10 +4724,26 @@ function parseBodyChild(node, sourceXml, relationshipMap, relationships, mediaPa
4697
4724
  }
4698
4725
  }
4699
4726
  if (nodeType === "sdt") {
4700
- return parseSdtElement(node, sourceXml, relationshipMap, relationships, mediaParts, sourcePartPath);
4727
+ return parseSdtElement(
4728
+ node,
4729
+ sourceXml,
4730
+ relationshipMap,
4731
+ relationships,
4732
+ mediaParts,
4733
+ sourcePartPath,
4734
+ sourceXmlPath
4735
+ );
4701
4736
  }
4702
4737
  if (nodeType === "customXml") {
4703
- return parseCustomXmlElement(node, sourceXml, relationshipMap, relationships, mediaParts, sourcePartPath);
4738
+ return parseCustomXmlElement(
4739
+ node,
4740
+ sourceXml,
4741
+ relationshipMap,
4742
+ relationships,
4743
+ mediaParts,
4744
+ sourcePartPath,
4745
+ sourceXmlPath
4746
+ );
4704
4747
  }
4705
4748
  if (nodeType === "altChunk") {
4706
4749
  return parseAltChunkElement(node, sourceXml);
@@ -4846,6 +4889,7 @@ function parseBodyChild(node, sourceXml, relationshipMap, relationships, mediaPa
4846
4889
  type: "bookmark_start",
4847
4890
  bookmarkId: bkId,
4848
4891
  name: bkName,
4892
+ sourceRef: createElementSourceRef(sourcePartPath, "bookmarkStart", child),
4849
4893
  rawXml: sourceXml.slice(child.start, child.end)
4850
4894
  };
4851
4895
  flushActiveComplexField(children, () => {
@@ -4873,6 +4917,7 @@ function parseBodyChild(node, sourceXml, relationshipMap, relationships, mediaPa
4873
4917
  const bookmarkNode = {
4874
4918
  type: "bookmark_end",
4875
4919
  bookmarkId: bkEndId,
4920
+ sourceRef: createElementSourceRef(sourcePartPath, "bookmarkEnd", child),
4876
4921
  rawXml: sourceXml.slice(child.start, child.end)
4877
4922
  };
4878
4923
  flushActiveComplexField(children, () => {
@@ -5080,7 +5125,7 @@ function flushActiveComplexField(children, reset, activeComplexField) {
5080
5125
  });
5081
5126
  reset();
5082
5127
  }
5083
- function parseTableElement(node, sourceXml, relationshipMap, relationships, mediaParts, sourcePartPath) {
5128
+ function parseTableElement(node, sourceXml, relationshipMap, relationships, mediaParts, sourcePartPath, sourceXmlPath) {
5084
5129
  let styleId;
5085
5130
  let tblLook;
5086
5131
  let propertiesXml;
@@ -5124,13 +5169,24 @@ function parseTableElement(node, sourceXml, relationshipMap, relationships, medi
5124
5169
  break;
5125
5170
  }
5126
5171
  case "tr": {
5127
- rows.push(parseTableRowElement(child, sourceXml, relationshipMap, relationships, mediaParts, sourcePartPath));
5172
+ rows.push(
5173
+ parseTableRowElement(
5174
+ child,
5175
+ sourceXml,
5176
+ relationshipMap,
5177
+ relationships,
5178
+ mediaParts,
5179
+ sourcePartPath,
5180
+ `${sourceXmlPath}/tr[${rows.length + 1}]`
5181
+ )
5182
+ );
5128
5183
  break;
5129
5184
  }
5130
5185
  }
5131
5186
  }
5132
5187
  return {
5133
5188
  type: "table",
5189
+ sourceRef: createStableTableSourceRef(sourcePartPath, "tbl", sourceXmlPath),
5134
5190
  ...styleId ? { styleId } : {},
5135
5191
  ...tblLook ? { tblLook } : {},
5136
5192
  ...propertiesXml ? { propertiesXml } : {},
@@ -5151,7 +5207,7 @@ function parseTableElement(node, sourceXml, relationshipMap, relationships, medi
5151
5207
  rawXml: sourceXml.slice(node.start, node.end)
5152
5208
  };
5153
5209
  }
5154
- function parseTableRowElement(node, sourceXml, relationshipMap, relationships, mediaParts, sourcePartPath) {
5210
+ function parseTableRowElement(node, sourceXml, relationshipMap, relationships, mediaParts, sourcePartPath, sourceXmlPath) {
5155
5211
  let propertiesXml;
5156
5212
  let unknownPropertyChildren;
5157
5213
  let gridBefore;
@@ -5183,12 +5239,23 @@ function parseTableRowElement(node, sourceXml, relationshipMap, relationships, m
5183
5239
  cnfStyle = readRowCnfStyle2(child);
5184
5240
  break;
5185
5241
  case "tc":
5186
- cells.push(parseTableCellElement(child, sourceXml, relationshipMap, relationships, mediaParts, sourcePartPath));
5242
+ cells.push(
5243
+ parseTableCellElement(
5244
+ child,
5245
+ sourceXml,
5246
+ relationshipMap,
5247
+ relationships,
5248
+ mediaParts,
5249
+ sourcePartPath,
5250
+ `${sourceXmlPath}/tc[${cells.length + 1}]`
5251
+ )
5252
+ );
5187
5253
  break;
5188
5254
  }
5189
5255
  }
5190
5256
  return {
5191
5257
  type: "table_row",
5258
+ sourceRef: createStableTableSourceRef(sourcePartPath, "tr", sourceXmlPath),
5192
5259
  ...propertiesXml ? { propertiesXml } : {},
5193
5260
  ...unknownPropertyChildren ? { unknownPropertyChildren } : {},
5194
5261
  ...gridBefore !== void 0 ? { gridBefore } : {},
@@ -5205,7 +5272,7 @@ function parseTableRowElement(node, sourceXml, relationshipMap, relationships, m
5205
5272
  rawXml: sourceXml.slice(node.start, node.end)
5206
5273
  };
5207
5274
  }
5208
- function parseTableCellElement(node, sourceXml, relationshipMap, relationships, mediaParts, sourcePartPath) {
5275
+ function parseTableCellElement(node, sourceXml, relationshipMap, relationships, mediaParts, sourcePartPath, sourceXmlPath) {
5209
5276
  let propertiesXml;
5210
5277
  let unknownPropertyChildren;
5211
5278
  let gridSpan;
@@ -5240,13 +5307,27 @@ function parseTableCellElement(node, sourceXml, relationshipMap, relationships,
5240
5307
  break;
5241
5308
  }
5242
5309
  default: {
5243
- children.push(parseBodyChild(child, sourceXml, relationshipMap, relationships, mediaParts, sourcePartPath));
5310
+ children.push(
5311
+ parseBodyChild(
5312
+ child,
5313
+ sourceXml,
5314
+ relationshipMap,
5315
+ relationships,
5316
+ mediaParts,
5317
+ sourcePartPath,
5318
+ 0,
5319
+ `${sourceXmlPath}/${localName(child.name)}[${countPriorElementSiblingsByName(node, child) + 1}]`
5320
+ )
5321
+ );
5244
5322
  break;
5245
5323
  }
5246
5324
  }
5247
5325
  }
5248
5326
  return {
5249
5327
  type: "table_cell",
5328
+ sourceRef: createStableTableSourceRef(sourcePartPath, "tc", sourceXmlPath, {
5329
+ tableCellPath: sourceXmlPath
5330
+ }),
5250
5331
  ...propertiesXml ? { propertiesXml } : {},
5251
5332
  ...unknownPropertyChildren ? { unknownPropertyChildren } : {},
5252
5333
  ...gridSpan ? { gridSpan } : {},
@@ -5264,7 +5345,7 @@ function parseTableCellElement(node, sourceXml, relationshipMap, relationships,
5264
5345
  rawXml: sourceXml.slice(node.start, node.end)
5265
5346
  };
5266
5347
  }
5267
- function parseSdtElement(node, sourceXml, relationshipMap, relationships, mediaParts, sourcePartPath) {
5348
+ function parseSdtElement(node, sourceXml, relationshipMap, relationships, mediaParts, sourcePartPath, sourceXmlPath) {
5268
5349
  const propertiesNode = node.children.find(
5269
5350
  (child) => child.type === "element" && localName(child.name) === "sdtPr"
5270
5351
  );
@@ -5277,7 +5358,20 @@ function parseSdtElement(node, sourceXml, relationshipMap, relationships, mediaP
5277
5358
  rawXml: sourceXml.slice(node.start, node.end)
5278
5359
  };
5279
5360
  }
5280
- const children = contentNode.children.filter((child) => child.type === "element").map((child) => parseBodyChild(child, sourceXml, relationshipMap, relationships, mediaParts, sourcePartPath));
5361
+ const children = mapElementChildrenWithXmlPath(
5362
+ contentNode,
5363
+ `${sourceXmlPath}/sdtContent[1]`,
5364
+ (child, childXmlPath) => parseBodyChild(
5365
+ child,
5366
+ sourceXml,
5367
+ relationshipMap,
5368
+ relationships,
5369
+ mediaParts,
5370
+ sourcePartPath,
5371
+ 0,
5372
+ childXmlPath
5373
+ )
5374
+ );
5281
5375
  return {
5282
5376
  type: "sdt",
5283
5377
  sourceRef: createElementSourceRef(sourcePartPath, "sdt", node),
@@ -5286,7 +5380,7 @@ function parseSdtElement(node, sourceXml, relationshipMap, relationships, mediaP
5286
5380
  rawXml: sourceXml.slice(node.start, node.end)
5287
5381
  };
5288
5382
  }
5289
- function parseCustomXmlElement(node, sourceXml, relationshipMap, relationships, mediaParts, sourcePartPath) {
5383
+ function parseCustomXmlElement(node, sourceXml, relationshipMap, relationships, mediaParts, sourcePartPath, sourceXmlPath) {
5290
5384
  const uri = readOptionalAttribute2(node, "uri");
5291
5385
  const element = readOptionalAttribute2(node, "element");
5292
5386
  if (!uri && !element) {
@@ -5295,9 +5389,20 @@ function parseCustomXmlElement(node, sourceXml, relationshipMap, relationships,
5295
5389
  rawXml: sourceXml.slice(node.start, node.end)
5296
5390
  };
5297
5391
  }
5298
- const children = node.children.filter(
5299
- (child) => child.type === "element" && localName(child.name) !== "customXmlPr"
5300
- ).map((child) => parseBodyChild(child, sourceXml, relationshipMap, relationships, mediaParts, sourcePartPath));
5392
+ const children = mapElementChildrenWithXmlPath(
5393
+ node,
5394
+ sourceXmlPath,
5395
+ (child, childXmlPath) => localName(child.name) === "customXmlPr" ? void 0 : parseBodyChild(
5396
+ child,
5397
+ sourceXml,
5398
+ relationshipMap,
5399
+ relationships,
5400
+ mediaParts,
5401
+ sourcePartPath,
5402
+ 0,
5403
+ childXmlPath
5404
+ )
5405
+ ).filter((child) => child !== void 0);
5301
5406
  return {
5302
5407
  type: "custom_xml",
5303
5408
  ...uri ? { uri } : {},
@@ -5829,6 +5934,43 @@ function createElementSourceRef(partPath, element, node) {
5829
5934
  endOffset: node.end
5830
5935
  };
5831
5936
  }
5937
+ function createStableTableSourceRef(partPath, element, xmlPath, extras = {}) {
5938
+ return {
5939
+ sourceId: `part:${partPath}#${xmlPath}`,
5940
+ partPath,
5941
+ storyKind: storyKindFromPartPath(partPath),
5942
+ element,
5943
+ xmlPath,
5944
+ ...extras
5945
+ };
5946
+ }
5947
+ function mapElementChildrenWithXmlPath(parent, parentXmlPath, mapChild) {
5948
+ const ordinals = /* @__PURE__ */ new Map();
5949
+ const mapped = [];
5950
+ for (const child of parent.children) {
5951
+ if (child.type !== "element") {
5952
+ continue;
5953
+ }
5954
+ const name = localName(child.name);
5955
+ const ordinal = (ordinals.get(name) ?? 0) + 1;
5956
+ ordinals.set(name, ordinal);
5957
+ mapped.push(mapChild(child, `${parentXmlPath}/${name}[${ordinal}]`));
5958
+ }
5959
+ return mapped;
5960
+ }
5961
+ function countPriorElementSiblingsByName(parent, target) {
5962
+ const name = localName(target.name);
5963
+ let count = 0;
5964
+ for (const child of parent.children) {
5965
+ if (child === target) {
5966
+ return count;
5967
+ }
5968
+ if (child.type === "element" && localName(child.name) === name) {
5969
+ count += 1;
5970
+ }
5971
+ }
5972
+ return count;
5973
+ }
5832
5974
  function createFieldSequenceSourceRef(partPath, node) {
5833
5975
  activeFieldSequenceOrdinal += 1;
5834
5976
  return {
@@ -5930,7 +6072,10 @@ function parseRun(node, sourceXml, relationships, mediaParts, sourcePartPath) {
5930
6072
  })
5931
6073
  });
5932
6074
  if (frame) {
5933
- result.push(frame);
6075
+ result.push({
6076
+ ...frame,
6077
+ sourceRef: createElementSourceRef(sourcePartPath, "drawing", child)
6078
+ });
5934
6079
  break;
5935
6080
  }
5936
6081
  } catch {
@@ -5979,6 +6124,7 @@ function parseRun(node, sourceXml, relationships, mediaParts, sourcePartPath) {
5979
6124
  ...parsedMedia.map((media) => ({
5980
6125
  type: "image",
5981
6126
  mediaId: media.mediaId,
6127
+ sourceRef: createElementSourceRef(sourcePartPath, "drawing", child),
5982
6128
  relationshipId: media.relationshipId,
5983
6129
  packagePartName: media.packagePartName,
5984
6130
  contentType: media.contentType,
@@ -6009,7 +6155,10 @@ function parseRun(node, sourceXml, relationships, mediaParts, sourcePartPath) {
6009
6155
  })
6010
6156
  });
6011
6157
  if (frame) {
6012
- result.push(frame);
6158
+ result.push({
6159
+ ...frame,
6160
+ sourceRef: createElementSourceRef(sourcePartPath, "AlternateContent", child)
6161
+ });
6013
6162
  break;
6014
6163
  }
6015
6164
  } catch {
@@ -6046,7 +6195,10 @@ function parseRun(node, sourceXml, relationships, mediaParts, sourcePartPath) {
6046
6195
  try {
6047
6196
  const oleNode = parseObject(child, objectXml, relationships);
6048
6197
  if (oleNode) {
6049
- result.push(oleNode);
6198
+ result.push({
6199
+ ...oleNode,
6200
+ sourceRef: createElementSourceRef(sourcePartPath, "object", child)
6201
+ });
6050
6202
  break;
6051
6203
  }
6052
6204
  } catch {
package/dist/legal.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { C as CanonicalDocument, e as DocumentNode } from './canonical-document-fNawStsc.cjs';
1
+ import { C as CanonicalDocument, e as DocumentNode } from './canonical-document-ByIqTd4s.cjs';
2
2
 
3
3
  interface LegalBookmark {
4
4
  bookmarkId: string;
package/dist/legal.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { C as CanonicalDocument, e as DocumentNode } from './canonical-document-fNawStsc.js';
1
+ import { C as CanonicalDocument, e as DocumentNode } from './canonical-document-ByIqTd4s.js';
2
2
 
3
3
  interface LegalBookmark {
4
4
  bookmarkId: string;
package/dist/legal.js CHANGED
@@ -4,13 +4,13 @@ import {
4
4
  isHiddenBookmarkName,
5
5
  parseBookmarksFromDocumentXml,
6
6
  resolveWalkableRoot
7
- } from "./chunk-2ZWFQ74R.js";
7
+ } from "./chunk-OBCP6VTG.js";
8
8
  import {
9
9
  extractComplexFieldsFromBodyXml,
10
10
  parseFieldsFromParagraphXml,
11
11
  parseMainDocumentXml
12
- } from "./chunk-NQZUGMLW.js";
13
- import "./chunk-AQA7OZ2R.js";
12
+ } from "./chunk-TMU7JMXX.js";
13
+ import "./chunk-TFSXOIAI.js";
14
14
  import "./chunk-IHE7YOAY.js";
15
15
  import "./chunk-UTL65BUI.js";
16
16
  import "./chunk-DNXYUIIS.js";
@@ -1,6 +1,6 @@
1
- import { C as CanonicalDocument } from './canonical-document-fNawStsc.js';
2
- import { ar as EditorStateNamespace, as as EditorStateLocation, a as EditorSessionState, P as PersistedEditorSnapshot, r as EditorError, t as ProtectionSnapshot, b as ExportDocxOptions, c as ExportResult, L as LoadStage, E as EditorHostAdapter, at as LoadScheduler, o as EditorSurfaceSnapshot } from './public-types-C948HNVF.js';
3
- import { E as EmbeddedDocumentManifest, e as ProgressiveSurfaceProjector } from './types-B1tlF1bq.js';
1
+ import { C as CanonicalDocument } from './canonical-document-ByIqTd4s.js';
2
+ import { ar as EditorStateNamespace, as as EditorStateLocation, a as EditorSessionState, P as PersistedEditorSnapshot, r as EditorError, t as ProtectionSnapshot, b as ExportDocxOptions, c as ExportResult, L as LoadStage, E as EditorHostAdapter, at as LoadScheduler, o as EditorSurfaceSnapshot } from './public-types-Dl1jiWjk.js';
3
+ import { E as EmbeddedDocumentManifest, e as ProgressiveSurfaceProjector } from './types-DEvRwq9C.js';
4
4
 
5
5
  interface EditorStatePayloadNamespaceEntry {
6
6
  namespace: EditorStateNamespace;
@@ -271,5 +271,23 @@ interface LoadedDocxEditorSession {
271
271
  * `src/session/export/stateful-export.ts` and is imported directly.
272
272
  */
273
273
  declare function loadDocxSessionAsync(options: LoadDocxEditorSessionAsyncOptions): Promise<LoadedDocxEditorSession>;
274
+ /**
275
+ * Session-layer owner of the sync load path.
276
+ *
277
+ * Slice 5e-7.e.2 relocates the body of `loadDocxEditorSession` from
278
+ * `src/io/docx-session.ts` into this module. Body mirrors
279
+ * `loadDocxSessionAsync` minus the async-only orchestration shell:
280
+ * - No `scheduler.yield()` calls (sync execution).
281
+ * - No laycache short-circuit branch (`laycacheEnvelope` is not on
282
+ * `LoadDocxEditorSessionOptions`).
283
+ * - No progressive-snapshot branch (`onProgressiveSnapshot` /
284
+ * `surfaceProjector` not on `LoadDocxEditorSessionOptions`).
285
+ * - Uses `normalizeParsedTextDocument` (sync).
286
+ *
287
+ * Byte-equivalence with the async path is asserted by
288
+ * `test/io/fastload-parity.test.ts` on every F*.docx fixture. Drift
289
+ * between the two sync/async bodies will fail that test.
290
+ */
291
+ declare function loadDocxSessionSync(options: LoadDocxEditorSessionOptions): LoadedDocxEditorSession;
274
292
 
275
- export { type LoadedDocxEditorSession as L, type LoadDocxEditorSessionAsyncOptions as a, type LoadDocxEditorSessionOptions as b, loadDocxSessionAsync as l };
293
+ export { type LoadedDocxEditorSession as L, loadDocxSessionSync as a, type LoadDocxEditorSessionAsyncOptions as b, type LoadDocxEditorSessionOptions as c, loadDocxSessionAsync as l };
@@ -1,6 +1,6 @@
1
- import { C as CanonicalDocument } from './canonical-document-fNawStsc.cjs';
2
- import { ar as EditorStateNamespace, as as EditorStateLocation, a as EditorSessionState, P as PersistedEditorSnapshot, r as EditorError, t as ProtectionSnapshot, b as ExportDocxOptions, c as ExportResult, L as LoadStage, E as EditorHostAdapter, at as LoadScheduler, o as EditorSurfaceSnapshot } from './public-types-Dpch9JG0.cjs';
3
- import { E as EmbeddedDocumentManifest, e as ProgressiveSurfaceProjector } from './types-C9vZVpKy.cjs';
1
+ import { C as CanonicalDocument } from './canonical-document-ByIqTd4s.cjs';
2
+ import { ar as EditorStateNamespace, as as EditorStateLocation, a as EditorSessionState, P as PersistedEditorSnapshot, r as EditorError, t as ProtectionSnapshot, b as ExportDocxOptions, c as ExportResult, L as LoadStage, E as EditorHostAdapter, at as LoadScheduler, o as EditorSurfaceSnapshot } from './public-types-D_y4Ptcj.cjs';
3
+ import { E as EmbeddedDocumentManifest, e as ProgressiveSurfaceProjector } from './types-BoSRp2Vg.cjs';
4
4
 
5
5
  interface EditorStatePayloadNamespaceEntry {
6
6
  namespace: EditorStateNamespace;
@@ -271,5 +271,23 @@ interface LoadedDocxEditorSession {
271
271
  * `src/session/export/stateful-export.ts` and is imported directly.
272
272
  */
273
273
  declare function loadDocxSessionAsync(options: LoadDocxEditorSessionAsyncOptions): Promise<LoadedDocxEditorSession>;
274
+ /**
275
+ * Session-layer owner of the sync load path.
276
+ *
277
+ * Slice 5e-7.e.2 relocates the body of `loadDocxEditorSession` from
278
+ * `src/io/docx-session.ts` into this module. Body mirrors
279
+ * `loadDocxSessionAsync` minus the async-only orchestration shell:
280
+ * - No `scheduler.yield()` calls (sync execution).
281
+ * - No laycache short-circuit branch (`laycacheEnvelope` is not on
282
+ * `LoadDocxEditorSessionOptions`).
283
+ * - No progressive-snapshot branch (`onProgressiveSnapshot` /
284
+ * `surfaceProjector` not on `LoadDocxEditorSessionOptions`).
285
+ * - Uses `normalizeParsedTextDocument` (sync).
286
+ *
287
+ * Byte-equivalence with the async path is asserted by
288
+ * `test/io/fastload-parity.test.ts` on every F*.docx fixture. Drift
289
+ * between the two sync/async bodies will fail that test.
290
+ */
291
+ declare function loadDocxSessionSync(options: LoadDocxEditorSessionOptions): LoadedDocxEditorSession;
274
292
 
275
- export { type LoadedDocxEditorSession as L, type LoadDocxEditorSessionAsyncOptions as a, type LoadDocxEditorSessionOptions as b, loadDocxSessionAsync as l };
293
+ export { type LoadedDocxEditorSession as L, loadDocxSessionSync as a, type LoadDocxEditorSessionAsyncOptions as b, type LoadDocxEditorSessionOptions as c, loadDocxSessionAsync as l };