ooxml-core 0.4.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/NOTICE +2 -0
  2. package/README.md +1 -0
  3. package/dist/digest/algorithm-names.d.ts +20 -0
  4. package/dist/digest/algorithm-names.d.ts.map +1 -0
  5. package/dist/digest/base64.d.ts +8 -0
  6. package/dist/digest/base64.d.ts.map +1 -0
  7. package/dist/digest/digest.d.ts +13 -0
  8. package/dist/digest/digest.d.ts.map +1 -0
  9. package/dist/digest/index.cjs +594 -0
  10. package/dist/digest/index.d.ts +8 -0
  11. package/dist/digest/index.d.ts.map +1 -0
  12. package/dist/digest/index.mjs +581 -0
  13. package/dist/digest/password-hash.d.ts +30 -0
  14. package/dist/digest/password-hash.d.ts.map +1 -0
  15. package/dist/digest/sha1.d.ts +3 -0
  16. package/dist/digest/sha1.d.ts.map +1 -0
  17. package/dist/digest/sha256.d.ts +10 -0
  18. package/dist/digest/sha256.d.ts.map +1 -0
  19. package/dist/digest/sha512.d.ts +5 -0
  20. package/dist/digest/sha512.d.ts.map +1 -0
  21. package/dist/docx/block-parser.d.ts.map +1 -1
  22. package/dist/docx/embedded.cjs +153 -59
  23. package/dist/docx/embedded.mjs +153 -59
  24. package/dist/docx/equation.d.ts +8 -0
  25. package/dist/docx/equation.d.ts.map +1 -0
  26. package/dist/docx/index.cjs +153 -59
  27. package/dist/docx/index.mjs +153 -59
  28. package/dist/docx/layout/adapter.d.ts.map +1 -1
  29. package/dist/docx/layout/index.cjs +3 -1
  30. package/dist/docx/layout/index.mjs +3 -1
  31. package/dist/docx/load/index.cjs +155 -61
  32. package/dist/docx/load/index.mjs +155 -61
  33. package/dist/docx/model-run.d.ts +5 -0
  34. package/dist/docx/model-run.d.ts.map +1 -1
  35. package/dist/docx/parse-revisions.d.ts.map +1 -1
  36. package/dist/docx/parse-table.d.ts.map +1 -1
  37. package/dist/docx/write-inline.d.ts.map +1 -1
  38. package/dist/docx/write-table-margins.d.ts +5 -0
  39. package/dist/docx/write-table-margins.d.ts.map +1 -0
  40. package/dist/docx/write-table-properties.d.ts +6 -2
  41. package/dist/docx/write-table-properties.d.ts.map +1 -1
  42. package/dist/docx/write-table.d.ts.map +1 -1
  43. package/dist/index.cjs +2640 -13
  44. package/dist/index.d.ts +2 -0
  45. package/dist/index.d.ts.map +1 -1
  46. package/dist/index.mjs +2639 -14
  47. package/dist/math/index.cjs +2050 -0
  48. package/dist/math/index.d.ts +15 -0
  49. package/dist/math/index.d.ts.map +1 -0
  50. package/dist/math/index.mjs +1985 -0
  51. package/dist/math/latex-omml-siblings.d.ts +21 -0
  52. package/dist/math/latex-omml-siblings.d.ts.map +1 -0
  53. package/dist/math/latex-omml-symbols.d.ts +42 -0
  54. package/dist/math/latex-omml-symbols.d.ts.map +1 -0
  55. package/dist/math/latex-to-omml-commands.d.ts +9 -0
  56. package/dist/math/latex-to-omml-commands.d.ts.map +1 -0
  57. package/dist/math/latex-to-omml-constructs.d.ts +39 -0
  58. package/dist/math/latex-to-omml-constructs.d.ts.map +1 -0
  59. package/dist/math/latex-to-omml-environments.d.ts +28 -0
  60. package/dist/math/latex-to-omml-environments.d.ts.map +1 -0
  61. package/dist/math/latex-to-omml.d.ts +9 -0
  62. package/dist/math/latex-to-omml.d.ts.map +1 -0
  63. package/dist/math/omml-color.d.ts +11 -0
  64. package/dist/math/omml-color.d.ts.map +1 -0
  65. package/dist/math/omml-dom.d.ts +7 -0
  66. package/dist/math/omml-dom.d.ts.map +1 -0
  67. package/dist/math/omml-mathml-converters.d.ts +39 -0
  68. package/dist/math/omml-mathml-converters.d.ts.map +1 -0
  69. package/dist/math/omml-mathml-helpers.d.ts +23 -0
  70. package/dist/math/omml-mathml-helpers.d.ts.map +1 -0
  71. package/dist/math/omml-node.d.ts +7 -0
  72. package/dist/math/omml-node.d.ts.map +1 -0
  73. package/dist/math/omml-to-latex-helpers.d.ts +41 -0
  74. package/dist/math/omml-to-latex-helpers.d.ts.map +1 -0
  75. package/dist/math/omml-to-latex-layout.d.ts +18 -0
  76. package/dist/math/omml-to-latex-layout.d.ts.map +1 -0
  77. package/dist/math/omml-to-latex.d.ts +6 -0
  78. package/dist/math/omml-to-latex.d.ts.map +1 -0
  79. package/dist/math/omml-to-mathml.d.ts +21 -0
  80. package/dist/math/omml-to-mathml.d.ts.map +1 -0
  81. package/dist/xlsx/edit/history.d.ts +1 -1
  82. package/dist/xlsx/edit/history.d.ts.map +1 -1
  83. package/dist/xlsx/edit/index.d.ts +1 -1
  84. package/dist/xlsx/edit/index.d.ts.map +1 -1
  85. package/dist/xlsx/edit/protection.d.ts +18 -6
  86. package/dist/xlsx/edit/protection.d.ts.map +1 -1
  87. package/dist/xlsx/edit/types.d.ts +2 -2
  88. package/dist/xlsx/index.cjs +671 -28
  89. package/dist/xlsx/index.mjs +670 -29
  90. package/dist/xlsx/load/index.cjs +56 -19
  91. package/dist/xlsx/load/index.mjs +56 -19
  92. package/dist/xlsx/model.d.ts +21 -0
  93. package/dist/xlsx/model.d.ts.map +1 -1
  94. package/dist/xlsx/read/load.d.ts.map +1 -1
  95. package/dist/xlsx/read/password-hash.d.ts +15 -0
  96. package/dist/xlsx/read/password-hash.d.ts.map +1 -0
  97. package/dist/xlsx/read/sheet-props.d.ts.map +1 -1
  98. package/dist/xlsx/read/workbook-part.d.ts +3 -1
  99. package/dist/xlsx/read/workbook-part.d.ts.map +1 -1
  100. package/dist/xlsx/write/password-hash.d.ts +8 -0
  101. package/dist/xlsx/write/password-hash.d.ts.map +1 -0
  102. package/dist/xlsx/write/sheet-props.d.ts.map +1 -1
  103. package/dist/xlsx/write/workbook-part.d.ts.map +1 -1
  104. package/package.json +11 -1
@@ -899,6 +899,46 @@ function orderSectionProperties(sectPr) {
899
899
  orderChildren(sectPr, SECTPR_ORDER);
900
900
  }
901
901
 
902
+ // src/docx/write-table-margins.ts
903
+ var SIDES = ["top", "left", "bottom", "right"];
904
+ var ORDER = ["top", "start", "left", "bottom", "end", "right"];
905
+ function patchMarginProperties(doc, host, propertiesTag, marginTag, propertiesOrder, next, base) {
906
+ const changed = SIDES.filter((side) => next?.[side] !== base?.[side]);
907
+ if (!changed.length) return;
908
+ for (const side of changed) {
909
+ const value = next?.[side];
910
+ if (value !== void 0 && (!Number.isSafeInteger(value) || value < 0))
911
+ throw new Error("Table cell margins must be nonnegative whole twips.");
912
+ }
913
+ let properties = first2(host, propertiesTag);
914
+ if (!properties) {
915
+ properties = makeW(doc, propertiesTag);
916
+ host.insertBefore(properties, host.firstChild);
917
+ }
918
+ let margins = first2(properties, marginTag);
919
+ if (!margins) {
920
+ margins = makeW(doc, marginTag);
921
+ properties.appendChild(margins);
922
+ }
923
+ for (const side of changed) {
924
+ const logical = side === "left" ? "start" : side === "right" ? "end" : side;
925
+ const edge = first2(margins, logical) ?? first2(margins, side) ?? makeW(doc, side);
926
+ for (const alias of /* @__PURE__ */ new Set([side, logical]))
927
+ for (const old of children2(margins, alias)) margins.removeChild(old);
928
+ const value = next?.[side];
929
+ if (value === void 0) continue;
930
+ edge.setAttributeNS(WORD_NS, "w:w", String(value));
931
+ edge.setAttributeNS(WORD_NS, "w:type", "dxa");
932
+ margins.appendChild(edge);
933
+ }
934
+ if (!Array.from(margins.childNodes).some((node) => node.nodeType === 1) && !margins.attributes.length)
935
+ properties.removeChild(margins);
936
+ else orderChildren(margins, ORDER);
937
+ orderChildren(properties, propertiesOrder);
938
+ if (!Array.from(properties.childNodes).some((node) => node.nodeType === 1) && !properties.attributes.length)
939
+ host.removeChild(properties);
940
+ }
941
+
902
942
  // src/docx/write-table-properties.ts
903
943
  var ROW_ORDER = [
904
944
  "cnfStyle",
@@ -958,26 +998,15 @@ function patchRowProperties(doc, tr, next, base) {
958
998
  orderChildren(props, ROW_ORDER);
959
999
  }
960
1000
  function patchTableMargins(doc, table, node, base) {
961
- if (JSON.stringify(table.cellMargins ?? {}) === JSON.stringify(base?.cellMargins ?? {})) return;
962
- let props = first2(node, "tblPr");
963
- if (!props) {
964
- props = makeW(doc, "tblPr");
965
- node.insertBefore(props, node.firstChild);
966
- }
967
- let margins = first2(props, "tblCellMar");
968
- if (!margins) {
969
- margins = makeW(doc, "tblCellMar");
970
- props.appendChild(margins);
971
- }
972
- const built = buildMargins(doc, table.cellMargins ?? {}, "tblCellMar");
973
- for (const side of ["top", "left", "bottom", "right"]) {
974
- if (table.cellMargins?.[side] === base?.cellMargins?.[side]) continue;
975
- for (const old of children2(margins, side)) margins.removeChild(old);
976
- const replacement = first2(built, side);
977
- if (replacement) margins.appendChild(replacement);
978
- }
979
- orderChildren(margins, ["top", "left", "start", "bottom", "right", "end"]);
980
- orderChildren(props, TABLE_ORDER);
1001
+ patchMarginProperties(
1002
+ doc,
1003
+ node,
1004
+ "tblPr",
1005
+ "tblCellMar",
1006
+ TABLE_ORDER,
1007
+ table.cellMargins,
1008
+ base?.cellMargins
1009
+ );
981
1010
  }
982
1011
  var CELL_ORDER = [
983
1012
  "cnfStyle",
@@ -1001,6 +1030,9 @@ var CELL_ORDER = [
1001
1030
  ];
1002
1031
  var CELL_BORDER_ORDER = ["top", "start", "left", "bottom", "end", "right", "insideH", "insideV"];
1003
1032
  var CELL_SIDES = ["top", "left", "bottom", "right"];
1033
+ function patchCellMargins(doc, tc, next, base) {
1034
+ patchMarginProperties(doc, tc, "tcPr", "tcMar", CELL_ORDER, next, base);
1035
+ }
1004
1036
  function patchCellBorders(doc, tc, next, base) {
1005
1037
  const changed = CELL_SIDES.filter(
1006
1038
  (side) => JSON.stringify(next?.[side]) !== JSON.stringify(base?.[side])
@@ -1028,6 +1060,23 @@ function patchCellBorders(doc, tc, next, base) {
1028
1060
  orderChildren(props, CELL_ORDER);
1029
1061
  if (!Array.from(props.childNodes).some((node) => node.nodeType === 1)) tc.removeChild(props);
1030
1062
  }
1063
+ function patchCellShading(doc, tc, next, base) {
1064
+ if (next.shadingFill === base?.shadingFill && JSON.stringify(next.shadingThemeFill) === JSON.stringify(base?.shadingThemeFill))
1065
+ return;
1066
+ if (next.shadingFill && next.shadingFill !== "auto" && !/^#?[0-9a-f]{6}$/i.test(next.shadingFill))
1067
+ throw new Error("Cell shading must be a six-digit RGB color or auto.");
1068
+ let props = first2(tc, "tcPr");
1069
+ if (!props) {
1070
+ props = makeW(doc, "tcPr");
1071
+ tc.insertBefore(props, tc.firstChild);
1072
+ }
1073
+ for (const old of children2(props, "shd")) props.removeChild(old);
1074
+ const built = buildCellProperties(doc, next);
1075
+ const replacement = built && first2(built, "shd");
1076
+ if (replacement) props.appendChild(replacement);
1077
+ orderChildren(props, CELL_ORDER);
1078
+ if (!Array.from(props.childNodes).some((node) => node.nodeType === 1)) tc.removeChild(props);
1079
+ }
1031
1080
 
1032
1081
  // src/docx/write-table.ts
1033
1082
  function canEditTableStructure(table) {
@@ -1071,15 +1120,7 @@ var TABLE_DESCRIPTOR_KEYS = [
1071
1120
  "style",
1072
1121
  "look"
1073
1122
  ];
1074
- var CELL_DESCRIPTOR_KEYS = [
1075
- "gridSpan",
1076
- "verticalMerge",
1077
- "widthTwips",
1078
- "verticalAlign",
1079
- "shadingFill",
1080
- "shadingThemeFill",
1081
- "margins"
1082
- ];
1123
+ var CELL_DESCRIPTOR_KEYS = ["gridSpan", "verticalMerge", "widthTwips", "verticalAlign"];
1083
1124
  function pick(source, keys) {
1084
1125
  const record = source;
1085
1126
  const result = {};
@@ -1105,7 +1146,7 @@ function assertNoDescriptorEdits(table, base) {
1105
1146
  if (!source) continue;
1106
1147
  if (JSON.stringify(pick(cell, CELL_DESCRIPTOR_KEYS)) !== JSON.stringify(pick(source, CELL_DESCRIPTOR_KEYS)))
1107
1148
  throw new Error(
1108
- "Cannot edit table cell width, merge, vertical alignment, shading, or margins on an existing cell; only cell text and borders are supported. The original DOCX package remains unchanged."
1149
+ "Cannot edit table cell width, merge or vertical alignment on an existing cell; only cell text, borders, shading and margins are supported. The original DOCX package remains unchanged."
1109
1150
  );
1110
1151
  }
1111
1152
  }
@@ -1174,6 +1215,8 @@ function writeTable(doc, table, node, base, writeParagraph, replaceSlots2) {
1174
1215
  throw new Error("Moving paragraphs between table cells is not supported.");
1175
1216
  const tc = source?.cell ?? makeW(doc, "tc");
1176
1217
  patchCellBorders(doc, tc, cell.borders, source?.model.borders);
1218
+ patchCellShading(doc, tc, cell, source?.model);
1219
+ patchCellMargins(doc, tc, cell.margins, source?.model.margins);
1177
1220
  const oldParagraphs = children2(tc, "p");
1178
1221
  const nextParagraphs = cell.paragraphs.map((paragraph) => {
1179
1222
  const index = source?.paragraphs.findIndex((p) => p.id === paragraph.id) ?? -1;
@@ -1316,7 +1359,7 @@ function parseTintShade(value) {
1316
1359
  }
1317
1360
 
1318
1361
  // src/docx/table-borders.ts
1319
- var SIDES = [
1362
+ var SIDES2 = [
1320
1363
  "top",
1321
1364
  "bottom",
1322
1365
  "left",
@@ -1342,7 +1385,7 @@ function parseTableBorders(bordersElement) {
1342
1385
  if (!bordersElement) return void 0;
1343
1386
  const result = {};
1344
1387
  const alias = { left: "start", right: "end" };
1345
- for (const side of SIDES) {
1388
+ for (const side of SIDES2) {
1346
1389
  const aliasName = alias[side];
1347
1390
  const value = borderSide(
1348
1391
  first2(bordersElement, side) ?? (aliasName ? first2(bordersElement, aliasName) : void 0)
@@ -1379,13 +1422,13 @@ function parseParagraphBorders(pBdr) {
1379
1422
  }
1380
1423
 
1381
1424
  // src/docx/page-borders.ts
1382
- var SIDES2 = ["top", "left", "bottom", "right"];
1425
+ var SIDES3 = ["top", "left", "bottom", "right"];
1383
1426
  var ATTRIBUTES = ["offsetFrom", "display", "zOrder"];
1384
1427
  var setW4 = (element, name, value) => element.setAttributeNS(WORD_NS, `w:${name}`, value);
1385
1428
  function parsePageBorders(element) {
1386
1429
  if (!element) return void 0;
1387
1430
  const result = {};
1388
- for (const side of SIDES2) {
1431
+ for (const side of SIDES3) {
1389
1432
  const source = first2(element, side);
1390
1433
  const value = borderSide(source);
1391
1434
  const art = getW(source, "art");
@@ -1423,7 +1466,7 @@ function patchPageBorders(doc, sectPr, next, base, create) {
1423
1466
  return;
1424
1467
  }
1425
1468
  const element = create(doc, sectPr, "pgBorders");
1426
- for (const side of SIDES2) {
1469
+ for (const side of SIDES3) {
1427
1470
  if (JSON.stringify(next[side]) === JSON.stringify(base?.[side])) continue;
1428
1471
  for (const old of children2(element, side)) element.removeChild(old);
1429
1472
  const value = next[side];
@@ -1748,7 +1791,7 @@ function applySectionEdits(doc, body, blocks, sections, base, references = /* @_
1748
1791
  }
1749
1792
 
1750
1793
  // src/docx/write-paragraph-decoration.ts
1751
- var SIDES3 = ["top", "left", "bottom", "right", "between"];
1794
+ var SIDES4 = ["top", "left", "bottom", "right", "between"];
1752
1795
  function wordColor(color) {
1753
1796
  const hex = /^#?([0-9a-f]{6})$/i.exec(color ?? "")?.[1];
1754
1797
  return hex ? hex.toUpperCase() : "auto";
@@ -1782,7 +1825,7 @@ function updateBorders(doc, props, paragraph, base) {
1782
1825
  const borders = paragraph.borders;
1783
1826
  if (!borders) return;
1784
1827
  const pBdr = makeW(doc, "pBdr");
1785
- for (const side of SIDES3) {
1828
+ for (const side of SIDES4) {
1786
1829
  const value = borders[side];
1787
1830
  if (value) pBdr.appendChild(borderElement(doc, side, value));
1788
1831
  }
@@ -4213,6 +4256,30 @@ function createRun(doc, run, base, old, allocator) {
4213
4256
  if (!run.text) node.appendChild(makeW(doc, "t"));
4214
4257
  return node;
4215
4258
  }
4259
+ var MATH_NAMESPACES = /* @__PURE__ */ new Set([
4260
+ "http://schemas.openxmlformats.org/officeDocument/2006/math",
4261
+ "http://purl.oclc.org/ooxml/officeDocument/math"
4262
+ ]);
4263
+ function isEquationElement(element) {
4264
+ return MATH_NAMESPACES.has(element.namespaceURI ?? "") && (element.localName === "oMath" || element.localName === "oMathPara");
4265
+ }
4266
+ function parseEquation(element) {
4267
+ if (!isEquationElement(element)) return void 0;
4268
+ return {
4269
+ text: "",
4270
+ equation: {
4271
+ omml: new XMLSerializer().serializeToString(element),
4272
+ display: element.localName === "oMathPara"
4273
+ }
4274
+ };
4275
+ }
4276
+ function preserveEquation(run, base, old) {
4277
+ if (!old || !isEquationElement(old) || !base?.equation || run.text !== "" || run.equation?.omml !== base.equation.omml || run.equation?.display !== base.equation.display)
4278
+ throw new Error(
4279
+ "Equation editing or insertion is unsupported; imported OMML must remain unchanged."
4280
+ );
4281
+ return old.cloneNode(true);
4282
+ }
4216
4283
 
4217
4284
  // src/docx/breaks.ts
4218
4285
  function hasSpecialBreak(element) {
@@ -4311,10 +4378,11 @@ function collectParagraphRuns(node, parseRun3, parseOther, resolveLink, active =
4311
4378
  if (!isCommentReferenceRun(item)) push(parseRun3(item));
4312
4379
  } else if (named2(item, "hyperlink")) {
4313
4380
  const link = resolveLink?.(item);
4314
- for (const run of children2(item, "r")) {
4315
- const parsed = parseRun3(run);
4316
- if (link) parsed.link = link;
4317
- push(parsed);
4381
+ for (const child3 of Array.from(item.childNodes).filter(isElement)) {
4382
+ for (const parsed of named2(child3, "r") ? [parseRun3(child3)] : parseOther?.(child3) ?? []) {
4383
+ if (link) parsed.link = link;
4384
+ push(parsed);
4385
+ }
4318
4386
  }
4319
4387
  } else if ((!item.namespaceURI || item.namespaceURI === WORD_NS) && Object.hasOwn(REVISION_WRAPPERS, item.localName)) {
4320
4388
  const kind = expectDefined(
@@ -4325,7 +4393,12 @@ function collectParagraphRuns(node, parseRun3, parseOther, resolveLink, active =
4325
4393
  const revision = revisionFrom(item, kind);
4326
4394
  const range = kind === "moveFrom" || kind === "moveTo" ? moves[kind].at(-1) : void 0;
4327
4395
  if (range) revision.move = { name: range.name, rangeId: range.id };
4328
- for (const run of children2(item, "r")) push(parseRun3(run, revision));
4396
+ for (const child3 of Array.from(item.childNodes).filter(isElement)) {
4397
+ for (const parsed of named2(child3, "r") ? [parseRun3(child3, revision)] : parseOther?.(child3) ?? []) {
4398
+ parsed.revision = revision;
4399
+ push(parsed);
4400
+ }
4401
+ }
4329
4402
  } else if (trackMoveRange(item, moves)) {
4330
4403
  continue;
4331
4404
  } else if (named2(item, "commentRangeStart")) {
@@ -4372,7 +4445,9 @@ function runsOf(parent, container, slots) {
4372
4445
  if (child3.nodeType === 3 && child3.textContent?.trim()) return false;
4373
4446
  continue;
4374
4447
  }
4375
- if (named2(child3, "r")) {
4448
+ if (isEquationElement(child3)) {
4449
+ slots.push({ element: child3, ...container && { container } });
4450
+ } else if (named2(child3, "r")) {
4376
4451
  if (isCommentReferenceRun(child3)) continue;
4377
4452
  if (!runIsSafe(child3)) return false;
4378
4453
  slots.push({ element: child3, ...container && { container } });
@@ -4396,7 +4471,9 @@ function collectInlineSlots(paragraph) {
4396
4471
  if (child3.nodeType === 3 && child3.textContent?.trim()) return void 0;
4397
4472
  continue;
4398
4473
  }
4399
- if (named2(child3, "r")) {
4474
+ if (isEquationElement(child3)) {
4475
+ slots.push({ element: child3 });
4476
+ } else if (named2(child3, "r")) {
4400
4477
  if (isCommentReferenceRun(child3)) continue;
4401
4478
  if (!runIsSafe(child3)) return void 0;
4402
4479
  slots.push({ element: child3 });
@@ -4412,7 +4489,7 @@ function collectInlineSlots(paragraph) {
4412
4489
  }
4413
4490
  function replaceableInlineChildren(paragraph) {
4414
4491
  return Array.from(paragraph.childNodes).filter(
4415
- (child3) => isElement(child3) && (named2(child3, "r") || named2(child3, "hyperlink") || named2(child3, "fldSimple") || isRevisionWrapperElement(child3) || isCommentAnchorElement(child3))
4492
+ (child3) => isElement(child3) && (isEquationElement(child3) || named2(child3, "r") || named2(child3, "hyperlink") || named2(child3, "fldSimple") || isRevisionWrapperElement(child3) || isCommentAnchorElement(child3))
4416
4493
  );
4417
4494
  }
4418
4495
  function sameLink(a, b) {
@@ -4437,7 +4514,7 @@ function newHyperlink(doc, link, allocator) {
4437
4514
  }
4438
4515
  function runNodes(doc, run, base, old, opens, closes, allocator) {
4439
4516
  const nodes = opens.flatMap((edge) => rangeStartNodes(doc, edge));
4440
- const node = createRun(doc, run, base, old, allocator);
4517
+ const node = run.equation ? preserveEquation(run, base, old) : createRun(doc, run, base, old, allocator);
4441
4518
  const revision = run.revision;
4442
4519
  if (revision && ["insert", "delete", "moveFrom", "moveTo"].includes(revision.kind)) {
4443
4520
  if (revision.kind === "delete" || revision.kind === "moveFrom") convertToDeleteText(doc, node);
@@ -4449,15 +4526,23 @@ function runNodes(doc, run, base, old, opens, closes, allocator) {
4449
4526
  function buildInlineContent(doc, runs, base, slots, allocator, ranges) {
4450
4527
  const { opens, closes } = rangeEdges(runs, ranges);
4451
4528
  const runAt = (at) => expectDefined(runs[at], `run ${at}`);
4452
- const nodesFor = (index2) => runNodes(
4453
- doc,
4454
- runAt(index2),
4455
- base?.[index2],
4456
- slots[index2]?.element,
4457
- opens.get(index2) ?? [],
4458
- closes.get(index2) ?? [],
4459
- allocator
4460
- );
4529
+ const nodesFor = (index2) => {
4530
+ const run = runAt(index2);
4531
+ const sourceIndex = run.equation ? base?.findIndex(
4532
+ (source2) => source2.equation?.omml === run.equation?.omml && source2.equation?.display === run.equation?.display
4533
+ ) : index2;
4534
+ const source = sourceIndex === void 0 ? void 0 : base?.[sourceIndex];
4535
+ const old = sourceIndex === void 0 ? void 0 : slots[sourceIndex]?.element;
4536
+ return runNodes(
4537
+ doc,
4538
+ run,
4539
+ !run.equation && source?.equation ? void 0 : source,
4540
+ !run.equation && old && isEquationElement(old) ? void 0 : old,
4541
+ opens.get(index2) ?? [],
4542
+ closes.get(index2) ?? [],
4543
+ allocator
4544
+ );
4545
+ };
4461
4546
  const output = [];
4462
4547
  let index = 0;
4463
4548
  while (index < runs.length) {
@@ -6458,14 +6543,14 @@ function parseCell(cell, parseParagraph3, id) {
6458
6543
  const vMerge = first2(props, "vMerge");
6459
6544
  if (vMerge) result.verticalMerge = getW(vMerge, "val") === "restart" ? "restart" : "continue";
6460
6545
  const tcW = first2(props, "tcW");
6461
- if (getW(tcW, "type") !== "nil") {
6546
+ if ((getW(tcW, "type") ?? "dxa") === "dxa") {
6462
6547
  const width = dxa(getW(tcW, "w"));
6463
6548
  if (width !== void 0) result.widthTwips = width;
6464
6549
  }
6465
6550
  const vAlign = enumValue(isStVerticalJc, getW(first2(props, "vAlign"), "val"), "w:tcPr/w:vAlign");
6466
6551
  if (vAlign) result.verticalAlign = vAlign;
6467
6552
  const shd = first2(props, "shd");
6468
- const fill = parseShadingFill(shd);
6553
+ const fill = parseShadingFill(shd) ?? (getW(shd, "fill") === "auto" && !getW(shd, "themeFill") ? "auto" : void 0);
6469
6554
  if (fill) result.shadingFill = fill;
6470
6555
  const themeFill = parseShadingThemeFill(shd);
6471
6556
  if (themeFill) result.shadingThemeFill = themeFill;
@@ -6504,7 +6589,9 @@ function parseMargins(element) {
6504
6589
  ["left", "start"],
6505
6590
  ["right", "end"]
6506
6591
  ]) {
6507
- const value = dxa(getW(first2(element, side) ?? first2(element, logical), "w"));
6592
+ const edge = first2(element, logical) ?? first2(element, side);
6593
+ const type = getW(edge, "type") ?? "dxa";
6594
+ const value = type === "nil" ? parseSignedTwips("0") : type === "dxa" ? parseSignedTwips(getW(edge, "w")) : void 0;
6508
6595
  if (value !== void 0) parsed[side] = value;
6509
6596
  }
6510
6597
  return Object.keys(parsed).length ? parsed : void 0;
@@ -6534,7 +6621,8 @@ function parseTable(node, id, parseParagraph3) {
6534
6621
  }) : [];
6535
6622
  if (grid.length) table.grid = grid;
6536
6623
  const tblPr = first2(node, "tblPr");
6537
- const width = dxa(getW(first2(tblPr, "tblW"), "w"));
6624
+ const tableWidth = first2(tblPr, "tblW");
6625
+ const width = (getW(tableWidth, "type") ?? "dxa") === "dxa" ? dxa(getW(tableWidth, "w")) : void 0;
6538
6626
  if (width !== void 0) table.widthTwips = width;
6539
6627
  const justification = enumValue(isStJcTable, getW(first2(tblPr, "jc"), "val"), "w:tblPr/w:jc");
6540
6628
  if (justification) {
@@ -6708,13 +6796,19 @@ function parseParagraph2(node, id) {
6708
6796
  node,
6709
6797
  (element, revision) => trackField(element, parseRun2(element, revision)),
6710
6798
  (item) => {
6799
+ const equation = parseEquation(item);
6800
+ if (equation) return [equation];
6711
6801
  if (!named2(item, "fldSimple")) return void 0;
6712
6802
  const instr = getW(item, "instr") ?? "";
6713
6803
  const link = parseSimpleHyperlinkField(instr);
6714
- const results = children2(item, "r").map((run) => parseRun2(run));
6804
+ const results = Array.from(item.childNodes).filter(isElement).flatMap((child3) => {
6805
+ const equation2 = parseEquation(child3);
6806
+ return equation2 ? [equation2] : named2(child3, "r") ? [parseRun2(child3)] : [];
6807
+ });
6715
6808
  if (link) return results.map((run) => ({ ...run, link }));
6716
6809
  const field = { instr: instr.trim(), simple: true };
6717
- if (!results.some((run) => run.text)) return [{ text: fieldPlaceholderText(instr), field }];
6810
+ if (!results.some((run) => run.text || run.equation))
6811
+ return [{ text: fieldPlaceholderText(instr), field }];
6718
6812
  return results.map((run) => ({ ...run, field }));
6719
6813
  },
6720
6814
  (hyperlink) => {
@@ -20,6 +20,11 @@ export interface Revision {
20
20
  }
21
21
  export interface TextRun {
22
22
  text: string;
23
+ /** Imported, display-only equation. Source OMML is preserved; equation editing is unsupported. */
24
+ equation?: {
25
+ omml: string;
26
+ display: boolean;
27
+ };
23
28
  bold?: boolean;
24
29
  italic?: boolean;
25
30
  underline?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"model-run.d.ts","sourceRoot":"","sources":["../../src/docx/model-run.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,KAAK,EACX,mBAAmB,EACnB,aAAa,EACb,eAAe,EACf,kBAAkB,EAClB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE1D,qEAAqE;AACrE,MAAM,WAAW,QAAQ;IACxB,IAAI,EAAE,QAAQ,GAAG,QAAQ,GAAG,UAAU,GAAG,QAAQ,GAAG,cAAc,GAAG,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B,EAAE,EAAE,MAAM,EACV,cAAc,EAAE,CAAC,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,KAAK,SAAS,GACtD,KAAK,CA4CP"}
1
+ {"version":3,"file":"parse-table.d.ts","sourceRoot":"","sources":["../../src/docx/parse-table.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAyB,KAAK,UAAU,EAAW,MAAM,UAAU,CAAC;AAyH3E,8FAA8F;AAC9F,wBAAgB,UAAU,CACzB,IAAI,EAAE,UAAU,EAChB,EAAE,EAAE,MAAM,EACV,cAAc,EAAE,CAAC,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,KAAK,SAAS,GACtD,KAAK,CA8CP"}
@@ -1 +1 @@
1
- {"version":3,"file":"write-inline.d.ts","sourceRoot":"","sources":["../../src/docx/write-inline.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAiB,OAAO,EAAE,MAAM,YAAY,CAAC;AACzD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACzE,OAAO,EAIN,KAAK,eAAe,EAEpB,MAAM,mBAAmB,CAAC;AAW3B,OAAO,EAON,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,MAAM,UAAU,CAAC;AAElB;;;GAGG;AACH,MAAM,WAAW,UAAU;IAC1B,OAAO,CAAC,EAAE,UAAU,CAAC;IACrB,SAAS,CAAC,EAAE,UAAU,CAAC;CACvB;AA4DD;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,UAAU,GAAG,UAAU,EAAE,GAAG,SAAS,CAyBlF;AAED,8EAA8E;AAC9E,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,UAAU,GAAG,UAAU,EAAE,CAU7E;AAmDD,4FAA4F;AAC5F,wBAAgB,kBAAkB,CACjC,GAAG,EAAE,WAAW,EAChB,IAAI,EAAE,OAAO,EAAE,EACf,IAAI,EAAE,OAAO,EAAE,GAAG,SAAS,EAC3B,KAAK,EAAE,UAAU,EAAE,EACnB,SAAS,CAAC,EAAE,qBAAqB,EACjC,MAAM,CAAC,EAAE,eAAe,GACtB,UAAU,EAAE,CA+Cd"}
1
+ {"version":3,"file":"write-inline.d.ts","sourceRoot":"","sources":["../../src/docx/write-inline.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAiB,OAAO,EAAE,MAAM,YAAY,CAAC;AACzD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACzE,OAAO,EAIN,KAAK,eAAe,EAEpB,MAAM,mBAAmB,CAAC;AAY3B,OAAO,EAON,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,MAAM,UAAU,CAAC;AAElB;;;GAGG;AACH,MAAM,WAAW,UAAU;IAC1B,OAAO,CAAC,EAAE,UAAU,CAAC;IACrB,SAAS,CAAC,EAAE,UAAU,CAAC;CACvB;AA8DD;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,UAAU,GAAG,UAAU,EAAE,GAAG,SAAS,CA2BlF;AAED,8EAA8E;AAC9E,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,UAAU,GAAG,UAAU,EAAE,CAW7E;AAqDD,4FAA4F;AAC5F,wBAAgB,kBAAkB,CACjC,GAAG,EAAE,WAAW,EAChB,IAAI,EAAE,OAAO,EAAE,EACf,IAAI,EAAE,OAAO,EAAE,GAAG,SAAS,EAC3B,KAAK,EAAE,UAAU,EAAE,EACnB,SAAS,CAAC,EAAE,qBAAqB,EACjC,MAAM,CAAC,EAAE,eAAe,GACtB,UAAU,EAAE,CA2Dd"}
@@ -0,0 +1,5 @@
1
+ import type { TableCellMargins } from './table-model.js';
2
+ import { type XmlDocument, type XmlElement } from './xml.js';
3
+ /** Patch only changed margin sides, retaining logical edge names and unrelated XML. */
4
+ export declare function patchMarginProperties(doc: XmlDocument, host: XmlElement, propertiesTag: 'tblPr' | 'tcPr', marginTag: 'tblCellMar' | 'tcMar', propertiesOrder: readonly string[], next: TableCellMargins | undefined, base: TableCellMargins | undefined): void;
5
+ //# sourceMappingURL=write-table-margins.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"write-table-margins.d.ts","sourceRoot":"","sources":["../../src/docx/write-table-margins.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEzD,OAAO,EAAmC,KAAK,WAAW,EAAE,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AAK9F,uFAAuF;AACvF,wBAAgB,qBAAqB,CACpC,GAAG,EAAE,WAAW,EAChB,IAAI,EAAE,UAAU,EAChB,aAAa,EAAE,OAAO,GAAG,MAAM,EAC/B,SAAS,EAAE,YAAY,GAAG,OAAO,EACjC,eAAe,EAAE,SAAS,MAAM,EAAE,EAClC,IAAI,EAAE,gBAAgB,GAAG,SAAS,EAClC,IAAI,EAAE,gBAAgB,GAAG,SAAS,GAChC,IAAI,CAyCN"}
@@ -1,13 +1,17 @@
1
- import type { Table } from './model.js';
2
- import type { TableBorders, TableRowProperties } from './table-model.js';
1
+ import type { Table, TableCell } from './model.js';
2
+ import type { TableBorders, TableCellMargins, TableRowProperties } from './table-model.js';
3
3
  import { type XmlDocument, type XmlElement } from './xml.js';
4
4
  /** Changes only modeled row fields, preserving unmodeled trPr children and attributes. */
5
5
  export declare function patchRowProperties(doc: XmlDocument, tr: XmlElement, next: TableRowProperties | undefined, base: TableRowProperties | undefined): void;
6
6
  /** Updates table defaults without replacing borders, style, look or extension XML. */
7
7
  export declare function patchTableMargins(doc: XmlDocument, table: Table, node: XmlElement, base?: Table): void;
8
+ /** Changes individual cell overrides; deleting an override restores table/default inheritance. */
9
+ export declare function patchCellMargins(doc: XmlDocument, tc: XmlElement, next: TableCellMargins | undefined, base: TableCellMargins | undefined): void;
8
10
  /**
9
11
  * Changes only the cell border sides that differ from `base`, keeping every other `tcPr` child
10
12
  * (width, shading, margins, extensions) and untouched sides exactly as they were.
11
13
  */
12
14
  export declare function patchCellBorders(doc: XmlDocument, tc: XmlElement, next: TableBorders | undefined, base: TableBorders | undefined): void;
15
+ /** Replaces only changed cell shading, preserving widths, borders, margins and extension XML. */
16
+ export declare function patchCellShading(doc: XmlDocument, tc: XmlElement, next: TableCell, base?: TableCell): void;
13
17
  //# sourceMappingURL=write-table-properties.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"write-table-properties.d.ts","sourceRoot":"","sources":["../../src/docx/write-table-properties.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAIzE,OAAO,EAA0B,KAAK,WAAW,EAAE,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AAwCrF,0FAA0F;AAC1F,wBAAgB,kBAAkB,CACjC,GAAG,EAAE,WAAW,EAChB,EAAE,EAAE,UAAU,EACd,IAAI,EAAE,kBAAkB,GAAG,SAAS,EACpC,IAAI,EAAE,kBAAkB,GAAG,SAAS,GAClC,IAAI,CAmBN;AAED,sFAAsF;AACtF,wBAAgB,iBAAiB,CAChC,GAAG,EAAE,WAAW,EAChB,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,UAAU,EAChB,IAAI,CAAC,EAAE,KAAK,GACV,IAAI,CAqBN;AAyBD;;;GAGG;AACH,wBAAgB,gBAAgB,CAC/B,GAAG,EAAE,WAAW,EAChB,EAAE,EAAE,UAAU,EACd,IAAI,EAAE,YAAY,GAAG,SAAS,EAC9B,IAAI,EAAE,YAAY,GAAG,SAAS,GAC5B,IAAI,CA0BN"}
1
+ {"version":3,"file":"write-table-properties.d.ts","sourceRoot":"","sources":["../../src/docx/write-table-properties.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;A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