@harbour-enterprises/superdoc 0.24.0-next.2 → 0.24.0-next.4

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 (82) hide show
  1. package/dist/chunks/{PdfViewer--Z8scsXq.es.js → PdfViewer-D7C8g2G4.es.js} +1 -1
  2. package/dist/chunks/{PdfViewer-CYiJzT44.cjs → PdfViewer-kOVuv-4I.cjs} +1 -1
  3. package/dist/chunks/blank-docx-ABm6XYAA.es.js +4 -0
  4. package/dist/chunks/blank-docx-DfW3Eeh2.cjs +3 -0
  5. package/dist/chunks/{index-CBSXpA57.cjs → index-BFKwBQjS.cjs} +12 -4
  6. package/dist/chunks/{index-CCf_X9Jy.es.js → index-CnEAVnHQ.es.js} +12 -4
  7. package/dist/chunks/{super-editor.es-CZFQdEKI.cjs → super-editor.es-BmGTQ05x.cjs} +1954 -1216
  8. package/dist/chunks/{super-editor.es-BFco6Gra.es.js → super-editor.es-CBPoWvjs.es.js} +1954 -1216
  9. package/dist/core/SuperDoc.d.ts.map +1 -1
  10. package/dist/core/types/index.d.ts.map +1 -1
  11. package/dist/style.css +32 -31
  12. package/dist/super-editor/ai-writer.es.js +2 -2
  13. package/dist/super-editor/chunks/{converter-nWAUAQ83.js → converter-DpPj67OW.js} +1537 -1175
  14. package/dist/super-editor/chunks/{docx-zipper-B2uMUaj9.js → docx-zipper-6Kc95yG-.js} +1 -1
  15. package/dist/super-editor/chunks/{editor-DAyiX5AL.js → editor-Dx6AhT5N.js} +454 -57
  16. package/dist/super-editor/chunks/{toolbar-LmzuO_YJ.js → toolbar-CXSg2lJ9.js} +2 -2
  17. package/dist/super-editor/converter.es.js +1 -1
  18. package/dist/super-editor/docx-zipper.es.js +2 -2
  19. package/dist/super-editor/editor.es.js +3 -3
  20. package/dist/super-editor/file-zipper.es.js +1 -1
  21. package/dist/super-editor/style.css +5 -4
  22. package/dist/super-editor/super-editor/src/core/Editor.d.ts +11 -0
  23. package/dist/super-editor/super-editor/src/core/helpers/canRenderFont.d.ts +12 -0
  24. package/dist/super-editor/super-editor/src/core/super-converter/SuperConverter.d.ts +6 -1
  25. package/dist/super-editor/super-editor/src/core/super-converter/helpers.d.ts +23 -1
  26. package/dist/super-editor/super-editor/src/core/super-converter/v2/importer/docxImporter.d.ts +3 -1
  27. package/dist/super-editor/super-editor/src/core/super-converter/v2/importer/tableImporter.d.ts +5 -3
  28. package/dist/super-editor/super-editor/src/core/super-converter/v2/importer/trackChangesImporter.d.ts +5 -0
  29. package/dist/super-editor/super-editor/src/core/super-converter/v2/importer/types/index.d.ts +5 -0
  30. package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/helpers.d.ts +1 -0
  31. package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/utils.d.ts +9 -0
  32. package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/del/del-translator.d.ts +7 -0
  33. package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/del/index.d.ts +1 -0
  34. package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/gridSpan/gridSpan-translator.d.ts +6 -0
  35. package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/gridSpan/index.d.ts +1 -0
  36. package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/header/header-translator.d.ts +6 -0
  37. package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/header/index.d.ts +1 -0
  38. package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/headers/headers-translator.d.ts +7 -0
  39. package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/headers/index.d.ts +1 -0
  40. package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/hideMark/hideMark-translator.d.ts +6 -0
  41. package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/hideMark/index.d.ts +1 -0
  42. package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/ins/index.d.ts +1 -0
  43. package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/ins/ins-translator.d.ts +7 -0
  44. package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/noWrap/index.d.ts +1 -0
  45. package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/noWrap/noWrap-translator.d.ts +6 -0
  46. package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/shd/shd-translator.d.ts +1 -1
  47. package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/tc/helpers/translate-table-cell.d.ts +0 -5
  48. package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/tcBorders/index.d.ts +1 -0
  49. package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/tcBorders/tcBorders-translator.d.ts +6 -0
  50. package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/tcFitText/index.d.ts +1 -0
  51. package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/tcFitText/tcFitText-translator.d.ts +6 -0
  52. package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/tcMar/index.d.ts +1 -0
  53. package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/tcMar/tcMar-translator.d.ts +6 -0
  54. package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/tcPr/index.d.ts +1 -0
  55. package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/tcPr/tcPr-translator.d.ts +5 -0
  56. package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/tcW/index.d.ts +1 -0
  57. package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/tcW/tcW-translator.d.ts +6 -0
  58. package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/textDirection/index.d.ts +1 -0
  59. package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/textDirection/textDirection-translator.d.ts +6 -0
  60. package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/tl2br/index.d.ts +1 -0
  61. package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/tl2br/tl2br-translator.d.ts +6 -0
  62. package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/tr2bl/index.d.ts +1 -0
  63. package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/tr2bl/tr2bl-translator.d.ts +6 -0
  64. package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/vAlign/index.d.ts +1 -0
  65. package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/vAlign/vAlign-translator.d.ts +6 -0
  66. package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/vMerge/index.d.ts +1 -0
  67. package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/vMerge/vMerge-translator.d.ts +6 -0
  68. package/dist/super-editor/super-editor/src/extensions/image/image.d.ts +1 -1
  69. package/dist/super-editor/super-editor/src/extensions/image/imageHelpers/index.d.ts +1 -0
  70. package/dist/super-editor/super-editor/src/extensions/image/imageHelpers/legacyAttributes.d.ts +17 -0
  71. package/dist/super-editor/super-editor/src/extensions/table-cell/table-cell.d.ts +112 -0
  72. package/dist/super-editor/super-editor.es.js +91 -76
  73. package/dist/super-editor/toolbar.es.js +2 -2
  74. package/dist/super-editor.cjs +1 -1
  75. package/dist/super-editor.es.js +1 -1
  76. package/dist/superdoc.cjs +3 -3
  77. package/dist/superdoc.es.js +3 -3
  78. package/dist/superdoc.umd.js +1964 -1218
  79. package/dist/superdoc.umd.js.map +1 -1
  80. package/package.json +1 -1
  81. package/dist/chunks/blank-docx-CPqX9RF5.cjs +0 -3
  82. package/dist/chunks/blank-docx-iwdyG9RH.es.js +0 -4
@@ -15088,14 +15088,21 @@ function twipsToInches(twips) {
15088
15088
  function twipsToPixels(twips) {
15089
15089
  if (twips == null) return;
15090
15090
  const inches = twipsToInches(twips);
15091
+ return inchesToPixels(inches);
15092
+ }
15093
+ function pixelsToTwips(pixels) {
15094
+ const inches = pixelsToInches(pixels);
15095
+ return inchesToTwips(inches);
15096
+ }
15097
+ function inchesToPixels(inches) {
15091
15098
  if (inches == null) return;
15092
15099
  const pixels = inches * 96;
15093
15100
  return Math.round(pixels * 1e3) / 1e3;
15094
15101
  }
15095
- function pixelsToTwips(pixels) {
15102
+ function pixelsToInches(pixels) {
15096
15103
  if (pixels == null) return;
15097
15104
  const inches = Number(pixels) / 96;
15098
- return inchesToTwips(inches);
15105
+ return inches;
15099
15106
  }
15100
15107
  function twipsToLines(twips) {
15101
15108
  if (twips == null) return;
@@ -15120,9 +15127,9 @@ function pixelsToEmu(px) {
15120
15127
  if (typeof px === "string") px = parseFloat(px);
15121
15128
  return Math.round(px * 9525);
15122
15129
  }
15123
- function eigthPointsToPixels(eigthPoints) {
15124
- if (eigthPoints == null) return;
15125
- const points = parseFloat(eigthPoints) / 8;
15130
+ function eighthPointsToPixels(eighthPoints) {
15131
+ if (eighthPoints == null) return;
15132
+ const points = parseFloat(eighthPoints) / 8;
15126
15133
  const pixels = points * 1.3333;
15127
15134
  return pixels;
15128
15135
  }
@@ -15146,6 +15153,71 @@ function degreesToRot(degrees) {
15146
15153
  if (degrees == null) return;
15147
15154
  return degrees * 6e4;
15148
15155
  }
15156
+ function pixelsToPolygonUnits(pixels) {
15157
+ if (pixels == null) return;
15158
+ const pu = pixels * 96;
15159
+ return Math.round(pu);
15160
+ }
15161
+ function polygonUnitsToPixels(pu) {
15162
+ if (pu == null) return;
15163
+ const pixels = Number(pu) / 96;
15164
+ return Math.round(pixels * 1e3) / 1e3;
15165
+ }
15166
+ function polygonToObj(polygonNode) {
15167
+ if (!polygonNode) return null;
15168
+ const points = [];
15169
+ polygonNode.elements.forEach((element) => {
15170
+ if (["wp:start", "wp:lineTo"].includes(element.name)) {
15171
+ const { x, y: y2 } = element.attributes;
15172
+ points.push([polygonUnitsToPixels(x), polygonUnitsToPixels(y2)]);
15173
+ }
15174
+ });
15175
+ if (points.length > 1) {
15176
+ const firstPoint = points[0];
15177
+ const lastPoint = points[points.length - 1];
15178
+ if (firstPoint[0] === lastPoint[0] && firstPoint[1] === lastPoint[1]) {
15179
+ points.pop();
15180
+ }
15181
+ }
15182
+ return points;
15183
+ }
15184
+ function objToPolygon(points) {
15185
+ if (!points || !Array.isArray(points)) return null;
15186
+ const polygonNode = {
15187
+ name: "wp:wrapPolygon",
15188
+ type: "wp:wrapPolygon",
15189
+ attributes: {
15190
+ edited: "0"
15191
+ },
15192
+ elements: []
15193
+ };
15194
+ points.forEach((point, index2) => {
15195
+ const [x, y2] = point;
15196
+ const tagName = index2 === 0 ? "wp:start" : "wp:lineTo";
15197
+ const pointNode = {
15198
+ name: tagName,
15199
+ type: tagName,
15200
+ attributes: {
15201
+ x: pixelsToPolygonUnits(x),
15202
+ y: pixelsToPolygonUnits(y2)
15203
+ }
15204
+ };
15205
+ polygonNode.elements.push(pointNode);
15206
+ });
15207
+ if (points.length > 0) {
15208
+ const [startX, startY] = points[0];
15209
+ const closePointNode = {
15210
+ name: "wp:lineTo",
15211
+ type: "wp:lineTo",
15212
+ attributes: {
15213
+ x: pixelsToPolygonUnits(startX),
15214
+ y: pixelsToPolygonUnits(startY)
15215
+ }
15216
+ };
15217
+ polygonNode.elements.push(closePointNode);
15218
+ }
15219
+ return polygonNode;
15220
+ }
15149
15221
  const getTextIndentExportValue = (indent) => {
15150
15222
  const [value, unit] = parseSizeUnit(indent);
15151
15223
  const functionsMap = {
@@ -24470,37 +24542,37 @@ const _NodeTranslator = class _NodeTranslator {
24470
24542
  /** @type {typeof TranslatorTypes} */
24471
24543
  __publicField(_NodeTranslator, "translatorTypes", TranslatorTypes);
24472
24544
  let NodeTranslator = _NodeTranslator;
24473
- const encode$1c = (attributes) => {
24545
+ const encode$1b = (attributes) => {
24474
24546
  return attributes["w:type"];
24475
24547
  };
24476
- const decode$14 = (attrs) => {
24548
+ const decode$13 = (attrs) => {
24477
24549
  const { lineBreakType } = attrs;
24478
24550
  return lineBreakType;
24479
24551
  };
24480
24552
  const attrConfig$G = Object.freeze({
24481
24553
  xmlName: "w:type",
24482
24554
  sdName: "lineBreakType",
24483
- encode: encode$1c,
24484
- decode: decode$14
24555
+ encode: encode$1b,
24556
+ decode: decode$13
24485
24557
  });
24486
- const encode$1b = (attributes) => {
24558
+ const encode$1a = (attributes) => {
24487
24559
  const xmlAttrValue = attributes["w:clear"];
24488
24560
  return xmlAttrValue;
24489
24561
  };
24490
- const decode$13 = (attrs) => {
24562
+ const decode$12 = (attrs) => {
24491
24563
  const { clear } = attrs;
24492
24564
  return clear;
24493
24565
  };
24494
24566
  const attrConfig$F = Object.freeze({
24495
24567
  xmlName: "w:clear",
24496
24568
  sdName: "clear",
24497
- encode: encode$1b,
24498
- decode: decode$13
24569
+ encode: encode$1a,
24570
+ decode: decode$12
24499
24571
  });
24500
- const validXmlAttributes$n = [attrConfig$G, attrConfig$F];
24501
- const XML_NODE_NAME$z = "w:br";
24572
+ const validXmlAttributes$p = [attrConfig$G, attrConfig$F];
24573
+ const XML_NODE_NAME$y = "w:br";
24502
24574
  const SD_NODE_NAME$h = "lineBreak";
24503
- const encode$1a = (_2, encodedAttrs) => {
24575
+ const encode$19 = (_2, encodedAttrs) => {
24504
24576
  const isPageBreak = encodedAttrs?.lineBreakType === "page";
24505
24577
  const translated = {
24506
24578
  type: isPageBreak ? "hardBreak" : "lineBreak"
@@ -24510,7 +24582,7 @@ const encode$1a = (_2, encodedAttrs) => {
24510
24582
  }
24511
24583
  return translated;
24512
24584
  };
24513
- const decode$12 = (params, decodedAttrs) => {
24585
+ const decode$11 = (params, decodedAttrs) => {
24514
24586
  const { node } = params;
24515
24587
  if (!node) return;
24516
24588
  const wBreak = { name: "w:br" };
@@ -24527,39 +24599,39 @@ const decode$12 = (params, decodedAttrs) => {
24527
24599
  };
24528
24600
  return translated;
24529
24601
  };
24530
- const config$w = {
24531
- xmlName: XML_NODE_NAME$z,
24602
+ const config$x = {
24603
+ xmlName: XML_NODE_NAME$y,
24532
24604
  sdNodeOrKeyName: SD_NODE_NAME$h,
24533
24605
  type: NodeTranslator.translatorTypes.NODE,
24534
- encode: encode$1a,
24535
- decode: decode$12,
24536
- attributes: validXmlAttributes$n
24606
+ encode: encode$19,
24607
+ decode: decode$11,
24608
+ attributes: validXmlAttributes$p
24537
24609
  };
24538
- const translator$1a = NodeTranslator.from(config$w);
24539
- const encode$19 = (attributes) => attributes?.["w:val"];
24540
- const decode$11 = (attrs) => attrs?.highlight;
24610
+ const translator$1r = NodeTranslator.from(config$x);
24611
+ const encode$18 = (attributes) => attributes?.["w:val"];
24612
+ const decode$10 = (attrs) => attrs?.highlight;
24541
24613
  const attrConfig$E = Object.freeze({
24542
24614
  xmlName: "w:val",
24543
24615
  sdName: "highlight",
24544
- encode: encode$19,
24545
- decode: decode$11
24616
+ encode: encode$18,
24617
+ decode: decode$10
24546
24618
  });
24547
- const validXmlAttributes$m = [attrConfig$E];
24548
- const XML_NODE_NAME$y = "w:highlight";
24549
- const SD_ATTR_KEY$g = "highlight";
24619
+ const validXmlAttributes$o = [attrConfig$E];
24620
+ const XML_NODE_NAME$x = "w:highlight";
24621
+ const SD_ATTR_KEY$f = "highlight";
24550
24622
  const DISABLED_TOKENS = /* @__PURE__ */ new Set(["transparent", "none", "inherit"]);
24551
- const encode$18 = (params, encodedAttrs = {}) => {
24623
+ const encode$17 = (params, encodedAttrs = {}) => {
24552
24624
  const { nodes } = params;
24553
24625
  const node = nodes?.[0];
24554
24626
  const value = encodedAttrs.highlight ?? node?.attributes?.["w:val"];
24555
24627
  return {
24556
24628
  type: "attr",
24557
- xmlName: XML_NODE_NAME$y,
24558
- sdNodeOrKeyName: SD_ATTR_KEY$g,
24629
+ xmlName: XML_NODE_NAME$x,
24630
+ sdNodeOrKeyName: SD_ATTR_KEY$f,
24559
24631
  attributes: { "w:val": value ?? null }
24560
24632
  };
24561
24633
  };
24562
- const decode$10 = (params) => {
24634
+ const decode$$ = (params) => {
24563
24635
  const attrs = params?.node?.attrs || {};
24564
24636
  const highlightValue = attrs.highlight ?? attrs.color ?? null;
24565
24637
  if (!highlightValue) return void 0;
@@ -24567,14 +24639,14 @@ const decode$10 = (params) => {
24567
24639
  if (!normalizedValue) return void 0;
24568
24640
  if (DISABLED_TOKENS.has(normalizedValue)) {
24569
24641
  return {
24570
- name: XML_NODE_NAME$y,
24642
+ name: XML_NODE_NAME$x,
24571
24643
  attributes: { "w:val": "none" }
24572
24644
  };
24573
24645
  }
24574
24646
  const keyword = getDocxHighlightKeywordFromHex(highlightValue);
24575
24647
  if (keyword) {
24576
24648
  return {
24577
- name: XML_NODE_NAME$y,
24649
+ name: XML_NODE_NAME$x,
24578
24650
  attributes: { "w:val": keyword }
24579
24651
  };
24580
24652
  }
@@ -24589,63 +24661,63 @@ const decode$10 = (params) => {
24589
24661
  }
24590
24662
  };
24591
24663
  };
24592
- const config$v = {
24593
- xmlName: XML_NODE_NAME$y,
24594
- sdNodeOrKeyName: SD_ATTR_KEY$g,
24664
+ const config$w = {
24665
+ xmlName: XML_NODE_NAME$x,
24666
+ sdNodeOrKeyName: SD_ATTR_KEY$f,
24595
24667
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
24596
- encode: encode$18,
24597
- decode: decode$10,
24598
- attributes: validXmlAttributes$m
24668
+ encode: encode$17,
24669
+ decode: decode$$,
24670
+ attributes: validXmlAttributes$o
24599
24671
  };
24600
- const translator$19 = NodeTranslator.from(config$v);
24601
- const encode$17 = (attributes) => {
24672
+ const translator$1q = NodeTranslator.from(config$w);
24673
+ const encode$16 = (attributes) => {
24602
24674
  return attributes["w:val"];
24603
24675
  };
24604
- const decode$$ = (attrs) => {
24676
+ const decode$_ = (attrs) => {
24605
24677
  const { tabSize } = attrs || {};
24606
24678
  return tabSize;
24607
24679
  };
24608
24680
  const attrConfig$D = Object.freeze({
24609
24681
  xmlName: "w:val",
24610
24682
  sdName: "tabSize",
24611
- encode: encode$17,
24612
- decode: decode$$
24683
+ encode: encode$16,
24684
+ decode: decode$_
24613
24685
  });
24614
- const encode$16 = (attributes) => {
24686
+ const encode$15 = (attributes) => {
24615
24687
  return attributes["w:leader"];
24616
24688
  };
24617
- const decode$_ = (attrs) => {
24689
+ const decode$Z = (attrs) => {
24618
24690
  const { leader } = attrs || {};
24619
24691
  return leader;
24620
24692
  };
24621
24693
  const attrConfig$C = Object.freeze({
24622
24694
  xmlName: "w:leader",
24623
24695
  sdName: "leader",
24624
- encode: encode$16,
24625
- decode: decode$_
24696
+ encode: encode$15,
24697
+ decode: decode$Z
24626
24698
  });
24627
- const encode$15 = (attributes) => {
24699
+ const encode$14 = (attributes) => {
24628
24700
  return attributes["w:pos"];
24629
24701
  };
24630
- const decode$Z = (attrs) => {
24702
+ const decode$Y = (attrs) => {
24631
24703
  const { pos } = attrs || {};
24632
24704
  return pos;
24633
24705
  };
24634
24706
  const attrConfig$B = Object.freeze({
24635
24707
  xmlName: "w:pos",
24636
24708
  sdName: "pos",
24637
- encode: encode$15,
24638
- decode: decode$Z
24709
+ encode: encode$14,
24710
+ decode: decode$Y
24639
24711
  });
24640
- const validXmlAttributes$l = [attrConfig$D, attrConfig$B, attrConfig$C];
24641
- const XML_NODE_NAME$x = "w:tab";
24712
+ const validXmlAttributes$n = [attrConfig$D, attrConfig$B, attrConfig$C];
24713
+ const XML_NODE_NAME$w = "w:tab";
24642
24714
  const SD_NODE_NAME$g = "tab";
24643
- const encode$14 = (_2, encodedAttrs = {}) => {
24715
+ const encode$13 = (_2, encodedAttrs = {}) => {
24644
24716
  const translated = { type: "tab" };
24645
24717
  if (encodedAttrs) translated.attrs = { ...encodedAttrs };
24646
24718
  return translated;
24647
24719
  };
24648
- const decode$Y = (params, decodedAttrs = {}) => {
24720
+ const decode$X = (params, decodedAttrs = {}) => {
24649
24721
  const { node } = params || {};
24650
24722
  if (!node) return;
24651
24723
  const wTab = { name: "w:tab" };
@@ -24661,15 +24733,15 @@ const decode$Y = (params, decodedAttrs = {}) => {
24661
24733
  }
24662
24734
  return translated;
24663
24735
  };
24664
- const config$u = {
24665
- xmlName: XML_NODE_NAME$x,
24736
+ const config$v = {
24737
+ xmlName: XML_NODE_NAME$w,
24666
24738
  sdNodeOrKeyName: SD_NODE_NAME$g,
24667
24739
  type: NodeTranslator.translatorTypes.NODE,
24668
- encode: encode$14,
24669
- decode: decode$Y,
24670
- attributes: validXmlAttributes$l
24740
+ encode: encode$13,
24741
+ decode: decode$X,
24742
+ attributes: validXmlAttributes$n
24671
24743
  };
24672
- const translator$18 = NodeTranslator.from(config$u);
24744
+ const translator$1p = NodeTranslator.from(config$v);
24673
24745
  const mergeTextNodes = (nodes) => {
24674
24746
  if (!nodes || !Array.isArray(nodes)) {
24675
24747
  return nodes;
@@ -24895,9 +24967,9 @@ const parseParagraphBorders = (pBdr) => {
24895
24967
  const { attributes: a } = el;
24896
24968
  if (a["w:val"] === "nil" || a["w:val"] === void 0) return;
24897
24969
  let sizePx;
24898
- if (a["w:sz"] !== void 0) sizePx = eigthPointsToPixels(a["w:sz"]);
24970
+ if (a["w:sz"] !== void 0) sizePx = eighthPointsToPixels(a["w:sz"]);
24899
24971
  let spacePx;
24900
- if (a["w:space"] !== void 0) spacePx = eigthPointsToPixels(a["w:space"]);
24972
+ if (a["w:space"] !== void 0) spacePx = eighthPointsToPixels(a["w:space"]);
24901
24973
  result[side] = {
24902
24974
  val: a["w:val"],
24903
24975
  size: sizePx,
@@ -25187,91 +25259,91 @@ const handleParagraphNode$1 = (params) => {
25187
25259
  }
25188
25260
  return schemaNode;
25189
25261
  };
25190
- const encode$13 = (attributes) => {
25262
+ const encode$12 = (attributes) => {
25191
25263
  return attributes["w:rsidDel"];
25192
25264
  };
25193
- const decode$X = (attrs) => {
25265
+ const decode$W = (attrs) => {
25194
25266
  return attrs.rsidDel;
25195
25267
  };
25196
25268
  const attrConfig$A = Object.freeze({
25197
25269
  xmlName: "w:rsidDel",
25198
25270
  sdName: "rsidDel",
25199
- encode: encode$13,
25200
- decode: decode$X
25271
+ encode: encode$12,
25272
+ decode: decode$W
25201
25273
  });
25202
- const encode$12 = (attributes) => {
25274
+ const encode$11 = (attributes) => {
25203
25275
  return attributes["w:rsidP"];
25204
25276
  };
25205
- const decode$W = (attrs) => {
25277
+ const decode$V = (attrs) => {
25206
25278
  return attrs.rsidP;
25207
25279
  };
25208
25280
  const attrConfig$z = Object.freeze({
25209
25281
  xmlName: "w:rsidP",
25210
25282
  sdName: "rsidP",
25211
- encode: encode$12,
25212
- decode: decode$W
25283
+ encode: encode$11,
25284
+ decode: decode$V
25213
25285
  });
25214
- const encode$11 = (attributes) => {
25286
+ const encode$10 = (attributes) => {
25215
25287
  return attributes["w:rsidR"];
25216
25288
  };
25217
- const decode$V = (attrs) => {
25289
+ const decode$U = (attrs) => {
25218
25290
  return attrs.rsidR;
25219
25291
  };
25220
25292
  const attrConfig$y = Object.freeze({
25221
25293
  xmlName: "w:rsidR",
25222
25294
  sdName: "rsidR",
25223
- encode: encode$11,
25224
- decode: decode$V
25295
+ encode: encode$10,
25296
+ decode: decode$U
25225
25297
  });
25226
- const encode$10 = (attributes) => {
25298
+ const encode$$ = (attributes) => {
25227
25299
  return attributes["w:rsidRPr"];
25228
25300
  };
25229
- const decode$U = (attrs) => {
25301
+ const decode$T = (attrs) => {
25230
25302
  return attrs.rsidRPr;
25231
25303
  };
25232
25304
  const attrConfig$x = Object.freeze({
25233
25305
  xmlName: "w:rsidRPr",
25234
25306
  sdName: "rsidRPr",
25235
- encode: encode$10,
25236
- decode: decode$U
25307
+ encode: encode$$,
25308
+ decode: decode$T
25237
25309
  });
25238
- const encode$$ = (attributes) => {
25310
+ const encode$_ = (attributes) => {
25239
25311
  return attributes["w:rsidRDefault"];
25240
25312
  };
25241
- const decode$T = (attrs) => {
25313
+ const decode$S = (attrs) => {
25242
25314
  return attrs.rsidRDefault;
25243
25315
  };
25244
25316
  const attrConfig$w = Object.freeze({
25245
25317
  xmlName: "w:rsidRDefault",
25246
25318
  sdName: "rsidRDefault",
25247
- encode: encode$$,
25248
- decode: decode$T
25319
+ encode: encode$_,
25320
+ decode: decode$S
25249
25321
  });
25250
- const encode$_ = (attributes) => {
25322
+ const encode$Z = (attributes) => {
25251
25323
  return attributes["w14:paraId"];
25252
25324
  };
25253
- const decode$S = (attrs) => {
25325
+ const decode$R = (attrs) => {
25254
25326
  return attrs.paraId;
25255
25327
  };
25256
25328
  const attrConfig$v = Object.freeze({
25257
25329
  xmlName: "w14:paraId",
25258
25330
  sdName: "paraId",
25259
- encode: encode$_,
25260
- decode: decode$S
25331
+ encode: encode$Z,
25332
+ decode: decode$R
25261
25333
  });
25262
- const encode$Z = (attributes) => {
25334
+ const encode$Y = (attributes) => {
25263
25335
  return attributes["w14:textId"];
25264
25336
  };
25265
- const decode$R = (attrs) => {
25337
+ const decode$Q = (attrs) => {
25266
25338
  return attrs.textId;
25267
25339
  };
25268
25340
  const attrConfig$u = Object.freeze({
25269
25341
  xmlName: "w14:textId",
25270
25342
  sdName: "textId",
25271
- encode: encode$Z,
25272
- decode: decode$R
25343
+ encode: encode$Y,
25344
+ decode: decode$Q
25273
25345
  });
25274
- const validXmlAttributes$k = [
25346
+ const validXmlAttributes$m = [
25275
25347
  attrConfig$v,
25276
25348
  attrConfig$u,
25277
25349
  attrConfig$y,
@@ -25280,9 +25352,9 @@ const validXmlAttributes$k = [
25280
25352
  attrConfig$x,
25281
25353
  attrConfig$A
25282
25354
  ];
25283
- const XML_NODE_NAME$w = "w:p";
25355
+ const XML_NODE_NAME$v = "w:p";
25284
25356
  const SD_NODE_NAME$f = "paragraph";
25285
- const encode$Y = (params, encodedAttrs = {}) => {
25357
+ const encode$X = (params, encodedAttrs = {}) => {
25286
25358
  const node = handleParagraphNode$1(params);
25287
25359
  if (!node) return void 0;
25288
25360
  if (encodedAttrs && Object.keys(encodedAttrs).length) {
@@ -25290,7 +25362,7 @@ const encode$Y = (params, encodedAttrs = {}) => {
25290
25362
  }
25291
25363
  return node;
25292
25364
  };
25293
- const decode$Q = (params, decodedAttrs = {}) => {
25365
+ const decode$P = (params, decodedAttrs = {}) => {
25294
25366
  const translated = translateParagraphNode(params);
25295
25367
  if (!translated) return void 0;
25296
25368
  if (decodedAttrs && Object.keys(decodedAttrs).length) {
@@ -25298,16 +25370,16 @@ const decode$Q = (params, decodedAttrs = {}) => {
25298
25370
  }
25299
25371
  return translated;
25300
25372
  };
25301
- const config$t = {
25302
- xmlName: XML_NODE_NAME$w,
25373
+ const config$u = {
25374
+ xmlName: XML_NODE_NAME$v,
25303
25375
  sdNodeOrKeyName: SD_NODE_NAME$f,
25304
25376
  type: NodeTranslator.translatorTypes.NODE,
25305
- encode: encode$Y,
25306
- decode: decode$Q,
25307
- attributes: validXmlAttributes$k
25377
+ encode: encode$X,
25378
+ decode: decode$P,
25379
+ attributes: validXmlAttributes$m
25308
25380
  };
25309
- const translator$17 = NodeTranslator.from(config$t);
25310
- const encode$X = (attributes) => {
25381
+ const translator$1o = NodeTranslator.from(config$u);
25382
+ const encode$W = (attributes) => {
25311
25383
  const raw = attributes?.["w:val"];
25312
25384
  if (raw === void 0 || raw === null) return void 0;
25313
25385
  if (typeof raw === "boolean") return raw;
@@ -25317,24 +25389,24 @@ const encode$X = (attributes) => {
25317
25389
  if (val === "1" || val === "true" || val === "on") return true;
25318
25390
  return void 0;
25319
25391
  };
25320
- const decode$P = (runProps) => {
25392
+ const decode$O = (runProps) => {
25321
25393
  if (runProps?.bold === false) return "0";
25322
25394
  return void 0;
25323
25395
  };
25324
25396
  const attrConfig$t = Object.freeze({
25325
25397
  xmlName: "w:val",
25326
25398
  sdName: "bold",
25327
- encode: encode$X,
25328
- decode: decode$P
25399
+ encode: encode$W,
25400
+ decode: decode$O
25329
25401
  });
25330
- const validXmlAttributes$j = [attrConfig$t];
25331
- const XML_NODE_NAME$v = "w:b";
25332
- const SD_ATTR_KEY$f = "bold";
25333
- const encode$W = (params, encodedAttrs = {}) => {
25402
+ const validXmlAttributes$l = [attrConfig$t];
25403
+ const XML_NODE_NAME$u = "w:b";
25404
+ const SD_ATTR_KEY$e = "bold";
25405
+ const encode$V = (params, encodedAttrs = {}) => {
25334
25406
  const { nodes } = params;
25335
25407
  const node = nodes[0];
25336
25408
  if (!node) return void 0;
25337
- const val = encodedAttrs?.[SD_ATTR_KEY$f];
25409
+ const val = encodedAttrs?.[SD_ATTR_KEY$e];
25338
25410
  let attributes;
25339
25411
  if (val === false) attributes = { "w:val": "0" };
25340
25412
  else if (val === true)
@@ -25342,85 +25414,85 @@ const encode$W = (params, encodedAttrs = {}) => {
25342
25414
  else attributes = node.attributes || {};
25343
25415
  return {
25344
25416
  type: "attr",
25345
- xmlName: XML_NODE_NAME$v,
25346
- sdNodeOrKeyName: SD_ATTR_KEY$f,
25417
+ xmlName: XML_NODE_NAME$u,
25418
+ sdNodeOrKeyName: SD_ATTR_KEY$e,
25347
25419
  attributes
25348
25420
  };
25349
25421
  };
25350
- const config$s = {
25351
- xmlName: XML_NODE_NAME$v,
25352
- sdNodeOrKeyName: SD_ATTR_KEY$f,
25422
+ const config$t = {
25423
+ xmlName: XML_NODE_NAME$u,
25424
+ sdNodeOrKeyName: SD_ATTR_KEY$e,
25353
25425
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25354
- encode: encode$W,
25355
- attributes: validXmlAttributes$j
25426
+ encode: encode$V,
25427
+ attributes: validXmlAttributes$l
25356
25428
  };
25357
- const translator$16 = NodeTranslator.from(config$s);
25358
- const XML_NODE_NAME$u = "w:i";
25359
- const SD_ATTR_KEY$e = "italic";
25360
- const encode$V = (params) => {
25429
+ const translator$1n = NodeTranslator.from(config$t);
25430
+ const XML_NODE_NAME$t = "w:i";
25431
+ const SD_ATTR_KEY$d = "italic";
25432
+ const encode$U = (params) => {
25361
25433
  const { nodes } = params;
25362
25434
  const node = nodes?.[0];
25363
25435
  if (!node) return void 0;
25364
25436
  return {
25365
25437
  type: "attr",
25366
- xmlName: XML_NODE_NAME$u,
25367
- sdNodeOrKeyName: SD_ATTR_KEY$e,
25438
+ xmlName: XML_NODE_NAME$t,
25439
+ sdNodeOrKeyName: SD_ATTR_KEY$d,
25368
25440
  attributes: {
25369
25441
  "w:val": node.attributes?.["w:val"] ?? null
25370
25442
  }
25371
25443
  };
25372
25444
  };
25373
- const config$r = {
25374
- xmlName: XML_NODE_NAME$u,
25375
- sdNodeOrKeyName: SD_ATTR_KEY$e,
25445
+ const config$s = {
25446
+ xmlName: XML_NODE_NAME$t,
25447
+ sdNodeOrKeyName: SD_ATTR_KEY$d,
25376
25448
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25377
- encode: encode$V
25449
+ encode: encode$U
25378
25450
  };
25379
- const translator$15 = NodeTranslator.from(config$r);
25380
- const encode$U = (attributes) => attributes?.["w:val"];
25381
- const decode$O = (attrs) => attrs?.underline;
25451
+ const translator$1m = NodeTranslator.from(config$s);
25452
+ const encode$T = (attributes) => attributes?.["w:val"];
25453
+ const decode$N = (attrs) => attrs?.underline;
25382
25454
  const attrConfig$s = Object.freeze({
25383
25455
  xmlName: "w:val",
25384
25456
  sdName: "underline",
25385
- encode: encode$U,
25386
- decode: decode$O
25457
+ encode: encode$T,
25458
+ decode: decode$N
25387
25459
  });
25388
- const encode$T = (attributes) => attributes?.["w:color"];
25389
- const decode$N = (attrs) => attrs?.color;
25460
+ const encode$S = (attributes) => attributes?.["w:color"];
25461
+ const decode$M = (attrs) => attrs?.color;
25390
25462
  const attrConfig$r = Object.freeze({
25391
25463
  xmlName: "w:color",
25392
25464
  sdName: "color",
25393
- encode: encode$T,
25394
- decode: decode$N
25465
+ encode: encode$S,
25466
+ decode: decode$M
25395
25467
  });
25396
- const encode$S = (attributes) => attributes?.["w:themeColor"];
25397
- const decode$M = (attrs) => attrs?.themeColor;
25468
+ const encode$R = (attributes) => attributes?.["w:themeColor"];
25469
+ const decode$L = (attrs) => attrs?.themeColor;
25398
25470
  const attrConfig$q = Object.freeze({
25399
25471
  xmlName: "w:themeColor",
25400
25472
  sdName: "themeColor",
25401
- encode: encode$S,
25402
- decode: decode$M
25473
+ encode: encode$R,
25474
+ decode: decode$L
25403
25475
  });
25404
- const encode$R = (attributes) => attributes?.["w:themeTint"];
25405
- const decode$L = (attrs) => attrs?.themeTint;
25476
+ const encode$Q = (attributes) => attributes?.["w:themeTint"];
25477
+ const decode$K = (attrs) => attrs?.themeTint;
25406
25478
  const attrConfig$p = Object.freeze({
25407
25479
  xmlName: "w:themeTint",
25408
25480
  sdName: "themeTint",
25409
- encode: encode$R,
25410
- decode: decode$L
25481
+ encode: encode$Q,
25482
+ decode: decode$K
25411
25483
  });
25412
- const encode$Q = (attributes) => attributes?.["w:themeShade"];
25413
- const decode$K = (attrs) => attrs?.themeShade;
25484
+ const encode$P = (attributes) => attributes?.["w:themeShade"];
25485
+ const decode$J = (attrs) => attrs?.themeShade;
25414
25486
  const attrConfig$o = Object.freeze({
25415
25487
  xmlName: "w:themeShade",
25416
25488
  sdName: "themeShade",
25417
- encode: encode$Q,
25418
- decode: decode$K
25489
+ encode: encode$P,
25490
+ decode: decode$J
25419
25491
  });
25420
- const validXmlAttributes$i = [attrConfig$s, attrConfig$r, attrConfig$q, attrConfig$p, attrConfig$o];
25421
- const XML_NODE_NAME$t = "w:u";
25422
- const SD_ATTR_KEY$d = "underline";
25423
- const encode$P = (params, encodedAttrs = {}) => {
25492
+ const validXmlAttributes$k = [attrConfig$s, attrConfig$r, attrConfig$q, attrConfig$p, attrConfig$o];
25493
+ const XML_NODE_NAME$s = "w:u";
25494
+ const SD_ATTR_KEY$c = "underline";
25495
+ const encode$O = (params, encodedAttrs = {}) => {
25424
25496
  const { nodes } = params;
25425
25497
  const node = nodes?.[0];
25426
25498
  const sourceAttrs = node?.attributes || {};
@@ -25436,12 +25508,12 @@ const encode$P = (params, encodedAttrs = {}) => {
25436
25508
  if (themeShade !== void 0 && themeShade !== null) attributes["w:themeShade"] = themeShade;
25437
25509
  return {
25438
25510
  type: "attr",
25439
- xmlName: XML_NODE_NAME$t,
25440
- sdNodeOrKeyName: SD_ATTR_KEY$d,
25511
+ xmlName: XML_NODE_NAME$s,
25512
+ sdNodeOrKeyName: SD_ATTR_KEY$c,
25441
25513
  attributes
25442
25514
  };
25443
25515
  };
25444
- const decode$J = (params) => {
25516
+ const decode$I = (params) => {
25445
25517
  const attrs = params?.node?.attrs || {};
25446
25518
  const underlineType = attrs.underlineType ?? attrs.underline ?? null;
25447
25519
  const color = attrs.underlineColor ?? attrs.color ?? null;
@@ -25459,20 +25531,20 @@ const decode$J = (params) => {
25459
25531
  if (themeTint) attributes["w:themeTint"] = themeTint;
25460
25532
  if (themeShade) attributes["w:themeShade"] = themeShade;
25461
25533
  return {
25462
- name: XML_NODE_NAME$t,
25534
+ name: XML_NODE_NAME$s,
25463
25535
  attributes
25464
25536
  };
25465
25537
  };
25466
- const config$q = {
25467
- xmlName: XML_NODE_NAME$t,
25468
- sdNodeOrKeyName: SD_ATTR_KEY$d,
25538
+ const config$r = {
25539
+ xmlName: XML_NODE_NAME$s,
25540
+ sdNodeOrKeyName: SD_ATTR_KEY$c,
25469
25541
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25470
- encode: encode$P,
25471
- decode: decode$J,
25472
- attributes: validXmlAttributes$i
25542
+ encode: encode$O,
25543
+ decode: decode$I,
25544
+ attributes: validXmlAttributes$k
25473
25545
  };
25474
- const translator$14 = NodeTranslator.from(config$q);
25475
- const encode$O = (attributes) => {
25546
+ const translator$1l = NodeTranslator.from(config$r);
25547
+ const encode$N = (attributes) => {
25476
25548
  const raw = attributes?.["w:val"];
25477
25549
  if (raw === void 0 || raw === null) return void 0;
25478
25550
  if (typeof raw === "boolean") return raw;
@@ -25482,24 +25554,24 @@ const encode$O = (attributes) => {
25482
25554
  if (val === "1" || val === "true" || val === "on") return true;
25483
25555
  return void 0;
25484
25556
  };
25485
- const decode$I = (attrs) => {
25557
+ const decode$H = (attrs) => {
25486
25558
  if (attrs?.strike === false) return "0";
25487
25559
  return void 0;
25488
25560
  };
25489
25561
  const attrConfig$n = Object.freeze({
25490
25562
  xmlName: "w:val",
25491
25563
  sdName: "strike",
25492
- encode: encode$O,
25493
- decode: decode$I
25564
+ encode: encode$N,
25565
+ decode: decode$H
25494
25566
  });
25495
- const validXmlAttributes$h = [attrConfig$n];
25496
- const XML_NODE_NAME$s = "w:strike";
25497
- const SD_ATTR_KEY$c = "strike";
25498
- const encode$N = (params, encodedAttrs = {}) => {
25567
+ const validXmlAttributes$j = [attrConfig$n];
25568
+ const XML_NODE_NAME$r = "w:strike";
25569
+ const SD_ATTR_KEY$b = "strike";
25570
+ const encode$M = (params, encodedAttrs = {}) => {
25499
25571
  const { nodes } = params;
25500
25572
  const node = nodes?.[0];
25501
25573
  if (!node) return void 0;
25502
- const val = encodedAttrs?.[SD_ATTR_KEY$c];
25574
+ const val = encodedAttrs?.[SD_ATTR_KEY$b];
25503
25575
  let attributes;
25504
25576
  if (val === false) attributes = { "w:val": "0" };
25505
25577
  else if (val === true) attributes = {};
@@ -25508,55 +25580,55 @@ const encode$N = (params, encodedAttrs = {}) => {
25508
25580
  else if (val === true && attributes["w:val"] === void 0) delete attributes["w:val"];
25509
25581
  return {
25510
25582
  type: "attr",
25511
- xmlName: XML_NODE_NAME$s,
25512
- sdNodeOrKeyName: SD_ATTR_KEY$c,
25583
+ xmlName: XML_NODE_NAME$r,
25584
+ sdNodeOrKeyName: SD_ATTR_KEY$b,
25513
25585
  attributes
25514
25586
  };
25515
25587
  };
25516
- const config$p = {
25517
- xmlName: XML_NODE_NAME$s,
25518
- sdNodeOrKeyName: SD_ATTR_KEY$c,
25588
+ const config$q = {
25589
+ xmlName: XML_NODE_NAME$r,
25590
+ sdNodeOrKeyName: SD_ATTR_KEY$b,
25519
25591
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25520
- encode: encode$N,
25521
- attributes: validXmlAttributes$h
25592
+ encode: encode$M,
25593
+ attributes: validXmlAttributes$j
25522
25594
  };
25523
- const translator$13 = NodeTranslator.from(config$p);
25524
- const encode$M = (attributes) => attributes?.["w:val"];
25525
- const decode$H = (attrs) => attrs?.color;
25595
+ const translator$1k = NodeTranslator.from(config$q);
25596
+ const encode$L = (attributes) => attributes?.["w:val"];
25597
+ const decode$G = (attrs) => attrs?.color;
25526
25598
  const attrConfig$m = Object.freeze({
25527
25599
  xmlName: "w:val",
25528
25600
  sdName: "color",
25529
- encode: encode$M,
25530
- decode: decode$H
25601
+ encode: encode$L,
25602
+ decode: decode$G
25531
25603
  });
25532
- const encode$L = (attributes) => attributes?.["w:themeColor"];
25533
- const decode$G = (attrs) => attrs?.themeColor;
25604
+ const encode$K = (attributes) => attributes?.["w:themeColor"];
25605
+ const decode$F = (attrs) => attrs?.themeColor;
25534
25606
  const attrConfig$l = Object.freeze({
25535
25607
  xmlName: "w:themeColor",
25536
25608
  sdName: "themeColor",
25537
- encode: encode$L,
25538
- decode: decode$G
25609
+ encode: encode$K,
25610
+ decode: decode$F
25539
25611
  });
25540
- const encode$K = (attributes) => attributes?.["w:themeTint"];
25541
- const decode$F = (attrs) => attrs?.themeTint;
25612
+ const encode$J = (attributes) => attributes?.["w:themeTint"];
25613
+ const decode$E = (attrs) => attrs?.themeTint;
25542
25614
  const attrConfig$k = Object.freeze({
25543
25615
  xmlName: "w:themeTint",
25544
25616
  sdName: "themeTint",
25545
- encode: encode$K,
25546
- decode: decode$F
25617
+ encode: encode$J,
25618
+ decode: decode$E
25547
25619
  });
25548
- const encode$J = (attributes) => attributes?.["w:themeShade"];
25549
- const decode$E = (attrs) => attrs?.themeShade;
25620
+ const encode$I = (attributes) => attributes?.["w:themeShade"];
25621
+ const decode$D = (attrs) => attrs?.themeShade;
25550
25622
  const attrConfig$j = Object.freeze({
25551
25623
  xmlName: "w:themeShade",
25552
25624
  sdName: "themeShade",
25553
- encode: encode$J,
25554
- decode: decode$E
25625
+ encode: encode$I,
25626
+ decode: decode$D
25555
25627
  });
25556
- const validXmlAttributes$g = [attrConfig$m, attrConfig$l, attrConfig$k, attrConfig$j];
25557
- const XML_NODE_NAME$r = "w:color";
25558
- const SD_ATTR_KEY$b = "color";
25559
- const encode$I = (params, encodedAttrs = {}) => {
25628
+ const validXmlAttributes$i = [attrConfig$m, attrConfig$l, attrConfig$k, attrConfig$j];
25629
+ const XML_NODE_NAME$q = "w:color";
25630
+ const SD_ATTR_KEY$a = "color";
25631
+ const encode$H = (params, encodedAttrs = {}) => {
25560
25632
  const { nodes } = params;
25561
25633
  const node = nodes?.[0];
25562
25634
  const sourceAttrs = node?.attributes || {};
@@ -25571,63 +25643,63 @@ const encode$I = (params, encodedAttrs = {}) => {
25571
25643
  if (themeShade !== void 0 && themeShade !== null) attributes["w:themeShade"] = themeShade;
25572
25644
  return {
25573
25645
  type: "attr",
25574
- xmlName: XML_NODE_NAME$r,
25575
- sdNodeOrKeyName: SD_ATTR_KEY$b,
25646
+ xmlName: XML_NODE_NAME$q,
25647
+ sdNodeOrKeyName: SD_ATTR_KEY$a,
25576
25648
  attributes
25577
25649
  };
25578
25650
  };
25579
- const config$o = {
25580
- xmlName: XML_NODE_NAME$r,
25581
- sdNodeOrKeyName: SD_ATTR_KEY$b,
25651
+ const config$p = {
25652
+ xmlName: XML_NODE_NAME$q,
25653
+ sdNodeOrKeyName: SD_ATTR_KEY$a,
25582
25654
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25583
- encode: encode$I,
25584
- attributes: validXmlAttributes$g
25655
+ encode: encode$H,
25656
+ attributes: validXmlAttributes$i
25585
25657
  };
25586
- const translator$12 = NodeTranslator.from(config$o);
25587
- const encode$H = (attributes) => attributes?.["w:eastAsia"];
25588
- const decode$D = (attrs) => attrs?.eastAsia;
25658
+ const translator$1j = NodeTranslator.from(config$p);
25659
+ const encode$G = (attributes) => attributes?.["w:eastAsia"];
25660
+ const decode$C = (attrs) => attrs?.eastAsia;
25589
25661
  const attrConfig$i = Object.freeze({
25590
25662
  xmlName: "w:eastAsia",
25591
25663
  sdName: "eastAsia",
25592
- encode: encode$H,
25593
- decode: decode$D
25664
+ encode: encode$G,
25665
+ decode: decode$C
25594
25666
  });
25595
- const encode$G = (attributes) => attributes?.["w:ascii"];
25596
- const decode$C = (attrs) => attrs?.ascii;
25667
+ const encode$F = (attributes) => attributes?.["w:ascii"];
25668
+ const decode$B = (attrs) => attrs?.ascii;
25597
25669
  const attrConfig$h = Object.freeze({
25598
25670
  xmlName: "w:ascii",
25599
25671
  sdName: "ascii",
25600
- encode: encode$G,
25601
- decode: decode$C
25672
+ encode: encode$F,
25673
+ decode: decode$B
25602
25674
  });
25603
- const encode$F = (attributes) => attributes?.["w:hAnsi"];
25604
- const decode$B = (attrs) => attrs?.hAnsi;
25675
+ const encode$E = (attributes) => attributes?.["w:hAnsi"];
25676
+ const decode$A = (attrs) => attrs?.hAnsi;
25605
25677
  const attrConfig$g = Object.freeze({
25606
25678
  xmlName: "w:hAnsi",
25607
25679
  sdName: "hAnsi",
25608
- encode: encode$F,
25609
- decode: decode$B
25680
+ encode: encode$E,
25681
+ decode: decode$A
25610
25682
  });
25611
- const encode$E = (attributes) => attributes?.["w:cs"];
25612
- const decode$A = (attrs) => attrs?.cs;
25683
+ const encode$D = (attributes) => attributes?.["w:cs"];
25684
+ const decode$z = (attrs) => attrs?.cs;
25613
25685
  const attrConfig$f = Object.freeze({
25614
25686
  xmlName: "w:cs",
25615
25687
  sdName: "cs",
25616
- encode: encode$E,
25617
- decode: decode$A
25618
- });
25619
- const encode$D = (attributes) => attributes?.["w:val"];
25620
- const decode$z = (attrs) => attrs?.value;
25688
+ encode: encode$D,
25689
+ decode: decode$z
25690
+ });
25691
+ const encode$C = (attributes) => attributes?.["w:val"];
25692
+ const decode$y = (attrs) => attrs?.value;
25621
25693
  const attrConfig$e = Object.freeze({
25622
25694
  xmlName: "w:val",
25623
25695
  sdName: "value",
25624
- encode: encode$D,
25625
- decode: decode$z
25696
+ encode: encode$C,
25697
+ decode: decode$y
25626
25698
  });
25627
- const validXmlAttributes$f = [attrConfig$i, attrConfig$h, attrConfig$g, attrConfig$f, attrConfig$e];
25628
- const XML_NODE_NAME$q = "w:rFonts";
25629
- const SD_ATTR_KEY$a = "fontFamily";
25630
- const encode$C = (params, encodedAttrs = {}) => {
25699
+ const validXmlAttributes$h = [attrConfig$i, attrConfig$h, attrConfig$g, attrConfig$f, attrConfig$e];
25700
+ const XML_NODE_NAME$p = "w:rFonts";
25701
+ const SD_ATTR_KEY$9 = "fontFamily";
25702
+ const encode$B = (params, encodedAttrs = {}) => {
25631
25703
  const { nodes } = params;
25632
25704
  const node = nodes?.[0];
25633
25705
  const sourceAttrs = node?.attributes || {};
@@ -25651,111 +25723,119 @@ const encode$C = (params, encodedAttrs = {}) => {
25651
25723
  attributes["w:val"] = attributes["w:eastAsia"];
25652
25724
  }
25653
25725
  if (attributes["w:val"] === void 0) delete attributes["w:val"];
25726
+ if (params.inlineDocumentFonts) {
25727
+ const font = attributes["w:ascii"];
25728
+ if (font) {
25729
+ if (!params.inlineDocumentFonts.includes(font)) {
25730
+ params.inlineDocumentFonts.push(font);
25731
+ }
25732
+ }
25733
+ }
25654
25734
  return {
25655
25735
  type: "attr",
25656
- xmlName: XML_NODE_NAME$q,
25657
- sdNodeOrKeyName: SD_ATTR_KEY$a,
25736
+ xmlName: XML_NODE_NAME$p,
25737
+ sdNodeOrKeyName: SD_ATTR_KEY$9,
25658
25738
  attributes
25659
25739
  };
25660
25740
  };
25661
- const config$n = {
25662
- xmlName: XML_NODE_NAME$q,
25663
- sdNodeOrKeyName: SD_ATTR_KEY$a,
25741
+ const config$o = {
25742
+ xmlName: XML_NODE_NAME$p,
25743
+ sdNodeOrKeyName: SD_ATTR_KEY$9,
25664
25744
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25665
- encode: encode$C,
25666
- attributes: validXmlAttributes$f
25745
+ encode: encode$B,
25746
+ attributes: validXmlAttributes$h
25667
25747
  };
25668
- const translator$11 = NodeTranslator.from(config$n);
25669
- const encode$B = (attributes) => attributes?.["w:val"];
25670
- const decode$y = (attrs) => attrs?.styleId;
25748
+ const translator$1i = NodeTranslator.from(config$o);
25749
+ const encode$A = (attributes) => attributes?.["w:val"];
25750
+ const decode$x = (attrs) => attrs?.styleId;
25671
25751
  const attrConfig$d = Object.freeze({
25672
25752
  xmlName: "w:val",
25673
25753
  sdName: "styleId",
25674
- encode: encode$B,
25675
- decode: decode$y
25754
+ encode: encode$A,
25755
+ decode: decode$x
25676
25756
  });
25677
- const validXmlAttributes$e = [attrConfig$d];
25678
- const XML_NODE_NAME$p = "w:rStyle";
25679
- const SD_ATTR_KEY$9 = "styleId";
25680
- const encode$A = (params, encodedAttrs = {}) => {
25757
+ const validXmlAttributes$g = [attrConfig$d];
25758
+ const XML_NODE_NAME$o = "w:rStyle";
25759
+ const SD_ATTR_KEY$8 = "styleId";
25760
+ const encode$z = (params, encodedAttrs = {}) => {
25681
25761
  const { nodes } = params;
25682
25762
  const node = nodes?.[0];
25683
25763
  const value = encodedAttrs.styleId ?? node?.attributes?.["w:val"];
25684
25764
  return {
25685
25765
  type: "attr",
25686
- xmlName: XML_NODE_NAME$p,
25687
- sdNodeOrKeyName: SD_ATTR_KEY$9,
25766
+ xmlName: XML_NODE_NAME$o,
25767
+ sdNodeOrKeyName: SD_ATTR_KEY$8,
25688
25768
  attributes: { "w:val": value ?? null }
25689
25769
  };
25690
25770
  };
25691
- const config$m = {
25692
- xmlName: XML_NODE_NAME$p,
25693
- sdNodeOrKeyName: SD_ATTR_KEY$9,
25771
+ const config$n = {
25772
+ xmlName: XML_NODE_NAME$o,
25773
+ sdNodeOrKeyName: SD_ATTR_KEY$8,
25694
25774
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25695
- encode: encode$A,
25696
- attributes: validXmlAttributes$e
25775
+ encode: encode$z,
25776
+ attributes: validXmlAttributes$g
25697
25777
  };
25698
- const translator$10 = NodeTranslator.from(config$m);
25699
- const encode$z = (attributes) => attributes?.["w:val"];
25700
- const decode$x = (attrs) => attrs?.fontSize;
25778
+ const translator$1h = NodeTranslator.from(config$n);
25779
+ const encode$y = (attributes) => attributes?.["w:val"];
25780
+ const decode$w = (attrs) => attrs?.fontSize;
25701
25781
  const attrConfig$c = Object.freeze({
25702
25782
  xmlName: "w:val",
25703
25783
  sdName: "fontSize",
25704
- encode: encode$z,
25705
- decode: decode$x
25784
+ encode: encode$y,
25785
+ decode: decode$w
25706
25786
  });
25707
- const validXmlAttributes$d = [attrConfig$c];
25708
- const XML_NODE_NAME$o = "w:sz";
25709
- const SD_ATTR_KEY$8 = "fontSize";
25710
- const encode$y = (params, encodedAttrs = {}) => {
25787
+ const validXmlAttributes$f = [attrConfig$c];
25788
+ const XML_NODE_NAME$n = "w:sz";
25789
+ const SD_ATTR_KEY$7 = "fontSize";
25790
+ const encode$x = (params, encodedAttrs = {}) => {
25711
25791
  const { nodes } = params;
25712
25792
  const node = nodes?.[0];
25713
25793
  const value = encodedAttrs.fontSize ?? node?.attributes?.["w:val"];
25714
25794
  return {
25715
25795
  type: "attr",
25716
- xmlName: XML_NODE_NAME$o,
25717
- sdNodeOrKeyName: SD_ATTR_KEY$8,
25796
+ xmlName: XML_NODE_NAME$n,
25797
+ sdNodeOrKeyName: SD_ATTR_KEY$7,
25718
25798
  attributes: { "w:val": value ?? null }
25719
25799
  };
25720
25800
  };
25721
- const config$l = {
25722
- xmlName: XML_NODE_NAME$o,
25723
- sdNodeOrKeyName: SD_ATTR_KEY$8,
25801
+ const config$m = {
25802
+ xmlName: XML_NODE_NAME$n,
25803
+ sdNodeOrKeyName: SD_ATTR_KEY$7,
25724
25804
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25725
- encode: encode$y,
25726
- attributes: validXmlAttributes$d
25805
+ encode: encode$x,
25806
+ attributes: validXmlAttributes$f
25727
25807
  };
25728
- const translator$$ = NodeTranslator.from(config$l);
25729
- const encode$x = (attributes) => attributes?.["w:val"];
25730
- const decode$w = (attrs) => attrs?.fontSizeCs;
25808
+ const translator$1g = NodeTranslator.from(config$m);
25809
+ const encode$w = (attributes) => attributes?.["w:val"];
25810
+ const decode$v = (attrs) => attrs?.fontSizeCs;
25731
25811
  const attrConfig$b = Object.freeze({
25732
25812
  xmlName: "w:val",
25733
25813
  sdName: "fontSizeCs",
25734
- encode: encode$x,
25735
- decode: decode$w
25814
+ encode: encode$w,
25815
+ decode: decode$v
25736
25816
  });
25737
- const validXmlAttributes$c = [attrConfig$b];
25738
- const XML_NODE_NAME$n = "w:szCs";
25739
- const SD_ATTR_KEY$7 = "fontSizeCs";
25740
- const encode$w = (params, encodedAttrs = {}) => {
25817
+ const validXmlAttributes$e = [attrConfig$b];
25818
+ const XML_NODE_NAME$m = "w:szCs";
25819
+ const SD_ATTR_KEY$6 = "fontSizeCs";
25820
+ const encode$v = (params, encodedAttrs = {}) => {
25741
25821
  const { nodes } = params;
25742
25822
  const node = nodes?.[0];
25743
25823
  const value = encodedAttrs.fontSizeCs ?? node?.attributes?.["w:val"];
25744
25824
  return {
25745
25825
  type: "attr",
25746
- xmlName: XML_NODE_NAME$n,
25747
- sdNodeOrKeyName: SD_ATTR_KEY$7,
25826
+ xmlName: XML_NODE_NAME$m,
25827
+ sdNodeOrKeyName: SD_ATTR_KEY$6,
25748
25828
  attributes: { "w:val": value ?? null }
25749
25829
  };
25750
25830
  };
25751
- const config$k = {
25752
- xmlName: XML_NODE_NAME$n,
25753
- sdNodeOrKeyName: SD_ATTR_KEY$7,
25831
+ const config$l = {
25832
+ xmlName: XML_NODE_NAME$m,
25833
+ sdNodeOrKeyName: SD_ATTR_KEY$6,
25754
25834
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25755
- encode: encode$w,
25756
- attributes: validXmlAttributes$c
25835
+ encode: encode$v,
25836
+ attributes: validXmlAttributes$e
25757
25837
  };
25758
- const translator$_ = NodeTranslator.from(config$k);
25838
+ const translator$1f = NodeTranslator.from(config$l);
25759
25839
  const generateV2HandlerEntity = (handlerName, translator2) => ({
25760
25840
  handlerName,
25761
25841
  handler: (params) => {
@@ -25779,7 +25859,7 @@ function createSingleAttrPropertyHandler(xmlName, sdName = null, attrName = "w:v
25779
25859
  xmlName,
25780
25860
  sdNodeOrKeyName: sdName,
25781
25861
  encode: ({ nodes }) => {
25782
- return transformEncode(nodes[0].attributes[attrName]) ?? void 0;
25862
+ return transformEncode(nodes[0]?.attributes?.[attrName]) ?? void 0;
25783
25863
  },
25784
25864
  decode: ({ node }) => {
25785
25865
  const value = node.attrs?.[sdName] != null ? transformDecode(node.attrs[sdName]) : void 0;
@@ -25811,8 +25891,32 @@ function createBorderPropertyHandler(xmlName, sdName = null) {
25811
25891
  xmlName,
25812
25892
  sdNodeOrKeyName: sdName,
25813
25893
  attributes: [
25814
- createAttributeHandler("w:val"),
25815
- createAttributeHandler("w:color"),
25894
+ createAttributeHandler(
25895
+ "w:val",
25896
+ "val",
25897
+ (v2) => v2 === "nil" ? "none" : v2,
25898
+ (v2) => v2 === "none" ? "nil" : v2
25899
+ ),
25900
+ createAttributeHandler(
25901
+ "w:color",
25902
+ "color",
25903
+ (v2) => {
25904
+ if (v2 === "auto") {
25905
+ return null;
25906
+ } else if (v2) {
25907
+ return `#${v2}`;
25908
+ } else {
25909
+ return void 0;
25910
+ }
25911
+ },
25912
+ (v2) => {
25913
+ if (v2) {
25914
+ return v2.replace("#", "");
25915
+ } else {
25916
+ return void 0;
25917
+ }
25918
+ }
25919
+ ),
25816
25920
  createAttributeHandler("w:themeColor"),
25817
25921
  createAttributeHandler("w:themeTint"),
25818
25922
  createAttributeHandler("w:themeShade"),
@@ -25878,6 +25982,37 @@ function decodeProperties(translatorsBySdName, properties) {
25878
25982
  });
25879
25983
  return elements;
25880
25984
  }
25985
+ function createNestedPropertiesTranslator(xmlName, sdName, propertyTranslators2, defaultEncodedAttrs = {}) {
25986
+ const propertyTranslatorsByXmlName = {};
25987
+ const propertyTranslatorsBySdName = {};
25988
+ propertyTranslators2.forEach((translator2) => {
25989
+ propertyTranslatorsByXmlName[translator2.xmlName] = translator2;
25990
+ propertyTranslatorsBySdName[translator2.sdNodeOrKeyName] = translator2;
25991
+ });
25992
+ return {
25993
+ xmlName,
25994
+ sdNodeOrKeyName: sdName,
25995
+ type: NodeTranslator.translatorTypes.NODE,
25996
+ attributes: [],
25997
+ encode: (params) => {
25998
+ const { nodes } = params;
25999
+ const node = nodes[0];
26000
+ const attributes = { ...defaultEncodedAttrs, ...encodeProperties(node, propertyTranslatorsByXmlName) };
26001
+ return Object.keys(attributes).length > 0 ? attributes : void 0;
26002
+ },
26003
+ decode: (params) => {
26004
+ const currentValue = params.node.attrs?.[sdName];
26005
+ const elements = decodeProperties(propertyTranslatorsBySdName, currentValue);
26006
+ const newNode = {
26007
+ name: xmlName,
26008
+ type: "element",
26009
+ attributes: {},
26010
+ elements
26011
+ };
26012
+ return newNode;
26013
+ }
26014
+ };
26015
+ }
25881
26016
  const parseBoolean = (value) => value != null ? ["1", "true"].includes(value) : void 0;
25882
26017
  const booleanToString = (value) => value != null ? value ? "1" : "0" : void 0;
25883
26018
  const parseInteger = (value) => {
@@ -25889,9 +26024,9 @@ const integerToString = (value) => {
25889
26024
  const intValue = parseInteger(value);
25890
26025
  return intValue != void 0 ? String(intValue) : void 0;
25891
26026
  };
25892
- const XML_NODE_NAME$m = "w:caps";
25893
- const SD_ATTR_KEY$6 = "textTransform";
25894
- const encode$v = (params, encodedAttrs = {}) => {
26027
+ const XML_NODE_NAME$l = "w:caps";
26028
+ const SD_ATTR_KEY$5 = "textTransform";
26029
+ const encode$u = (params, encodedAttrs = {}) => {
25895
26030
  const { nodes } = params;
25896
26031
  const node = nodes[0];
25897
26032
  if (!node) return void 0;
@@ -25903,31 +26038,31 @@ const encode$v = (params, encodedAttrs = {}) => {
25903
26038
  }
25904
26039
  return {
25905
26040
  type: "attr",
25906
- xmlName: XML_NODE_NAME$m,
25907
- sdNodeOrKeyName: SD_ATTR_KEY$6,
25908
- attributes: { [SD_ATTR_KEY$6]: result }
26041
+ xmlName: XML_NODE_NAME$l,
26042
+ sdNodeOrKeyName: SD_ATTR_KEY$5,
26043
+ attributes: { [SD_ATTR_KEY$5]: result }
25909
26044
  };
25910
26045
  };
25911
- const config$j = {
25912
- xmlName: XML_NODE_NAME$m,
25913
- sdNodeOrKeyName: SD_ATTR_KEY$6,
26046
+ const config$k = {
26047
+ xmlName: XML_NODE_NAME$l,
26048
+ sdNodeOrKeyName: SD_ATTR_KEY$5,
25914
26049
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25915
- encode: encode$v,
26050
+ encode: encode$u,
25916
26051
  attributes: [createAttributeHandler("w:val")]
25917
26052
  };
25918
- const translator$Z = NodeTranslator.from(config$j);
26053
+ const translator$1e = NodeTranslator.from(config$k);
25919
26054
  const runPropertyTranslators = Object.freeze({
25920
- "w:b": translator$16,
25921
- "w:i": translator$15,
25922
- "w:u": translator$14,
25923
- "w:strike": translator$13,
25924
- "w:color": translator$12,
25925
- "w:highlight": translator$19,
25926
- "w:rFonts": translator$11,
25927
- "w:rStyle": translator$10,
25928
- "w:sz": translator$$,
25929
- "w:szCs": translator$_,
25930
- "w:caps": translator$Z
26055
+ "w:b": translator$1n,
26056
+ "w:i": translator$1m,
26057
+ "w:u": translator$1l,
26058
+ "w:strike": translator$1k,
26059
+ "w:color": translator$1j,
26060
+ "w:highlight": translator$1q,
26061
+ "w:rFonts": translator$1i,
26062
+ "w:rStyle": translator$1h,
26063
+ "w:sz": translator$1g,
26064
+ "w:szCs": translator$1f,
26065
+ "w:caps": translator$1e
25931
26066
  });
25932
26067
  const rawRunPropertyXmlNames = Object.freeze(["w:lang", "w:shd"]);
25933
26068
  const RAW_CHILD_NAME_SET = new Set(rawRunPropertyXmlNames);
@@ -25941,9 +26076,9 @@ const toRunPropertyEntry = (candidate) => {
25941
26076
  attributes: { ...candidate.attributes || {} }
25942
26077
  };
25943
26078
  };
25944
- const XML_NODE_NAME$l = "w:rPr";
25945
- const SD_ATTR_KEY$5 = "runProperties";
25946
- const encode$u = (params) => {
26079
+ const XML_NODE_NAME$k = "w:rPr";
26080
+ const SD_ATTR_KEY$4 = "runProperties";
26081
+ const encode$t = (params) => {
25947
26082
  const { nodes } = params;
25948
26083
  const node = nodes?.[0] || {};
25949
26084
  const contents = Array.isArray(node.elements) ? node.elements : [];
@@ -25977,16 +26112,16 @@ const encode$u = (params) => {
25977
26112
  attributes: runPropsArray
25978
26113
  };
25979
26114
  };
25980
- const config$i = {
25981
- xmlName: XML_NODE_NAME$l,
25982
- sdNodeOrKeyName: SD_ATTR_KEY$5,
26115
+ const config$j = {
26116
+ xmlName: XML_NODE_NAME$k,
26117
+ sdNodeOrKeyName: SD_ATTR_KEY$4,
25983
26118
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25984
- encode: encode$u
26119
+ encode: encode$t
25985
26120
  };
25986
- const translator$Y = NodeTranslator.from(config$i);
26121
+ const translator$1d = NodeTranslator.from(config$j);
25987
26122
  const EAST_ASIAN_CHARACTER_REGEX = /[\u1100-\u11FF\u2E80-\u2EFF\u2F00-\u2FDF\u3040-\u30FF\u3100-\u312F\u3130-\u318F\u31A0-\u31BF\u3400-\u4DBF\u4E00-\u9FFF\uA960-\uA97F\uAC00-\uD7AF\uF900-\uFAFF\uFF00-\uFFEF]/u;
25988
26123
  const containsEastAsianCharacters = (text) => EAST_ASIAN_CHARACTER_REGEX.test(text);
25989
- const collectRunProperties = (params, rPrNode, translator2 = translator$Y) => {
26124
+ const collectRunProperties = (params, rPrNode, translator2 = translator$1d) => {
25990
26125
  if (!rPrNode) return { entries: [], hadRPr: false, styleChangeMarks: [] };
25991
26126
  const result = translator2.encode({ ...params, nodes: [rPrNode] }) || {};
25992
26127
  let entries = [];
@@ -26459,7 +26594,7 @@ const ensureTrackedWrapper = (runs, trackingMarksByType = /* @__PURE__ */ new Ma
26459
26594
  }
26460
26595
  return runs;
26461
26596
  };
26462
- const XML_NODE_NAME$k = "w:hyperlink";
26597
+ const XML_NODE_NAME$j = "w:hyperlink";
26463
26598
  const SD_NODE_NAME$e = "link";
26464
26599
  const _createAttributeHandler = (xmlName, sdName) => ({
26465
26600
  xmlName,
@@ -26467,7 +26602,7 @@ const _createAttributeHandler = (xmlName, sdName) => ({
26467
26602
  encode: (attributes) => attributes[xmlName],
26468
26603
  decode: (attributes) => attributes[sdName]
26469
26604
  });
26470
- const validXmlAttributes$b = [
26605
+ const validXmlAttributes$d = [
26471
26606
  _createAttributeHandler("w:anchor", "anchor"),
26472
26607
  _createAttributeHandler("w:docLocation", "docLocation"),
26473
26608
  {
@@ -26480,7 +26615,7 @@ const validXmlAttributes$b = [
26480
26615
  _createAttributeHandler("r:id", "rId"),
26481
26616
  _createAttributeHandler("w:tgtFrame", "target")
26482
26617
  ];
26483
- const encode$t = (params, encodedAttrs) => {
26618
+ const encode$s = (params, encodedAttrs) => {
26484
26619
  const { nodes, docx, nodeListHandler } = params;
26485
26620
  const node = nodes[0];
26486
26621
  let href = _resolveHref(docx, encodedAttrs);
@@ -26514,7 +26649,7 @@ const _resolveHref = (docx, encodedAttrs) => {
26514
26649
  }
26515
26650
  return href;
26516
26651
  };
26517
- function decode$v(params) {
26652
+ function decode$u(params) {
26518
26653
  const { hyperlinkGroup = [params.node] } = params.extraParams || {};
26519
26654
  const node = hyperlinkGroup[0];
26520
26655
  const linkMark = node.marks.find((m2) => m2.type === "link");
@@ -26563,55 +26698,55 @@ function _addNewLinkRelationship(params, link) {
26563
26698
  });
26564
26699
  return id;
26565
26700
  }
26566
- const config$h = {
26567
- xmlName: XML_NODE_NAME$k,
26701
+ const config$i = {
26702
+ xmlName: XML_NODE_NAME$j,
26568
26703
  sdNodeOrKeyName: SD_NODE_NAME$e,
26569
26704
  type: NodeTranslator.translatorTypes.NODE,
26570
- encode: encode$t,
26571
- decode: decode$v,
26572
- attributes: validXmlAttributes$b
26705
+ encode: encode$s,
26706
+ decode: decode$u,
26707
+ attributes: validXmlAttributes$d
26573
26708
  };
26574
- const translator$X = NodeTranslator.from(config$h);
26575
- const encode$s = (attributes) => {
26709
+ const translator$1c = NodeTranslator.from(config$i);
26710
+ const encode$r = (attributes) => {
26576
26711
  return attributes["w:rsidR"];
26577
26712
  };
26578
- const decode$u = (attrs) => {
26713
+ const decode$t = (attrs) => {
26579
26714
  return attrs.rsidR;
26580
26715
  };
26581
26716
  const attrConfig$a = Object.freeze({
26582
26717
  xmlName: "w:rsidR",
26583
26718
  sdName: "rsidR",
26584
- encode: encode$s,
26585
- decode: decode$u
26719
+ encode: encode$r,
26720
+ decode: decode$t
26586
26721
  });
26587
- const encode$r = (attributes) => {
26722
+ const encode$q = (attributes) => {
26588
26723
  return attributes["w:rsidRPr"];
26589
26724
  };
26590
- const decode$t = (attrs) => {
26725
+ const decode$s = (attrs) => {
26591
26726
  return attrs.rsidRPr;
26592
26727
  };
26593
26728
  const attrConfig$9 = Object.freeze({
26594
26729
  xmlName: "w:rsidRPr",
26595
26730
  sdName: "rsidRPr",
26596
- encode: encode$r,
26597
- decode: decode$t
26731
+ encode: encode$q,
26732
+ decode: decode$s
26598
26733
  });
26599
- const encode$q = (attributes) => {
26734
+ const encode$p = (attributes) => {
26600
26735
  return attributes["w:rsidDel"];
26601
26736
  };
26602
- const decode$s = (attrs) => {
26737
+ const decode$r = (attrs) => {
26603
26738
  return attrs.rsidDel;
26604
26739
  };
26605
26740
  const attrConfig$8 = Object.freeze({
26606
26741
  xmlName: "w:rsidDel",
26607
26742
  sdName: "rsidDel",
26608
- encode: encode$q,
26609
- decode: decode$s
26743
+ encode: encode$p,
26744
+ decode: decode$r
26610
26745
  });
26611
- const validXmlAttributes$a = [attrConfig$a, attrConfig$9, attrConfig$8];
26612
- const XML_NODE_NAME$j = "w:r";
26746
+ const validXmlAttributes$c = [attrConfig$a, attrConfig$9, attrConfig$8];
26747
+ const XML_NODE_NAME$i = "w:r";
26613
26748
  const SD_KEY_NAME = "run";
26614
- const encode$p = (params, encodedAttrs = {}) => {
26749
+ const encode$o = (params, encodedAttrs = {}) => {
26615
26750
  const { nodes = [], nodeListHandler } = params || {};
26616
26751
  const runNode = nodes[0];
26617
26752
  if (!runNode) return void 0;
@@ -26659,7 +26794,7 @@ const encode$p = (params, encodedAttrs = {}) => {
26659
26794
  }
26660
26795
  return runNodeResult;
26661
26796
  };
26662
- const decode$r = (params, decodedAttrs = {}) => {
26797
+ const decode$q = (params, decodedAttrs = {}) => {
26663
26798
  const { node } = params || {};
26664
26799
  if (!node) return void 0;
26665
26800
  const isLinkNode = node.marks?.some((m2) => m2.type === "link");
@@ -26668,7 +26803,7 @@ const decode$r = (params, decodedAttrs = {}) => {
26668
26803
  ...params.extraParams,
26669
26804
  linkProcessed: true
26670
26805
  };
26671
- return translator$X.decode({ ...params, extraParams });
26806
+ return translator$1c.decode({ ...params, extraParams });
26672
26807
  }
26673
26808
  const { runNode: runNodeForExport, trackingMarksByType } = prepareRunTrackingContext(node);
26674
26809
  const runAttrs = runNodeForExport.attrs || {};
@@ -26724,7 +26859,7 @@ const decode$r = (params, decodedAttrs = {}) => {
26724
26859
  runs.push(trackedClone);
26725
26860
  return;
26726
26861
  }
26727
- const runWrapper = { name: XML_NODE_NAME$j, elements: [] };
26862
+ const runWrapper = { name: XML_NODE_NAME$i, elements: [] };
26728
26863
  applyBaseRunProps(runWrapper);
26729
26864
  if (!Array.isArray(runWrapper.elements)) runWrapper.elements = [];
26730
26865
  runWrapper.elements.push(cloneXmlNode(child));
@@ -26732,7 +26867,7 @@ const decode$r = (params, decodedAttrs = {}) => {
26732
26867
  });
26733
26868
  const trackedRuns = ensureTrackedWrapper(runs, trackingMarksByType);
26734
26869
  if (!trackedRuns.length) {
26735
- const emptyRun = { name: XML_NODE_NAME$j, elements: [] };
26870
+ const emptyRun = { name: XML_NODE_NAME$i, elements: [] };
26736
26871
  applyBaseRunProps(emptyRun);
26737
26872
  trackedRuns.push(emptyRun);
26738
26873
  }
@@ -26746,15 +26881,15 @@ const decode$r = (params, decodedAttrs = {}) => {
26746
26881
  }
26747
26882
  return trackedRuns;
26748
26883
  };
26749
- const config$g = {
26750
- xmlName: XML_NODE_NAME$j,
26884
+ const config$h = {
26885
+ xmlName: XML_NODE_NAME$i,
26751
26886
  sdNodeOrKeyName: SD_KEY_NAME,
26752
26887
  type: NodeTranslator.translatorTypes.NODE,
26753
- encode: encode$p,
26754
- decode: decode$r,
26755
- attributes: validXmlAttributes$a
26888
+ encode: encode$o,
26889
+ decode: decode$q,
26890
+ attributes: validXmlAttributes$c
26756
26891
  };
26757
- const translator$W = NodeTranslator.from(config$g);
26892
+ const translator$1b = NodeTranslator.from(config$h);
26758
26893
  function preProcessVerticalMergeCells(table, { editorSchema }) {
26759
26894
  if (!table || !Array.isArray(table.content)) {
26760
26895
  return table;
@@ -26795,13 +26930,13 @@ function preProcessVerticalMergeCells(table, { editorSchema }) {
26795
26930
  }
26796
26931
  return table;
26797
26932
  }
26798
- const translator$V = NodeTranslator.from({
26933
+ const translator$1a = NodeTranslator.from({
26799
26934
  xmlName: "w:cantSplit",
26800
26935
  sdNodeOrKeyName: "cantSplit",
26801
26936
  encode: ({ nodes }) => ["1", "true"].includes(nodes[0].attributes?.["w:val"] ?? "1"),
26802
26937
  decode: ({ node }) => node.attrs?.cantSplit ? { attributes: {} } : void 0
26803
26938
  });
26804
- const translator$U = NodeTranslator.from({
26939
+ const translator$19 = NodeTranslator.from({
26805
26940
  xmlName: "w:cnfStyle",
26806
26941
  sdNodeOrKeyName: "cnfStyle",
26807
26942
  attributes: [
@@ -26827,8 +26962,8 @@ const translator$U = NodeTranslator.from({
26827
26962
  return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
26828
26963
  }
26829
26964
  });
26830
- const translator$T = NodeTranslator.from(createSingleAttrPropertyHandler("w:divId"));
26831
- const translator$S = NodeTranslator.from(
26965
+ const translator$18 = NodeTranslator.from(createSingleAttrPropertyHandler("w:divId"));
26966
+ const translator$17 = NodeTranslator.from(
26832
26967
  createSingleAttrPropertyHandler(
26833
26968
  "w:gridAfter",
26834
26969
  null,
@@ -26837,7 +26972,7 @@ const translator$S = NodeTranslator.from(
26837
26972
  (v2) => integerToString(v2)
26838
26973
  )
26839
26974
  );
26840
- const translator$R = NodeTranslator.from(
26975
+ const translator$16 = NodeTranslator.from(
26841
26976
  createSingleAttrPropertyHandler(
26842
26977
  "w:gridBefore",
26843
26978
  null,
@@ -26846,21 +26981,21 @@ const translator$R = NodeTranslator.from(
26846
26981
  (v2) => integerToString(v2)
26847
26982
  )
26848
26983
  );
26849
- const translator$Q = NodeTranslator.from({
26984
+ const translator$15 = NodeTranslator.from({
26850
26985
  xmlName: "w:hidden",
26851
26986
  sdNodeOrKeyName: "hidden",
26852
26987
  encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
26853
26988
  decode: ({ node }) => node.attrs.hidden ? { attributes: {} } : void 0
26854
26989
  });
26855
- const translator$P = NodeTranslator.from(createSingleAttrPropertyHandler("w:jc", "justification"));
26856
- const translator$O = NodeTranslator.from(createMeasurementPropertyHandler("w:tblCellSpacing", "tableCellSpacing"));
26857
- const translator$N = NodeTranslator.from({
26990
+ const translator$14 = NodeTranslator.from(createSingleAttrPropertyHandler("w:jc", "justification"));
26991
+ const translator$13 = NodeTranslator.from(createMeasurementPropertyHandler("w:tblCellSpacing", "tableCellSpacing"));
26992
+ const translator$12 = NodeTranslator.from({
26858
26993
  xmlName: "w:tblHeader",
26859
26994
  sdNodeOrKeyName: "repeatHeader",
26860
26995
  encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
26861
26996
  decode: ({ node }) => node.attrs.repeatHeader ? { attributes: {} } : void 0
26862
26997
  });
26863
- const translator$M = NodeTranslator.from({
26998
+ const translator$11 = NodeTranslator.from({
26864
26999
  xmlName: "w:trHeight",
26865
27000
  sdNodeOrKeyName: "rowHeight",
26866
27001
  encode: ({ nodes }) => {
@@ -26887,73 +27022,32 @@ const translator$M = NodeTranslator.from({
26887
27022
  return Object.keys(heightAttrs).length > 0 ? { attributes: heightAttrs } : void 0;
26888
27023
  }
26889
27024
  });
26890
- const translator$L = NodeTranslator.from(createMeasurementPropertyHandler("w:wAfter"));
26891
- const translator$K = NodeTranslator.from(createMeasurementPropertyHandler("w:wBefore"));
26892
- const XML_NODE_NAME$i = "w:trPr";
26893
- const SD_ATTR_KEY$4 = "tableRowProperties";
26894
- const encode$o = (params) => {
26895
- const { nodes } = params;
26896
- const node = nodes[0];
26897
- let attributes = {
27025
+ const translator$10 = NodeTranslator.from(createMeasurementPropertyHandler("w:wAfter"));
27026
+ const translator$$ = NodeTranslator.from(createMeasurementPropertyHandler("w:wBefore"));
27027
+ const propertyTranslators$6 = [
27028
+ translator$1a,
27029
+ translator$19,
27030
+ translator$18,
27031
+ translator$17,
27032
+ translator$16,
27033
+ translator$15,
27034
+ translator$14,
27035
+ translator$13,
27036
+ translator$12,
27037
+ translator$11,
27038
+ translator$10,
27039
+ translator$$
27040
+ ];
27041
+ const translator$_ = NodeTranslator.from(
27042
+ createNestedPropertiesTranslator("w:trPr", "tableRowProperties", propertyTranslators$6, {
26898
27043
  cantSplit: false,
26899
27044
  hidden: false,
26900
27045
  repeatHeader: false
26901
- };
26902
- attributes = {
26903
- ...attributes,
26904
- ...encodeProperties(node, propertyTranslatorsByXmlName$2)
26905
- };
26906
- return {
26907
- type: NodeTranslator.translatorTypes.ATTRIBUTE,
26908
- xmlName: XML_NODE_NAME$i,
26909
- sdNodeOrKeyName: SD_ATTR_KEY$4,
26910
- attributes
26911
- };
26912
- };
26913
- const decode$q = (params) => {
26914
- const { tableRowProperties = {} } = params.node.attrs || {};
26915
- const elements = decodeProperties(propertyTranslatorsBySdName$2, tableRowProperties);
26916
- const newNode = {
26917
- name: "w:trPr",
26918
- type: "element",
26919
- attributes: {},
26920
- elements
26921
- };
26922
- return newNode;
26923
- };
26924
- const propertyTranslators$3 = [
26925
- translator$V,
26926
- translator$U,
26927
- translator$T,
26928
- translator$S,
26929
- translator$R,
26930
- translator$Q,
26931
- translator$P,
26932
- translator$O,
26933
- translator$N,
26934
- translator$M,
26935
- translator$L,
26936
- translator$K
26937
- ];
26938
- const propertyTranslatorsByXmlName$2 = {};
26939
- propertyTranslators$3.forEach((translator2) => {
26940
- propertyTranslatorsByXmlName$2[translator2.xmlName] = translator2;
26941
- });
26942
- const propertyTranslatorsBySdName$2 = {};
26943
- propertyTranslators$3.forEach((translator2) => {
26944
- propertyTranslatorsBySdName$2[translator2.sdNodeOrKeyName] = translator2;
26945
- });
26946
- const config$f = {
26947
- xmlName: XML_NODE_NAME$i,
26948
- sdNodeOrKeyName: SD_ATTR_KEY$4,
26949
- type: NodeTranslator.translatorTypes.ATTRIBUTE,
26950
- encode: encode$o,
26951
- decode: decode$q
26952
- };
26953
- const translator$J = NodeTranslator.from(config$f);
27046
+ })
27047
+ );
26954
27048
  const XML_NODE_NAME$h = "w:tr";
26955
27049
  const SD_NODE_NAME$d = "tableRow";
26956
- const validXmlAttributes$9 = ["w:rsidDel", "w:rsidR", "w:rsidRPr", "w:rsidTr", "w14:paraId", "w14:textId"].map(
27050
+ const validXmlAttributes$b = ["w:rsidDel", "w:rsidR", "w:rsidRPr", "w:rsidTr", "w14:paraId", "w14:textId"].map(
26957
27051
  (xmlName) => createAttributeHandler(xmlName)
26958
27052
  );
26959
27053
  const encode$n = (params, encodedAttrs) => {
@@ -26961,10 +27055,10 @@ const encode$n = (params, encodedAttrs) => {
26961
27055
  let tableRowProperties = {};
26962
27056
  const tPr = row.elements.find((el) => el.name === "w:trPr");
26963
27057
  if (tPr) {
26964
- ({ attributes: tableRowProperties } = translator$J.encode({
27058
+ tableRowProperties = translator$_.encode({
26965
27059
  ...params,
26966
27060
  nodes: [tPr]
26967
- }));
27061
+ });
26968
27062
  }
26969
27063
  encodedAttrs["tableRowProperties"] = Object.freeze(tableRowProperties);
26970
27064
  encodedAttrs["rowHeight"] = twipsToPixels(tableRowProperties["rowHeight"]?.value);
@@ -26974,7 +27068,7 @@ const encode$n = (params, encodedAttrs) => {
26974
27068
  let currentColumnIndex = 0;
26975
27069
  const content = cellNodes?.map((n) => {
26976
27070
  let columnWidth = gridColumnWidths?.[currentColumnIndex] || null;
26977
- const result = translator$a.encode({
27071
+ const result = translator$c.encode({
26978
27072
  ...params,
26979
27073
  extraParams: {
26980
27074
  ...params.extraParams,
@@ -27008,7 +27102,7 @@ const decode$p = (params, decodedAttrs) => {
27008
27102
  }
27009
27103
  }
27010
27104
  tableRowProperties["cantSplit"] = node.attrs["cantSplit"];
27011
- const trPr = translator$J.decode({
27105
+ const trPr = translator$_.decode({
27012
27106
  ...params,
27013
27107
  node: { ...node, attrs: { ...node.attrs, tableRowProperties } }
27014
27108
  });
@@ -27020,22 +27114,22 @@ const decode$p = (params, decodedAttrs) => {
27020
27114
  elements
27021
27115
  };
27022
27116
  };
27023
- const config$e = {
27117
+ const config$g = {
27024
27118
  xmlName: XML_NODE_NAME$h,
27025
27119
  sdNodeOrKeyName: SD_NODE_NAME$d,
27026
27120
  type: NodeTranslator.translatorTypes.NODE,
27027
27121
  encode: encode$n,
27028
27122
  decode: decode$p,
27029
- attributes: validXmlAttributes$9
27123
+ attributes: validXmlAttributes$b
27030
27124
  };
27031
- const translator$I = NodeTranslator.from(config$e);
27032
- const translator$H = NodeTranslator.from({
27125
+ const translator$Z = NodeTranslator.from(config$g);
27126
+ const translator$Y = NodeTranslator.from({
27033
27127
  xmlName: "w:bidiVisual",
27034
27128
  sdNodeOrKeyName: "rightToLeft",
27035
27129
  encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
27036
27130
  decode: ({ node }) => node.attrs.rightToLeft ? { attributes: {} } : void 0
27037
27131
  });
27038
- const translator$G = NodeTranslator.from({
27132
+ const translator$X = NodeTranslator.from({
27039
27133
  xmlName: "w:shd",
27040
27134
  sdNodeOrKeyName: "shading",
27041
27135
  attributes: [
@@ -27057,11 +27151,11 @@ const translator$G = NodeTranslator.from({
27057
27151
  return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
27058
27152
  }
27059
27153
  });
27060
- const translator$F = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblCaption", "caption"));
27061
- const translator$E = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblDescription", "description"));
27062
- const translator$D = NodeTranslator.from(createMeasurementPropertyHandler("w:tblInd", "tableIndent"));
27063
- const translator$C = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblLayout", "tableLayout", "w:type"));
27064
- const translator$B = NodeTranslator.from({
27154
+ const translator$W = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblCaption", "caption"));
27155
+ const translator$V = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblDescription", "description"));
27156
+ const translator$U = NodeTranslator.from(createMeasurementPropertyHandler("w:tblInd", "tableIndent"));
27157
+ const translator$T = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblLayout", "tableLayout", "w:type"));
27158
+ const translator$S = NodeTranslator.from({
27065
27159
  xmlName: "w:tblLook",
27066
27160
  sdNodeOrKeyName: "tblLook",
27067
27161
  attributes: ["w:firstColumn", "w:firstRow", "w:lastColumn", "w:lastRow", "w:noHBand", "w:noVBand"].map((attr) => createAttributeHandler(attr, null, parseBoolean, booleanToString)).concat([createAttributeHandler("w:val")]),
@@ -27073,16 +27167,16 @@ const translator$B = NodeTranslator.from({
27073
27167
  return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
27074
27168
  }
27075
27169
  });
27076
- const translator$A = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblOverlap", "overlap"));
27077
- const translator$z = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblStyle", "tableStyleId"));
27078
- const translator$y = NodeTranslator.from(
27170
+ const translator$R = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblOverlap", "overlap"));
27171
+ const translator$Q = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblStyle", "tableStyleId"));
27172
+ const translator$P = NodeTranslator.from(
27079
27173
  createSingleAttrPropertyHandler("w:tblStyleColBandSize", "tableStyleColBandSize")
27080
27174
  );
27081
- const translator$x = NodeTranslator.from(
27175
+ const translator$O = NodeTranslator.from(
27082
27176
  createSingleAttrPropertyHandler("w:tblStyleRowBandSize", "tableStyleRowBandSize")
27083
27177
  );
27084
- const translator$w = NodeTranslator.from(createMeasurementPropertyHandler("w:tblW", "tableWidth"));
27085
- const translator$v = NodeTranslator.from({
27178
+ const translator$N = NodeTranslator.from(createMeasurementPropertyHandler("w:tblW", "tableWidth"));
27179
+ const translator$M = NodeTranslator.from({
27086
27180
  xmlName: "w:tblpPr",
27087
27181
  sdNodeOrKeyName: "floatingTableProperties",
27088
27182
  attributes: ["w:leftFromText", "w:rightFromText", "w:topFromText", "w:bottomFromText", "w:tblpX", "w:tblpY"].map((attr) => createAttributeHandler(attr, null, parseInteger, integerToString)).concat(["w:horzAnchor", "w:vertAnchor", "w:tblpXSpec", "w:tblpYSpec"].map((attr) => createAttributeHandler(attr))),
@@ -27094,160 +27188,67 @@ const translator$v = NodeTranslator.from({
27094
27188
  return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
27095
27189
  }
27096
27190
  });
27097
- const translator$u = NodeTranslator.from(createBorderPropertyHandler("w:bottom"));
27098
- const translator$t = NodeTranslator.from(createMeasurementPropertyHandler("w:bottom", "marginBottom"));
27099
- const translator$s = NodeTranslator.from(createBorderPropertyHandler("w:end"));
27100
- const translator$r = NodeTranslator.from(createMeasurementPropertyHandler("w:end", "marginEnd"));
27101
- const translator$q = NodeTranslator.from(createBorderPropertyHandler("w:insideH"));
27102
- const translator$p = NodeTranslator.from(createBorderPropertyHandler("w:insideV"));
27103
- const translator$o = NodeTranslator.from(createBorderPropertyHandler("w:left"));
27104
- const translator$n = NodeTranslator.from(createMeasurementPropertyHandler("w:left", "marginLeft"));
27105
- const translator$m = NodeTranslator.from(createBorderPropertyHandler("w:right"));
27106
- const translator$l = NodeTranslator.from(createMeasurementPropertyHandler("w:right", "marginRight"));
27107
- const translator$k = NodeTranslator.from(createBorderPropertyHandler("w:start"));
27108
- const translator$j = NodeTranslator.from(createMeasurementPropertyHandler("w:start", "marginStart"));
27109
- const translator$i = NodeTranslator.from(createBorderPropertyHandler("w:top"));
27110
- const translator$h = NodeTranslator.from(createMeasurementPropertyHandler("w:top", "marginTop"));
27111
- const XML_NODE_NAME$g = "w:tblBorders";
27112
- const SD_ATTR_KEY$3 = "borders";
27113
- const encode$m = (params) => {
27114
- const { nodes } = params;
27115
- const node = nodes[0];
27116
- const attributes = encodeProperties(node, tblBordersTranslatorsByXmlName);
27117
- return Object.keys(attributes).length > 0 ? attributes : void 0;
27118
- };
27119
- const decode$o = (params) => {
27120
- const { borders = {} } = params.node.attrs || {};
27121
- const elements = decodeProperties(tblBordersTranslatorsBySdName, borders);
27122
- const newNode = {
27123
- name: "w:tblBorders",
27124
- type: "element",
27125
- attributes: {},
27126
- elements
27127
- };
27128
- return newNode;
27129
- };
27130
- const propertyTranslators$2 = [
27131
- translator$u,
27132
- translator$s,
27133
- translator$q,
27134
- translator$p,
27135
- translator$o,
27136
- translator$m,
27137
- translator$k,
27138
- translator$i
27139
- ];
27140
- const tblBordersTranslatorsByXmlName = {};
27141
- const tblBordersTranslatorsBySdName = {};
27142
- propertyTranslators$2.forEach((translator2) => {
27143
- tblBordersTranslatorsByXmlName[translator2.xmlName] = translator2;
27144
- tblBordersTranslatorsBySdName[translator2.sdNodeOrKeyName] = translator2;
27145
- });
27146
- const translator$g = NodeTranslator.from({
27147
- xmlName: XML_NODE_NAME$g,
27148
- sdNodeOrKeyName: SD_ATTR_KEY$3,
27149
- type: NodeTranslator.translatorTypes.NODE,
27150
- attributes: [],
27151
- encode: encode$m,
27152
- decode: decode$o
27153
- });
27154
- const XML_NODE_NAME$f = "w:tblCellMar";
27155
- const SD_ATTR_KEY$2 = "cellMargins";
27156
- const encode$l = (params) => {
27157
- const { nodes } = params;
27158
- const node = nodes[0];
27159
- const attributes = encodeProperties(node, propertyTranslatorsByXmlName$1);
27160
- return Object.keys(attributes).length > 0 ? attributes : void 0;
27161
- };
27162
- const decode$n = (params) => {
27163
- const { cellMargins = {} } = params.node.attrs || {};
27164
- const elements = decodeProperties(propertyTranslatorsBySdName$1, cellMargins);
27165
- const newNode = {
27166
- name: XML_NODE_NAME$f,
27167
- type: "element",
27168
- attributes: {},
27169
- elements
27170
- };
27171
- return newNode;
27172
- };
27173
- const propertyTranslators$1 = [
27174
- translator$t,
27175
- translator$r,
27176
- translator$n,
27177
- translator$l,
27178
- translator$j,
27179
- translator$h
27180
- ];
27181
- const propertyTranslatorsByXmlName$1 = {};
27182
- const propertyTranslatorsBySdName$1 = {};
27183
- propertyTranslators$1.forEach((translator2) => {
27184
- propertyTranslatorsByXmlName$1[translator2.xmlName] = translator2;
27185
- propertyTranslatorsBySdName$1[translator2.sdNodeOrKeyName] = translator2;
27186
- });
27187
- const translator$f = NodeTranslator.from({
27188
- xmlName: XML_NODE_NAME$f,
27189
- sdNodeOrKeyName: SD_ATTR_KEY$2,
27190
- type: NodeTranslator.translatorTypes.NODE,
27191
- attributes: [],
27192
- encode: encode$l,
27193
- decode: decode$n
27194
- });
27195
- const XML_NODE_NAME$e = "w:tblPr";
27196
- const SD_ATTR_KEY$1 = "tableProperties";
27197
- const encode$k = (params) => {
27198
- const { nodes } = params;
27199
- const node = nodes[0];
27200
- const attributes = encodeProperties(node, propertyTranslatorsByXmlName);
27201
- return {
27202
- xmlName: XML_NODE_NAME$e,
27203
- sdNodeOrKeyName: SD_ATTR_KEY$1,
27204
- attributes
27205
- };
27206
- };
27207
- const decode$m = (params) => {
27208
- const { tableProperties = {} } = params.node.attrs || {};
27209
- const elements = decodeProperties(propertyTranslatorsBySdName, tableProperties);
27210
- const newNode = {
27211
- name: "w:tblPr",
27212
- type: "element",
27213
- attributes: {},
27214
- elements
27215
- };
27216
- return newNode;
27217
- };
27218
- const propertyTranslators = [
27191
+ const translator$L = NodeTranslator.from(createBorderPropertyHandler("w:bottom"));
27192
+ const translator$K = NodeTranslator.from(createMeasurementPropertyHandler("w:bottom", "marginBottom"));
27193
+ const translator$J = NodeTranslator.from(createBorderPropertyHandler("w:end"));
27194
+ const translator$I = NodeTranslator.from(createMeasurementPropertyHandler("w:end", "marginEnd"));
27195
+ const translator$H = NodeTranslator.from(createBorderPropertyHandler("w:insideH"));
27196
+ const translator$G = NodeTranslator.from(createBorderPropertyHandler("w:insideV"));
27197
+ const translator$F = NodeTranslator.from(createBorderPropertyHandler("w:left"));
27198
+ const translator$E = NodeTranslator.from(createMeasurementPropertyHandler("w:left", "marginLeft"));
27199
+ const translator$D = NodeTranslator.from(createBorderPropertyHandler("w:right"));
27200
+ const translator$C = NodeTranslator.from(createMeasurementPropertyHandler("w:right", "marginRight"));
27201
+ const translator$B = NodeTranslator.from(createBorderPropertyHandler("w:start"));
27202
+ const translator$A = NodeTranslator.from(createMeasurementPropertyHandler("w:start", "marginStart"));
27203
+ const translator$z = NodeTranslator.from(createBorderPropertyHandler("w:top"));
27204
+ const translator$y = NodeTranslator.from(createMeasurementPropertyHandler("w:top", "marginTop"));
27205
+ const propertyTranslators$5 = [
27206
+ translator$L,
27207
+ translator$J,
27219
27208
  translator$H,
27220
- translator$P,
27221
27209
  translator$G,
27222
27210
  translator$F,
27223
- translator$O,
27224
- translator$E,
27225
27211
  translator$D,
27226
- translator$C,
27227
27212
  translator$B,
27213
+ translator$z
27214
+ ];
27215
+ const translator$x = NodeTranslator.from(
27216
+ createNestedPropertiesTranslator("w:tblBorders", "borders", propertyTranslators$5)
27217
+ );
27218
+ const propertyTranslators$4 = [
27219
+ translator$K,
27220
+ translator$I,
27221
+ translator$E,
27222
+ translator$C,
27228
27223
  translator$A,
27229
- translator$z,
27230
- translator$y,
27224
+ translator$y
27225
+ ];
27226
+ const translator$w = NodeTranslator.from(
27227
+ createNestedPropertiesTranslator("w:tblCellMar", "cellMargins", propertyTranslators$4)
27228
+ );
27229
+ const propertyTranslators$3 = [
27230
+ translator$Y,
27231
+ translator$14,
27232
+ translator$X,
27233
+ translator$W,
27234
+ translator$13,
27235
+ translator$V,
27236
+ translator$U,
27237
+ translator$T,
27238
+ translator$S,
27239
+ translator$R,
27240
+ translator$Q,
27241
+ translator$P,
27242
+ translator$O,
27243
+ translator$N,
27244
+ translator$M,
27231
27245
  translator$x,
27232
- translator$w,
27233
- translator$v,
27234
- translator$g,
27235
- translator$f
27246
+ translator$w
27236
27247
  ];
27237
- const propertyTranslatorsByXmlName = {};
27238
- const propertyTranslatorsBySdName = {};
27239
- propertyTranslators.forEach((translator2) => {
27240
- propertyTranslatorsByXmlName[translator2.xmlName] = translator2;
27241
- propertyTranslatorsBySdName[translator2.sdNodeOrKeyName] = translator2;
27242
- });
27243
- const config$d = {
27244
- xmlName: XML_NODE_NAME$e,
27245
- sdNodeOrKeyName: SD_ATTR_KEY$1,
27246
- encode: encode$k,
27247
- decode: decode$m
27248
- };
27249
- const translator$e = NodeTranslator.from(config$d);
27250
- const translator$d = NodeTranslator.from(
27248
+ const translator$v = NodeTranslator.from(
27249
+ createNestedPropertiesTranslator("w:tblPr", "tableProperties", propertyTranslators$3)
27250
+ );
27251
+ const translator$u = NodeTranslator.from(
27251
27252
  createSingleAttrPropertyHandler("w:gridCol", "col", "w:w", parseInteger, integerToString)
27252
27253
  );
27253
27254
  const DEFAULT_COLUMN_WIDTH_PX = 100;
@@ -27297,20 +27298,20 @@ const resolveFallbackColumnWidthTwips = (params, totalColumns, cellMinWidthTwips
27297
27298
  }
27298
27299
  return Math.max(fallbackWidthTwips, cellMinWidthTwips);
27299
27300
  };
27300
- const XML_NODE_NAME$d = "w:tblGrid";
27301
- const SD_ATTR_KEY = "grid";
27301
+ const XML_NODE_NAME$g = "w:tblGrid";
27302
+ const SD_ATTR_KEY$3 = "grid";
27302
27303
  const cellMinWidth = pixelsToTwips(10);
27303
- const encode$j = (params) => {
27304
+ const encode$m = (params) => {
27304
27305
  const { nodes } = params;
27305
27306
  const node = nodes[0];
27306
- const attributes = encodeProperties(node, { [translator$d.xmlName]: translator$d }, true);
27307
+ const attributes = encodeProperties(node, { [translator$u.xmlName]: translator$u }, true);
27307
27308
  return {
27308
- xmlName: XML_NODE_NAME$d,
27309
- sdNodeOrKeyName: SD_ATTR_KEY,
27309
+ xmlName: XML_NODE_NAME$g,
27310
+ sdNodeOrKeyName: SD_ATTR_KEY$3,
27310
27311
  attributes
27311
27312
  };
27312
27313
  };
27313
- const decode$l = (params) => {
27314
+ const decode$o = (params) => {
27314
27315
  const { grid: rawGrid } = params.node.attrs || {};
27315
27316
  const grid = Array.isArray(rawGrid) ? rawGrid : [];
27316
27317
  const { firstRow = {} } = params.extraParams || {};
@@ -27329,10 +27330,10 @@ const decode$l = (params) => {
27329
27330
  numericWidth = fallbackColumnWidthTwips;
27330
27331
  }
27331
27332
  numericWidth = Math.max(numericWidth, cellMinWidth);
27332
- const decoded = translator$d.decode({
27333
+ const decoded = translator$u.decode({
27333
27334
  node: { type: (
27334
27335
  /** @type {string} */
27335
- translator$d.sdNodeOrKeyName
27336
+ translator$u.sdNodeOrKeyName
27336
27337
  ), attrs: { col: numericWidth } }
27337
27338
  });
27338
27339
  if (decoded) elements.push(decoded);
@@ -27367,19 +27368,19 @@ const decode$l = (params) => {
27367
27368
  columnIndex++;
27368
27369
  }
27369
27370
  const newNode = {
27370
- name: XML_NODE_NAME$d,
27371
+ name: XML_NODE_NAME$g,
27371
27372
  attributes: {},
27372
27373
  elements
27373
27374
  };
27374
27375
  return newNode;
27375
27376
  };
27376
- const config$c = {
27377
- xmlName: XML_NODE_NAME$d,
27378
- sdNodeOrKeyName: SD_ATTR_KEY,
27379
- encode: encode$j,
27380
- decode: decode$l
27377
+ const config$f = {
27378
+ xmlName: XML_NODE_NAME$g,
27379
+ sdNodeOrKeyName: SD_ATTR_KEY$3,
27380
+ encode: encode$m,
27381
+ decode: decode$o
27381
27382
  };
27382
- const translator$c = NodeTranslator.from(config$c);
27383
+ const translator$t = NodeTranslator.from(config$f);
27383
27384
  const DEFAULT_PAGE_WIDTH_TWIPS = 12240;
27384
27385
  const DEFAULT_PAGE_MARGIN_TWIPS = 1440;
27385
27386
  const DEFAULT_CONTENT_WIDTH_TWIPS = DEFAULT_PAGE_WIDTH_TWIPS - 2 * DEFAULT_PAGE_MARGIN_TWIPS;
@@ -27442,19 +27443,19 @@ const buildFallbackGridForTable = ({ params, rows, tableWidth, tableWidthMeasure
27442
27443
  columnWidths: Array(columnCount).fill(fallbackColumnWidthPx)
27443
27444
  };
27444
27445
  };
27445
- const XML_NODE_NAME$c = "w:tbl";
27446
+ const XML_NODE_NAME$f = "w:tbl";
27446
27447
  const SD_NODE_NAME$c = "table";
27447
- const encode$i = (params, encodedAttrs) => {
27448
+ const encode$l = (params, encodedAttrs) => {
27448
27449
  const { nodes } = params;
27449
27450
  const node = nodes[0];
27450
27451
  const tblPr = node.elements.find((el) => el.name === "w:tblPr");
27451
27452
  if (tblPr) {
27452
- const encodedProperties = translator$e.encode({ ...params, nodes: [tblPr] });
27453
- encodedAttrs["tableProperties"] = encodedProperties?.attributes || {};
27453
+ const encodedProperties = translator$v.encode({ ...params, nodes: [tblPr] });
27454
+ encodedAttrs["tableProperties"] = encodedProperties || {};
27454
27455
  }
27455
27456
  const tblGrid = node.elements.find((el) => el.name === "w:tblGrid");
27456
27457
  if (tblGrid) {
27457
- encodedAttrs["grid"] = translator$c.encode({ ...params, nodes: [tblGrid] }).attributes;
27458
+ encodedAttrs["grid"] = translator$t.encode({ ...params, nodes: [tblGrid] }).attributes;
27458
27459
  }
27459
27460
  [
27460
27461
  "tableStyleId",
@@ -27521,7 +27522,7 @@ const encode$i = (params, encodedAttrs) => {
27521
27522
  }
27522
27523
  const content = [];
27523
27524
  rows.forEach((row) => {
27524
- const result = translator$I.encode({
27525
+ const result = translator$Z.encode({
27525
27526
  ...params,
27526
27527
  nodes: [row],
27527
27528
  extraParams: {
@@ -27540,13 +27541,13 @@ const encode$i = (params, encodedAttrs) => {
27540
27541
  attrs: encodedAttrs
27541
27542
  };
27542
27543
  };
27543
- const decode$k = (params, decodedAttrs) => {
27544
+ const decode$n = (params, decodedAttrs) => {
27544
27545
  params.node = preProcessVerticalMergeCells(params.node, params);
27545
27546
  const { node } = params;
27546
27547
  const elements = translateChildNodes(params);
27547
27548
  const firstRow = node.content?.find((n) => n.type === "tableRow");
27548
27549
  const properties = node.attrs.grid;
27549
- const element = translator$c.decode({
27550
+ const element = translator$t.decode({
27550
27551
  ...params,
27551
27552
  node: { ...node, attrs: { ...node.attrs, grid: properties } },
27552
27553
  extraParams: {
@@ -27556,7 +27557,7 @@ const decode$k = (params, decodedAttrs) => {
27556
27557
  if (element) elements.unshift(element);
27557
27558
  if (node.attrs?.tableProperties) {
27558
27559
  const properties2 = { ...node.attrs.tableProperties };
27559
- const element2 = translator$e.decode({
27560
+ const element2 = translator$v.decode({
27560
27561
  ...params,
27561
27562
  node: { ...node, attrs: { ...node.attrs, tableProperties: properties2 } }
27562
27563
  });
@@ -27576,7 +27577,7 @@ function _processTableBorders(rawBorders) {
27576
27577
  const color = attributes.color;
27577
27578
  const size = attributes.size;
27578
27579
  if (color && color !== "auto") attrs["color"] = color.startsWith("#") ? color : `#${color}`;
27579
- if (size && size !== "auto") attrs["size"] = eigthPointsToPixels(size);
27580
+ if (size && size !== "auto") attrs["size"] = eighthPointsToPixels(size);
27580
27581
  const rowBorderNames = ["insideH", "insideV"];
27581
27582
  if (rowBorderNames.includes(name)) rowBorders[name] = attrs;
27582
27583
  borders[name] = attrs;
@@ -27622,7 +27623,7 @@ function _getReferencedTableStyles(tableStyleReference, params) {
27622
27623
  if (baseTblPr && baseTblPr.elements) {
27623
27624
  tblPr.elements.push(...baseTblPr.elements);
27624
27625
  }
27625
- const tableProperties = translator$e.encode({ ...params, nodes: [tblPr] }).attributes;
27626
+ const tableProperties = translator$v.encode({ ...params, nodes: [tblPr] });
27626
27627
  const { borders, rowBorders } = _processTableBorders(tableProperties.borders || {});
27627
27628
  if (borders) stylesToReturn.borders = borders;
27628
27629
  if (rowBorders) stylesToReturn.rowBorders = rowBorders;
@@ -27639,16 +27640,16 @@ function _getReferencedTableStyles(tableStyleReference, params) {
27639
27640
  }
27640
27641
  return stylesToReturn;
27641
27642
  }
27642
- const config$b = {
27643
- xmlName: XML_NODE_NAME$c,
27643
+ const config$e = {
27644
+ xmlName: XML_NODE_NAME$f,
27644
27645
  sdNodeOrKeyName: SD_NODE_NAME$c,
27645
27646
  type: NodeTranslator.translatorTypes.NODE,
27646
- encode: encode$i,
27647
- decode: decode$k,
27647
+ encode: encode$l,
27648
+ decode: decode$n,
27648
27649
  attributes: []
27649
27650
  };
27650
- const translator$b = NodeTranslator.from(config$b);
27651
- const tableNodeHandlerEntity = generateV2HandlerEntity("tableNodeHandler", translator$b);
27651
+ const translator$s = NodeTranslator.from(config$e);
27652
+ const tableNodeHandlerEntity = generateV2HandlerEntity("tableNodeHandler", translator$s);
27652
27653
  function getReferencedTableStyles(tblStyleTag, docx) {
27653
27654
  if (!tblStyleTag) return null;
27654
27655
  const stylesToReturn = {};
@@ -27719,16 +27720,135 @@ function processTableBorders(borderElements) {
27719
27720
  const color = attributes["w:color"];
27720
27721
  const size = attributes["w:sz"];
27721
27722
  if (color && color !== "auto") attrs["color"] = color.startsWith("#") ? color : `#${color}`;
27722
- if (size && size !== "auto") attrs["size"] = eigthPointsToPixels(size);
27723
+ if (size && size !== "auto") attrs["size"] = eighthPointsToPixels(size);
27723
27724
  const rowBorderNames = ["insideH", "insideV"];
27724
27725
  if (rowBorderNames.includes(borderName)) rowBorders[borderName] = attrs;
27725
27726
  borders[borderName] = attrs;
27726
27727
  });
27727
27728
  return {
27728
- borders,
27729
- rowBorders
27729
+ borders,
27730
+ rowBorders
27731
+ };
27732
+ }
27733
+ const translator$r = NodeTranslator.from(createMeasurementPropertyHandler("w:tcW", "cellWidth"));
27734
+ const translator$q = NodeTranslator.from(
27735
+ createSingleAttrPropertyHandler(
27736
+ "w:gridSpan",
27737
+ null,
27738
+ "w:val",
27739
+ (v2) => parseInteger(v2) ?? void 0,
27740
+ (v2) => integerToString(v2)
27741
+ )
27742
+ );
27743
+ const translator$p = NodeTranslator.from(createSingleAttrPropertyHandler("w:vMerge"));
27744
+ const translator$o = NodeTranslator.from(createBorderPropertyHandler("w:tl2br"));
27745
+ const translator$n = NodeTranslator.from(createBorderPropertyHandler("w:tr2bl"));
27746
+ const propertyTranslators$2 = [
27747
+ translator$z,
27748
+ translator$B,
27749
+ translator$F,
27750
+ translator$L,
27751
+ translator$J,
27752
+ translator$D,
27753
+ translator$H,
27754
+ translator$G,
27755
+ translator$o,
27756
+ translator$n
27757
+ ];
27758
+ const translator$m = NodeTranslator.from(
27759
+ createNestedPropertiesTranslator("w:tcBorders", "borders", propertyTranslators$2)
27760
+ );
27761
+ const translator$l = NodeTranslator.from(
27762
+ createSingleAttrPropertyHandler(
27763
+ "w:noWrap",
27764
+ null,
27765
+ "w:val",
27766
+ (v2) => parseBoolean(v2 ?? "true"),
27767
+ (v2) => booleanToString(v2)
27768
+ )
27769
+ );
27770
+ const propertyTranslators$1 = [
27771
+ translator$K,
27772
+ translator$I,
27773
+ translator$E,
27774
+ translator$C,
27775
+ translator$A,
27776
+ translator$y
27777
+ ];
27778
+ const translator$k = NodeTranslator.from(
27779
+ createNestedPropertiesTranslator("w:tcMar", "cellMargins", propertyTranslators$1)
27780
+ );
27781
+ const translator$j = NodeTranslator.from(createSingleAttrPropertyHandler("w:textDirection"));
27782
+ const translator$i = NodeTranslator.from(
27783
+ createSingleAttrPropertyHandler(
27784
+ "w:tcFitText",
27785
+ null,
27786
+ "w:val",
27787
+ (v2) => parseBoolean(v2 ?? "true"),
27788
+ (v2) => booleanToString(v2)
27789
+ )
27790
+ );
27791
+ const translator$h = NodeTranslator.from(createSingleAttrPropertyHandler("w:vAlign"));
27792
+ const translator$g = NodeTranslator.from(
27793
+ createSingleAttrPropertyHandler(
27794
+ "w:hideMark",
27795
+ null,
27796
+ "w:val",
27797
+ (v2) => parseBoolean(v2 ?? "true"),
27798
+ (v2) => booleanToString(v2)
27799
+ )
27800
+ );
27801
+ const translator$f = NodeTranslator.from(createSingleAttrPropertyHandler("w:header"));
27802
+ const XML_NODE_NAME$e = "w:headers";
27803
+ const SD_ATTR_KEY$2 = "headers";
27804
+ const encode$k = (params) => {
27805
+ const { nodes } = params;
27806
+ const node = nodes[0];
27807
+ const attributes = encodeProperties(node, { [translator$f.xmlName]: translator$f }, true);
27808
+ return {
27809
+ xmlName: XML_NODE_NAME$e,
27810
+ sdNodeOrKeyName: SD_ATTR_KEY$2,
27811
+ attributes
27730
27812
  };
27731
- }
27813
+ };
27814
+ const decode$m = (params) => {
27815
+ const { headers = [] } = params.node.attrs || {};
27816
+ const newNode = {
27817
+ name: XML_NODE_NAME$e,
27818
+ attributes: {},
27819
+ elements: headers.map(
27820
+ (header) => translator$f.decode({
27821
+ node: { type: "header", attrs: header }
27822
+ })
27823
+ )
27824
+ };
27825
+ return newNode;
27826
+ };
27827
+ const config$d = {
27828
+ xmlName: XML_NODE_NAME$e,
27829
+ sdNodeOrKeyName: SD_ATTR_KEY$2,
27830
+ encode: encode$k,
27831
+ decode: decode$m
27832
+ };
27833
+ const translator$e = NodeTranslator.from(config$d);
27834
+ const propertyTranslators = [
27835
+ translator$19,
27836
+ translator$r,
27837
+ translator$q,
27838
+ translator$p,
27839
+ translator$m,
27840
+ translator$X,
27841
+ translator$l,
27842
+ translator$k,
27843
+ translator$j,
27844
+ translator$i,
27845
+ translator$h,
27846
+ translator$g,
27847
+ translator$e
27848
+ ];
27849
+ const translator$d = NodeTranslator.from(
27850
+ createNestedPropertiesTranslator("w:tcPr", "tableCellProperties", propertyTranslators)
27851
+ );
27732
27852
  function handleTableCellNode({
27733
27853
  params,
27734
27854
  node,
@@ -27741,8 +27861,10 @@ function handleTableCellNode({
27741
27861
  allColumnWidths = []
27742
27862
  }) {
27743
27863
  const { docx, nodeListHandler } = params;
27864
+ const attributes = {};
27744
27865
  const tcPr = node.elements.find((el) => el.name === "w:tcPr");
27745
- const borders = tcPr?.elements?.find((el) => el.name === "w:tcBorders");
27866
+ const tableCellProperties = tcPr ? translator$d.encode({ ...params, nodes: [tcPr] }) ?? {} : {};
27867
+ attributes["tableCellProperties"] = tableCellProperties;
27746
27868
  if (rowBorders?.insideH) {
27747
27869
  rowBorders["bottom"] = rowBorders.insideH;
27748
27870
  delete rowBorders.insideH;
@@ -27751,33 +27873,20 @@ function handleTableCellNode({
27751
27873
  rowBorders["right"] = rowBorders.insideV;
27752
27874
  delete rowBorders?.insideV;
27753
27875
  }
27754
- const inlineBorders = processInlineCellBorders(borders, rowBorders);
27755
- const gridColumnWidths = allColumnWidths;
27756
- const tcWidth = tcPr?.elements?.find((el) => el.name === "w:tcW");
27757
- let width = tcWidth ? twipsToPixels(tcWidth.attributes["w:w"]) : null;
27758
- const widthType = tcWidth?.attributes["w:type"];
27876
+ if (rowBorders) attributes["borders"] = { ...rowBorders };
27877
+ const inlineBorders = processInlineCellBorders(tableCellProperties.borders, rowBorders);
27878
+ if (inlineBorders) attributes["borders"] = Object.assign(attributes["borders"] || {}, inlineBorders);
27879
+ const colspan = tableCellProperties.gridSpan;
27880
+ if (colspan && !isNaN(parseInt(colspan, 10))) attributes["colspan"] = parseInt(colspan, 10);
27881
+ let width = tableCellProperties.cellWidth?.value ? twipsToPixels(tableCellProperties.cellWidth?.value) : null;
27882
+ const widthType = tableCellProperties.cellWidth?.type;
27883
+ if (widthType) attributes["widthType"] = widthType;
27759
27884
  if (!width && columnWidth) width = columnWidth;
27760
- const vMerge = getTableCellMergeTag(node);
27761
- const { attributes: vMergeAttrs } = vMerge || {};
27762
- const backgroundColor = tcPr?.elements?.find((el) => el.name === "w:shd");
27763
- const background = {
27764
- color: backgroundColor?.attributes["w:fill"]
27765
- };
27766
- const colspanTag = tcPr?.elements?.find((el) => el.name === "w:gridSpan");
27767
- const colspan = colspanTag?.attributes["w:val"];
27768
- const marginTag = tcPr?.elements?.find((el) => el.name === "w:tcMar");
27769
- const verticalAlignTag = tcPr?.elements?.find((el) => el.name === "w:vAlign");
27770
- const verticalAlign = verticalAlignTag?.attributes["w:val"] || "top";
27771
- const attributes = {};
27772
- const referencedStyles = getReferencedTableStyles(styleTag, docx) || {};
27773
- attributes.cellMargins = getTableCellMargins(marginTag, referencedStyles);
27774
- const { fontSize, fonts = {} } = referencedStyles;
27775
- const fontFamily = fonts["ascii"];
27776
27885
  if (width) {
27777
27886
  attributes["colwidth"] = [width];
27778
27887
  attributes["widthUnit"] = "px";
27779
- const defaultColWidths = gridColumnWidths;
27780
- const hasDefaultColWidths = gridColumnWidths && gridColumnWidths.length > 0;
27888
+ const defaultColWidths = allColumnWidths;
27889
+ const hasDefaultColWidths = allColumnWidths && allColumnWidths.length > 0;
27781
27890
  const colspanNum = parseInt(colspan || 1, 10);
27782
27891
  if (colspanNum && colspanNum > 1 && hasDefaultColWidths) {
27783
27892
  let colwidth = [];
@@ -27795,15 +27904,19 @@ function handleTableCellNode({
27795
27904
  }
27796
27905
  }
27797
27906
  }
27798
- if (widthType) attributes["widthType"] = widthType;
27799
- if (colspan) attributes["colspan"] = parseInt(colspan, 10);
27800
- if (background) attributes["background"] = background;
27801
- attributes["verticalAlign"] = verticalAlign;
27907
+ const background = {
27908
+ color: tableCellProperties.shading?.fill
27909
+ };
27910
+ if (background.color) attributes["background"] = background;
27911
+ const verticalAlign = tableCellProperties.vAlign;
27912
+ if (verticalAlign) attributes["verticalAlign"] = verticalAlign;
27913
+ const referencedStyles = getReferencedTableStyles(styleTag, docx) || { fontSize: null, fonts: {}, cellMargins: {} };
27914
+ attributes.cellMargins = getTableCellMargins(tableCellProperties.cellMargins, referencedStyles);
27915
+ const { fontSize, fonts = {} } = referencedStyles;
27916
+ const fontFamily = fonts["ascii"];
27802
27917
  if (fontSize) attributes["fontSize"] = fontSize;
27803
- if (fontFamily) attributes["fontFamily"] = fontFamily["ascii"];
27804
- if (rowBorders) attributes["borders"] = { ...rowBorders };
27805
- if (inlineBorders) attributes["borders"] = Object.assign(attributes["borders"] || {}, inlineBorders);
27806
- if (vMergeAttrs && vMergeAttrs["w:val"] === "restart") {
27918
+ if (fontFamily) attributes["fontFamily"] = fontFamily;
27919
+ if (tableCellProperties.vMerge === "restart") {
27807
27920
  const rows = table.elements.filter((el) => el.name === "w:tr");
27808
27921
  const currentRowIndex = rows.findIndex((r) => r === row);
27809
27922
  const remainingRows = rows.slice(currentRowIndex + 1);
@@ -27814,9 +27927,8 @@ function handleTableCellNode({
27814
27927
  const firstCell = remainingRow.elements.findIndex((el) => el.name === "w:tc");
27815
27928
  const cellAtIndex = remainingRow.elements[firstCell + cellIndex];
27816
27929
  if (!cellAtIndex) break;
27817
- const vMerge2 = getTableCellMergeTag(cellAtIndex);
27818
- const { attributes: currentCellMergeAttrs } = vMerge2 || {};
27819
- if (!vMerge2 && !currentCellMergeAttrs || currentCellMergeAttrs && currentCellMergeAttrs["w:val"] === "restart") {
27930
+ const vMerge = getTableCellVMerge(cellAtIndex);
27931
+ if (!vMerge || vMerge === "restart") {
27820
27932
  break;
27821
27933
  }
27822
27934
  rowspan++;
@@ -27836,69 +27948,52 @@ function handleTableCellNode({
27836
27948
  }
27837
27949
  const processInlineCellBorders = (borders, rowBorders) => {
27838
27950
  if (!borders) return null;
27839
- const processedBorders = {};
27840
- const inlineBorderBottom = processBorder(borders, "bottom", rowBorders);
27841
- if (inlineBorderBottom) processedBorders["bottom"] = inlineBorderBottom;
27842
- const inlineBorderTop = processBorder(borders, "top", rowBorders);
27843
- if (inlineBorderTop) processedBorders["top"] = inlineBorderTop;
27844
- const inlineBorderLeft = processBorder(borders, "left", rowBorders);
27845
- if (inlineBorderLeft) processedBorders["left"] = inlineBorderLeft;
27846
- const inlineBorderRight = processBorder(borders, "right", rowBorders);
27847
- if (inlineBorderRight) processedBorders["right"] = inlineBorderRight;
27848
- return processedBorders;
27849
- };
27850
- const processBorder = (borders, direction, rowBorders = {}) => {
27851
- const borderAttrs = borders?.elements?.find((el) => el.name === `w:${direction}`)?.attributes;
27852
- if (borderAttrs && borderAttrs["w:val"] !== "nil") {
27853
- const border = {};
27854
- const color = borderAttrs["w:color"];
27855
- if (color) border["color"] = color === "auto" ? "#000000" : `#${color}`;
27856
- const size = borderAttrs["w:sz"];
27857
- if (size) border["size"] = eigthPointsToPixels(size);
27858
- return border;
27859
- }
27860
- if (borderAttrs && borderAttrs["w:val"] === "nil") {
27861
- const border = Object.assign({}, rowBorders[direction] || {});
27862
- if (!Object.keys(border)) return null;
27863
- border["val"] = "none";
27864
- return border;
27865
- }
27866
- return null;
27951
+ return ["bottom", "top", "left", "right"].reduce((acc, direction) => {
27952
+ const borderAttrs = borders[direction];
27953
+ const rowBorderAttrs = rowBorders[direction];
27954
+ if (borderAttrs && borderAttrs["val"] !== "nil") {
27955
+ const color = borderAttrs["color"];
27956
+ let size = borderAttrs["size"];
27957
+ if (size) size = eighthPointsToPixels(size);
27958
+ acc[direction] = { color, size, val: borderAttrs["val"] };
27959
+ return acc;
27960
+ }
27961
+ if (borderAttrs && borderAttrs["val"] === "nil") {
27962
+ const border = Object.assign({}, rowBorderAttrs || {});
27963
+ if (!Object.keys(border).length) {
27964
+ return acc;
27965
+ } else {
27966
+ border["val"] = "none";
27967
+ acc[direction] = border;
27968
+ return acc;
27969
+ }
27970
+ }
27971
+ return acc;
27972
+ }, {});
27867
27973
  };
27868
- const getTableCellMergeTag = (node) => {
27974
+ const getTableCellVMerge = (node) => {
27869
27975
  const tcPr = node.elements.find((el) => el.name === "w:tcPr");
27870
27976
  const vMerge = tcPr?.elements?.find((el) => el.name === "w:vMerge");
27871
- return vMerge;
27872
- };
27873
- const getTableCellMargins = (marginTag, referencedStyles) => {
27874
- const inlineMarginLeftTag = marginTag?.elements?.find((el) => el.name === "w:left");
27875
- const inlineMarginRightTag = marginTag?.elements?.find((el) => el.name === "w:right");
27876
- const inlineMarginTopTag = marginTag?.elements?.find((el) => el.name === "w:top");
27877
- const inlineMarginBottomTag = marginTag?.elements?.find((el) => el.name === "w:bottom");
27878
- const inlineMarginLeftValue = inlineMarginLeftTag?.attributes["w:w"];
27879
- const inlineMarginRightValue = inlineMarginRightTag?.attributes["w:w"];
27880
- const inlineMarginTopValue = inlineMarginTopTag?.attributes["w:w"];
27881
- const inlineMarginBottomValue = inlineMarginBottomTag?.attributes["w:w"];
27977
+ if (!vMerge) return null;
27978
+ return vMerge.attributes?.["w:val"] || "continue";
27979
+ };
27980
+ const getTableCellMargins = (inlineMargins, referencedStyles) => {
27882
27981
  const { cellMargins = {} } = referencedStyles;
27883
- const {
27884
- marginLeft: marginLeftStyle,
27885
- marginRight: marginRightStyle,
27886
- marginTop: marginTopStyle,
27887
- marginBottom: marginBottomStyle
27888
- } = cellMargins;
27889
- const resolveMargin = (inlineValue, styleValue) => {
27890
- if (inlineValue != null) return inlineValue;
27891
- if (styleValue == null) return void 0;
27892
- if (typeof styleValue === "object") return styleValue.value;
27893
- return styleValue;
27894
- };
27895
- const margins = {
27896
- left: twipsToPixels(resolveMargin(inlineMarginLeftValue, marginLeftStyle)),
27897
- right: twipsToPixels(resolveMargin(inlineMarginRightValue, marginRightStyle)),
27898
- top: twipsToPixels(resolveMargin(inlineMarginTopValue, marginTopStyle)),
27899
- bottom: twipsToPixels(resolveMargin(inlineMarginBottomValue, marginBottomStyle))
27900
- };
27901
- return margins;
27982
+ return ["left", "right", "top", "bottom"].reduce((acc, direction) => {
27983
+ const key = `margin${direction.charAt(0).toUpperCase() + direction.slice(1)}`;
27984
+ const inlineValue = inlineMargins ? inlineMargins?.[key]?.value : null;
27985
+ const styleValue = cellMargins ? cellMargins[key] : null;
27986
+ if (inlineValue != null) {
27987
+ acc[direction] = twipsToPixels(inlineValue);
27988
+ } else if (styleValue == null) {
27989
+ acc[direction] = void 0;
27990
+ } else if (typeof styleValue === "object") {
27991
+ acc[direction] = twipsToPixels(styleValue.value);
27992
+ } else {
27993
+ acc[direction] = twipsToPixels(styleValue);
27994
+ }
27995
+ return acc;
27996
+ }, {});
27902
27997
  };
27903
27998
  function translateTableCell(params) {
27904
27999
  const elements = translateChildNodes({
@@ -27913,107 +28008,91 @@ function translateTableCell(params) {
27913
28008
  };
27914
28009
  }
27915
28010
  function generateTableCellProperties(node) {
27916
- const elements = [];
28011
+ const tableCellProperties = { ...node.attrs?.tableCellProperties || {} };
27917
28012
  const { attrs } = node;
27918
- const { colwidth = [], cellWidthType = "dxa", background = {}, colspan, rowspan, widthUnit } = attrs;
28013
+ const { colwidth = [], cellWidthType = "dxa", widthUnit } = attrs;
27919
28014
  const colwidthSum = colwidth.reduce((acc, curr) => acc + curr, 0);
27920
- const cellWidthElement = {
27921
- name: "w:tcW",
27922
- attributes: {
27923
- "w:w": widthUnit === "px" ? pixelsToTwips(colwidthSum) : inchesToTwips(colwidthSum),
27924
- "w:type": cellWidthType
27925
- }
27926
- };
27927
- elements.push(cellWidthElement);
27928
- if (colspan) {
27929
- const gridSpanElement = {
27930
- name: "w:gridSpan",
27931
- attributes: { "w:val": `${colspan}` }
28015
+ const propertiesWidthPixels = twipsToPixels(tableCellProperties.cellWidth?.value);
28016
+ if (propertiesWidthPixels !== colwidthSum) {
28017
+ tableCellProperties["cellWidth"] = {
28018
+ value: widthUnit === "px" ? pixelsToTwips(colwidthSum) : inchesToTwips(colwidthSum),
28019
+ type: cellWidthType
27932
28020
  };
27933
- elements.push(gridSpanElement);
27934
28021
  }
27935
- const { color } = background || {};
27936
- if (color) {
27937
- const cellBgElement = {
27938
- name: "w:shd",
27939
- attributes: { "w:fill": color }
27940
- };
27941
- elements.push(cellBgElement);
28022
+ const { colspan } = attrs;
28023
+ if (colspan > 1 && tableCellProperties.gridSpan !== colspan) {
28024
+ tableCellProperties["gridSpan"] = colspan;
28025
+ } else if (!colspan || tableCellProperties?.gridSpan === 1) {
28026
+ delete tableCellProperties.gridSpan;
28027
+ }
28028
+ const { background = {} } = attrs;
28029
+ if (background?.color && tableCellProperties.shading?.fill !== background?.color) {
28030
+ tableCellProperties["shading"] = { fill: background.color };
28031
+ } else if (!background?.color && tableCellProperties?.shading?.fill) {
28032
+ delete tableCellProperties.shading;
27942
28033
  }
27943
28034
  const { cellMargins } = attrs;
27944
28035
  if (cellMargins) {
27945
- const cellMarginsElement = {
27946
- name: "w:tcMar",
27947
- elements: generateCellMargins(cellMargins)
27948
- };
27949
- elements.push(cellMarginsElement);
28036
+ ["left", "right", "top", "bottom"].forEach((side) => {
28037
+ const key = `margin${side.charAt(0).toUpperCase() + side.slice(1)}`;
28038
+ if (cellMargins[side] != null) {
28039
+ if (!tableCellProperties.cellMargins) tableCellProperties["cellMargins"] = {};
28040
+ let currentPropertyValuePixels = twipsToPixels(tableCellProperties.cellMargins?.[key]?.value);
28041
+ if (currentPropertyValuePixels !== cellMargins[side]) {
28042
+ tableCellProperties.cellMargins[key] = { value: pixelsToTwips(cellMargins[side]), type: "dxa" };
28043
+ }
28044
+ } else if (tableCellProperties?.cellMargins?.[key]) {
28045
+ delete tableCellProperties.cellMargins[key];
28046
+ }
28047
+ });
27950
28048
  }
27951
28049
  const { verticalAlign } = attrs;
27952
- if (verticalAlign) {
27953
- const vertAlignElement = {
27954
- name: "w:vAlign",
27955
- attributes: { "w:val": verticalAlign }
27956
- };
27957
- elements.push(vertAlignElement);
27958
- }
27959
- if (rowspan && rowspan > 1) {
27960
- const vMergeElement = {
27961
- name: "w:vMerge",
27962
- type: "element",
27963
- attributes: { "w:val": "restart" }
27964
- };
27965
- elements.push(vMergeElement);
28050
+ if (verticalAlign && verticalAlign !== tableCellProperties.vAlign) {
28051
+ tableCellProperties["vAlign"] = verticalAlign;
28052
+ } else if (!verticalAlign && tableCellProperties?.vAlign) {
28053
+ delete tableCellProperties.vAlign;
28054
+ }
28055
+ const { rowspan } = attrs;
28056
+ if (rowspan && rowspan > 1 && tableCellProperties.vMerge !== "restart") {
28057
+ tableCellProperties["vMerge"] = "restart";
27966
28058
  } else if (attrs.continueMerge) {
27967
- const vMergeElement = {
27968
- name: "w:vMerge",
27969
- type: "element"
27970
- };
27971
- elements.push(vMergeElement);
28059
+ tableCellProperties["vMerge"] = "continue";
28060
+ } else if (tableCellProperties?.vMerge) {
28061
+ delete tableCellProperties.vMerge;
27972
28062
  }
27973
28063
  const { borders = {} } = attrs;
27974
28064
  if (!!borders && Object.keys(borders).length) {
27975
- const cellBordersElement = {
27976
- name: "w:tcBorders",
27977
- elements: Object.entries(borders).map(([key, value]) => {
27978
- if (!value.size || value.val === "none") {
27979
- return {
27980
- name: `w:${key}`,
27981
- attributes: {
27982
- "w:val": "nil"
27983
- }
28065
+ ["top", "bottom", "left", "right"].forEach((side) => {
28066
+ if (borders[side]) {
28067
+ let currentPropertyValue = tableCellProperties.borders?.[side];
28068
+ let currentPropertySizePixels = eighthPointsToPixels(currentPropertyValue?.size);
28069
+ let color = borders[side].color;
28070
+ if (borders[side].color && color === "#000000") {
28071
+ color = "auto";
28072
+ }
28073
+ if (currentPropertySizePixels !== borders[side].size || currentPropertyValue?.color !== color || borders[side].val !== currentPropertyValue?.val) {
28074
+ if (!tableCellProperties.borders) tableCellProperties["borders"] = {};
28075
+ tableCellProperties.borders[side] = {
28076
+ size: pixelsToEightPoints(borders[side].size || 0),
28077
+ color,
28078
+ space: borders[side].space || 0,
28079
+ val: borders[side].val || "single"
27984
28080
  };
27985
28081
  }
27986
- return {
27987
- name: `w:${key}`,
27988
- attributes: {
27989
- "w:val": "single",
27990
- "w:color": value.color ? value.color.substring(1) : "auto",
27991
- "w:sz": pixelsToEightPoints(value.size),
27992
- "w:space": value.space || 0
27993
- }
27994
- };
27995
- })
27996
- };
27997
- elements.push(cellBordersElement);
28082
+ } else if (tableCellProperties.borders?.[side]) {
28083
+ delete tableCellProperties.borders[side];
28084
+ }
28085
+ });
28086
+ } else if (tableCellProperties?.borders) {
28087
+ delete tableCellProperties.borders;
27998
28088
  }
27999
- return {
28000
- name: "w:tcPr",
28001
- elements
28002
- };
28003
- }
28004
- function generateCellMargins(cellMargins) {
28005
- const elements = [];
28006
- const { top, right, bottom, left } = cellMargins;
28007
- if (top != null) elements.push({ name: "w:top", attributes: { "w:w": pixelsToTwips(top) } });
28008
- if (right != null) elements.push({ name: "w:right", attributes: { "w:w": pixelsToTwips(right) } });
28009
- if (bottom != null) elements.push({ name: "w:bottom", attributes: { "w:w": pixelsToTwips(bottom) } });
28010
- if (left != null) elements.push({ name: "w:left", attributes: { "w:w": pixelsToTwips(left) } });
28011
- return elements;
28089
+ const result = translator$d.decode({ node: { ...node, attrs: { ...node.attrs, tableCellProperties } } });
28090
+ return result;
28012
28091
  }
28013
- const XML_NODE_NAME$b = "w:tc";
28092
+ const XML_NODE_NAME$d = "w:tc";
28014
28093
  const SD_NODE_NAME$b = "tableCell";
28015
- const validXmlAttributes$8 = [];
28016
- function encode$h(params, encodedAttrs) {
28094
+ const validXmlAttributes$a = [];
28095
+ function encode$j(params, encodedAttrs) {
28017
28096
  const {
28018
28097
  node,
28019
28098
  table,
@@ -28040,22 +28119,22 @@ function encode$h(params, encodedAttrs) {
28040
28119
  }
28041
28120
  return schemaNode;
28042
28121
  }
28043
- function decode$j(params, decodedAttrs) {
28122
+ function decode$l(params, decodedAttrs) {
28044
28123
  const translated = translateTableCell(params);
28045
28124
  if (decodedAttrs && Object.keys(decodedAttrs).length) {
28046
28125
  translated.attributes = { ...translated.attributes || {}, ...decodedAttrs };
28047
28126
  }
28048
28127
  return translated;
28049
28128
  }
28050
- const config$a = {
28051
- xmlName: XML_NODE_NAME$b,
28129
+ const config$c = {
28130
+ xmlName: XML_NODE_NAME$d,
28052
28131
  sdNodeOrKeyName: SD_NODE_NAME$b,
28053
28132
  type: NodeTranslator.translatorTypes.NODE,
28054
- encode: encode$h,
28055
- decode: decode$j,
28056
- attributes: validXmlAttributes$8
28133
+ encode: encode$j,
28134
+ decode: decode$l,
28135
+ attributes: validXmlAttributes$a
28057
28136
  };
28058
- const translator$a = NodeTranslator.from(config$a);
28137
+ const translator$c = NodeTranslator.from(config$c);
28059
28138
  function parseTagValueJSON(json) {
28060
28139
  if (typeof json !== "string") {
28061
28140
  return {};
@@ -28482,8 +28561,64 @@ function handleImageNode(node, params, isAnchor) {
28482
28561
  const vRelativeFrom = positionVTag?.attributes.relativeFrom;
28483
28562
  const alignV = positionVTag?.elements?.find((el) => el.name === "wp:align")?.elements[0]?.text;
28484
28563
  const simplePos = node.elements.find((el) => el.name === "wp:simplePos");
28485
- const wrapSquare = node.elements.find((el) => el.name === "wp:wrapSquare");
28486
- const wrapTopAndBottom = node.elements.find((el) => el.name === "wp:wrapTopAndBottom");
28564
+ const wrapNode = isAnchor ? node.elements.find(
28565
+ (el) => ["wp:wrapNone", "wp:wrapSquare", "wp:wrapThrough", "wp:wrapTight", "wp:wrapTopAndBottom"].includes(el.name)
28566
+ ) : null;
28567
+ const wrap2 = isAnchor ? { type: wrapNode?.name.slice(7) || "None", attrs: {} } : { type: "Inline" };
28568
+ switch (wrap2.type) {
28569
+ case "Square":
28570
+ wrap2.attrs.wrapText = wrapNode.attributes.wrapText;
28571
+ if ("distB" in (wrapNode.attributes || {})) {
28572
+ wrap2.attrs.distBottom = emuToPixels(wrapNode.attributes.distB);
28573
+ }
28574
+ if ("distL" in (wrapNode.attributes || {})) {
28575
+ wrap2.attrs.distLeft = emuToPixels(wrapNode.attributes.distL);
28576
+ }
28577
+ if ("distR" in (wrapNode.attributes || {})) {
28578
+ wrap2.attrs.distRight = emuToPixels(wrapNode.attributes.distR);
28579
+ }
28580
+ if ("distT" in (wrapNode.attributes || {})) {
28581
+ wrap2.attrs.distTop = emuToPixels(wrapNode.attributes.distT);
28582
+ }
28583
+ break;
28584
+ case "Tight":
28585
+ case "Through": {
28586
+ if ("distL" in (wrapNode.attributes || {})) {
28587
+ wrap2.attrs.distLeft = emuToPixels(wrapNode.attributes.distL);
28588
+ }
28589
+ if ("distR" in (wrapNode.attributes || {})) {
28590
+ wrap2.attrs.distRight = emuToPixels(wrapNode.attributes.distR);
28591
+ }
28592
+ if ("distT" in (wrapNode.attributes || {})) {
28593
+ wrap2.attrs.distTop = emuToPixels(wrapNode.attributes.distT);
28594
+ }
28595
+ if ("distB" in (wrapNode.attributes || {})) {
28596
+ wrap2.attrs.distBottom = emuToPixels(wrapNode.attributes.distB);
28597
+ }
28598
+ if ("wrapText" in (wrapNode.attributes || {})) {
28599
+ wrap2.attrs.wrapText = wrapNode.attributes.wrapText;
28600
+ }
28601
+ const polygon = wrapNode.elements?.find((el) => el.name === "wp:wrapPolygon");
28602
+ if (polygon) {
28603
+ wrap2.attrs.polygon = polygonToObj(polygon);
28604
+ if (polygon.attributes?.edited !== void 0) {
28605
+ wrap2.attrs.polygonEdited = polygon.attributes.edited;
28606
+ }
28607
+ }
28608
+ break;
28609
+ }
28610
+ case "TopAndBottom":
28611
+ if ("distB" in (wrapNode.attributes || {})) {
28612
+ wrap2.attrs.distBottom = emuToPixels(wrapNode.attributes.distB);
28613
+ }
28614
+ if ("distT" in (wrapNode.attributes || {})) {
28615
+ wrap2.attrs.distTop = emuToPixels(wrapNode.attributes.distT);
28616
+ }
28617
+ break;
28618
+ case "None":
28619
+ wrap2.attrs.behindDoc = node.attributes?.behindDoc === "1";
28620
+ break;
28621
+ }
28487
28622
  const docPr = node.elements.find((el) => el.name === "wp:docPr");
28488
28623
  let anchorData = null;
28489
28624
  if (hRelativeFrom || alignH || vRelativeFrom || alignV) {
@@ -28495,7 +28630,7 @@ function handleImageNode(node, params, isAnchor) {
28495
28630
  };
28496
28631
  }
28497
28632
  const marginOffset = {
28498
- left: positionHValue,
28633
+ horizontal: positionHValue,
28499
28634
  top: positionVValue
28500
28635
  };
28501
28636
  const { attributes: blipAttributes = {} } = blip;
@@ -28534,10 +28669,7 @@ function handleImageNode(node, params, isAnchor) {
28534
28669
  y: simplePos.attributes.y
28535
28670
  }
28536
28671
  },
28537
- ...wrapSquare && {
28538
- wrapText: wrapSquare.attributes.wrapText
28539
- },
28540
- wrapTopAndBottom: !!wrapTopAndBottom,
28672
+ wrap: wrap2,
28541
28673
  originalPadding: {
28542
28674
  distT: attributes["distT"],
28543
28675
  distB: attributes["distB"],
@@ -28885,7 +29017,6 @@ function addNewImageRelationship(params, imagePath) {
28885
29017
  function translateAnchorNode(params) {
28886
29018
  const { attrs } = params.node;
28887
29019
  const anchorElements = [];
28888
- const wrapElements = [];
28889
29020
  if (attrs.simplePos) {
28890
29021
  anchorElements.push({
28891
29022
  name: "wp:simplePos",
@@ -28897,10 +29028,10 @@ function translateAnchorNode(params) {
28897
29028
  }
28898
29029
  if (attrs.anchorData) {
28899
29030
  const hElements = [];
28900
- if (attrs.marginOffset.left !== void 0) {
29031
+ if (attrs.marginOffset.horizontal !== void 0) {
28901
29032
  hElements.push({
28902
29033
  name: "wp:posOffset",
28903
- elements: [{ type: "text", text: pixelsToEmu(attrs.marginOffset.left).toString() }]
29034
+ elements: [{ type: "text", text: pixelsToEmu(attrs.marginOffset.horizontal).toString() }]
28904
29035
  });
28905
29036
  }
28906
29037
  if (attrs.anchorData.alignH) {
@@ -28933,38 +29064,110 @@ function translateAnchorNode(params) {
28933
29064
  ...vElements.length && { elements: vElements }
28934
29065
  });
28935
29066
  }
28936
- if (attrs.wrapText) {
28937
- wrapElements.push({
28938
- name: "wp:wrapSquare",
28939
- attributes: {
28940
- wrapText: attrs.wrapText
28941
- }
28942
- });
29067
+ const nodeElements = translateImageNode(params);
29068
+ const inlineAttrs = {
29069
+ ...attrs.originalAttributes || {},
29070
+ ...nodeElements.attributes || {}
29071
+ };
29072
+ if (inlineAttrs.relativeHeight == null) {
29073
+ inlineAttrs.relativeHeight = 1;
28943
29074
  }
28944
- if (attrs.wrapTopAndBottom) {
28945
- wrapElements.push({
28946
- name: "wp:wrapTopAndBottom"
28947
- });
29075
+ if (attrs.originalAttributes?.simplePos !== void 0) {
29076
+ inlineAttrs.simplePos = attrs.originalAttributes.simplePos;
29077
+ } else if (attrs.simplePos !== void 0) {
29078
+ inlineAttrs.simplePos = attrs.simplePos;
28948
29079
  }
28949
- if (!wrapElements.length) {
28950
- wrapElements.push({
28951
- name: "wp:wrapNone"
28952
- });
29080
+ if (attrs.originalAttributes?.locked !== void 0) {
29081
+ inlineAttrs.locked = attrs.originalAttributes.locked;
28953
29082
  }
28954
- const nodeElements = translateImageNode(params);
28955
- const inlineAttrs = {
28956
- ...nodeElements.attributes,
28957
- simplePos: attrs.originalAttributes?.simplePos,
28958
- relativeHeight: 1,
28959
- behindDoc: attrs.originalAttributes?.behindDoc,
28960
- locked: attrs.originalAttributes?.locked,
28961
- layoutInCell: attrs.originalAttributes?.layoutInCell,
28962
- allowOverlap: attrs.originalAttributes?.allowOverlap
29083
+ if (attrs.originalAttributes?.layoutInCell !== void 0) {
29084
+ inlineAttrs.layoutInCell = attrs.originalAttributes.layoutInCell;
29085
+ }
29086
+ if (attrs.originalAttributes?.allowOverlap !== void 0) {
29087
+ inlineAttrs.allowOverlap = attrs.originalAttributes.allowOverlap;
29088
+ }
29089
+ const wrapElement = {
29090
+ name: `wp:wrap${attrs.wrap?.type || "None"}`
29091
+ // Important: wp:anchor will break if no wrapping is specified. We need to use wrapNone.
28963
29092
  };
29093
+ switch (attrs.wrap?.type) {
29094
+ case "Square":
29095
+ wrapElement.attributes = {
29096
+ wrapText: attrs.wrap.attrs.wrapText
29097
+ };
29098
+ if ("distBottom" in (attrs.wrap.attrs || {})) {
29099
+ wrapElement.attributes.distB = pixelsToEmu(attrs.wrap.attrs.distBottom);
29100
+ }
29101
+ if ("distLeft" in (attrs.wrap.attrs || {})) {
29102
+ wrapElement.attributes.distL = pixelsToEmu(attrs.wrap.attrs.distLeft);
29103
+ }
29104
+ if ("distRight" in (attrs.wrap.attrs || {})) {
29105
+ wrapElement.attributes.distR = pixelsToEmu(attrs.wrap.attrs.distRight);
29106
+ }
29107
+ if ("distTop" in (attrs.wrap.attrs || {})) {
29108
+ wrapElement.attributes.distT = pixelsToEmu(attrs.wrap.attrs.distTop);
29109
+ }
29110
+ break;
29111
+ case "TopAndBottom": {
29112
+ const attributes = {};
29113
+ let hasKeys = false;
29114
+ if ("distBottom" in (attrs.wrap.attrs || {})) {
29115
+ attributes.distB = pixelsToEmu(attrs.wrap.attrs.distBottom);
29116
+ hasKeys = true;
29117
+ }
29118
+ if ("distTop" in (attrs.wrap.attrs || {})) {
29119
+ attributes.distT = pixelsToEmu(attrs.wrap.attrs.distTop);
29120
+ hasKeys = true;
29121
+ }
29122
+ if (hasKeys) {
29123
+ wrapElement.attributes = attributes;
29124
+ }
29125
+ break;
29126
+ }
29127
+ case "Through":
29128
+ case "Tight": {
29129
+ const attributes = {};
29130
+ if ("distLeft" in (attrs.wrap.attrs || {})) {
29131
+ attributes.distL = pixelsToEmu(attrs.wrap.attrs.distLeft);
29132
+ }
29133
+ if ("distRight" in (attrs.wrap.attrs || {})) {
29134
+ attributes.distR = pixelsToEmu(attrs.wrap.attrs.distRight);
29135
+ }
29136
+ if ("distTop" in (attrs.wrap.attrs || {})) {
29137
+ attributes.distT = pixelsToEmu(attrs.wrap.attrs.distTop);
29138
+ }
29139
+ if ("distBottom" in (attrs.wrap.attrs || {})) {
29140
+ attributes.distB = pixelsToEmu(attrs.wrap.attrs.distBottom);
29141
+ }
29142
+ const wrapText = attrs.wrap.attrs?.wrapText || "bothSides";
29143
+ {
29144
+ attributes.wrapText = wrapText;
29145
+ }
29146
+ if (Object.keys(attributes).length) {
29147
+ wrapElement.attributes = attributes;
29148
+ }
29149
+ if (attrs.wrap.attrs?.polygon) {
29150
+ const polygonNode = objToPolygon(attrs.wrap.attrs.polygon);
29151
+ if (polygonNode) {
29152
+ if (attrs.wrap.attrs?.polygonEdited !== void 0) {
29153
+ polygonNode.attributes = {
29154
+ ...polygonNode.attributes || {},
29155
+ edited: String(attrs.wrap.attrs.polygonEdited)
29156
+ };
29157
+ }
29158
+ wrapElement.elements = [polygonNode];
29159
+ }
29160
+ }
29161
+ break;
29162
+ }
29163
+ case "None":
29164
+ inlineAttrs.behindDoc = attrs.wrap.attrs?.behindDoc ? "1" : "0";
29165
+ break;
29166
+ }
28964
29167
  const effectIndex = nodeElements.elements.findIndex((el) => el.name === "wp:effectExtent");
28965
29168
  const elementsWithWrap = [
28966
29169
  ...nodeElements.elements.slice(0, effectIndex + 1),
28967
- ...wrapElements,
29170
+ wrapElement,
28968
29171
  ...nodeElements.elements.slice(effectIndex + 1)
28969
29172
  ];
28970
29173
  return {
@@ -28973,32 +29176,32 @@ function translateAnchorNode(params) {
28973
29176
  elements: [...anchorElements, ...elementsWithWrap]
28974
29177
  };
28975
29178
  }
28976
- const XML_NODE_NAME$a = "wp:anchor";
29179
+ const XML_NODE_NAME$c = "wp:anchor";
28977
29180
  const SD_NODE_NAME$a = ["image"];
28978
- const validXmlAttributes$7 = ["distT", "distB", "distL", "distR"].map((xmlName) => createAttributeHandler(xmlName));
28979
- function encode$g(params) {
29181
+ const validXmlAttributes$9 = ["distT", "distB", "distL", "distR"].map((xmlName) => createAttributeHandler(xmlName));
29182
+ function encode$i(params) {
28980
29183
  const { node } = params.extraParams;
28981
29184
  if (!node || !node.type) {
28982
29185
  return null;
28983
29186
  }
28984
29187
  return handleAnchorNode(params);
28985
29188
  }
28986
- function decode$i(params) {
29189
+ function decode$k(params) {
28987
29190
  const { node } = params;
28988
29191
  if (!node || !node.type) {
28989
29192
  return null;
28990
29193
  }
28991
29194
  return translateAnchorNode(params);
28992
29195
  }
28993
- const config$9 = {
28994
- xmlName: XML_NODE_NAME$a,
29196
+ const config$b = {
29197
+ xmlName: XML_NODE_NAME$c,
28995
29198
  sdNodeOrKeyName: SD_NODE_NAME$a,
28996
29199
  type: NodeTranslator.translatorTypes.NODE,
28997
- encode: encode$g,
28998
- decode: decode$i,
28999
- attributes: validXmlAttributes$7
29200
+ encode: encode$i,
29201
+ decode: decode$k,
29202
+ attributes: validXmlAttributes$9
29000
29203
  };
29001
- const translator$9 = NodeTranslator.from(config$9);
29204
+ const translator$b = NodeTranslator.from(config$b);
29002
29205
  function handleInlineNode(params) {
29003
29206
  const { node } = params.extraParams;
29004
29207
  if (node.name !== "wp:inline") {
@@ -29014,41 +29217,41 @@ function translateInlineNode(params) {
29014
29217
  elements: nodeElements.elements
29015
29218
  };
29016
29219
  }
29017
- const XML_NODE_NAME$9 = "wp:inline";
29220
+ const XML_NODE_NAME$b = "wp:inline";
29018
29221
  const SD_NODE_NAME$9 = ["image"];
29019
- const validXmlAttributes$6 = ["distT", "distB", "distL", "distR"].map((xmlName) => createAttributeHandler(xmlName));
29020
- function encode$f(params) {
29222
+ const validXmlAttributes$8 = ["distT", "distB", "distL", "distR"].map((xmlName) => createAttributeHandler(xmlName));
29223
+ function encode$h(params) {
29021
29224
  const { node } = params.extraParams;
29022
29225
  if (!node || !node.type) {
29023
29226
  return null;
29024
29227
  }
29025
29228
  return handleInlineNode(params);
29026
29229
  }
29027
- function decode$h(params) {
29230
+ function decode$j(params) {
29028
29231
  const { node } = params;
29029
29232
  if (!node || !node.type) {
29030
29233
  return null;
29031
29234
  }
29032
29235
  return translateInlineNode(params);
29033
29236
  }
29034
- const config$8 = {
29035
- xmlName: XML_NODE_NAME$9,
29237
+ const config$a = {
29238
+ xmlName: XML_NODE_NAME$b,
29036
29239
  sdNodeOrKeyName: SD_NODE_NAME$9,
29037
29240
  type: NodeTranslator.translatorTypes.NODE,
29038
- encode: encode$f,
29039
- decode: decode$h,
29040
- attributes: validXmlAttributes$6
29241
+ encode: encode$h,
29242
+ decode: decode$j,
29243
+ attributes: validXmlAttributes$8
29041
29244
  };
29042
- const translator$8 = NodeTranslator.from(config$8);
29043
- const XML_NODE_NAME$8 = "w:drawing";
29245
+ const translator$a = NodeTranslator.from(config$a);
29246
+ const XML_NODE_NAME$a = "w:drawing";
29044
29247
  const SD_NODE_NAME$8 = [];
29045
- const validXmlAttributes$5 = [];
29046
- function encode$e(params) {
29248
+ const validXmlAttributes$7 = [];
29249
+ function encode$g(params) {
29047
29250
  const nodes = params.nodes;
29048
29251
  const node = nodes[0];
29049
29252
  const translatorByChildName = {
29050
- "wp:anchor": translator$9,
29051
- "wp:inline": translator$8
29253
+ "wp:anchor": translator$b,
29254
+ "wp:inline": translator$a
29052
29255
  };
29053
29256
  return node.elements.reduce((acc, child) => {
29054
29257
  if (acc) return acc;
@@ -29057,12 +29260,12 @@ function encode$e(params) {
29057
29260
  return translator2.encode({ ...params, extraParams: { node: child } }) || acc;
29058
29261
  }, null);
29059
29262
  }
29060
- function decode$g(params) {
29263
+ function decode$i(params) {
29061
29264
  const { node } = params;
29062
29265
  if (!node || !node.type) {
29063
29266
  return null;
29064
29267
  }
29065
- const childTranslator = node.attrs.isAnchor ? translator$9 : translator$8;
29268
+ const childTranslator = node.attrs.isAnchor ? translator$b : translator$a;
29066
29269
  const resultNode = childTranslator.decode(params);
29067
29270
  return wrapTextInRun(
29068
29271
  {
@@ -29072,15 +29275,15 @@ function decode$g(params) {
29072
29275
  []
29073
29276
  );
29074
29277
  }
29075
- const config$7 = {
29076
- xmlName: XML_NODE_NAME$8,
29278
+ const config$9 = {
29279
+ xmlName: XML_NODE_NAME$a,
29077
29280
  sdNodeOrKeyName: SD_NODE_NAME$8,
29078
29281
  type: NodeTranslator.translatorTypes.NODE,
29079
- encode: encode$e,
29080
- decode: decode$g,
29081
- attributes: validXmlAttributes$5
29282
+ encode: encode$g,
29283
+ decode: decode$i,
29284
+ attributes: validXmlAttributes$7
29082
29285
  };
29083
- const translator$7 = NodeTranslator.from(config$7);
29286
+ const translator$9 = NodeTranslator.from(config$9);
29084
29287
  class CommandService {
29085
29288
  /**
29086
29289
  * @param {import('./commands/types/index.js').CommandServiceOptions} props
@@ -30428,7 +30631,7 @@ function prepareTextAnnotation(params) {
30428
30631
  return getTextNodeForExport(attrs.displayLabel, [...marks, ...marksFromAttrs], params);
30429
30632
  }
30430
30633
  function prepareImageAnnotation(params, imageSize) {
30431
- return translator$7.decode({
30634
+ return translator$9.decode({
30432
30635
  ...params,
30433
30636
  imageSize
30434
30637
  });
@@ -30743,10 +30946,10 @@ function generateSdtPrTagForStructuredContent({ node }) {
30743
30946
  };
30744
30947
  return result;
30745
30948
  }
30746
- const XML_NODE_NAME$7 = "w:sdt";
30949
+ const XML_NODE_NAME$9 = "w:sdt";
30747
30950
  const SD_NODE_NAME$7 = ["fieldAnnotation", "structuredContent", "structuredContentBlock", "documentSection"];
30748
- const validXmlAttributes$4 = [];
30749
- function encode$d(params) {
30951
+ const validXmlAttributes$6 = [];
30952
+ function encode$f(params) {
30750
30953
  const nodes = params.nodes;
30751
30954
  const node = nodes[0];
30752
30955
  const { type: sdtType, handler: handler2 } = sdtNodeTypeStrategy(node);
@@ -30756,7 +30959,7 @@ function encode$d(params) {
30756
30959
  const result = handler2(params);
30757
30960
  return result;
30758
30961
  }
30759
- function decode$f(params) {
30962
+ function decode$h(params) {
30760
30963
  const { node } = params;
30761
30964
  if (!node || !node.type) {
30762
30965
  return null;
@@ -30774,85 +30977,85 @@ function decode$f(params) {
30774
30977
  const result = decoder();
30775
30978
  return result;
30776
30979
  }
30777
- const config$6 = {
30778
- xmlName: XML_NODE_NAME$7,
30980
+ const config$8 = {
30981
+ xmlName: XML_NODE_NAME$9,
30779
30982
  sdNodeOrKeyName: SD_NODE_NAME$7,
30780
30983
  type: NodeTranslator.translatorTypes.NODE,
30781
- encode: encode$d,
30782
- decode: decode$f,
30783
- attributes: validXmlAttributes$4
30984
+ encode: encode$f,
30985
+ decode: decode$h,
30986
+ attributes: validXmlAttributes$6
30784
30987
  };
30785
- const translator$6 = NodeTranslator.from(config$6);
30786
- const encode$c = (attributes) => {
30988
+ const translator$8 = NodeTranslator.from(config$8);
30989
+ const encode$e = (attributes) => {
30787
30990
  return attributes["w:id"];
30788
30991
  };
30789
- const decode$e = (attrs) => {
30992
+ const decode$g = (attrs) => {
30790
30993
  return attrs.id;
30791
30994
  };
30792
30995
  const attrConfig$7 = Object.freeze({
30793
30996
  xmlName: "w:id",
30794
30997
  sdName: "id",
30795
- encode: encode$c,
30796
- decode: decode$e
30998
+ encode: encode$e,
30999
+ decode: decode$g
30797
31000
  });
30798
- const encode$b = (attributes) => {
31001
+ const encode$d = (attributes) => {
30799
31002
  return attributes["w:name"];
30800
31003
  };
30801
- const decode$d = (attrs) => {
31004
+ const decode$f = (attrs) => {
30802
31005
  return attrs.name;
30803
31006
  };
30804
31007
  const attrConfig$6 = Object.freeze({
30805
31008
  xmlName: "w:name",
30806
31009
  sdName: "name",
30807
- encode: encode$b,
30808
- decode: decode$d
31010
+ encode: encode$d,
31011
+ decode: decode$f
30809
31012
  });
30810
- const encode$a = (attributes) => {
31013
+ const encode$c = (attributes) => {
30811
31014
  return attributes["w:colFirst"];
30812
31015
  };
30813
- const decode$c = (attrs) => {
31016
+ const decode$e = (attrs) => {
30814
31017
  return attrs.colFirst;
30815
31018
  };
30816
31019
  const attrConfig$5 = Object.freeze({
30817
31020
  xmlName: "w:colFirst",
30818
31021
  sdName: "colFirst",
30819
- encode: encode$a,
30820
- decode: decode$c
31022
+ encode: encode$c,
31023
+ decode: decode$e
30821
31024
  });
30822
- const encode$9 = (attributes) => {
31025
+ const encode$b = (attributes) => {
30823
31026
  return attributes["w:colLast"];
30824
31027
  };
30825
- const decode$b = (attrs) => {
31028
+ const decode$d = (attrs) => {
30826
31029
  return attrs.colLast;
30827
31030
  };
30828
31031
  const attrConfig$4 = Object.freeze({
30829
31032
  xmlName: "w:colLast",
30830
31033
  sdName: "colLast",
30831
- encode: encode$9,
30832
- decode: decode$b
31034
+ encode: encode$b,
31035
+ decode: decode$d
30833
31036
  });
30834
- const encode$8 = (attributes) => {
31037
+ const encode$a = (attributes) => {
30835
31038
  return attributes["w:displacedByCustomXml"];
30836
31039
  };
30837
- const decode$a = (attrs) => {
31040
+ const decode$c = (attrs) => {
30838
31041
  return attrs.displacedByCustomXml;
30839
31042
  };
30840
31043
  const attrConfig$3 = Object.freeze({
30841
31044
  xmlName: "w:displacedByCustomXml",
30842
31045
  sdName: "displacedByCustomXml",
30843
- encode: encode$8,
30844
- decode: decode$a
31046
+ encode: encode$a,
31047
+ decode: decode$c
30845
31048
  });
30846
- const validXmlAttributes$3 = [attrConfig$7, attrConfig$6, attrConfig$5, attrConfig$4, attrConfig$3];
30847
- const XML_NODE_NAME$6 = "w:bookmarkStart";
31049
+ const validXmlAttributes$5 = [attrConfig$7, attrConfig$6, attrConfig$5, attrConfig$4, attrConfig$3];
31050
+ const XML_NODE_NAME$8 = "w:bookmarkStart";
30848
31051
  const SD_NODE_NAME$6 = "bookmarkStart";
30849
- const encode$7 = (params, encodedAttrs = {}) => {
31052
+ const encode$9 = (params, encodedAttrs = {}) => {
30850
31053
  return {
30851
31054
  type: "bookmarkStart",
30852
31055
  attrs: encodedAttrs
30853
31056
  };
30854
31057
  };
30855
- const decode$9 = (params, decodedAttrs = {}) => {
31058
+ const decode$b = (params, decodedAttrs = {}) => {
30856
31059
  const result = {
30857
31060
  name: "w:bookmarkStart",
30858
31061
  elements: []
@@ -30862,49 +31065,49 @@ const decode$9 = (params, decodedAttrs = {}) => {
30862
31065
  }
30863
31066
  return result;
30864
31067
  };
30865
- const config$5 = {
30866
- xmlName: XML_NODE_NAME$6,
31068
+ const config$7 = {
31069
+ xmlName: XML_NODE_NAME$8,
30867
31070
  sdNodeOrKeyName: SD_NODE_NAME$6,
30868
31071
  type: NodeTranslator.translatorTypes.NODE,
30869
- encode: encode$7,
30870
- decode: decode$9,
30871
- attributes: validXmlAttributes$3
31072
+ encode: encode$9,
31073
+ decode: decode$b,
31074
+ attributes: validXmlAttributes$5
30872
31075
  };
30873
- const translator$5 = NodeTranslator.from(config$5);
30874
- const encode$6 = (attributes) => {
31076
+ const translator$7 = NodeTranslator.from(config$7);
31077
+ const encode$8 = (attributes) => {
30875
31078
  return attributes["w:id"];
30876
31079
  };
30877
- const decode$8 = (attrs) => {
31080
+ const decode$a = (attrs) => {
30878
31081
  return attrs.id;
30879
31082
  };
30880
31083
  const attrConfig$2 = Object.freeze({
30881
31084
  xmlName: "w:id",
30882
31085
  sdName: "id",
30883
- encode: encode$6,
30884
- decode: decode$8
31086
+ encode: encode$8,
31087
+ decode: decode$a
30885
31088
  });
30886
- const encode$5 = (attributes) => {
31089
+ const encode$7 = (attributes) => {
30887
31090
  return attributes["w:displacedByCustomXml"];
30888
31091
  };
30889
- const decode$7 = (attrs) => {
31092
+ const decode$9 = (attrs) => {
30890
31093
  return attrs.displacedByCustomXml;
30891
31094
  };
30892
31095
  const attrConfig$1 = Object.freeze({
30893
31096
  xmlName: "w:displacedByCustomXml",
30894
31097
  sdName: "displacedByCustomXml",
30895
- encode: encode$5,
30896
- decode: decode$7
31098
+ encode: encode$7,
31099
+ decode: decode$9
30897
31100
  });
30898
- const validXmlAttributes$2 = [attrConfig$2, attrConfig$1];
30899
- const XML_NODE_NAME$5 = "w:bookmarkEnd";
31101
+ const validXmlAttributes$4 = [attrConfig$2, attrConfig$1];
31102
+ const XML_NODE_NAME$7 = "w:bookmarkEnd";
30900
31103
  const SD_NODE_NAME$5 = "bookmarkEnd";
30901
- const encode$4 = (params, encodedAttrs = {}) => {
31104
+ const encode$6 = (params, encodedAttrs = {}) => {
30902
31105
  return {
30903
31106
  type: "bookmarkEnd",
30904
31107
  attrs: encodedAttrs
30905
31108
  };
30906
31109
  };
30907
- const decode$6 = (params, decodedAttrs = {}) => {
31110
+ const decode$8 = (params, decodedAttrs = {}) => {
30908
31111
  const result = {
30909
31112
  name: "w:bookmarkEnd",
30910
31113
  elements: []
@@ -30914,27 +31117,27 @@ const decode$6 = (params, decodedAttrs = {}) => {
30914
31117
  }
30915
31118
  return result;
30916
31119
  };
30917
- const config$4 = {
30918
- xmlName: XML_NODE_NAME$5,
31120
+ const config$6 = {
31121
+ xmlName: XML_NODE_NAME$7,
30919
31122
  sdNodeOrKeyName: SD_NODE_NAME$5,
30920
31123
  type: NodeTranslator.translatorTypes.NODE,
30921
- encode: encode$4,
30922
- decode: decode$6,
30923
- attributes: validXmlAttributes$2
31124
+ encode: encode$6,
31125
+ decode: decode$8,
31126
+ attributes: validXmlAttributes$4
30924
31127
  };
30925
- const translator$4 = NodeTranslator.from(config$4);
30926
- const decode$5 = (attrs) => attrs?.["w:id"];
31128
+ const translator$6 = NodeTranslator.from(config$6);
31129
+ const decode$7 = (attrs) => attrs?.["w:id"];
30927
31130
  const attrConfig = Object.freeze({
30928
31131
  xmlName: "w:id",
30929
31132
  sdName: "w:id",
30930
31133
  // We do not translate it from 'w:id' to 'id' when encoding, so the name is the same
30931
31134
  encode: () => {
30932
31135
  },
30933
- decode: decode$5
31136
+ decode: decode$7
30934
31137
  });
30935
- const XML_NODE_NAME$4 = "w:commentRange";
31138
+ const XML_NODE_NAME$6 = "w:commentRange";
30936
31139
  const SD_NODE_NAME$4 = "commentRange";
30937
- const decode$4 = (params) => {
31140
+ const decode$6 = (params) => {
30938
31141
  const { node, comments, commentsExportType, exportedCommentDefs } = params;
30939
31142
  if (!node) return;
30940
31143
  if (!comments) return;
@@ -30977,19 +31180,19 @@ const getCommentSchema = (type2, commentIndex) => {
30977
31180
  };
30978
31181
  };
30979
31182
  const getConfig = (type2) => ({
30980
- xmlName: `${XML_NODE_NAME$4}${type2}`,
31183
+ xmlName: `${XML_NODE_NAME$6}${type2}`,
30981
31184
  sdNodeOrKeyName: `${SD_NODE_NAME$4}${type2}`,
30982
31185
  type: NodeTranslator.translatorTypes.NODE,
30983
31186
  encode: () => {
30984
31187
  },
30985
- decode: decode$4,
31188
+ decode: decode$6,
30986
31189
  attributes: [attrConfig]
30987
31190
  });
30988
31191
  const commentRangeStartTranslator = NodeTranslator.from(getConfig("Start"));
30989
31192
  const commentRangeEndTranslator = NodeTranslator.from(getConfig("End"));
30990
- const XML_NODE_NAME$3 = "sd:pageReference";
31193
+ const XML_NODE_NAME$5 = "sd:pageReference";
30991
31194
  const SD_NODE_NAME$3 = "pageReference";
30992
- const encode$3 = (params) => {
31195
+ const encode$5 = (params) => {
30993
31196
  const { nodes = [], nodeListHandler } = params || {};
30994
31197
  const node = nodes[0];
30995
31198
  const processedText = nodeListHandler.handler({
@@ -31006,7 +31209,7 @@ const encode$3 = (params) => {
31006
31209
  };
31007
31210
  return processedNode;
31008
31211
  };
31009
- const decode$3 = (params) => {
31212
+ const decode$5 = (params) => {
31010
31213
  const { node } = params;
31011
31214
  const outputMarks = processOutputMarks(node.attrs?.marksAsAttrs || []);
31012
31215
  const contentNodes = (node.content ?? []).flatMap((n) => exportSchemaToJson({ ...params, node: n }));
@@ -31079,17 +31282,17 @@ const decode$3 = (params) => {
31079
31282
  ];
31080
31283
  return translated;
31081
31284
  };
31082
- const config$3 = {
31083
- xmlName: XML_NODE_NAME$3,
31285
+ const config$5 = {
31286
+ xmlName: XML_NODE_NAME$5,
31084
31287
  sdNodeOrKeyName: SD_NODE_NAME$3,
31085
31288
  type: NodeTranslator.translatorTypes.NODE,
31086
- encode: encode$3,
31087
- decode: decode$3
31289
+ encode: encode$5,
31290
+ decode: decode$5
31088
31291
  };
31089
- const translator$3 = NodeTranslator.from(config$3);
31090
- const XML_NODE_NAME$2 = "sd:tableOfContents";
31292
+ const translator$5 = NodeTranslator.from(config$5);
31293
+ const XML_NODE_NAME$4 = "sd:tableOfContents";
31091
31294
  const SD_NODE_NAME$2 = "tableOfContents";
31092
- const encode$2 = (params) => {
31295
+ const encode$4 = (params) => {
31093
31296
  const { nodes = [], nodeListHandler } = params || {};
31094
31297
  const node = nodes[0];
31095
31298
  const processedContent = nodeListHandler.handler({
@@ -31105,7 +31308,7 @@ const encode$2 = (params) => {
31105
31308
  };
31106
31309
  return processedNode;
31107
31310
  };
31108
- const decode$2 = (params) => {
31311
+ const decode$4 = (params) => {
31109
31312
  const { node } = params;
31110
31313
  const contentNodes = node.content.map((n) => exportSchemaToJson({ ...params, node: n }));
31111
31314
  const tocBeginElements = [
@@ -31152,14 +31355,14 @@ const decode$2 = (params) => {
31152
31355
  }
31153
31356
  return contentNodes;
31154
31357
  };
31155
- const config$2 = {
31156
- xmlName: XML_NODE_NAME$2,
31358
+ const config$4 = {
31359
+ xmlName: XML_NODE_NAME$4,
31157
31360
  sdNodeOrKeyName: SD_NODE_NAME$2,
31158
31361
  type: NodeTranslator.translatorTypes.NODE,
31159
- encode: encode$2,
31160
- decode: decode$2
31362
+ encode: encode$4,
31363
+ decode: decode$4
31161
31364
  };
31162
- const translator$2 = NodeTranslator.from(config$2);
31365
+ const translator$4 = NodeTranslator.from(config$4);
31163
31366
  function parseInlineStyles(styleString) {
31164
31367
  if (!styleString) return {};
31165
31368
  return styleString.split(";").filter((style) => !!style.trim()).reduce((acc, style) => {
@@ -31293,7 +31496,7 @@ const handleDrawingNode = (params) => {
31293
31496
  if (mainNode.name === "w:drawing") node = mainNode;
31294
31497
  else node = mainNode.elements.find((el) => el.name === "w:drawing");
31295
31498
  if (!node) return { nodes: [], consumed: 0 };
31296
- const schemaNode = translator$7.encode(params);
31499
+ const schemaNode = translator$9.encode(params);
31297
31500
  const newNodes = schemaNode ? [schemaNode] : [];
31298
31501
  return { nodes: newNodes, consumed: 1 };
31299
31502
  };
@@ -31301,6 +31504,203 @@ const drawingNodeHandlerEntity = {
31301
31504
  handlerName: "drawingNodeHandler",
31302
31505
  handler: handleDrawingNode
31303
31506
  };
31507
+ const createTrackStyleMark = (marks) => {
31508
+ const trackStyleMark = marks.find((mark) => mark.type === "trackFormat");
31509
+ if (trackStyleMark) {
31510
+ return {
31511
+ type: "element",
31512
+ name: "w:rPrChange",
31513
+ attributes: {
31514
+ "w:id": trackStyleMark.attrs.id,
31515
+ "w:author": trackStyleMark.attrs.author,
31516
+ "w:authorEmail": trackStyleMark.attrs.authorEmail,
31517
+ "w:date": trackStyleMark.attrs.date
31518
+ },
31519
+ elements: trackStyleMark.attrs.before.map((mark) => processOutputMarks([mark])).filter((r) => r !== void 0)
31520
+ };
31521
+ }
31522
+ return void 0;
31523
+ };
31524
+ const XML_NODE_NAME$3 = "w:del";
31525
+ const SD_ATTR_KEY$1 = "trackDelete";
31526
+ const validXmlAttributes$3 = [
31527
+ createAttributeHandler("w:id", "id"),
31528
+ createAttributeHandler("w:date", "date"),
31529
+ createAttributeHandler("w:author", "author"),
31530
+ createAttributeHandler("w:authorEmail", "authorEmail")
31531
+ ];
31532
+ const encode$3 = (params, encodedAttrs = {}) => {
31533
+ const { nodeListHandler, extraParams = {} } = params;
31534
+ const { node } = extraParams;
31535
+ const subs = nodeListHandler.handler({
31536
+ ...params,
31537
+ insideTrackChange: true,
31538
+ nodes: node.elements,
31539
+ path: [...params.path || [], node]
31540
+ });
31541
+ encodedAttrs.importedAuthor = `${encodedAttrs.author} (imported)`;
31542
+ subs.forEach((subElement) => {
31543
+ if (subElement.marks === void 0) subElement.marks = [];
31544
+ subElement.marks.push({ type: "trackDelete", attrs: encodedAttrs });
31545
+ });
31546
+ return subs;
31547
+ };
31548
+ function decode$3(params) {
31549
+ const { node } = params;
31550
+ if (!node || !node.type) {
31551
+ return null;
31552
+ }
31553
+ const trackingMarks = ["trackInsert", "trackFormat", "trackDelete"];
31554
+ const marks = node.marks;
31555
+ const trackedMark = marks.find((m2) => m2.type === "trackDelete");
31556
+ const trackStyleMark = createTrackStyleMark(marks);
31557
+ node.marks = marks.filter((m2) => !trackingMarks.includes(m2.type));
31558
+ if (trackStyleMark) {
31559
+ node.marks.push(trackStyleMark);
31560
+ }
31561
+ const translatedTextNode = exportSchemaToJson({ ...params, node });
31562
+ const textNode = translatedTextNode.elements.find((n) => n.name === "w:t");
31563
+ textNode.name = "w:delText";
31564
+ return {
31565
+ name: "w:del",
31566
+ attributes: {
31567
+ "w:id": trackedMark.attrs.id,
31568
+ "w:author": trackedMark.attrs.author,
31569
+ "w:authorEmail": trackedMark.attrs.authorEmail,
31570
+ "w:date": trackedMark.attrs.date
31571
+ },
31572
+ elements: [translatedTextNode]
31573
+ };
31574
+ }
31575
+ const config$3 = {
31576
+ xmlName: XML_NODE_NAME$3,
31577
+ sdNodeOrKeyName: SD_ATTR_KEY$1,
31578
+ type: NodeTranslator.translatorTypes.ATTRIBUTE,
31579
+ encode: encode$3,
31580
+ decode: decode$3,
31581
+ attributes: validXmlAttributes$3
31582
+ };
31583
+ const translator$3 = NodeTranslator.from(config$3);
31584
+ const XML_NODE_NAME$2 = "w:ins";
31585
+ const SD_ATTR_KEY = "trackInsert";
31586
+ const validXmlAttributes$2 = [
31587
+ createAttributeHandler("w:id", "id"),
31588
+ createAttributeHandler("w:date", "date"),
31589
+ createAttributeHandler("w:author", "author"),
31590
+ createAttributeHandler("w:authorEmail", "authorEmail")
31591
+ ];
31592
+ const encode$2 = (params, encodedAttrs = {}) => {
31593
+ const { nodeListHandler, extraParams = {} } = params;
31594
+ const { node } = extraParams;
31595
+ const subs = nodeListHandler.handler({
31596
+ ...params,
31597
+ insideTrackChange: true,
31598
+ nodes: node.elements,
31599
+ path: [...params.path || [], node]
31600
+ });
31601
+ encodedAttrs.importedAuthor = `${encodedAttrs.author} (imported)`;
31602
+ subs.forEach((subElement) => {
31603
+ if (subElement.marks === void 0) subElement.marks = [];
31604
+ subElement.marks.push({ type: "trackInsert", attrs: encodedAttrs });
31605
+ });
31606
+ return subs;
31607
+ };
31608
+ function decode$2(params) {
31609
+ const { node } = params;
31610
+ if (!node || !node.type) {
31611
+ return null;
31612
+ }
31613
+ const trackingMarks = ["trackInsert", "trackFormat", "trackDelete"];
31614
+ const marks = node.marks;
31615
+ const trackedMark = marks.find((m2) => m2.type === "trackInsert");
31616
+ const trackStyleMark = createTrackStyleMark(marks);
31617
+ node.marks = marks.filter((m2) => !trackingMarks.includes(m2.type));
31618
+ if (trackStyleMark) {
31619
+ node.marks.push(trackStyleMark);
31620
+ }
31621
+ const translatedTextNode = exportSchemaToJson({ ...params, node });
31622
+ return {
31623
+ name: "w:ins",
31624
+ attributes: {
31625
+ "w:id": trackedMark.attrs.id,
31626
+ "w:author": trackedMark.attrs.author,
31627
+ "w:authorEmail": trackedMark.attrs.authorEmail,
31628
+ "w:date": trackedMark.attrs.date
31629
+ },
31630
+ elements: [translatedTextNode]
31631
+ };
31632
+ }
31633
+ const config$2 = {
31634
+ xmlName: XML_NODE_NAME$2,
31635
+ sdNodeOrKeyName: SD_ATTR_KEY,
31636
+ type: NodeTranslator.translatorTypes.ATTRIBUTE,
31637
+ encode: encode$2,
31638
+ decode: decode$2,
31639
+ attributes: validXmlAttributes$2
31640
+ };
31641
+ const translator$2 = NodeTranslator.from(config$2);
31642
+ const isTrackChangeElement = (node) => node?.name === "w:del" || node?.name === "w:ins";
31643
+ const unwrapTrackChangeNode = (node) => {
31644
+ if (!node) {
31645
+ return null;
31646
+ }
31647
+ if (isTrackChangeElement(node)) {
31648
+ return node;
31649
+ }
31650
+ if (node.name === "w:sdt") {
31651
+ const content = node.elements?.find((element) => element.name === "w:sdtContent");
31652
+ if (!content?.elements?.length) {
31653
+ return null;
31654
+ }
31655
+ for (const child of content.elements) {
31656
+ const trackChange = unwrapTrackChangeNode(child);
31657
+ if (trackChange) {
31658
+ return trackChange;
31659
+ }
31660
+ }
31661
+ }
31662
+ return null;
31663
+ };
31664
+ const handleTrackChangeNode = (params) => {
31665
+ const { nodes } = params;
31666
+ if (nodes.length === 0) {
31667
+ return { nodes: [], consumed: 0 };
31668
+ }
31669
+ const mainNode = unwrapTrackChangeNode(nodes[0]);
31670
+ if (!mainNode) {
31671
+ return { nodes: [], consumed: 0 };
31672
+ }
31673
+ let result;
31674
+ const translatorParams = {
31675
+ ...params,
31676
+ nodes: [mainNode]
31677
+ };
31678
+ switch (mainNode.name) {
31679
+ case "w:del":
31680
+ result = translator$3.encode({
31681
+ extraParams: {
31682
+ node: mainNode
31683
+ },
31684
+ ...translatorParams
31685
+ });
31686
+ break;
31687
+ case "w:ins":
31688
+ result = translator$2.encode({
31689
+ extraParams: {
31690
+ node: mainNode
31691
+ },
31692
+ ...translatorParams
31693
+ });
31694
+ break;
31695
+ }
31696
+ return { nodes: result, consumed: 1 };
31697
+ };
31698
+ const trackChangeNodeHandlerEntity = {
31699
+ handlerName: "trackChangeNodeHandler",
31700
+ handler: handleTrackChangeNode
31701
+ };
31702
+ const hyperlinkNodeHandlerEntity = generateV2HandlerEntity("hyperlinkNodeHandler", translator$1c);
31703
+ const runNodeHandlerEntity = generateV2HandlerEntity("runNodeHandler", translator$1b);
31304
31704
  function parseProperties(node) {
31305
31705
  const marks = [];
31306
31706
  const unknownMarks = [];
@@ -31352,51 +31752,6 @@ function getElementName(element) {
31352
31752
  const isPropertiesElement = (element) => {
31353
31753
  return !!SuperConverter.propertyTypes[element.name || element.type];
31354
31754
  };
31355
- const handleTrackChangeNode = (params) => {
31356
- const { nodes, nodeListHandler } = params;
31357
- if (nodes.length === 0 || !(nodes[0].name === "w:del" || nodes[0].name === "w:ins" || nodes[0].name === "w:sdt")) {
31358
- return { nodes: [], consumed: 0 };
31359
- }
31360
- const mainNode = nodes[0];
31361
- let node;
31362
- if (["w:ins", "w:del"].includes(mainNode.name)) {
31363
- node = mainNode;
31364
- } else {
31365
- const sdtContent = mainNode.elements.find((el) => el.name === "w:sdtContent");
31366
- const trackedChange = sdtContent?.elements.find((el) => ["w:ins", "w:del"].includes(el.name));
31367
- if (trackedChange) node = trackedChange;
31368
- }
31369
- if (!node) {
31370
- return { nodes: [], consumed: 0 };
31371
- }
31372
- const { name } = node;
31373
- const { attributes, elements } = parseProperties(node);
31374
- const subs = nodeListHandler.handler({
31375
- ...params,
31376
- insideTrackChange: true,
31377
- nodes: elements,
31378
- path: [...params.path || [], node]
31379
- });
31380
- const changeType = name === "w:del" ? TrackDeleteMarkName : TrackInsertMarkName;
31381
- const mappedAttributes = {
31382
- id: attributes["w:id"],
31383
- date: attributes["w:date"],
31384
- author: attributes["w:author"],
31385
- authorEmail: attributes["w:authorEmail"],
31386
- importedAuthor: `${attributes["w:author"]} (imported)`
31387
- };
31388
- subs.forEach((subElement) => {
31389
- if (subElement.marks === void 0) subElement.marks = [];
31390
- subElement.marks.push({ type: changeType, attrs: mappedAttributes });
31391
- });
31392
- return { nodes: subs, consumed: 1 };
31393
- };
31394
- const trackChangeNodeHandlerEntity = {
31395
- handlerName: "trackChangeNodeHandler",
31396
- handler: handleTrackChangeNode
31397
- };
31398
- const hyperlinkNodeHandlerEntity = generateV2HandlerEntity("hyperlinkNodeHandler", translator$X);
31399
- const runNodeHandlerEntity = generateV2HandlerEntity("runNodeHandler", translator$W);
31400
31755
  const handleTextNode = (params) => {
31401
31756
  const { nodes, insideTrackChange } = params;
31402
31757
  if (nodes.length === 0 || !(nodes[0].name === "w:t" || insideTrackChange && nodes[0].name === "w:delText")) {
@@ -31437,7 +31792,7 @@ const handleParagraphNode = (params) => {
31437
31792
  if (nodes.length === 0 || nodes[0].name !== "w:p") {
31438
31793
  return { nodes: [], consumed: 0 };
31439
31794
  }
31440
- const schemaNode = translator$17.encode(params);
31795
+ const schemaNode = translator$1o.encode(params);
31441
31796
  const newNodes = schemaNode ? [schemaNode] : [];
31442
31797
  return { nodes: newNodes, consumed: 1 };
31443
31798
  };
@@ -31450,7 +31805,7 @@ const handleSdtNode = (params) => {
31450
31805
  if (nodes.length === 0 || nodes[0].name !== "w:sdt") {
31451
31806
  return { nodes: [], consumed: 0 };
31452
31807
  }
31453
- const result = translator$6.encode(params);
31808
+ const result = translator$8.encode(params);
31454
31809
  if (!result) {
31455
31810
  return { nodes: [], consumed: 0 };
31456
31811
  }
@@ -31540,7 +31895,7 @@ const handler = (params) => {
31540
31895
  if (nodes.length === 0 || nodes[0].name !== "w:br") {
31541
31896
  return { nodes: [], consumed: 0 };
31542
31897
  }
31543
- const result = translator$1a.encode(params);
31898
+ const result = translator$1r.encode(params);
31544
31899
  if (!result) return { nodes: [], consumed: 0 };
31545
31900
  return {
31546
31901
  nodes: [result],
@@ -31612,7 +31967,7 @@ const handleBookmarkStartNode = (params) => {
31612
31967
  if (isCustomMarkBookmark(nodes[0], params.editor)) {
31613
31968
  return handleBookmarkNode(params);
31614
31969
  }
31615
- const node = translator$5.encode(params);
31970
+ const node = translator$7.encode(params);
31616
31971
  if (!node) return { nodes: [], consumed: 0 };
31617
31972
  return { nodes: [node], consumed: 1 };
31618
31973
  };
@@ -31644,7 +31999,7 @@ const handleBookmarkEndNode = (params) => {
31644
31999
  if (!nodes.length || nodes[0].name !== "w:bookmarkEnd") {
31645
32000
  return { nodes: [], consumed: 0 };
31646
32001
  }
31647
- const node = translator$4.encode(params);
32002
+ const node = translator$6.encode(params);
31648
32003
  if (!node) return { nodes: [], consumed: 0 };
31649
32004
  return { nodes: [node], consumed: 1 };
31650
32005
  };
@@ -31777,7 +32132,7 @@ const autoTotalPageCountEntity = {
31777
32132
  handlerName: "autoTotalPageCountEntity",
31778
32133
  handler: handleAutoTotalPageNumber
31779
32134
  };
31780
- const pageReferenceEntity = generateV2HandlerEntity("pageReferenceNodeHandler", translator$3);
32135
+ const pageReferenceEntity = generateV2HandlerEntity("pageReferenceNodeHandler", translator$5);
31781
32136
  const handlePictNode = (params) => {
31782
32137
  const { nodes } = params;
31783
32138
  if (!nodes.length || nodes[0].name !== "w:p") {
@@ -32166,14 +32521,14 @@ const handleTabNode = (params) => {
32166
32521
  if (!nodes.length || nodes[0].name !== "w:tab") {
32167
32522
  return { nodes: [], consumed: 0 };
32168
32523
  }
32169
- const node = translator$18.encode(params);
32524
+ const node = translator$1p.encode(params);
32170
32525
  return { nodes: [node], consumed: 1 };
32171
32526
  };
32172
32527
  const tabNodeEntityHandler = {
32173
32528
  handlerName: "w:tabTranslator",
32174
32529
  handler: handleTabNode
32175
32530
  };
32176
- const tableOfContentsHandlerEntity = generateV2HandlerEntity("tableOfContentsHandler", translator$2);
32531
+ const tableOfContentsHandlerEntity = generateV2HandlerEntity("tableOfContentsHandler", translator$4);
32177
32532
  function preProcessPageInstruction(nodesToCombine) {
32178
32533
  const pageNumNode = {
32179
32534
  name: "sd:autoPageNumber",
@@ -32418,12 +32773,14 @@ const createDocumentJson = (docx, converter, editor) => {
32418
32773
  const content = pruneIgnoredNodes(contentElements);
32419
32774
  const comments = importCommentData({ docx, converter, editor });
32420
32775
  const lists = {};
32776
+ const inlineDocumentFonts = [];
32421
32777
  let parsedContent = nodeListHandler.handler({
32422
32778
  nodes: content,
32423
32779
  nodeListHandler,
32424
32780
  docx,
32425
32781
  converter,
32426
32782
  editor,
32783
+ inlineDocumentFonts,
32427
32784
  lists,
32428
32785
  path: []
32429
32786
  });
@@ -32446,6 +32803,7 @@ const createDocumentJson = (docx, converter, editor) => {
32446
32803
  savedTagsToRestore: node,
32447
32804
  pageStyles: getDocumentStyles(node, docx, converter, editor),
32448
32805
  comments,
32806
+ inlineDocumentFonts,
32449
32807
  linkedStyles: getStyleDefinitions(docx),
32450
32808
  numbering: getNumberingDefinitions(docx)
32451
32809
  };
@@ -32509,6 +32867,7 @@ const createNodeListHandler = (nodeHandlers) => {
32509
32867
  filename,
32510
32868
  parentStyleId,
32511
32869
  lists,
32870
+ inlineDocumentFonts,
32512
32871
  path = []
32513
32872
  }) => {
32514
32873
  if (!elements || !elements.length) return [];
@@ -32535,6 +32894,7 @@ const createNodeListHandler = (nodeHandlers) => {
32535
32894
  filename,
32536
32895
  parentStyleId,
32537
32896
  lists,
32897
+ inlineDocumentFonts,
32538
32898
  path
32539
32899
  });
32540
32900
  },
@@ -33222,35 +33582,35 @@ function exportSchemaToJson(params) {
33222
33582
  doc: translateDocumentNode,
33223
33583
  body: translateBodyNode,
33224
33584
  heading: translateHeadingNode,
33225
- paragraph: translator$17,
33226
- run: translator$W,
33585
+ paragraph: translator$1o,
33586
+ run: translator$1b,
33227
33587
  text: translateTextNode,
33228
33588
  bulletList: translateList,
33229
33589
  orderedList: translateList,
33230
- lineBreak: translator$1a,
33231
- table: translator$b,
33232
- tableRow: translator$I,
33233
- tableCell: translator$a,
33234
- bookmarkStart: translator$5,
33235
- bookmarkEnd: translator$4,
33236
- fieldAnnotation: translator$6,
33237
- tab: translator$18,
33238
- image: translator$7,
33239
- hardBreak: translator$1a,
33590
+ lineBreak: translator$1r,
33591
+ table: translator$s,
33592
+ tableRow: translator$Z,
33593
+ tableCell: translator$c,
33594
+ bookmarkStart: translator$7,
33595
+ bookmarkEnd: translator$6,
33596
+ fieldAnnotation: translator$8,
33597
+ tab: translator$1p,
33598
+ image: translator$9,
33599
+ hardBreak: translator$1r,
33240
33600
  commentRangeStart: commentRangeStartTranslator,
33241
33601
  commentRangeEnd: commentRangeEndTranslator,
33242
33602
  commentReference: () => null,
33243
33603
  shapeContainer: translator,
33244
33604
  shapeTextbox: translator,
33245
33605
  contentBlock: translator,
33246
- structuredContent: translator$6,
33247
- structuredContentBlock: translator$6,
33248
- documentPartObject: translator$6,
33249
- documentSection: translator$6,
33606
+ structuredContent: translator$8,
33607
+ structuredContentBlock: translator$8,
33608
+ documentPartObject: translator$8,
33609
+ documentSection: translator$8,
33250
33610
  "page-number": translatePageNumberNode,
33251
33611
  "total-page-number": translateTotalPageNumberNode,
33252
- pageReference: translator$3,
33253
- tableOfContents: translator$2
33612
+ pageReference: translator$5,
33613
+ tableOfContents: translator$4
33254
33614
  };
33255
33615
  let handler2 = router[type2];
33256
33616
  if (handler2 && "decode" in handler2 && typeof handler2.decode === "function") {
@@ -33586,62 +33946,22 @@ function getTextNodeForExport(text, marks, params) {
33586
33946
  function translateTextNode(params) {
33587
33947
  const { node, extraParams } = params;
33588
33948
  const trackedMarks = [TrackInsertMarkName, TrackDeleteMarkName];
33589
- const isTrackedNode = node.marks?.some((m2) => trackedMarks.includes(m2.type));
33590
- if (isTrackedNode) return translateTrackedNode(params);
33949
+ const trackedMark = node.marks?.find((m2) => trackedMarks.includes(m2.type));
33950
+ if (trackedMark) {
33951
+ switch (trackedMark.type) {
33952
+ case "trackDelete":
33953
+ return translator$3.decode(params);
33954
+ case "trackInsert":
33955
+ return translator$2.decode(params);
33956
+ }
33957
+ }
33591
33958
  const isLinkNode = node.marks?.some((m2) => m2.type === "link");
33592
33959
  if (isLinkNode && !extraParams?.linkProcessed) {
33593
- return translator$X.decode(params);
33960
+ return translator$1c.decode(params);
33594
33961
  }
33595
33962
  const { text, marks = [] } = node;
33596
33963
  return getTextNodeForExport(text, marks, params);
33597
33964
  }
33598
- function createTrackStyleMark(marks) {
33599
- const trackStyleMark = marks.find((mark) => mark.type === TrackFormatMarkName);
33600
- if (trackStyleMark) {
33601
- const markElement = {
33602
- type: "element",
33603
- name: "w:rPrChange",
33604
- attributes: {
33605
- "w:id": trackStyleMark.attrs.id,
33606
- "w:author": trackStyleMark.attrs.author,
33607
- "w:authorEmail": trackStyleMark.attrs.authorEmail,
33608
- "w:date": trackStyleMark.attrs.date
33609
- },
33610
- elements: trackStyleMark.attrs.before.map((mark) => processOutputMarks([mark])).filter((r) => r !== void 0)
33611
- };
33612
- return markElement;
33613
- }
33614
- return void 0;
33615
- }
33616
- function translateTrackedNode(params) {
33617
- const { node } = params;
33618
- const marks = node.marks;
33619
- const trackingMarks = [TrackInsertMarkName, TrackDeleteMarkName, TrackFormatMarkName];
33620
- const trackedMark = marks.find((m2) => trackingMarks.includes(m2.type));
33621
- const isInsert = trackedMark.type === TrackInsertMarkName;
33622
- const trackStyleMark = createTrackStyleMark(marks);
33623
- node.marks = marks.filter((m2) => !trackingMarks.includes(m2.type));
33624
- if (trackStyleMark) {
33625
- node.marks.push(trackStyleMark);
33626
- }
33627
- const translatedTextNode = exportSchemaToJson({ ...params, node });
33628
- if (!isInsert) {
33629
- const textNode = translatedTextNode.elements.find((n) => n.name === "w:t");
33630
- textNode.name = "w:delText";
33631
- }
33632
- const trackedNode = {
33633
- name: isInsert ? "w:ins" : "w:del",
33634
- type: "element",
33635
- attributes: {
33636
- "w:id": trackedMark.attrs.id,
33637
- "w:author": trackedMark.attrs.author,
33638
- "w:authorEmail": trackedMark.attrs.authorEmail,
33639
- "w:date": trackedMark.attrs.date
33640
- },
33641
- elements: [translatedTextNode]
33642
- };
33643
- return trackedNode;
33644
- }
33645
33965
  function wrapTextInRun(nodeOrNodes, marks) {
33646
33966
  let elements = [];
33647
33967
  if (Array.isArray(nodeOrNodes)) elements = nodeOrNodes;
@@ -33897,7 +34217,7 @@ function translateMark(mark) {
33897
34217
  markElement.type = "element";
33898
34218
  break;
33899
34219
  case "underline": {
33900
- const translated = translator$14.decode({
34220
+ const translated = translator$1l.decode({
33901
34221
  node: {
33902
34222
  attrs: {
33903
34223
  underlineType: attrs.underlineType ?? attrs.underline ?? null,
@@ -33961,7 +34281,7 @@ function translateMark(mark) {
33961
34281
  break;
33962
34282
  case "highlight": {
33963
34283
  const highlightValue = attrs.color ?? attrs.highlight ?? null;
33964
- const translated = translator$19.decode({ node: { attrs: { highlight: highlightValue } } });
34284
+ const translated = translator$1q.decode({ node: { attrs: { highlight: highlightValue } } });
33965
34285
  return translated || {};
33966
34286
  }
33967
34287
  case "link":
@@ -34340,6 +34660,7 @@ const _SuperConverter = class _SuperConverter {
34340
34660
  this.fonts = params?.fonts || {};
34341
34661
  this.addedMedia = {};
34342
34662
  this.comments = [];
34663
+ this.inlineDocumentFonts = [];
34343
34664
  this.docHiglightColors = /* @__PURE__ */ new Set([]);
34344
34665
  this.xml = params?.xml;
34345
34666
  this.declaration = null;
@@ -34626,6 +34947,23 @@ const _SuperConverter = class _SuperConverter {
34626
34947
  return result;
34627
34948
  }
34628
34949
  getDocumentFonts() {
34950
+ const inlineDocumentFonts = [...new Set(this.inlineDocumentFonts || [])];
34951
+ const fontTable = this.convertedXml["word/fontTable.xml"];
34952
+ if (!fontTable) {
34953
+ return inlineDocumentFonts;
34954
+ }
34955
+ const wFonts = fontTable.elements?.find((element) => element.name === "w:fonts");
34956
+ if (!wFonts) {
34957
+ return inlineDocumentFonts;
34958
+ }
34959
+ if (!wFonts.elements) {
34960
+ return inlineDocumentFonts;
34961
+ }
34962
+ const fontsInFontTable = wFonts.elements.filter((element) => element.name === "w:font").map((element) => element.attributes["w:name"]);
34963
+ const allFonts = [...inlineDocumentFonts, ...fontsInFontTable];
34964
+ return [...new Set(allFonts)];
34965
+ }
34966
+ getFontFaceImportString() {
34629
34967
  const fontTable = this.convertedXml["word/fontTable.xml"];
34630
34968
  if (!fontTable || !Object.keys(this.fonts).length) return;
34631
34969
  const fonts = fontTable.elements.find((el) => el.name === "w:fonts");
@@ -34639,6 +34977,7 @@ const _SuperConverter = class _SuperConverter {
34639
34977
  const rels = this.convertedXml["word/_rels/fontTable.xml.rels"];
34640
34978
  const relationships = rels?.elements.find((el) => el.name === "Relationships") || {};
34641
34979
  const { elements } = relationships;
34980
+ const fontsImported = [];
34642
34981
  let styleString = "";
34643
34982
  for (const font of fontsToInclude) {
34644
34983
  const filePath = elements.find((el) => el.attributes.Id === font.attributes["r:id"])?.attributes?.Target;
@@ -34655,6 +34994,9 @@ const _SuperConverter = class _SuperConverter {
34655
34994
  const isItalic = font.name.includes("Italic");
34656
34995
  const isLight = font.name.includes("Light");
34657
34996
  const fontWeight = isNormal ? "normal" : isBold ? "bold" : isLight ? "200" : "normal";
34997
+ if (!fontsImported.includes(font.fontFamily)) {
34998
+ fontsImported.push(font.fontFamily);
34999
+ }
34658
35000
  styleString += `
34659
35001
  @font-face {
34660
35002
  font-style: ${isItalic ? "italic" : "normal"};
@@ -34665,7 +35007,10 @@ const _SuperConverter = class _SuperConverter {
34665
35007
  }
34666
35008
  `;
34667
35009
  }
34668
- return styleString;
35010
+ return {
35011
+ styleString,
35012
+ fontsImported
35013
+ };
34669
35014
  }
34670
35015
  getDocumentInternalId() {
34671
35016
  const settingsLocation = "word/settings.xml";
@@ -34720,6 +35065,7 @@ const _SuperConverter = class _SuperConverter {
34720
35065
  this.numbering = result.numbering;
34721
35066
  this.comments = result.comments;
34722
35067
  this.linkedStyles = result.linkedStyles;
35068
+ this.inlineDocumentFonts = result.inlineDocumentFonts;
34723
35069
  return result.pmDoc;
34724
35070
  } else {
34725
35071
  return null;
@@ -35095,7 +35441,7 @@ export {
35095
35441
  objectIncludes as Z,
35096
35442
  AddMarkStep as _,
35097
35443
  Plugin as a,
35098
- translator$D as a$,
35444
+ translator$10 as a$,
35099
35445
  twipsToLines as a0,
35100
35446
  pixelsToTwips as a1,
35101
35447
  helpers as a2,
@@ -35106,33 +35452,33 @@ export {
35106
35452
  createDocFromMarkdown as a7,
35107
35453
  createDocFromHTML as a8,
35108
35454
  EditorState as a9,
35109
- vClickOutside as aA,
35110
- getActiveFormatting as aB,
35111
- readFromClipboard as aC,
35112
- handleClipboardPaste as aD,
35113
- getFileObject as aE,
35114
- runPropertyTranslators as aF,
35115
- commentRangeEndTranslator as aG,
35116
- commentRangeStartTranslator as aH,
35117
- translator$8 as aI,
35118
- translator$9 as aJ,
35119
- translator$K as aK,
35120
- translator$L as aL,
35121
- translator$14 as aM,
35122
- translator$J as aN,
35123
- translator$M as aO,
35124
- translator$I as aP,
35125
- translator$i as aQ,
35126
- translator$a as aR,
35127
- translator$v as aS,
35128
- translator$w as aT,
35129
- translator$x as aU,
35130
- translator$y as aV,
35131
- translator$z as aW,
35132
- translator$e as aX,
35133
- translator$A as aY,
35134
- translator$B as aZ,
35135
- translator$C as a_,
35455
+ xmljs as aA,
35456
+ vClickOutside as aB,
35457
+ getActiveFormatting as aC,
35458
+ readFromClipboard as aD,
35459
+ handleClipboardPaste as aE,
35460
+ getFileObject as aF,
35461
+ runPropertyTranslators as aG,
35462
+ translator$d as aH,
35463
+ translator$k as aI,
35464
+ translator$m as aJ,
35465
+ translator$e as aK,
35466
+ translator$f as aL,
35467
+ translator$n as aM,
35468
+ translator$o as aN,
35469
+ translator$j as aO,
35470
+ translator$g as aP,
35471
+ translator$r as aQ,
35472
+ translator$i as aR,
35473
+ translator$l as aS,
35474
+ translator$h as aT,
35475
+ translator$q as aU,
35476
+ translator$p as aV,
35477
+ commentRangeEndTranslator as aW,
35478
+ commentRangeStartTranslator as aX,
35479
+ translator$a as aY,
35480
+ translator$b as aZ,
35481
+ translator$$ as a_,
35136
35482
  hasSomeParentWithClass as aa,
35137
35483
  isActive as ab,
35138
35484
  unflattenListsInHtml as ac,
@@ -35155,59 +35501,75 @@ export {
35155
35501
  isInTable as at,
35156
35502
  generateDocxRandomId as au,
35157
35503
  insertNewRelationship as av,
35158
- commonjsGlobal as aw,
35159
- getDefaultExportFromCjs$2 as ax,
35160
- getContentTypesFromXml as ay,
35161
- xmljs as az,
35504
+ inchesToPixels as aw,
35505
+ commonjsGlobal as ax,
35506
+ getDefaultExportFromCjs$2 as ay,
35507
+ getContentTypesFromXml as az,
35162
35508
  Slice as b,
35163
- translator$N as b0,
35164
- translator$c as b1,
35165
- translator$E as b2,
35166
- translator$O as b3,
35167
- translator$f as b4,
35168
- translator$F as b5,
35169
- translator$g as b6,
35170
- translator$b as b7,
35171
- translator$18 as b8,
35172
- translator$_ as b9,
35173
- translator$U as bA,
35174
- translator$V as bB,
35175
- translator$1a as bC,
35176
- translator$u as bD,
35177
- translator$5 as bE,
35178
- translator$4 as bF,
35179
- translator$H as bG,
35180
- translator$16 as bH,
35181
- translator$2 as bI,
35182
- translator$3 as bJ,
35183
- translator$1 as bK,
35184
- _sfc_main as bL,
35185
- translator$$ as ba,
35186
- translator$13 as bb,
35187
- translator$k as bc,
35188
- translator$G as bd,
35189
- translator$6 as be,
35190
- translator$m as bf,
35191
- translator$10 as bg,
35192
- translator$Y as bh,
35193
- translator$11 as bi,
35194
- translator$W as bj,
35195
- translator$17 as bk,
35196
- translator$o as bl,
35197
- translator$P as bm,
35198
- translator$p as bn,
35199
- translator$q as bo,
35200
- translator$15 as bp,
35201
- translator$X as bq,
35202
- translator$19 as br,
35203
- translator$Q as bs,
35204
- translator$d as bt,
35205
- translator$R as bu,
35206
- translator$S as bv,
35207
- translator$s as bw,
35208
- translator$7 as bx,
35209
- translator$T as by,
35210
- translator$12 as bz,
35509
+ _sfc_main as b$,
35510
+ translator$1l as b0,
35511
+ translator$_ as b1,
35512
+ translator$11 as b2,
35513
+ translator$Z as b3,
35514
+ translator$z as b4,
35515
+ translator$c as b5,
35516
+ translator$M as b6,
35517
+ translator$N as b7,
35518
+ translator$O as b8,
35519
+ translator$P as b9,
35520
+ translator$1o as bA,
35521
+ translator$F as bB,
35522
+ translator$14 as bC,
35523
+ translator$G as bD,
35524
+ translator$H as bE,
35525
+ translator$1m as bF,
35526
+ translator$1c as bG,
35527
+ translator$1q as bH,
35528
+ translator$15 as bI,
35529
+ translator$u as bJ,
35530
+ translator$16 as bK,
35531
+ translator$17 as bL,
35532
+ translator$J as bM,
35533
+ translator$9 as bN,
35534
+ translator$18 as bO,
35535
+ translator$1j as bP,
35536
+ translator$19 as bQ,
35537
+ translator$1a as bR,
35538
+ translator$1r as bS,
35539
+ translator$L as bT,
35540
+ translator$7 as bU,
35541
+ translator$6 as bV,
35542
+ translator$Y as bW,
35543
+ translator$1n as bX,
35544
+ translator$4 as bY,
35545
+ translator$5 as bZ,
35546
+ translator$1 as b_,
35547
+ translator$Q as ba,
35548
+ translator$v as bb,
35549
+ translator$R as bc,
35550
+ translator$S as bd,
35551
+ translator$T as be,
35552
+ translator$U as bf,
35553
+ translator$12 as bg,
35554
+ translator$t as bh,
35555
+ translator$V as bi,
35556
+ translator$13 as bj,
35557
+ translator$w as bk,
35558
+ translator$W as bl,
35559
+ translator$x as bm,
35560
+ translator$s as bn,
35561
+ translator$1p as bo,
35562
+ translator$1f as bp,
35563
+ translator$1g as bq,
35564
+ translator$1k as br,
35565
+ translator$B as bs,
35566
+ translator$X as bt,
35567
+ translator$8 as bu,
35568
+ translator$D as bv,
35569
+ translator$1h as bw,
35570
+ translator$1d as bx,
35571
+ translator$1i as by,
35572
+ translator$1b as bz,
35211
35573
  DOMParser$1 as c,
35212
35574
  Mark as d,
35213
35575
  dropPoint as e,