@beyondwork/docx-react-component 1.0.120 → 1.0.121

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
@@ -6,7 +6,7 @@ import {
6
6
  createHeaderFooterStoryKey,
7
7
  createNoteStoryKey,
8
8
  sha256TextHex
9
- } from "./chunk-AQA7OZ2R.js";
9
+ } from "./chunk-TFSXOIAI.js";
10
10
  import {
11
11
  SCOPE_MARKER_BOOKMARK_PREFIX,
12
12
  buildGrabBagSourceChildFromParsed,
@@ -1487,6 +1487,7 @@ function parseInteger(value) {
1487
1487
  // src/io/ooxml/parse-bookmark-references.ts
1488
1488
  var HYPERLINK_ANCHOR_RE = /<(?:\w+:)?hyperlink\b[^>]*\bw:anchor\s*=\s*"([^"]*)"/gi;
1489
1489
  var INSTR_TEXT_RE = /<(?:\w+:)?instrText\b[^>]*>([\s\S]*?)<\/(?:\w+:)?instrText>/gi;
1490
+ var SIMPLE_FIELD_INSTR_RE = /<(?:\w+:)?fldSimple\b[^>]*\bw:instr\s*=\s*"([^"]*)"/gi;
1490
1491
  var TOC_FIELD_RE = /\bTOC\b/;
1491
1492
  var REFLIKE_FIELD_RE = /\b(?:HYPERLINK|REF|PAGEREF|NOTEREF)\s+([A-Za-z0-9_:.\-]+)/g;
1492
1493
  var DATA_BINDING_RE = /<(?:\w+:)?dataBinding\b/i;
@@ -1505,12 +1506,14 @@ function scanBookmarkReferences(documentXml, callerAllowlist = []) {
1505
1506
  }
1506
1507
  INSTR_TEXT_RE.lastIndex = 0;
1507
1508
  while ((m = INSTR_TEXT_RE.exec(documentXml)) !== null) {
1508
- const instrText = m[1] ?? "";
1509
- if (TOC_FIELD_RE.test(instrText)) retainAllToc = true;
1510
- REFLIKE_FIELD_RE.lastIndex = 0;
1511
- let r;
1512
- while ((r = REFLIKE_FIELD_RE.exec(instrText)) !== null) {
1513
- if (r[1]) retained.add(r[1]);
1509
+ if (scanInstructionForRetainedBookmarks(m[1] ?? "", retained)) {
1510
+ retainAllToc = true;
1511
+ }
1512
+ }
1513
+ SIMPLE_FIELD_INSTR_RE.lastIndex = 0;
1514
+ while ((m = SIMPLE_FIELD_INSTR_RE.exec(documentXml)) !== null) {
1515
+ if (scanInstructionForRetainedBookmarks(m[1] ?? "", retained)) {
1516
+ retainAllToc = true;
1514
1517
  }
1515
1518
  }
1516
1519
  retainRevisionBoundedBookmarks(documentXml, retained);
@@ -1520,6 +1523,15 @@ function scanBookmarkReferences(documentXml, callerAllowlist = []) {
1520
1523
  retainAll
1521
1524
  };
1522
1525
  }
1526
+ function scanInstructionForRetainedBookmarks(instruction, retained) {
1527
+ const hasTocField = TOC_FIELD_RE.test(instruction);
1528
+ REFLIKE_FIELD_RE.lastIndex = 0;
1529
+ let r;
1530
+ while ((r = REFLIKE_FIELD_RE.exec(instruction)) !== null) {
1531
+ if (r[1]) retained.add(r[1]);
1532
+ }
1533
+ return hasTocField;
1534
+ }
1523
1535
  function retainRevisionBoundedBookmarks(documentXml, retained) {
1524
1536
  const starts = /* @__PURE__ */ new Map();
1525
1537
  BOOKMARK_START_RE.lastIndex = 0;
@@ -4416,7 +4428,7 @@ var SAFE_TABLE_FIELD_FAMILIES = /* @__PURE__ */ new Set([
4416
4428
  "FORMULA"
4417
4429
  ]);
4418
4430
  var RISKY_TABLE_MARKUP_RE = /<w:(ins|del|moveFrom|moveTo|rPrChange|pPrChange|tblPrChange|trPrChange|tcPrChange|sectPrChange|cellIns|cellDel|cellMerge|smartTag)\b/;
4419
- var SIMPLE_FIELD_INSTR_RE = /\bw:instr="([^"]*)"/g;
4431
+ var SIMPLE_FIELD_INSTR_RE2 = /\bw:instr="([^"]*)"/g;
4420
4432
  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;
4421
4433
  function decodeXmlEntities(text) {
4422
4434
  return text.replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&apos;/g, "'").replace(/&amp;/g, "&");
@@ -4457,7 +4469,7 @@ function isSafeTableFieldInstruction(instruction) {
4457
4469
  }
4458
4470
  function tableRequiresOpaquePreservation(rawXml) {
4459
4471
  if (RISKY_TABLE_MARKUP_RE.test(rawXml)) return true;
4460
- const simpleInstructions = [...rawXml.matchAll(SIMPLE_FIELD_INSTR_RE)].map(
4472
+ const simpleInstructions = [...rawXml.matchAll(SIMPLE_FIELD_INSTR_RE2)].map(
4461
4473
  (match) => match[1] ?? ""
4462
4474
  );
4463
4475
  const complexInstructions = extractComplexFieldInstructionsFromRaw(rawXml);
@@ -5140,7 +5152,11 @@ function parseMainDocumentXmlInner(xml, relationships, mediaParts, sourcePartPat
5140
5152
  const documentElement = findChildElement2(root, "document");
5141
5153
  const bodyElement = findChildElement2(documentElement, "body");
5142
5154
  const relationshipMap = new Map(relationships.map((relationship) => [relationship.id, relationship]));
5143
- 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 === ""));
5155
+ const allBlocks = mapElementChildrenWithXmlPath(
5156
+ bodyElement,
5157
+ "/document[1]/body[1]",
5158
+ (node, xmlPath) => parseBodyChild(node, xml, relationshipMap, relationships, mediaParts, sourcePartPath, 0, xmlPath)
5159
+ ).filter((block) => !(block.type === "opaque_block" && block.rawXml === ""));
5144
5160
  let finalSectionProperties;
5145
5161
  const blocks = [];
5146
5162
  for (let i = 0; i < allBlocks.length; i++) {
@@ -5230,22 +5246,25 @@ function parseBlockStreamFromXml(xml, ctx) {
5230
5246
  const priorDepth = activeTxbxBlockStreamDepth;
5231
5247
  activeTxbxBlockStreamDepth = depth;
5232
5248
  try {
5233
- return wrapper.children.filter((n) => n.type === "element").map(
5234
- (n) => parseBodyChild(
5249
+ return mapElementChildrenWithXmlPath(
5250
+ wrapper,
5251
+ `/${localName(wrapper.name)}[1]`,
5252
+ (n, xmlPath) => parseBodyChild(
5235
5253
  n,
5236
5254
  xml,
5237
5255
  relationshipMap,
5238
5256
  ctx.relationships,
5239
5257
  ctx.mediaParts,
5240
5258
  ctx.sourcePartPath,
5241
- depth
5259
+ depth,
5260
+ xmlPath
5242
5261
  )
5243
5262
  );
5244
5263
  } finally {
5245
5264
  activeTxbxBlockStreamDepth = priorDepth;
5246
5265
  }
5247
5266
  }
5248
- function parseBodyChild(node, sourceXml, relationshipMap, relationships, mediaParts, sourcePartPath, _depth = 0) {
5267
+ function parseBodyChild(node, sourceXml, relationshipMap, relationships, mediaParts, sourcePartPath, _depth = 0, sourceXmlPath = `/${localName(node.name)}[1]`) {
5249
5268
  const nodeType = localName(node.name);
5250
5269
  if (nodeType === "tbl") {
5251
5270
  const rawTableXml = sourceXml.slice(node.start, node.end);
@@ -5256,7 +5275,15 @@ function parseBodyChild(node, sourceXml, relationshipMap, relationships, mediaPa
5256
5275
  };
5257
5276
  }
5258
5277
  try {
5259
- return parseTableElement(node, sourceXml, relationshipMap, relationships, mediaParts, sourcePartPath);
5278
+ return parseTableElement(
5279
+ node,
5280
+ sourceXml,
5281
+ relationshipMap,
5282
+ relationships,
5283
+ mediaParts,
5284
+ sourcePartPath,
5285
+ sourceXmlPath
5286
+ );
5260
5287
  } catch {
5261
5288
  return {
5262
5289
  type: "opaque_block",
@@ -5265,10 +5292,26 @@ function parseBodyChild(node, sourceXml, relationshipMap, relationships, mediaPa
5265
5292
  }
5266
5293
  }
5267
5294
  if (nodeType === "sdt") {
5268
- return parseSdtElement(node, sourceXml, relationshipMap, relationships, mediaParts, sourcePartPath);
5295
+ return parseSdtElement(
5296
+ node,
5297
+ sourceXml,
5298
+ relationshipMap,
5299
+ relationships,
5300
+ mediaParts,
5301
+ sourcePartPath,
5302
+ sourceXmlPath
5303
+ );
5269
5304
  }
5270
5305
  if (nodeType === "customXml") {
5271
- return parseCustomXmlElement(node, sourceXml, relationshipMap, relationships, mediaParts, sourcePartPath);
5306
+ return parseCustomXmlElement(
5307
+ node,
5308
+ sourceXml,
5309
+ relationshipMap,
5310
+ relationships,
5311
+ mediaParts,
5312
+ sourcePartPath,
5313
+ sourceXmlPath
5314
+ );
5272
5315
  }
5273
5316
  if (nodeType === "altChunk") {
5274
5317
  return parseAltChunkElement(node, sourceXml);
@@ -5414,6 +5457,7 @@ function parseBodyChild(node, sourceXml, relationshipMap, relationships, mediaPa
5414
5457
  type: "bookmark_start",
5415
5458
  bookmarkId: bkId,
5416
5459
  name: bkName,
5460
+ sourceRef: createElementSourceRef(sourcePartPath, "bookmarkStart", child),
5417
5461
  rawXml: sourceXml.slice(child.start, child.end)
5418
5462
  };
5419
5463
  flushActiveComplexField(children, () => {
@@ -5441,6 +5485,7 @@ function parseBodyChild(node, sourceXml, relationshipMap, relationships, mediaPa
5441
5485
  const bookmarkNode = {
5442
5486
  type: "bookmark_end",
5443
5487
  bookmarkId: bkEndId,
5488
+ sourceRef: createElementSourceRef(sourcePartPath, "bookmarkEnd", child),
5444
5489
  rawXml: sourceXml.slice(child.start, child.end)
5445
5490
  };
5446
5491
  flushActiveComplexField(children, () => {
@@ -5648,7 +5693,7 @@ function flushActiveComplexField(children, reset, activeComplexField) {
5648
5693
  });
5649
5694
  reset();
5650
5695
  }
5651
- function parseTableElement(node, sourceXml, relationshipMap, relationships, mediaParts, sourcePartPath) {
5696
+ function parseTableElement(node, sourceXml, relationshipMap, relationships, mediaParts, sourcePartPath, sourceXmlPath) {
5652
5697
  let styleId;
5653
5698
  let tblLook;
5654
5699
  let propertiesXml;
@@ -5692,13 +5737,24 @@ function parseTableElement(node, sourceXml, relationshipMap, relationships, medi
5692
5737
  break;
5693
5738
  }
5694
5739
  case "tr": {
5695
- rows.push(parseTableRowElement(child, sourceXml, relationshipMap, relationships, mediaParts, sourcePartPath));
5740
+ rows.push(
5741
+ parseTableRowElement(
5742
+ child,
5743
+ sourceXml,
5744
+ relationshipMap,
5745
+ relationships,
5746
+ mediaParts,
5747
+ sourcePartPath,
5748
+ `${sourceXmlPath}/tr[${rows.length + 1}]`
5749
+ )
5750
+ );
5696
5751
  break;
5697
5752
  }
5698
5753
  }
5699
5754
  }
5700
5755
  return {
5701
5756
  type: "table",
5757
+ sourceRef: createStableTableSourceRef(sourcePartPath, "tbl", sourceXmlPath),
5702
5758
  ...styleId ? { styleId } : {},
5703
5759
  ...tblLook ? { tblLook } : {},
5704
5760
  ...propertiesXml ? { propertiesXml } : {},
@@ -5719,7 +5775,7 @@ function parseTableElement(node, sourceXml, relationshipMap, relationships, medi
5719
5775
  rawXml: sourceXml.slice(node.start, node.end)
5720
5776
  };
5721
5777
  }
5722
- function parseTableRowElement(node, sourceXml, relationshipMap, relationships, mediaParts, sourcePartPath) {
5778
+ function parseTableRowElement(node, sourceXml, relationshipMap, relationships, mediaParts, sourcePartPath, sourceXmlPath) {
5723
5779
  let propertiesXml;
5724
5780
  let unknownPropertyChildren;
5725
5781
  let gridBefore;
@@ -5751,12 +5807,23 @@ function parseTableRowElement(node, sourceXml, relationshipMap, relationships, m
5751
5807
  cnfStyle = readRowCnfStyle2(child);
5752
5808
  break;
5753
5809
  case "tc":
5754
- cells.push(parseTableCellElement(child, sourceXml, relationshipMap, relationships, mediaParts, sourcePartPath));
5810
+ cells.push(
5811
+ parseTableCellElement(
5812
+ child,
5813
+ sourceXml,
5814
+ relationshipMap,
5815
+ relationships,
5816
+ mediaParts,
5817
+ sourcePartPath,
5818
+ `${sourceXmlPath}/tc[${cells.length + 1}]`
5819
+ )
5820
+ );
5755
5821
  break;
5756
5822
  }
5757
5823
  }
5758
5824
  return {
5759
5825
  type: "table_row",
5826
+ sourceRef: createStableTableSourceRef(sourcePartPath, "tr", sourceXmlPath),
5760
5827
  ...propertiesXml ? { propertiesXml } : {},
5761
5828
  ...unknownPropertyChildren ? { unknownPropertyChildren } : {},
5762
5829
  ...gridBefore !== void 0 ? { gridBefore } : {},
@@ -5773,7 +5840,7 @@ function parseTableRowElement(node, sourceXml, relationshipMap, relationships, m
5773
5840
  rawXml: sourceXml.slice(node.start, node.end)
5774
5841
  };
5775
5842
  }
5776
- function parseTableCellElement(node, sourceXml, relationshipMap, relationships, mediaParts, sourcePartPath) {
5843
+ function parseTableCellElement(node, sourceXml, relationshipMap, relationships, mediaParts, sourcePartPath, sourceXmlPath) {
5777
5844
  let propertiesXml;
5778
5845
  let unknownPropertyChildren;
5779
5846
  let gridSpan;
@@ -5808,13 +5875,27 @@ function parseTableCellElement(node, sourceXml, relationshipMap, relationships,
5808
5875
  break;
5809
5876
  }
5810
5877
  default: {
5811
- children.push(parseBodyChild(child, sourceXml, relationshipMap, relationships, mediaParts, sourcePartPath));
5878
+ children.push(
5879
+ parseBodyChild(
5880
+ child,
5881
+ sourceXml,
5882
+ relationshipMap,
5883
+ relationships,
5884
+ mediaParts,
5885
+ sourcePartPath,
5886
+ 0,
5887
+ `${sourceXmlPath}/${localName(child.name)}[${countPriorElementSiblingsByName(node, child) + 1}]`
5888
+ )
5889
+ );
5812
5890
  break;
5813
5891
  }
5814
5892
  }
5815
5893
  }
5816
5894
  return {
5817
5895
  type: "table_cell",
5896
+ sourceRef: createStableTableSourceRef(sourcePartPath, "tc", sourceXmlPath, {
5897
+ tableCellPath: sourceXmlPath
5898
+ }),
5818
5899
  ...propertiesXml ? { propertiesXml } : {},
5819
5900
  ...unknownPropertyChildren ? { unknownPropertyChildren } : {},
5820
5901
  ...gridSpan ? { gridSpan } : {},
@@ -5832,7 +5913,7 @@ function parseTableCellElement(node, sourceXml, relationshipMap, relationships,
5832
5913
  rawXml: sourceXml.slice(node.start, node.end)
5833
5914
  };
5834
5915
  }
5835
- function parseSdtElement(node, sourceXml, relationshipMap, relationships, mediaParts, sourcePartPath) {
5916
+ function parseSdtElement(node, sourceXml, relationshipMap, relationships, mediaParts, sourcePartPath, sourceXmlPath) {
5836
5917
  const propertiesNode = node.children.find(
5837
5918
  (child) => child.type === "element" && localName(child.name) === "sdtPr"
5838
5919
  );
@@ -5845,7 +5926,20 @@ function parseSdtElement(node, sourceXml, relationshipMap, relationships, mediaP
5845
5926
  rawXml: sourceXml.slice(node.start, node.end)
5846
5927
  };
5847
5928
  }
5848
- const children = contentNode.children.filter((child) => child.type === "element").map((child) => parseBodyChild(child, sourceXml, relationshipMap, relationships, mediaParts, sourcePartPath));
5929
+ const children = mapElementChildrenWithXmlPath(
5930
+ contentNode,
5931
+ `${sourceXmlPath}/sdtContent[1]`,
5932
+ (child, childXmlPath) => parseBodyChild(
5933
+ child,
5934
+ sourceXml,
5935
+ relationshipMap,
5936
+ relationships,
5937
+ mediaParts,
5938
+ sourcePartPath,
5939
+ 0,
5940
+ childXmlPath
5941
+ )
5942
+ );
5849
5943
  return {
5850
5944
  type: "sdt",
5851
5945
  sourceRef: createElementSourceRef(sourcePartPath, "sdt", node),
@@ -5854,7 +5948,7 @@ function parseSdtElement(node, sourceXml, relationshipMap, relationships, mediaP
5854
5948
  rawXml: sourceXml.slice(node.start, node.end)
5855
5949
  };
5856
5950
  }
5857
- function parseCustomXmlElement(node, sourceXml, relationshipMap, relationships, mediaParts, sourcePartPath) {
5951
+ function parseCustomXmlElement(node, sourceXml, relationshipMap, relationships, mediaParts, sourcePartPath, sourceXmlPath) {
5858
5952
  const uri = readOptionalAttribute2(node, "uri");
5859
5953
  const element = readOptionalAttribute2(node, "element");
5860
5954
  if (!uri && !element) {
@@ -5863,9 +5957,20 @@ function parseCustomXmlElement(node, sourceXml, relationshipMap, relationships,
5863
5957
  rawXml: sourceXml.slice(node.start, node.end)
5864
5958
  };
5865
5959
  }
5866
- const children = node.children.filter(
5867
- (child) => child.type === "element" && localName(child.name) !== "customXmlPr"
5868
- ).map((child) => parseBodyChild(child, sourceXml, relationshipMap, relationships, mediaParts, sourcePartPath));
5960
+ const children = mapElementChildrenWithXmlPath(
5961
+ node,
5962
+ sourceXmlPath,
5963
+ (child, childXmlPath) => localName(child.name) === "customXmlPr" ? void 0 : parseBodyChild(
5964
+ child,
5965
+ sourceXml,
5966
+ relationshipMap,
5967
+ relationships,
5968
+ mediaParts,
5969
+ sourcePartPath,
5970
+ 0,
5971
+ childXmlPath
5972
+ )
5973
+ ).filter((child) => child !== void 0);
5869
5974
  return {
5870
5975
  type: "custom_xml",
5871
5976
  ...uri ? { uri } : {},
@@ -6397,6 +6502,43 @@ function createElementSourceRef(partPath, element, node) {
6397
6502
  endOffset: node.end
6398
6503
  };
6399
6504
  }
6505
+ function createStableTableSourceRef(partPath, element, xmlPath, extras = {}) {
6506
+ return {
6507
+ sourceId: `part:${partPath}#${xmlPath}`,
6508
+ partPath,
6509
+ storyKind: storyKindFromPartPath(partPath),
6510
+ element,
6511
+ xmlPath,
6512
+ ...extras
6513
+ };
6514
+ }
6515
+ function mapElementChildrenWithXmlPath(parent, parentXmlPath, mapChild) {
6516
+ const ordinals = /* @__PURE__ */ new Map();
6517
+ const mapped = [];
6518
+ for (const child of parent.children) {
6519
+ if (child.type !== "element") {
6520
+ continue;
6521
+ }
6522
+ const name = localName(child.name);
6523
+ const ordinal = (ordinals.get(name) ?? 0) + 1;
6524
+ ordinals.set(name, ordinal);
6525
+ mapped.push(mapChild(child, `${parentXmlPath}/${name}[${ordinal}]`));
6526
+ }
6527
+ return mapped;
6528
+ }
6529
+ function countPriorElementSiblingsByName(parent, target) {
6530
+ const name = localName(target.name);
6531
+ let count = 0;
6532
+ for (const child of parent.children) {
6533
+ if (child === target) {
6534
+ return count;
6535
+ }
6536
+ if (child.type === "element" && localName(child.name) === name) {
6537
+ count += 1;
6538
+ }
6539
+ }
6540
+ return count;
6541
+ }
6400
6542
  function createFieldSequenceSourceRef(partPath, node) {
6401
6543
  activeFieldSequenceOrdinal += 1;
6402
6544
  return {
@@ -6498,7 +6640,10 @@ function parseRun(node, sourceXml, relationships, mediaParts, sourcePartPath) {
6498
6640
  })
6499
6641
  });
6500
6642
  if (frame) {
6501
- result.push(frame);
6643
+ result.push({
6644
+ ...frame,
6645
+ sourceRef: createElementSourceRef(sourcePartPath, "drawing", child)
6646
+ });
6502
6647
  break;
6503
6648
  }
6504
6649
  } catch {
@@ -6547,6 +6692,7 @@ function parseRun(node, sourceXml, relationships, mediaParts, sourcePartPath) {
6547
6692
  ...parsedMedia.map((media) => ({
6548
6693
  type: "image",
6549
6694
  mediaId: media.mediaId,
6695
+ sourceRef: createElementSourceRef(sourcePartPath, "drawing", child),
6550
6696
  relationshipId: media.relationshipId,
6551
6697
  packagePartName: media.packagePartName,
6552
6698
  contentType: media.contentType,
@@ -6577,7 +6723,10 @@ function parseRun(node, sourceXml, relationships, mediaParts, sourcePartPath) {
6577
6723
  })
6578
6724
  });
6579
6725
  if (frame) {
6580
- result.push(frame);
6726
+ result.push({
6727
+ ...frame,
6728
+ sourceRef: createElementSourceRef(sourcePartPath, "AlternateContent", child)
6729
+ });
6581
6730
  break;
6582
6731
  }
6583
6732
  } catch {
@@ -6614,7 +6763,10 @@ function parseRun(node, sourceXml, relationships, mediaParts, sourcePartPath) {
6614
6763
  try {
6615
6764
  const oleNode = parseObject(child, objectXml, relationships);
6616
6765
  if (oleNode) {
6617
- result.push(oleNode);
6766
+ result.push({
6767
+ ...oleNode,
6768
+ sourceRef: createElementSourceRef(sourcePartPath, "object", child)
6769
+ });
6618
6770
  break;
6619
6771
  }
6620
6772
  } catch {