@harbour-enterprises/superdoc 0.22.1 → 0.23.0-next.10

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 (77) hide show
  1. package/dist/chunks/{PdfViewer-D2BPnEBG.cjs → PdfViewer-BsnSIYxD.cjs} +2 -2
  2. package/dist/chunks/{PdfViewer-CBmOiHsj.es.js → PdfViewer-CPZ7QD5u.es.js} +2 -2
  3. package/dist/chunks/{eventemitter3-CZv6vEhA.es.js → eventemitter3-CR2eBWft.es.js} +1 -1
  4. package/dist/chunks/{eventemitter3-B_kO1Pxm.cjs → eventemitter3-DSRogsNq.cjs} +1 -1
  5. package/dist/chunks/{index-BSDcfSFc.es.js → index-Cd9h9gMj.es.js} +32 -22
  6. package/dist/chunks/{index-B0CI50e4.cjs → index-DOd9uvCv.cjs} +32 -22
  7. package/dist/chunks/{jszip-b7l8QkfH.cjs → jszip-B4LDL19y.cjs} +1 -1
  8. package/dist/chunks/{jszip-B8KIZSNe.es.js → jszip-DAXEPCUv.es.js} +1 -1
  9. package/dist/chunks/{super-editor.es-DOOwW-Iv.cjs → super-editor.es-DAS3_Nt9.cjs} +1786 -1085
  10. package/dist/chunks/{super-editor.es-BW1T3N2-.es.js → super-editor.es-l3dTZlZX.es.js} +1786 -1085
  11. package/dist/chunks/{vue-DWle4Cai.cjs → vue-DKMj1I9B.cjs} +39 -42
  12. package/dist/chunks/{vue-CXxsqYcP.es.js → vue-ZWZLQtoU.es.js} +39 -42
  13. package/dist/chunks/xml-js-Bbc0NeKa.es.js +2 -0
  14. package/dist/chunks/xml-js-CWV8R-ek.cjs +3 -0
  15. package/dist/core/SuperDoc.d.ts +5 -18
  16. package/dist/core/SuperDoc.d.ts.map +1 -1
  17. package/dist/core/types/index.d.ts +29 -1
  18. package/dist/core/types/index.d.ts.map +1 -1
  19. package/dist/stores/superdoc-store.d.ts.map +1 -1
  20. package/dist/style.css +76 -54
  21. package/dist/super-editor/ai-writer.es.js +2 -2
  22. package/dist/super-editor/chunks/{converter-UuZxU-p8.js → converter-ClnqoStR.js} +1476 -1043
  23. package/dist/super-editor/chunks/{docx-zipper-Bss48sB0.js → docx-zipper-DC28ucAi.js} +1 -1
  24. package/dist/super-editor/chunks/{editor--v3HbUU0.js → editor-B2aHhS9B.js} +310 -42
  25. package/dist/super-editor/chunks/{toolbar-BeXlvdV8.js → toolbar-Cgyf_4bW.js} +4 -4
  26. package/dist/super-editor/converter.es.js +1 -1
  27. package/dist/super-editor/docx-zipper.es.js +2 -2
  28. package/dist/super-editor/editor.es.js +3 -3
  29. package/dist/super-editor/file-zipper.es.js +1 -1
  30. package/dist/super-editor/src/core/Attribute.d.ts +2 -2
  31. package/dist/super-editor/src/core/Schema.d.ts +2 -2
  32. package/dist/super-editor/src/core/super-converter/exporter.d.ts +4 -4
  33. package/dist/super-editor/src/core/super-converter/field-references/fld-preprocessors/hyperlink-preprocessor.d.ts +9 -0
  34. package/dist/super-editor/src/core/super-converter/field-references/fld-preprocessors/index.d.ts +2 -0
  35. package/dist/super-editor/src/core/super-converter/field-references/fld-preprocessors/num-pages-preprocessor.d.ts +9 -0
  36. package/dist/super-editor/src/core/super-converter/field-references/fld-preprocessors/page-preprocessor.d.ts +9 -0
  37. package/dist/super-editor/src/core/super-converter/field-references/fld-preprocessors/page-ref-preprocessor.d.ts +9 -0
  38. package/dist/super-editor/src/core/super-converter/field-references/fld-preprocessors/toc-preprocessor.d.ts +8 -0
  39. package/dist/super-editor/src/core/super-converter/field-references/index.d.ts +1 -0
  40. package/dist/super-editor/src/core/super-converter/field-references/preProcessNodesForFldChar.d.ts +21 -0
  41. package/dist/super-editor/src/core/super-converter/v2/exporter/helpers/translateChildNodes.d.ts +3 -3
  42. package/dist/super-editor/src/core/super-converter/v2/importer/pageReferenceImporter.d.ts +4 -0
  43. package/dist/super-editor/src/core/super-converter/v2/importer/tableOfContentsImporter.d.ts +4 -0
  44. package/dist/super-editor/src/core/super-converter/v2/types/index.d.ts +7 -1
  45. package/dist/super-editor/src/core/super-converter/v3/handlers/sd/pageReference/index.d.ts +1 -0
  46. package/dist/super-editor/src/core/super-converter/v3/handlers/sd/pageReference/pageReference-translator.d.ts +7 -0
  47. package/dist/super-editor/src/core/super-converter/v3/handlers/sd/tableOfContents/index.d.ts +1 -0
  48. package/dist/super-editor/src/core/super-converter/v3/handlers/sd/tableOfContents/tableOfContents-translator.d.ts +10 -0
  49. package/dist/super-editor/src/core/super-converter/v3/handlers/w/caps/caps-translator.d.ts +7 -0
  50. package/dist/super-editor/src/core/super-converter/v3/handlers/w/p/helpers/w-p-helpers.d.ts +0 -2
  51. package/dist/super-editor/src/core/super-converter/v3/handlers/w/sdt/helpers/handle-doc-part-obj.d.ts +9 -1
  52. package/dist/super-editor/src/core/super-converter/v3/handlers/w/sdt/helpers/translate-document-part-obj.d.ts +6 -0
  53. package/dist/super-editor/src/core/super-converter/v3/node-translator/node-translator.d.ts +2 -2
  54. package/dist/super-editor/src/extensions/image/imageHelpers/handleBase64.d.ts +4 -0
  55. package/dist/super-editor/src/extensions/image/imageHelpers/imageRegistrationPlugin.d.ts +1 -0
  56. package/dist/super-editor/src/extensions/image/imageHelpers/startImageUpload.d.ts +5 -0
  57. package/dist/super-editor/src/extensions/page-reference/index.d.ts +1 -0
  58. package/dist/super-editor/src/extensions/page-reference/page-reference.d.ts +2 -0
  59. package/dist/super-editor/src/extensions/structured-content/document-part-object.d.ts +2 -0
  60. package/dist/super-editor/src/extensions/structured-content/index.d.ts +1 -0
  61. package/dist/super-editor/src/extensions/structured-content/structuredContentHelpers/getStructuredContentTagsByAlias.d.ts +8 -0
  62. package/dist/super-editor/src/extensions/structured-content/structuredContentHelpers/index.d.ts +1 -0
  63. package/dist/super-editor/src/extensions/tab/helpers/tabDecorations.d.ts +2 -2
  64. package/dist/super-editor/src/extensions/table-of-contents/index.d.ts +1 -0
  65. package/dist/super-editor/src/extensions/table-of-contents/table-of-contents.d.ts +2 -0
  66. package/dist/super-editor/style.css +49 -27
  67. package/dist/super-editor/super-editor.es.js +10 -8
  68. package/dist/super-editor/toolbar.es.js +2 -2
  69. package/dist/super-editor.cjs +2 -2
  70. package/dist/super-editor.es.js +2 -2
  71. package/dist/superdoc.cjs +4 -4
  72. package/dist/superdoc.es.js +4 -4
  73. package/dist/superdoc.umd.js +1846 -1135
  74. package/dist/superdoc.umd.js.map +1 -1
  75. package/package.json +1 -1
  76. package/dist/chunks/xml-js-CX8FH0He.cjs +0 -3
  77. package/dist/chunks/xml-js-D0tLGmKu.es.js +0 -2
@@ -5092,6 +5092,19 @@ function requireSafeRegexTest() {
5092
5092
  };
5093
5093
  return safeRegexTest;
5094
5094
  }
5095
+ var generatorFunction;
5096
+ var hasRequiredGeneratorFunction;
5097
+ function requireGeneratorFunction() {
5098
+ if (hasRequiredGeneratorFunction) return generatorFunction;
5099
+ hasRequiredGeneratorFunction = 1;
5100
+ const cached = (
5101
+ /** @type {GeneratorFunctionConstructor} */
5102
+ function* () {
5103
+ }.constructor
5104
+ );
5105
+ generatorFunction = () => cached;
5106
+ return generatorFunction;
5107
+ }
5095
5108
  var isGeneratorFunction;
5096
5109
  var hasRequiredIsGeneratorFunction;
5097
5110
  function requireIsGeneratorFunction() {
@@ -5104,16 +5117,7 @@ function requireIsGeneratorFunction() {
5104
5117
  var getProto2 = requireGetProto();
5105
5118
  var toStr = callBound2("Object.prototype.toString");
5106
5119
  var fnToStr = callBound2("Function.prototype.toString");
5107
- var getGeneratorFunc = function() {
5108
- if (!hasToStringTag) {
5109
- return false;
5110
- }
5111
- try {
5112
- return Function("return function*() {}")();
5113
- } catch (e) {
5114
- }
5115
- };
5116
- var GeneratorFunction;
5120
+ var getGeneratorFunction = /* @__PURE__ */ requireGeneratorFunction();
5117
5121
  isGeneratorFunction = function isGeneratorFunction2(fn) {
5118
5122
  if (typeof fn !== "function") {
5119
5123
  return false;
@@ -5128,14 +5132,8 @@ function requireIsGeneratorFunction() {
5128
5132
  if (!getProto2) {
5129
5133
  return false;
5130
5134
  }
5131
- if (typeof GeneratorFunction === "undefined") {
5132
- var generatorFunc = getGeneratorFunc();
5133
- GeneratorFunction = generatorFunc ? (
5134
- /** @type {GeneratorFunctionConstructor} */
5135
- getProto2(generatorFunc)
5136
- ) : false;
5137
- }
5138
- return getProto2(fn) === GeneratorFunction;
5135
+ var GeneratorFunction = getGeneratorFunction();
5136
+ return GeneratorFunction && getProto2(fn) === GeneratorFunction.prototype;
5139
5137
  };
5140
5138
  return isGeneratorFunction;
5141
5139
  }
@@ -22966,13 +22964,56 @@ function translateChildNodes(params) {
22966
22964
  const { content: nodes } = params.node;
22967
22965
  if (!nodes) return [];
22968
22966
  const translatedNodes = [];
22969
- nodes.forEach((node) => {
22967
+ const hyperlinkGroup = [];
22968
+ let index = 0;
22969
+ while (index < nodes.length) {
22970
+ const node = nodes[index];
22971
+ const linkMark = _isLinkNode(node);
22972
+ if (linkMark) {
22973
+ hyperlinkGroup.push(node);
22974
+ const nextNode = index + 1 < nodes.length ? nodes[index + 1] : null;
22975
+ const nextIsLink = _isLinkNode(nextNode, linkMark);
22976
+ if (nextIsLink) {
22977
+ index++;
22978
+ continue;
22979
+ } else {
22980
+ let translatedLinkGroup = exportSchemaToJson({
22981
+ ...params,
22982
+ node: hyperlinkGroup[0],
22983
+ extraParams: { ...params.extraParams || {}, hyperlinkGroup: hyperlinkGroup.slice() }
22984
+ });
22985
+ if (translatedLinkGroup instanceof Array) translatedNodes.push(...translatedLinkGroup);
22986
+ else translatedNodes.push(translatedLinkGroup);
22987
+ hyperlinkGroup.length = 0;
22988
+ index++;
22989
+ continue;
22990
+ }
22991
+ }
22970
22992
  let translatedNode = exportSchemaToJson({ ...params, node });
22971
22993
  if (translatedNode instanceof Array) translatedNodes.push(...translatedNode);
22972
22994
  else translatedNodes.push(translatedNode);
22973
- });
22995
+ index++;
22996
+ }
22974
22997
  return translatedNodes.filter((n) => n);
22975
22998
  }
22999
+ function _isLinkNode(node, referenceMark = null) {
23000
+ if (!node || !node.marks && !node.attrs?.marksAsAttrs) return null;
23001
+ const marks = node.marks || node.attrs.marksAsAttrs;
23002
+ const linkMark = marks.find((mark) => mark.type === "link");
23003
+ if (!linkMark) return null;
23004
+ if (referenceMark) {
23005
+ return _isSameLinkMark(linkMark.attrs, referenceMark.attrs) ? linkMark : null;
23006
+ }
23007
+ return linkMark;
23008
+ }
23009
+ function _isSameLinkMark(attrsA, attrsB) {
23010
+ for (let key of ["anchor", "docLocation", "history", "href", "rId", "target"]) {
23011
+ if (attrsA[key] != attrsB[key]) {
23012
+ return false;
23013
+ }
23014
+ }
23015
+ return true;
23016
+ }
22976
23017
  const baseNumbering = {
22977
23018
  declaration: {
22978
23019
  attributes: {
@@ -24328,37 +24369,37 @@ const _NodeTranslator = class _NodeTranslator {
24328
24369
  /** @type {typeof TranslatorTypes} */
24329
24370
  __publicField(_NodeTranslator, "translatorTypes", TranslatorTypes);
24330
24371
  let NodeTranslator = _NodeTranslator;
24331
- const encode$18 = (attributes) => {
24372
+ const encode$1b = (attributes) => {
24332
24373
  return attributes["w:type"];
24333
24374
  };
24334
- const decode$$ = (attrs) => {
24375
+ const decode$11 = (attrs) => {
24335
24376
  const { lineBreakType } = attrs;
24336
24377
  return lineBreakType;
24337
24378
  };
24338
24379
  const attrConfig$F = Object.freeze({
24339
24380
  xmlName: "w:type",
24340
24381
  sdName: "lineBreakType",
24341
- encode: encode$18,
24342
- decode: decode$$
24382
+ encode: encode$1b,
24383
+ decode: decode$11
24343
24384
  });
24344
- const encode$17 = (attributes) => {
24385
+ const encode$1a = (attributes) => {
24345
24386
  const xmlAttrValue = attributes["w:clear"];
24346
24387
  return xmlAttrValue;
24347
24388
  };
24348
- const decode$_ = (attrs) => {
24389
+ const decode$10 = (attrs) => {
24349
24390
  const { clear } = attrs;
24350
24391
  return clear;
24351
24392
  };
24352
24393
  const attrConfig$E = Object.freeze({
24353
24394
  xmlName: "w:clear",
24354
24395
  sdName: "clear",
24355
- encode: encode$17,
24356
- decode: decode$_
24396
+ encode: encode$1a,
24397
+ decode: decode$10
24357
24398
  });
24358
24399
  const validXmlAttributes$m = [attrConfig$F, attrConfig$E];
24359
- const XML_NODE_NAME$u = "w:br";
24360
- const SD_NODE_NAME$d = "lineBreak";
24361
- const encode$16 = (_2, encodedAttrs) => {
24400
+ const XML_NODE_NAME$x = "w:br";
24401
+ const SD_NODE_NAME$f = "lineBreak";
24402
+ const encode$19 = (_2, encodedAttrs) => {
24362
24403
  const isPageBreak = encodedAttrs?.lineBreakType === "page";
24363
24404
  const translated = {
24364
24405
  type: isPageBreak ? "hardBreak" : "lineBreak"
@@ -24368,7 +24409,7 @@ const encode$16 = (_2, encodedAttrs) => {
24368
24409
  }
24369
24410
  return translated;
24370
24411
  };
24371
- const decode$Z = (params, decodedAttrs) => {
24412
+ const decode$$ = (params, decodedAttrs) => {
24372
24413
  const { node } = params;
24373
24414
  if (!node) return;
24374
24415
  const wBreak = { name: "w:br" };
@@ -24385,39 +24426,39 @@ const decode$Z = (params, decodedAttrs) => {
24385
24426
  };
24386
24427
  return translated;
24387
24428
  };
24388
- const config$s = {
24389
- xmlName: XML_NODE_NAME$u,
24390
- sdNodeOrKeyName: SD_NODE_NAME$d,
24429
+ const config$v = {
24430
+ xmlName: XML_NODE_NAME$x,
24431
+ sdNodeOrKeyName: SD_NODE_NAME$f,
24391
24432
  type: NodeTranslator.translatorTypes.NODE,
24392
- encode: encode$16,
24393
- decode: decode$Z,
24433
+ encode: encode$19,
24434
+ decode: decode$$,
24394
24435
  attributes: validXmlAttributes$m
24395
24436
  };
24396
- const translator$16 = NodeTranslator.from(config$s);
24397
- const encode$15 = (attributes) => attributes?.["w:val"];
24398
- const decode$Y = (attrs) => attrs?.highlight;
24437
+ const translator$19 = NodeTranslator.from(config$v);
24438
+ const encode$18 = (attributes) => attributes?.["w:val"];
24439
+ const decode$_ = (attrs) => attrs?.highlight;
24399
24440
  const attrConfig$D = Object.freeze({
24400
24441
  xmlName: "w:val",
24401
24442
  sdName: "highlight",
24402
- encode: encode$15,
24403
- decode: decode$Y
24443
+ encode: encode$18,
24444
+ decode: decode$_
24404
24445
  });
24405
24446
  const validXmlAttributes$l = [attrConfig$D];
24406
- const XML_NODE_NAME$t = "w:highlight";
24407
- const SD_ATTR_KEY$f = "highlight";
24447
+ const XML_NODE_NAME$w = "w:highlight";
24448
+ const SD_ATTR_KEY$g = "highlight";
24408
24449
  const DISABLED_TOKENS = /* @__PURE__ */ new Set(["transparent", "none", "inherit"]);
24409
- const encode$14 = (params, encodedAttrs = {}) => {
24450
+ const encode$17 = (params, encodedAttrs = {}) => {
24410
24451
  const { nodes } = params;
24411
24452
  const node = nodes?.[0];
24412
24453
  const value = encodedAttrs.highlight ?? node?.attributes?.["w:val"];
24413
24454
  return {
24414
24455
  type: "attr",
24415
- xmlName: XML_NODE_NAME$t,
24416
- sdNodeOrKeyName: SD_ATTR_KEY$f,
24456
+ xmlName: XML_NODE_NAME$w,
24457
+ sdNodeOrKeyName: SD_ATTR_KEY$g,
24417
24458
  attributes: { "w:val": value ?? null }
24418
24459
  };
24419
24460
  };
24420
- const decode$X = (params) => {
24461
+ const decode$Z = (params) => {
24421
24462
  const attrs = params?.node?.attrs || {};
24422
24463
  const highlightValue = attrs.highlight ?? attrs.color ?? null;
24423
24464
  if (!highlightValue) return void 0;
@@ -24425,14 +24466,14 @@ const decode$X = (params) => {
24425
24466
  if (!normalizedValue) return void 0;
24426
24467
  if (DISABLED_TOKENS.has(normalizedValue)) {
24427
24468
  return {
24428
- name: XML_NODE_NAME$t,
24469
+ name: XML_NODE_NAME$w,
24429
24470
  attributes: { "w:val": "none" }
24430
24471
  };
24431
24472
  }
24432
24473
  const keyword = getDocxHighlightKeywordFromHex(highlightValue);
24433
24474
  if (keyword) {
24434
24475
  return {
24435
- name: XML_NODE_NAME$t,
24476
+ name: XML_NODE_NAME$w,
24436
24477
  attributes: { "w:val": keyword }
24437
24478
  };
24438
24479
  }
@@ -24447,63 +24488,63 @@ const decode$X = (params) => {
24447
24488
  }
24448
24489
  };
24449
24490
  };
24450
- const config$r = {
24451
- xmlName: XML_NODE_NAME$t,
24452
- sdNodeOrKeyName: SD_ATTR_KEY$f,
24491
+ const config$u = {
24492
+ xmlName: XML_NODE_NAME$w,
24493
+ sdNodeOrKeyName: SD_ATTR_KEY$g,
24453
24494
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
24454
- encode: encode$14,
24455
- decode: decode$X,
24495
+ encode: encode$17,
24496
+ decode: decode$Z,
24456
24497
  attributes: validXmlAttributes$l
24457
24498
  };
24458
- const translator$15 = NodeTranslator.from(config$r);
24459
- const encode$13 = (attributes) => {
24499
+ const translator$18 = NodeTranslator.from(config$u);
24500
+ const encode$16 = (attributes) => {
24460
24501
  return attributes["w:val"];
24461
24502
  };
24462
- const decode$W = (attrs) => {
24503
+ const decode$Y = (attrs) => {
24463
24504
  const { tabSize } = attrs || {};
24464
24505
  return tabSize;
24465
24506
  };
24466
24507
  const attrConfig$C = Object.freeze({
24467
24508
  xmlName: "w:val",
24468
24509
  sdName: "tabSize",
24469
- encode: encode$13,
24470
- decode: decode$W
24510
+ encode: encode$16,
24511
+ decode: decode$Y
24471
24512
  });
24472
- const encode$12 = (attributes) => {
24513
+ const encode$15 = (attributes) => {
24473
24514
  return attributes["w:leader"];
24474
24515
  };
24475
- const decode$V = (attrs) => {
24516
+ const decode$X = (attrs) => {
24476
24517
  const { leader } = attrs || {};
24477
24518
  return leader;
24478
24519
  };
24479
24520
  const attrConfig$B = Object.freeze({
24480
24521
  xmlName: "w:leader",
24481
24522
  sdName: "leader",
24482
- encode: encode$12,
24483
- decode: decode$V
24523
+ encode: encode$15,
24524
+ decode: decode$X
24484
24525
  });
24485
- const encode$11 = (attributes) => {
24526
+ const encode$14 = (attributes) => {
24486
24527
  return attributes["w:pos"];
24487
24528
  };
24488
- const decode$U = (attrs) => {
24529
+ const decode$W = (attrs) => {
24489
24530
  const { pos } = attrs || {};
24490
24531
  return pos;
24491
24532
  };
24492
24533
  const attrConfig$A = Object.freeze({
24493
24534
  xmlName: "w:pos",
24494
24535
  sdName: "pos",
24495
- encode: encode$11,
24496
- decode: decode$U
24536
+ encode: encode$14,
24537
+ decode: decode$W
24497
24538
  });
24498
24539
  const validXmlAttributes$k = [attrConfig$C, attrConfig$A, attrConfig$B];
24499
- const XML_NODE_NAME$s = "w:tab";
24500
- const SD_NODE_NAME$c = "tab";
24501
- const encode$10 = (_2, encodedAttrs = {}) => {
24540
+ const XML_NODE_NAME$v = "w:tab";
24541
+ const SD_NODE_NAME$e = "tab";
24542
+ const encode$13 = (_2, encodedAttrs = {}) => {
24502
24543
  const translated = { type: "tab" };
24503
24544
  if (encodedAttrs) translated.attrs = { ...encodedAttrs };
24504
24545
  return translated;
24505
24546
  };
24506
- const decode$T = (params, decodedAttrs = {}) => {
24547
+ const decode$V = (params, decodedAttrs = {}) => {
24507
24548
  const { node } = params || {};
24508
24549
  if (!node) return;
24509
24550
  const wTab = { name: "w:tab" };
@@ -24519,15 +24560,15 @@ const decode$T = (params, decodedAttrs = {}) => {
24519
24560
  }
24520
24561
  return translated;
24521
24562
  };
24522
- const config$q = {
24523
- xmlName: XML_NODE_NAME$s,
24524
- sdNodeOrKeyName: SD_NODE_NAME$c,
24563
+ const config$t = {
24564
+ xmlName: XML_NODE_NAME$v,
24565
+ sdNodeOrKeyName: SD_NODE_NAME$e,
24525
24566
  type: NodeTranslator.translatorTypes.NODE,
24526
- encode: encode$10,
24527
- decode: decode$T,
24567
+ encode: encode$13,
24568
+ decode: decode$V,
24528
24569
  attributes: validXmlAttributes$k
24529
24570
  };
24530
- const translator$14 = NodeTranslator.from(config$q);
24571
+ const translator$17 = NodeTranslator.from(config$t);
24531
24572
  const mergeTextNodes = (nodes) => {
24532
24573
  if (!nodes || !Array.isArray(nodes)) {
24533
24574
  return nodes;
@@ -24901,104 +24942,10 @@ const getDefaultParagraphStyle = (docx, styleId = "") => {
24901
24942
  justify: pPrByIdJcAttr
24902
24943
  };
24903
24944
  };
24904
- const preProcessNodesForFldChar = (nodes = []) => {
24905
- const processedNodes = [];
24906
- let buffer2 = [];
24907
- let collecting = false;
24908
- for (const node of nodes) {
24909
- const fldCharEl = node.elements?.find((el) => el.name === "w:fldChar");
24910
- const fldType = fldCharEl?.attributes?.["w:fldCharType"];
24911
- if (fldType === "begin") {
24912
- buffer2 = [node];
24913
- collecting = true;
24914
- continue;
24915
- }
24916
- if (fldType === "separate" && collecting) {
24917
- buffer2.push(node);
24918
- continue;
24919
- }
24920
- if (fldType === "end" && collecting) {
24921
- buffer2.push(node);
24922
- processedNodes.push(...processCombinedNodesForFldChar(buffer2));
24923
- buffer2 = [];
24924
- collecting = false;
24925
- continue;
24926
- }
24927
- if (collecting) {
24928
- buffer2.push(node);
24929
- } else {
24930
- processedNodes.push(node);
24931
- }
24932
- }
24933
- if (buffer2.length) {
24934
- processedNodes.push(...buffer2);
24935
- }
24936
- return processedNodes;
24937
- };
24938
- const processCombinedNodesForFldChar = (nodesToCombine = []) => {
24939
- let processedNodes = [];
24940
- let hasPageMarker = false;
24941
- let isNumPages = false;
24942
- const textStart = nodesToCombine.findIndex(
24943
- (n) => n.elements?.some((el) => el.name === "w:fldChar" && el.attributes["w:fldCharType"] === "separate")
24944
- );
24945
- const textEnd = nodesToCombine.findIndex(
24946
- (n) => n.elements?.some((el) => el.name === "w:fldChar" && el.attributes["w:fldCharType"] === "end")
24947
- );
24948
- const textNodes = nodesToCombine.slice(textStart + 1, textEnd);
24949
- const instrTextContainer = nodesToCombine.find((n) => n.elements?.some((el) => el.name === "w:instrText"));
24950
- const instrTextNode = instrTextContainer?.elements?.find((el) => el.name === "w:instrText");
24951
- const instrText = instrTextNode?.elements[0].text;
24952
- if (!hasPageMarker) hasPageMarker = instrText?.trim().startsWith("PAGE");
24953
- if (!isNumPages) isNumPages = instrText?.trim().startsWith("NUMPAGES");
24954
- const urlMatch = instrText?.match(/HYPERLINK\s+"([^"]+)"/);
24955
- if (hasPageMarker) {
24956
- const pageNumNode = {
24957
- name: "sd:autoPageNumber",
24958
- type: "element"
24959
- };
24960
- nodesToCombine.forEach((n) => {
24961
- const rPrNode = n.elements.find((el) => el.name === "w:rPr");
24962
- if (rPrNode) pageNumNode.elements = [rPrNode];
24963
- });
24964
- processedNodes.push(pageNumNode);
24965
- } else if (isNumPages) {
24966
- const totalPageNumNode = {
24967
- name: "sd:totalPageNumber",
24968
- type: "element"
24969
- };
24970
- nodesToCombine.forEach((n) => {
24971
- const rPrNode = n.elements.find((el) => el.name === "w:rPr");
24972
- if (rPrNode) totalPageNumNode.elements = [rPrNode];
24973
- });
24974
- processedNodes.push(totalPageNumNode);
24975
- } else if (urlMatch && urlMatch?.length >= 2) {
24976
- const url = urlMatch[1];
24977
- const textMarks = [];
24978
- textNodes.forEach((n) => {
24979
- const rPr2 = n.elements.find((el) => el.name === "w:rPr");
24980
- if (!rPr2) return;
24981
- const { elements } = rPr2;
24982
- elements.forEach((el) => {
24983
- textMarks.push(el);
24984
- });
24985
- });
24986
- const linkMark = { name: "link", attributes: { href: url } };
24987
- const rPr = { name: "w:rPr", type: "element", elements: [linkMark, ...textMarks] };
24988
- processedNodes.push({
24989
- name: "w:r",
24990
- type: "element",
24991
- elements: [rPr, ...textNodes]
24992
- });
24993
- }
24994
- return processedNodes;
24995
- };
24996
24945
  const handleParagraphNode$1 = (params) => {
24997
24946
  const { nodes, docx, nodeListHandler, filename } = params;
24998
24947
  const node = carbonCopy(nodes[0]);
24999
24948
  let schemaNode;
25000
- let processedElements = preProcessNodesForFldChar(node.elements);
25001
- node.elements = processedElements;
25002
24949
  const handleStandardNode2 = nodeListHandler.handlerEntities.find(
25003
24950
  (e) => e.handlerName === "standardNodeHandler"
25004
24951
  )?.handler;
@@ -25139,89 +25086,89 @@ const handleParagraphNode$1 = (params) => {
25139
25086
  }
25140
25087
  return schemaNode;
25141
25088
  };
25142
- const encode$$ = (attributes) => {
25089
+ const encode$12 = (attributes) => {
25143
25090
  return attributes["w:rsidDel"];
25144
25091
  };
25145
- const decode$S = (attrs) => {
25092
+ const decode$U = (attrs) => {
25146
25093
  return attrs.rsidDel;
25147
25094
  };
25148
25095
  const attrConfig$z = Object.freeze({
25149
25096
  xmlName: "w:rsidDel",
25150
25097
  sdName: "rsidDel",
25151
- encode: encode$$,
25152
- decode: decode$S
25098
+ encode: encode$12,
25099
+ decode: decode$U
25153
25100
  });
25154
- const encode$_ = (attributes) => {
25101
+ const encode$11 = (attributes) => {
25155
25102
  return attributes["w:rsidP"];
25156
25103
  };
25157
- const decode$R = (attrs) => {
25104
+ const decode$T = (attrs) => {
25158
25105
  return attrs.rsidP;
25159
25106
  };
25160
25107
  const attrConfig$y = Object.freeze({
25161
25108
  xmlName: "w:rsidP",
25162
25109
  sdName: "rsidP",
25163
- encode: encode$_,
25164
- decode: decode$R
25110
+ encode: encode$11,
25111
+ decode: decode$T
25165
25112
  });
25166
- const encode$Z = (attributes) => {
25113
+ const encode$10 = (attributes) => {
25167
25114
  return attributes["w:rsidR"];
25168
25115
  };
25169
- const decode$Q = (attrs) => {
25116
+ const decode$S = (attrs) => {
25170
25117
  return attrs.rsidR;
25171
25118
  };
25172
25119
  const attrConfig$x = Object.freeze({
25173
25120
  xmlName: "w:rsidR",
25174
25121
  sdName: "rsidR",
25175
- encode: encode$Z,
25176
- decode: decode$Q
25122
+ encode: encode$10,
25123
+ decode: decode$S
25177
25124
  });
25178
- const encode$Y = (attributes) => {
25125
+ const encode$$ = (attributes) => {
25179
25126
  return attributes["w:rsidRPr"];
25180
25127
  };
25181
- const decode$P = (attrs) => {
25128
+ const decode$R = (attrs) => {
25182
25129
  return attrs.rsidRPr;
25183
25130
  };
25184
25131
  const attrConfig$w = Object.freeze({
25185
25132
  xmlName: "w:rsidRPr",
25186
25133
  sdName: "rsidRPr",
25187
- encode: encode$Y,
25188
- decode: decode$P
25134
+ encode: encode$$,
25135
+ decode: decode$R
25189
25136
  });
25190
- const encode$X = (attributes) => {
25137
+ const encode$_ = (attributes) => {
25191
25138
  return attributes["w:rsidRDefault"];
25192
25139
  };
25193
- const decode$O = (attrs) => {
25140
+ const decode$Q = (attrs) => {
25194
25141
  return attrs.rsidRDefault;
25195
25142
  };
25196
25143
  const attrConfig$v = Object.freeze({
25197
25144
  xmlName: "w:rsidRDefault",
25198
25145
  sdName: "rsidRDefault",
25199
- encode: encode$X,
25200
- decode: decode$O
25146
+ encode: encode$_,
25147
+ decode: decode$Q
25201
25148
  });
25202
- const encode$W = (attributes) => {
25149
+ const encode$Z = (attributes) => {
25203
25150
  return attributes["w14:paraId"];
25204
25151
  };
25205
- const decode$N = (attrs) => {
25152
+ const decode$P = (attrs) => {
25206
25153
  return attrs.paraId;
25207
25154
  };
25208
25155
  const attrConfig$u = Object.freeze({
25209
25156
  xmlName: "w14:paraId",
25210
25157
  sdName: "paraId",
25211
- encode: encode$W,
25212
- decode: decode$N
25158
+ encode: encode$Z,
25159
+ decode: decode$P
25213
25160
  });
25214
- const encode$V = (attributes) => {
25161
+ const encode$Y = (attributes) => {
25215
25162
  return attributes["w14:textId"];
25216
25163
  };
25217
- const decode$M = (attrs) => {
25164
+ const decode$O = (attrs) => {
25218
25165
  return attrs.textId;
25219
25166
  };
25220
25167
  const attrConfig$t = Object.freeze({
25221
25168
  xmlName: "w14:textId",
25222
25169
  sdName: "textId",
25223
- encode: encode$V,
25224
- decode: decode$M
25170
+ encode: encode$Y,
25171
+ decode: decode$O
25225
25172
  });
25226
25173
  const validXmlAttributes$j = [
25227
25174
  attrConfig$u,
@@ -25232,9 +25179,9 @@ const validXmlAttributes$j = [
25232
25179
  attrConfig$w,
25233
25180
  attrConfig$z
25234
25181
  ];
25235
- const XML_NODE_NAME$r = "w:p";
25236
- const SD_NODE_NAME$b = "paragraph";
25237
- const encode$U = (params, encodedAttrs = {}) => {
25182
+ const XML_NODE_NAME$u = "w:p";
25183
+ const SD_NODE_NAME$d = "paragraph";
25184
+ const encode$X = (params, encodedAttrs = {}) => {
25238
25185
  const node = handleParagraphNode$1(params);
25239
25186
  if (!node) return void 0;
25240
25187
  if (encodedAttrs && Object.keys(encodedAttrs).length) {
@@ -25242,7 +25189,7 @@ const encode$U = (params, encodedAttrs = {}) => {
25242
25189
  }
25243
25190
  return node;
25244
25191
  };
25245
- const decode$L = (params, decodedAttrs = {}) => {
25192
+ const decode$N = (params, decodedAttrs = {}) => {
25246
25193
  const translated = translateParagraphNode(params);
25247
25194
  if (!translated) return void 0;
25248
25195
  if (decodedAttrs && Object.keys(decodedAttrs).length) {
@@ -25250,16 +25197,16 @@ const decode$L = (params, decodedAttrs = {}) => {
25250
25197
  }
25251
25198
  return translated;
25252
25199
  };
25253
- const config$p = {
25254
- xmlName: XML_NODE_NAME$r,
25255
- sdNodeOrKeyName: SD_NODE_NAME$b,
25200
+ const config$s = {
25201
+ xmlName: XML_NODE_NAME$u,
25202
+ sdNodeOrKeyName: SD_NODE_NAME$d,
25256
25203
  type: NodeTranslator.translatorTypes.NODE,
25257
- encode: encode$U,
25258
- decode: decode$L,
25204
+ encode: encode$X,
25205
+ decode: decode$N,
25259
25206
  attributes: validXmlAttributes$j
25260
25207
  };
25261
- const translator$13 = NodeTranslator.from(config$p);
25262
- const encode$T = (attributes) => {
25208
+ const translator$16 = NodeTranslator.from(config$s);
25209
+ const encode$W = (attributes) => {
25263
25210
  const raw = attributes?.["w:val"];
25264
25211
  if (raw === void 0 || raw === null) return void 0;
25265
25212
  if (typeof raw === "boolean") return raw;
@@ -25269,24 +25216,24 @@ const encode$T = (attributes) => {
25269
25216
  if (val === "1" || val === "true" || val === "on") return true;
25270
25217
  return void 0;
25271
25218
  };
25272
- const decode$K = (runProps) => {
25219
+ const decode$M = (runProps) => {
25273
25220
  if (runProps?.bold === false) return "0";
25274
25221
  return void 0;
25275
25222
  };
25276
25223
  const attrConfig$s = Object.freeze({
25277
25224
  xmlName: "w:val",
25278
25225
  sdName: "bold",
25279
- encode: encode$T,
25280
- decode: decode$K
25226
+ encode: encode$W,
25227
+ decode: decode$M
25281
25228
  });
25282
25229
  const validXmlAttributes$i = [attrConfig$s];
25283
- const XML_NODE_NAME$q = "w:b";
25284
- const SD_ATTR_KEY$e = "bold";
25285
- const encode$S = (params, encodedAttrs = {}) => {
25230
+ const XML_NODE_NAME$t = "w:b";
25231
+ const SD_ATTR_KEY$f = "bold";
25232
+ const encode$V = (params, encodedAttrs = {}) => {
25286
25233
  const { nodes } = params;
25287
25234
  const node = nodes[0];
25288
25235
  if (!node) return void 0;
25289
- const val = encodedAttrs?.[SD_ATTR_KEY$e];
25236
+ const val = encodedAttrs?.[SD_ATTR_KEY$f];
25290
25237
  let attributes;
25291
25238
  if (val === false) attributes = { "w:val": "0" };
25292
25239
  else if (val === true)
@@ -25294,85 +25241,85 @@ const encode$S = (params, encodedAttrs = {}) => {
25294
25241
  else attributes = node.attributes || {};
25295
25242
  return {
25296
25243
  type: "attr",
25297
- xmlName: XML_NODE_NAME$q,
25298
- sdNodeOrKeyName: SD_ATTR_KEY$e,
25244
+ xmlName: XML_NODE_NAME$t,
25245
+ sdNodeOrKeyName: SD_ATTR_KEY$f,
25299
25246
  attributes
25300
25247
  };
25301
25248
  };
25302
- const config$o = {
25303
- xmlName: XML_NODE_NAME$q,
25304
- sdNodeOrKeyName: SD_ATTR_KEY$e,
25249
+ const config$r = {
25250
+ xmlName: XML_NODE_NAME$t,
25251
+ sdNodeOrKeyName: SD_ATTR_KEY$f,
25305
25252
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25306
- encode: encode$S,
25253
+ encode: encode$V,
25307
25254
  attributes: validXmlAttributes$i
25308
25255
  };
25309
- const translator$12 = NodeTranslator.from(config$o);
25310
- const XML_NODE_NAME$p = "w:i";
25311
- const SD_ATTR_KEY$d = "italic";
25312
- const encode$R = (params) => {
25256
+ const translator$15 = NodeTranslator.from(config$r);
25257
+ const XML_NODE_NAME$s = "w:i";
25258
+ const SD_ATTR_KEY$e = "italic";
25259
+ const encode$U = (params) => {
25313
25260
  const { nodes } = params;
25314
25261
  const node = nodes?.[0];
25315
25262
  if (!node) return void 0;
25316
25263
  return {
25317
25264
  type: "attr",
25318
- xmlName: XML_NODE_NAME$p,
25319
- sdNodeOrKeyName: SD_ATTR_KEY$d,
25265
+ xmlName: XML_NODE_NAME$s,
25266
+ sdNodeOrKeyName: SD_ATTR_KEY$e,
25320
25267
  attributes: {
25321
25268
  "w:val": node.attributes?.["w:val"] ?? null
25322
25269
  }
25323
25270
  };
25324
25271
  };
25325
- const config$n = {
25326
- xmlName: XML_NODE_NAME$p,
25327
- sdNodeOrKeyName: SD_ATTR_KEY$d,
25272
+ const config$q = {
25273
+ xmlName: XML_NODE_NAME$s,
25274
+ sdNodeOrKeyName: SD_ATTR_KEY$e,
25328
25275
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25329
- encode: encode$R
25276
+ encode: encode$U
25330
25277
  };
25331
- const translator$11 = NodeTranslator.from(config$n);
25332
- const encode$Q = (attributes) => attributes?.["w:val"];
25333
- const decode$J = (attrs) => attrs?.underline;
25278
+ const translator$14 = NodeTranslator.from(config$q);
25279
+ const encode$T = (attributes) => attributes?.["w:val"];
25280
+ const decode$L = (attrs) => attrs?.underline;
25334
25281
  const attrConfig$r = Object.freeze({
25335
25282
  xmlName: "w:val",
25336
25283
  sdName: "underline",
25337
- encode: encode$Q,
25338
- decode: decode$J
25284
+ encode: encode$T,
25285
+ decode: decode$L
25339
25286
  });
25340
- const encode$P = (attributes) => attributes?.["w:color"];
25341
- const decode$I = (attrs) => attrs?.color;
25287
+ const encode$S = (attributes) => attributes?.["w:color"];
25288
+ const decode$K = (attrs) => attrs?.color;
25342
25289
  const attrConfig$q = Object.freeze({
25343
25290
  xmlName: "w:color",
25344
25291
  sdName: "color",
25345
- encode: encode$P,
25346
- decode: decode$I
25292
+ encode: encode$S,
25293
+ decode: decode$K
25347
25294
  });
25348
- const encode$O = (attributes) => attributes?.["w:themeColor"];
25349
- const decode$H = (attrs) => attrs?.themeColor;
25295
+ const encode$R = (attributes) => attributes?.["w:themeColor"];
25296
+ const decode$J = (attrs) => attrs?.themeColor;
25350
25297
  const attrConfig$p = Object.freeze({
25351
25298
  xmlName: "w:themeColor",
25352
25299
  sdName: "themeColor",
25353
- encode: encode$O,
25354
- decode: decode$H
25300
+ encode: encode$R,
25301
+ decode: decode$J
25355
25302
  });
25356
- const encode$N = (attributes) => attributes?.["w:themeTint"];
25357
- const decode$G = (attrs) => attrs?.themeTint;
25303
+ const encode$Q = (attributes) => attributes?.["w:themeTint"];
25304
+ const decode$I = (attrs) => attrs?.themeTint;
25358
25305
  const attrConfig$o = Object.freeze({
25359
25306
  xmlName: "w:themeTint",
25360
25307
  sdName: "themeTint",
25361
- encode: encode$N,
25362
- decode: decode$G
25308
+ encode: encode$Q,
25309
+ decode: decode$I
25363
25310
  });
25364
- const encode$M = (attributes) => attributes?.["w:themeShade"];
25365
- const decode$F = (attrs) => attrs?.themeShade;
25311
+ const encode$P = (attributes) => attributes?.["w:themeShade"];
25312
+ const decode$H = (attrs) => attrs?.themeShade;
25366
25313
  const attrConfig$n = Object.freeze({
25367
25314
  xmlName: "w:themeShade",
25368
25315
  sdName: "themeShade",
25369
- encode: encode$M,
25370
- decode: decode$F
25316
+ encode: encode$P,
25317
+ decode: decode$H
25371
25318
  });
25372
25319
  const validXmlAttributes$h = [attrConfig$r, attrConfig$q, attrConfig$p, attrConfig$o, attrConfig$n];
25373
- const XML_NODE_NAME$o = "w:u";
25374
- const SD_ATTR_KEY$c = "underline";
25375
- const encode$L = (params, encodedAttrs = {}) => {
25320
+ const XML_NODE_NAME$r = "w:u";
25321
+ const SD_ATTR_KEY$d = "underline";
25322
+ const encode$O = (params, encodedAttrs = {}) => {
25376
25323
  const { nodes } = params;
25377
25324
  const node = nodes?.[0];
25378
25325
  const sourceAttrs = node?.attributes || {};
@@ -25388,12 +25335,12 @@ const encode$L = (params, encodedAttrs = {}) => {
25388
25335
  if (themeShade !== void 0 && themeShade !== null) attributes["w:themeShade"] = themeShade;
25389
25336
  return {
25390
25337
  type: "attr",
25391
- xmlName: XML_NODE_NAME$o,
25392
- sdNodeOrKeyName: SD_ATTR_KEY$c,
25338
+ xmlName: XML_NODE_NAME$r,
25339
+ sdNodeOrKeyName: SD_ATTR_KEY$d,
25393
25340
  attributes
25394
25341
  };
25395
25342
  };
25396
- const decode$E = (params) => {
25343
+ const decode$G = (params) => {
25397
25344
  const attrs = params?.node?.attrs || {};
25398
25345
  const underlineType = attrs.underlineType ?? attrs.underline ?? null;
25399
25346
  const color = attrs.underlineColor ?? attrs.color ?? null;
@@ -25411,20 +25358,20 @@ const decode$E = (params) => {
25411
25358
  if (themeTint) attributes["w:themeTint"] = themeTint;
25412
25359
  if (themeShade) attributes["w:themeShade"] = themeShade;
25413
25360
  return {
25414
- name: XML_NODE_NAME$o,
25361
+ name: XML_NODE_NAME$r,
25415
25362
  attributes
25416
25363
  };
25417
25364
  };
25418
- const config$m = {
25419
- xmlName: XML_NODE_NAME$o,
25420
- sdNodeOrKeyName: SD_ATTR_KEY$c,
25365
+ const config$p = {
25366
+ xmlName: XML_NODE_NAME$r,
25367
+ sdNodeOrKeyName: SD_ATTR_KEY$d,
25421
25368
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25422
- encode: encode$L,
25423
- decode: decode$E,
25369
+ encode: encode$O,
25370
+ decode: decode$G,
25424
25371
  attributes: validXmlAttributes$h
25425
25372
  };
25426
- const translator$10 = NodeTranslator.from(config$m);
25427
- const encode$K = (attributes) => {
25373
+ const translator$13 = NodeTranslator.from(config$p);
25374
+ const encode$N = (attributes) => {
25428
25375
  const raw = attributes?.["w:val"];
25429
25376
  if (raw === void 0 || raw === null) return void 0;
25430
25377
  if (typeof raw === "boolean") return raw;
@@ -25434,24 +25381,24 @@ const encode$K = (attributes) => {
25434
25381
  if (val === "1" || val === "true" || val === "on") return true;
25435
25382
  return void 0;
25436
25383
  };
25437
- const decode$D = (attrs) => {
25384
+ const decode$F = (attrs) => {
25438
25385
  if (attrs?.strike === false) return "0";
25439
25386
  return void 0;
25440
25387
  };
25441
25388
  const attrConfig$m = Object.freeze({
25442
25389
  xmlName: "w:val",
25443
25390
  sdName: "strike",
25444
- encode: encode$K,
25445
- decode: decode$D
25391
+ encode: encode$N,
25392
+ decode: decode$F
25446
25393
  });
25447
25394
  const validXmlAttributes$g = [attrConfig$m];
25448
- const XML_NODE_NAME$n = "w:strike";
25449
- const SD_ATTR_KEY$b = "strike";
25450
- const encode$J = (params, encodedAttrs = {}) => {
25395
+ const XML_NODE_NAME$q = "w:strike";
25396
+ const SD_ATTR_KEY$c = "strike";
25397
+ const encode$M = (params, encodedAttrs = {}) => {
25451
25398
  const { nodes } = params;
25452
25399
  const node = nodes?.[0];
25453
25400
  if (!node) return void 0;
25454
- const val = encodedAttrs?.[SD_ATTR_KEY$b];
25401
+ const val = encodedAttrs?.[SD_ATTR_KEY$c];
25455
25402
  let attributes;
25456
25403
  if (val === false) attributes = { "w:val": "0" };
25457
25404
  else if (val === true) attributes = {};
@@ -25460,55 +25407,55 @@ const encode$J = (params, encodedAttrs = {}) => {
25460
25407
  else if (val === true && attributes["w:val"] === void 0) delete attributes["w:val"];
25461
25408
  return {
25462
25409
  type: "attr",
25463
- xmlName: XML_NODE_NAME$n,
25464
- sdNodeOrKeyName: SD_ATTR_KEY$b,
25410
+ xmlName: XML_NODE_NAME$q,
25411
+ sdNodeOrKeyName: SD_ATTR_KEY$c,
25465
25412
  attributes
25466
25413
  };
25467
25414
  };
25468
- const config$l = {
25469
- xmlName: XML_NODE_NAME$n,
25470
- sdNodeOrKeyName: SD_ATTR_KEY$b,
25415
+ const config$o = {
25416
+ xmlName: XML_NODE_NAME$q,
25417
+ sdNodeOrKeyName: SD_ATTR_KEY$c,
25471
25418
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25472
- encode: encode$J,
25419
+ encode: encode$M,
25473
25420
  attributes: validXmlAttributes$g
25474
25421
  };
25475
- const translator$$ = NodeTranslator.from(config$l);
25476
- const encode$I = (attributes) => attributes?.["w:val"];
25477
- const decode$C = (attrs) => attrs?.color;
25422
+ const translator$12 = NodeTranslator.from(config$o);
25423
+ const encode$L = (attributes) => attributes?.["w:val"];
25424
+ const decode$E = (attrs) => attrs?.color;
25478
25425
  const attrConfig$l = Object.freeze({
25479
25426
  xmlName: "w:val",
25480
25427
  sdName: "color",
25481
- encode: encode$I,
25482
- decode: decode$C
25428
+ encode: encode$L,
25429
+ decode: decode$E
25483
25430
  });
25484
- const encode$H = (attributes) => attributes?.["w:themeColor"];
25485
- const decode$B = (attrs) => attrs?.themeColor;
25431
+ const encode$K = (attributes) => attributes?.["w:themeColor"];
25432
+ const decode$D = (attrs) => attrs?.themeColor;
25486
25433
  const attrConfig$k = Object.freeze({
25487
25434
  xmlName: "w:themeColor",
25488
25435
  sdName: "themeColor",
25489
- encode: encode$H,
25490
- decode: decode$B
25436
+ encode: encode$K,
25437
+ decode: decode$D
25491
25438
  });
25492
- const encode$G = (attributes) => attributes?.["w:themeTint"];
25493
- const decode$A = (attrs) => attrs?.themeTint;
25439
+ const encode$J = (attributes) => attributes?.["w:themeTint"];
25440
+ const decode$C = (attrs) => attrs?.themeTint;
25494
25441
  const attrConfig$j = Object.freeze({
25495
25442
  xmlName: "w:themeTint",
25496
25443
  sdName: "themeTint",
25497
- encode: encode$G,
25498
- decode: decode$A
25444
+ encode: encode$J,
25445
+ decode: decode$C
25499
25446
  });
25500
- const encode$F = (attributes) => attributes?.["w:themeShade"];
25501
- const decode$z = (attrs) => attrs?.themeShade;
25447
+ const encode$I = (attributes) => attributes?.["w:themeShade"];
25448
+ const decode$B = (attrs) => attrs?.themeShade;
25502
25449
  const attrConfig$i = Object.freeze({
25503
25450
  xmlName: "w:themeShade",
25504
25451
  sdName: "themeShade",
25505
- encode: encode$F,
25506
- decode: decode$z
25452
+ encode: encode$I,
25453
+ decode: decode$B
25507
25454
  });
25508
25455
  const validXmlAttributes$f = [attrConfig$l, attrConfig$k, attrConfig$j, attrConfig$i];
25509
- const XML_NODE_NAME$m = "w:color";
25510
- const SD_ATTR_KEY$a = "color";
25511
- const encode$E = (params, encodedAttrs = {}) => {
25456
+ const XML_NODE_NAME$p = "w:color";
25457
+ const SD_ATTR_KEY$b = "color";
25458
+ const encode$H = (params, encodedAttrs = {}) => {
25512
25459
  const { nodes } = params;
25513
25460
  const node = nodes?.[0];
25514
25461
  const sourceAttrs = node?.attributes || {};
@@ -25523,63 +25470,63 @@ const encode$E = (params, encodedAttrs = {}) => {
25523
25470
  if (themeShade !== void 0 && themeShade !== null) attributes["w:themeShade"] = themeShade;
25524
25471
  return {
25525
25472
  type: "attr",
25526
- xmlName: XML_NODE_NAME$m,
25527
- sdNodeOrKeyName: SD_ATTR_KEY$a,
25528
- attributes
25473
+ xmlName: XML_NODE_NAME$p,
25474
+ sdNodeOrKeyName: SD_ATTR_KEY$b,
25475
+ attributes
25529
25476
  };
25530
25477
  };
25531
- const config$k = {
25532
- xmlName: XML_NODE_NAME$m,
25533
- sdNodeOrKeyName: SD_ATTR_KEY$a,
25478
+ const config$n = {
25479
+ xmlName: XML_NODE_NAME$p,
25480
+ sdNodeOrKeyName: SD_ATTR_KEY$b,
25534
25481
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25535
- encode: encode$E,
25482
+ encode: encode$H,
25536
25483
  attributes: validXmlAttributes$f
25537
25484
  };
25538
- const translator$_ = NodeTranslator.from(config$k);
25539
- const encode$D = (attributes) => attributes?.["w:eastAsia"];
25540
- const decode$y = (attrs) => attrs?.eastAsia;
25485
+ const translator$11 = NodeTranslator.from(config$n);
25486
+ const encode$G = (attributes) => attributes?.["w:eastAsia"];
25487
+ const decode$A = (attrs) => attrs?.eastAsia;
25541
25488
  const attrConfig$h = Object.freeze({
25542
25489
  xmlName: "w:eastAsia",
25543
25490
  sdName: "eastAsia",
25544
- encode: encode$D,
25545
- decode: decode$y
25491
+ encode: encode$G,
25492
+ decode: decode$A
25546
25493
  });
25547
- const encode$C = (attributes) => attributes?.["w:ascii"];
25548
- const decode$x = (attrs) => attrs?.ascii;
25494
+ const encode$F = (attributes) => attributes?.["w:ascii"];
25495
+ const decode$z = (attrs) => attrs?.ascii;
25549
25496
  const attrConfig$g = Object.freeze({
25550
25497
  xmlName: "w:ascii",
25551
25498
  sdName: "ascii",
25552
- encode: encode$C,
25553
- decode: decode$x
25499
+ encode: encode$F,
25500
+ decode: decode$z
25554
25501
  });
25555
- const encode$B = (attributes) => attributes?.["w:hAnsi"];
25556
- const decode$w = (attrs) => attrs?.hAnsi;
25502
+ const encode$E = (attributes) => attributes?.["w:hAnsi"];
25503
+ const decode$y = (attrs) => attrs?.hAnsi;
25557
25504
  const attrConfig$f = Object.freeze({
25558
25505
  xmlName: "w:hAnsi",
25559
25506
  sdName: "hAnsi",
25560
- encode: encode$B,
25561
- decode: decode$w
25507
+ encode: encode$E,
25508
+ decode: decode$y
25562
25509
  });
25563
- const encode$A = (attributes) => attributes?.["w:cs"];
25564
- const decode$v = (attrs) => attrs?.cs;
25510
+ const encode$D = (attributes) => attributes?.["w:cs"];
25511
+ const decode$x = (attrs) => attrs?.cs;
25565
25512
  const attrConfig$e = Object.freeze({
25566
25513
  xmlName: "w:cs",
25567
25514
  sdName: "cs",
25568
- encode: encode$A,
25569
- decode: decode$v
25515
+ encode: encode$D,
25516
+ decode: decode$x
25570
25517
  });
25571
- const encode$z = (attributes) => attributes?.["w:val"];
25572
- const decode$u = (attrs) => attrs?.value;
25518
+ const encode$C = (attributes) => attributes?.["w:val"];
25519
+ const decode$w = (attrs) => attrs?.value;
25573
25520
  const attrConfig$d = Object.freeze({
25574
25521
  xmlName: "w:val",
25575
25522
  sdName: "value",
25576
- encode: encode$z,
25577
- decode: decode$u
25523
+ encode: encode$C,
25524
+ decode: decode$w
25578
25525
  });
25579
25526
  const validXmlAttributes$e = [attrConfig$h, attrConfig$g, attrConfig$f, attrConfig$e, attrConfig$d];
25580
- const XML_NODE_NAME$l = "w:rFonts";
25581
- const SD_ATTR_KEY$9 = "fontFamily";
25582
- const encode$y = (params, encodedAttrs = {}) => {
25527
+ const XML_NODE_NAME$o = "w:rFonts";
25528
+ const SD_ATTR_KEY$a = "fontFamily";
25529
+ const encode$B = (params, encodedAttrs = {}) => {
25583
25530
  const { nodes } = params;
25584
25531
  const node = nodes?.[0];
25585
25532
  const sourceAttrs = node?.attributes || {};
@@ -25605,120 +25552,281 @@ const encode$y = (params, encodedAttrs = {}) => {
25605
25552
  if (attributes["w:val"] === void 0) delete attributes["w:val"];
25606
25553
  return {
25607
25554
  type: "attr",
25608
- xmlName: XML_NODE_NAME$l,
25609
- sdNodeOrKeyName: SD_ATTR_KEY$9,
25555
+ xmlName: XML_NODE_NAME$o,
25556
+ sdNodeOrKeyName: SD_ATTR_KEY$a,
25610
25557
  attributes
25611
25558
  };
25612
25559
  };
25613
- const config$j = {
25614
- xmlName: XML_NODE_NAME$l,
25615
- sdNodeOrKeyName: SD_ATTR_KEY$9,
25560
+ const config$m = {
25561
+ xmlName: XML_NODE_NAME$o,
25562
+ sdNodeOrKeyName: SD_ATTR_KEY$a,
25616
25563
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25617
- encode: encode$y,
25564
+ encode: encode$B,
25618
25565
  attributes: validXmlAttributes$e
25619
25566
  };
25620
- const translator$Z = NodeTranslator.from(config$j);
25621
- const encode$x = (attributes) => attributes?.["w:val"];
25622
- const decode$t = (attrs) => attrs?.styleId;
25567
+ const translator$10 = NodeTranslator.from(config$m);
25568
+ const encode$A = (attributes) => attributes?.["w:val"];
25569
+ const decode$v = (attrs) => attrs?.styleId;
25623
25570
  const attrConfig$c = Object.freeze({
25624
25571
  xmlName: "w:val",
25625
25572
  sdName: "styleId",
25626
- encode: encode$x,
25627
- decode: decode$t
25573
+ encode: encode$A,
25574
+ decode: decode$v
25628
25575
  });
25629
25576
  const validXmlAttributes$d = [attrConfig$c];
25630
- const XML_NODE_NAME$k = "w:rStyle";
25631
- const SD_ATTR_KEY$8 = "styleId";
25632
- const encode$w = (params, encodedAttrs = {}) => {
25577
+ const XML_NODE_NAME$n = "w:rStyle";
25578
+ const SD_ATTR_KEY$9 = "styleId";
25579
+ const encode$z = (params, encodedAttrs = {}) => {
25633
25580
  const { nodes } = params;
25634
25581
  const node = nodes?.[0];
25635
25582
  const value = encodedAttrs.styleId ?? node?.attributes?.["w:val"];
25636
25583
  return {
25637
25584
  type: "attr",
25638
- xmlName: XML_NODE_NAME$k,
25639
- sdNodeOrKeyName: SD_ATTR_KEY$8,
25585
+ xmlName: XML_NODE_NAME$n,
25586
+ sdNodeOrKeyName: SD_ATTR_KEY$9,
25640
25587
  attributes: { "w:val": value ?? null }
25641
25588
  };
25642
25589
  };
25643
- const config$i = {
25644
- xmlName: XML_NODE_NAME$k,
25645
- sdNodeOrKeyName: SD_ATTR_KEY$8,
25590
+ const config$l = {
25591
+ xmlName: XML_NODE_NAME$n,
25592
+ sdNodeOrKeyName: SD_ATTR_KEY$9,
25646
25593
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25647
- encode: encode$w,
25594
+ encode: encode$z,
25648
25595
  attributes: validXmlAttributes$d
25649
25596
  };
25650
- const translator$Y = NodeTranslator.from(config$i);
25651
- const encode$v = (attributes) => attributes?.["w:val"];
25652
- const decode$s = (attrs) => attrs?.fontSize;
25597
+ const translator$$ = NodeTranslator.from(config$l);
25598
+ const encode$y = (attributes) => attributes?.["w:val"];
25599
+ const decode$u = (attrs) => attrs?.fontSize;
25653
25600
  const attrConfig$b = Object.freeze({
25654
25601
  xmlName: "w:val",
25655
25602
  sdName: "fontSize",
25656
- encode: encode$v,
25657
- decode: decode$s
25603
+ encode: encode$y,
25604
+ decode: decode$u
25658
25605
  });
25659
25606
  const validXmlAttributes$c = [attrConfig$b];
25660
- const XML_NODE_NAME$j = "w:sz";
25661
- const SD_ATTR_KEY$7 = "fontSize";
25662
- const encode$u = (params, encodedAttrs = {}) => {
25607
+ const XML_NODE_NAME$m = "w:sz";
25608
+ const SD_ATTR_KEY$8 = "fontSize";
25609
+ const encode$x = (params, encodedAttrs = {}) => {
25663
25610
  const { nodes } = params;
25664
25611
  const node = nodes?.[0];
25665
25612
  const value = encodedAttrs.fontSize ?? node?.attributes?.["w:val"];
25666
25613
  return {
25667
25614
  type: "attr",
25668
- xmlName: XML_NODE_NAME$j,
25669
- sdNodeOrKeyName: SD_ATTR_KEY$7,
25615
+ xmlName: XML_NODE_NAME$m,
25616
+ sdNodeOrKeyName: SD_ATTR_KEY$8,
25670
25617
  attributes: { "w:val": value ?? null }
25671
25618
  };
25672
25619
  };
25673
- const config$h = {
25674
- xmlName: XML_NODE_NAME$j,
25675
- sdNodeOrKeyName: SD_ATTR_KEY$7,
25620
+ const config$k = {
25621
+ xmlName: XML_NODE_NAME$m,
25622
+ sdNodeOrKeyName: SD_ATTR_KEY$8,
25676
25623
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25677
- encode: encode$u,
25624
+ encode: encode$x,
25678
25625
  attributes: validXmlAttributes$c
25679
25626
  };
25680
- const translator$X = NodeTranslator.from(config$h);
25681
- const encode$t = (attributes) => attributes?.["w:val"];
25682
- const decode$r = (attrs) => attrs?.fontSizeCs;
25627
+ const translator$_ = NodeTranslator.from(config$k);
25628
+ const encode$w = (attributes) => attributes?.["w:val"];
25629
+ const decode$t = (attrs) => attrs?.fontSizeCs;
25683
25630
  const attrConfig$a = Object.freeze({
25684
25631
  xmlName: "w:val",
25685
25632
  sdName: "fontSizeCs",
25686
- encode: encode$t,
25687
- decode: decode$r
25633
+ encode: encode$w,
25634
+ decode: decode$t
25688
25635
  });
25689
25636
  const validXmlAttributes$b = [attrConfig$a];
25690
- const XML_NODE_NAME$i = "w:szCs";
25691
- const SD_ATTR_KEY$6 = "fontSizeCs";
25692
- const encode$s = (params, encodedAttrs = {}) => {
25637
+ const XML_NODE_NAME$l = "w:szCs";
25638
+ const SD_ATTR_KEY$7 = "fontSizeCs";
25639
+ const encode$v = (params, encodedAttrs = {}) => {
25693
25640
  const { nodes } = params;
25694
25641
  const node = nodes?.[0];
25695
25642
  const value = encodedAttrs.fontSizeCs ?? node?.attributes?.["w:val"];
25696
25643
  return {
25697
25644
  type: "attr",
25698
- xmlName: XML_NODE_NAME$i,
25699
- sdNodeOrKeyName: SD_ATTR_KEY$6,
25645
+ xmlName: XML_NODE_NAME$l,
25646
+ sdNodeOrKeyName: SD_ATTR_KEY$7,
25700
25647
  attributes: { "w:val": value ?? null }
25701
25648
  };
25702
25649
  };
25703
- const config$g = {
25704
- xmlName: XML_NODE_NAME$i,
25705
- sdNodeOrKeyName: SD_ATTR_KEY$6,
25650
+ const config$j = {
25651
+ xmlName: XML_NODE_NAME$l,
25652
+ sdNodeOrKeyName: SD_ATTR_KEY$7,
25706
25653
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25707
- encode: encode$s,
25654
+ encode: encode$v,
25708
25655
  attributes: validXmlAttributes$b
25709
25656
  };
25710
- const translator$W = NodeTranslator.from(config$g);
25657
+ const translator$Z = NodeTranslator.from(config$j);
25658
+ const generateV2HandlerEntity = (handlerName, translator2) => ({
25659
+ handlerName,
25660
+ handler: (params) => {
25661
+ const { nodes } = params;
25662
+ if (nodes.length === 0 || nodes[0].name !== translator2.xmlName) {
25663
+ return { nodes: [], consumed: 0 };
25664
+ }
25665
+ const result = translator2.encode(params);
25666
+ if (!result) return { nodes: [], consumed: 0 };
25667
+ return {
25668
+ nodes: Array.isArray(result) ? result : [result],
25669
+ consumed: 1
25670
+ };
25671
+ }
25672
+ });
25673
+ function createSingleAttrPropertyHandler(xmlName, sdName = null, attrName = "w:val", transformEncode = null, transformDecode = null) {
25674
+ if (!sdName) sdName = xmlName.split(":")[1];
25675
+ if (!transformEncode) transformEncode = (v2) => v2;
25676
+ if (!transformDecode) transformDecode = (v2) => v2;
25677
+ return {
25678
+ xmlName,
25679
+ sdNodeOrKeyName: sdName,
25680
+ encode: ({ nodes }) => {
25681
+ return transformEncode(nodes[0].attributes[attrName]) ?? void 0;
25682
+ },
25683
+ decode: ({ node }) => {
25684
+ const value = node.attrs?.[sdName] != null ? transformDecode(node.attrs[sdName]) : void 0;
25685
+ return value != null ? { name: xmlName, attributes: { [attrName]: value } } : void 0;
25686
+ }
25687
+ };
25688
+ }
25689
+ function createMeasurementPropertyHandler(xmlName, sdName = null) {
25690
+ if (!sdName) sdName = xmlName.split(":")[1];
25691
+ return {
25692
+ xmlName,
25693
+ sdNodeOrKeyName: sdName,
25694
+ attributes: [
25695
+ createAttributeHandler("w:w", "value", parseInteger, integerToString),
25696
+ createAttributeHandler("w:type")
25697
+ ],
25698
+ encode: (_2, encodedAttrs) => {
25699
+ return encodedAttrs["value"] != null ? encodedAttrs : void 0;
25700
+ },
25701
+ decode: function({ node }) {
25702
+ const decodedAttrs = this.decodeAttributes({ node: { ...node, attrs: node.attrs[sdName] || {} } });
25703
+ return decodedAttrs["w:w"] != null ? { attributes: decodedAttrs } : void 0;
25704
+ }
25705
+ };
25706
+ }
25707
+ function createBorderPropertyHandler(xmlName, sdName = null) {
25708
+ if (!sdName) sdName = xmlName.split(":")[1];
25709
+ return {
25710
+ xmlName,
25711
+ sdNodeOrKeyName: sdName,
25712
+ attributes: [
25713
+ createAttributeHandler("w:val"),
25714
+ createAttributeHandler("w:color"),
25715
+ createAttributeHandler("w:themeColor"),
25716
+ createAttributeHandler("w:themeTint"),
25717
+ createAttributeHandler("w:themeShade"),
25718
+ createAttributeHandler("w:sz", "size", parseInteger, integerToString),
25719
+ createAttributeHandler("w:space", null, parseInteger, integerToString),
25720
+ createAttributeHandler("w:shadow", null, parseBoolean, booleanToString),
25721
+ createAttributeHandler("w:frame", null, parseBoolean, booleanToString)
25722
+ ],
25723
+ encode: (params, encodedAttrs) => {
25724
+ return Object.keys(encodedAttrs).length > 0 ? encodedAttrs : void 0;
25725
+ },
25726
+ decode: function({ node }, context) {
25727
+ const decodedAttrs = this.decodeAttributes({ node: { ...node, attrs: node.attrs[sdName] || {} } });
25728
+ return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
25729
+ }
25730
+ };
25731
+ }
25732
+ const createAttributeHandler = (xmlName, sdName = null, transformEncode = null, transformDecode = null) => {
25733
+ if (!transformEncode) transformEncode = (v2) => v2;
25734
+ if (!transformDecode) transformDecode = (v2) => v2;
25735
+ if (!sdName) sdName = xmlName.split(":")[1];
25736
+ return {
25737
+ xmlName,
25738
+ sdName,
25739
+ encode: (attributes) => transformEncode(attributes[xmlName]),
25740
+ decode: (attributes) => transformDecode(attributes[sdName])
25741
+ };
25742
+ };
25743
+ function encodeProperties(node, translatorsByXmlName, asArray = false) {
25744
+ if (!node?.elements || node.elements.length === 0) {
25745
+ return asArray ? [] : {};
25746
+ }
25747
+ const attributes = asArray ? [] : {};
25748
+ node.elements.forEach((el) => {
25749
+ const translator2 = translatorsByXmlName[el.name];
25750
+ if (translator2) {
25751
+ const encodedAttr = translator2.encode({ nodes: [el] });
25752
+ if (encodedAttr != null) {
25753
+ if (asArray) {
25754
+ attributes.push({ [translator2.sdNodeOrKeyName]: encodedAttr });
25755
+ } else {
25756
+ attributes[translator2.sdNodeOrKeyName] = encodedAttr;
25757
+ }
25758
+ }
25759
+ }
25760
+ });
25761
+ return attributes;
25762
+ }
25763
+ function decodeProperties(translatorsBySdName, properties) {
25764
+ if (!properties || typeof properties !== "object") {
25765
+ return [];
25766
+ }
25767
+ const elements = [];
25768
+ Object.keys(properties).forEach((key) => {
25769
+ const translator2 = translatorsBySdName[key];
25770
+ if (translator2) {
25771
+ const result = translator2.decode({ node: { attrs: { [key]: properties[key] } } });
25772
+ if (result != null) {
25773
+ result.name = translator2.xmlName;
25774
+ elements.push(result);
25775
+ }
25776
+ }
25777
+ });
25778
+ return elements;
25779
+ }
25780
+ const parseBoolean = (value) => value != null ? ["1", "true"].includes(value) : void 0;
25781
+ const booleanToString = (value) => value != null ? value ? "1" : "0" : void 0;
25782
+ const parseInteger = (value) => {
25783
+ if (value == null) return void 0;
25784
+ const intValue = parseInt(value, 10);
25785
+ return isNaN(intValue) ? void 0 : intValue;
25786
+ };
25787
+ const integerToString = (value) => {
25788
+ const intValue = parseInteger(value);
25789
+ return intValue != void 0 ? String(intValue) : void 0;
25790
+ };
25791
+ const XML_NODE_NAME$k = "w:caps";
25792
+ const SD_ATTR_KEY$6 = "textTransform";
25793
+ const encode$u = (params, encodedAttrs = {}) => {
25794
+ const { nodes } = params;
25795
+ const node = nodes[0];
25796
+ if (!node) return void 0;
25797
+ let result;
25798
+ if (!["false", "0"].includes(encodedAttrs.val)) {
25799
+ result = "uppercase";
25800
+ } else {
25801
+ return void 0;
25802
+ }
25803
+ return {
25804
+ type: "attr",
25805
+ xmlName: XML_NODE_NAME$k,
25806
+ sdNodeOrKeyName: SD_ATTR_KEY$6,
25807
+ attributes: { [SD_ATTR_KEY$6]: result }
25808
+ };
25809
+ };
25810
+ const config$i = {
25811
+ xmlName: XML_NODE_NAME$k,
25812
+ sdNodeOrKeyName: SD_ATTR_KEY$6,
25813
+ type: NodeTranslator.translatorTypes.ATTRIBUTE,
25814
+ encode: encode$u,
25815
+ attributes: [createAttributeHandler("w:val")]
25816
+ };
25817
+ const translator$Y = NodeTranslator.from(config$i);
25711
25818
  const runPropertyTranslators = Object.freeze({
25712
- "w:b": translator$12,
25713
- "w:i": translator$11,
25714
- "w:u": translator$10,
25715
- "w:strike": translator$$,
25716
- "w:color": translator$_,
25717
- "w:highlight": translator$15,
25718
- "w:rFonts": translator$Z,
25719
- "w:rStyle": translator$Y,
25720
- "w:sz": translator$X,
25721
- "w:szCs": translator$W
25819
+ "w:b": translator$15,
25820
+ "w:i": translator$14,
25821
+ "w:u": translator$13,
25822
+ "w:strike": translator$12,
25823
+ "w:color": translator$11,
25824
+ "w:highlight": translator$18,
25825
+ "w:rFonts": translator$10,
25826
+ "w:rStyle": translator$$,
25827
+ "w:sz": translator$_,
25828
+ "w:szCs": translator$Z,
25829
+ "w:caps": translator$Y
25722
25830
  });
25723
25831
  const rawRunPropertyXmlNames = Object.freeze(["w:lang", "w:shd"]);
25724
25832
  const RAW_CHILD_NAME_SET = new Set(rawRunPropertyXmlNames);
@@ -25732,9 +25840,9 @@ const toRunPropertyEntry = (candidate) => {
25732
25840
  attributes: { ...candidate.attributes || {} }
25733
25841
  };
25734
25842
  };
25735
- const XML_NODE_NAME$h = "w:rPr";
25843
+ const XML_NODE_NAME$j = "w:rPr";
25736
25844
  const SD_ATTR_KEY$5 = "runProperties";
25737
- const encode$r = (params) => {
25845
+ const encode$t = (params) => {
25738
25846
  const { nodes } = params;
25739
25847
  const node = nodes?.[0] || {};
25740
25848
  const contents = Array.isArray(node.elements) ? node.elements : [];
@@ -25768,16 +25876,16 @@ const encode$r = (params) => {
25768
25876
  attributes: runPropsArray
25769
25877
  };
25770
25878
  };
25771
- const config$f = {
25772
- xmlName: XML_NODE_NAME$h,
25879
+ const config$h = {
25880
+ xmlName: XML_NODE_NAME$j,
25773
25881
  sdNodeOrKeyName: SD_ATTR_KEY$5,
25774
25882
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25775
- encode: encode$r
25883
+ encode: encode$t
25776
25884
  };
25777
- const translator$V = NodeTranslator.from(config$f);
25885
+ const translator$X = NodeTranslator.from(config$h);
25778
25886
  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;
25779
25887
  const containsEastAsianCharacters = (text) => EAST_ASIAN_CHARACTER_REGEX.test(text);
25780
- const collectRunProperties = (params, rPrNode, translator2 = translator$V) => {
25888
+ const collectRunProperties = (params, rPrNode, translator2 = translator$X) => {
25781
25889
  if (!rPrNode) return { entries: [], hadRPr: false, styleChangeMarks: [] };
25782
25890
  const result = translator2.encode({ ...params, nodes: [rPrNode] }) || {};
25783
25891
  let entries = [];
@@ -25846,7 +25954,10 @@ const applyRunMarks = (node, inlineMarks, textStyleAttrs) => {
25846
25954
  };
25847
25955
  const deriveStyleMarks = ({ docx, paragraphStyleId, runStyleId }) => {
25848
25956
  const paragraphStyleMarks = collectStyleMarks(paragraphStyleId, docx);
25849
- const runStyleMarks = collectStyleMarks(runStyleId, docx);
25957
+ if (paragraphStyleId?.startsWith("TOC")) {
25958
+ return paragraphStyleMarks;
25959
+ }
25960
+ let runStyleMarks = collectStyleMarks(runStyleId, docx);
25850
25961
  const inlineMarks = mergeInlineMarkSets(paragraphStyleMarks.inlineMarks, runStyleMarks.inlineMarks);
25851
25962
  const textStyleAttrs = mergeTextStyleAttrs(paragraphStyleMarks.textStyleAttrs, runStyleMarks.textStyleAttrs);
25852
25963
  return { inlineMarks, textStyleAttrs };
@@ -26072,6 +26183,13 @@ const splitRunProperties = (entries = [], docx = null) => {
26072
26183
  }
26073
26184
  break;
26074
26185
  }
26186
+ case "w:caps": {
26187
+ if (attributes["textTransform"] != null) {
26188
+ hasTextStyle = true;
26189
+ textStyleAttrs.textTransform = attributes["textTransform"];
26190
+ }
26191
+ break;
26192
+ }
26075
26193
  case "w:rFonts": {
26076
26194
  const asciiFamily = attributes["w:ascii"] || attributes["w:hAnsi"] || (attributes["w:eastAsia"] ? void 0 : attributes["w:val"]);
26077
26195
  const eastAsiaFamily = attributes["w:eastAsia"];
@@ -26091,9 +26209,10 @@ const splitRunProperties = (entries = [], docx = null) => {
26091
26209
  case "w:sz":
26092
26210
  case "w:szCs": {
26093
26211
  const rawSize = Number(attributes["w:val"]);
26212
+ const attrName = entry.xmlName === "w:sz" ? "fontSize" : "fontSizeCs";
26094
26213
  if (Number.isFinite(rawSize) && rawSize > 0) {
26095
26214
  hasTextStyle = true;
26096
- textStyleAttrs.fontSize = `${rawSize / 2}pt`;
26215
+ textStyleAttrs[attrName] = `${rawSize / 2}pt`;
26097
26216
  }
26098
26217
  break;
26099
26218
  }
@@ -26239,46 +26358,166 @@ const ensureTrackedWrapper = (runs, trackingMarksByType = /* @__PURE__ */ new Ma
26239
26358
  }
26240
26359
  return runs;
26241
26360
  };
26242
- const encode$q = (attributes) => {
26361
+ const XML_NODE_NAME$i = "w:hyperlink";
26362
+ const SD_NODE_NAME$c = "link";
26363
+ const _createAttributeHandler = (xmlName, sdName) => ({
26364
+ xmlName,
26365
+ sdName,
26366
+ encode: (attributes) => attributes[xmlName],
26367
+ decode: (attributes) => attributes[sdName]
26368
+ });
26369
+ const validXmlAttributes$a = [
26370
+ _createAttributeHandler("w:anchor", "anchor"),
26371
+ _createAttributeHandler("w:docLocation", "docLocation"),
26372
+ {
26373
+ xmlName: "w:history",
26374
+ sdName: "history",
26375
+ encode: (attributes) => attributes["w:history"] === "1" || attributes["w:history"] === "true",
26376
+ decode: (attributes) => attributes["history"] ? "1" : "0"
26377
+ },
26378
+ _createAttributeHandler("w:tooltip", "tooltip"),
26379
+ _createAttributeHandler("r:id", "rId"),
26380
+ _createAttributeHandler("w:tgtFrame", "target")
26381
+ ];
26382
+ const encode$s = (params, encodedAttrs) => {
26383
+ const { nodes, docx, nodeListHandler } = params;
26384
+ const node = nodes[0];
26385
+ let href = _resolveHref(docx, encodedAttrs);
26386
+ const linkMark = { type: "link", attrs: { ...encodedAttrs, href } };
26387
+ const referenceNodeTypes = ["sd:pageReference", "sd:autoPageNumber", "sd:totalPageNumber"];
26388
+ const contentNodes = node.elements.filter((el) => el.name === "w:r" || referenceNodeTypes.includes(el.name));
26389
+ contentNodes.forEach((contentNode) => {
26390
+ const existingMarks = Array.isArray(contentNode.marks) ? contentNode.marks : [];
26391
+ const marksWithoutLink = existingMarks.filter((mark) => mark?.type !== "link");
26392
+ contentNode.marks = [...marksWithoutLink, linkMark];
26393
+ });
26394
+ const updatedNode = nodeListHandler.handler({
26395
+ ...params,
26396
+ nodes: contentNodes,
26397
+ path: [...params.path || [], node]
26398
+ });
26399
+ return updatedNode;
26400
+ };
26401
+ const _resolveHref = (docx, encodedAttrs) => {
26402
+ const rels = docx["word/_rels/document.xml.rels"];
26403
+ const relationships = rels.elements.find((el) => el.name === "Relationships");
26404
+ const { elements } = relationships;
26405
+ const { rId, anchor } = encodedAttrs;
26406
+ let href;
26407
+ if (!rId && anchor) {
26408
+ href = `#${anchor}`;
26409
+ } else if (rId) {
26410
+ const rel = elements.find((el) => el.attributes["Id"] === rId) || {};
26411
+ const { attributes: relAttributes = {} } = rel;
26412
+ href = relAttributes["Target"];
26413
+ }
26414
+ return href;
26415
+ };
26416
+ function decode$s(params) {
26417
+ const { hyperlinkGroup = [params.node] } = params.extraParams || {};
26418
+ const node = hyperlinkGroup[0];
26419
+ const linkMark = node.marks.find((m2) => m2.type === "link");
26420
+ const linkAttrs = this.decodeAttributes({ ...params, node: linkMark });
26421
+ let { anchor, href: link } = linkMark.attrs;
26422
+ const isExternalLink = !anchor;
26423
+ if (isExternalLink) {
26424
+ linkAttrs["r:id"] = _addNewLinkRelationship(params, link, linkAttrs["r:id"]);
26425
+ }
26426
+ let contentNodes = [];
26427
+ hyperlinkGroup.forEach((linkNode) => {
26428
+ if ("marks" in linkNode) {
26429
+ linkNode.marks = linkNode.marks.filter((m2) => m2.type !== "link");
26430
+ } else {
26431
+ linkNode.attrs.marksAsAttrs = linkNode.attrs.marksAsAttrs.filter((m2) => m2.type !== "link");
26432
+ }
26433
+ const outputNode = exportSchemaToJson({ ...params, node: linkNode });
26434
+ if (outputNode) {
26435
+ if (outputNode instanceof Array) contentNodes.push(...outputNode);
26436
+ else contentNodes.push(outputNode);
26437
+ }
26438
+ });
26439
+ const newNode = {
26440
+ name: "w:hyperlink",
26441
+ type: "element",
26442
+ attributes: {
26443
+ ...linkAttrs
26444
+ },
26445
+ elements: contentNodes
26446
+ };
26447
+ return newNode;
26448
+ }
26449
+ function _addNewLinkRelationship(params, link, rId) {
26450
+ if (!rId) rId = generateDocxRandomId();
26451
+ if (!params.relationships || !Array.isArray(params.relationships)) {
26452
+ params.relationships = [];
26453
+ }
26454
+ const existingRel = params.relationships.find(
26455
+ (rel) => rel.attributes && rel.attributes.Id === rId && rel.attributes.Target === link
26456
+ );
26457
+ if (existingRel) {
26458
+ return rId;
26459
+ }
26460
+ params.relationships.push({
26461
+ type: "element",
26462
+ name: "Relationship",
26463
+ attributes: {
26464
+ Id: rId,
26465
+ Type: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",
26466
+ Target: link,
26467
+ TargetMode: "External"
26468
+ }
26469
+ });
26470
+ return rId;
26471
+ }
26472
+ const config$g = {
26473
+ xmlName: XML_NODE_NAME$i,
26474
+ sdNodeOrKeyName: SD_NODE_NAME$c,
26475
+ type: NodeTranslator.translatorTypes.NODE,
26476
+ encode: encode$s,
26477
+ decode: decode$s,
26478
+ attributes: validXmlAttributes$a
26479
+ };
26480
+ const translator$W = NodeTranslator.from(config$g);
26481
+ const encode$r = (attributes) => {
26243
26482
  return attributes["w:rsidR"];
26244
26483
  };
26245
- const decode$q = (attrs) => {
26484
+ const decode$r = (attrs) => {
26246
26485
  return attrs.rsidR;
26247
26486
  };
26248
26487
  const attrConfig$9 = Object.freeze({
26249
26488
  xmlName: "w:rsidR",
26250
26489
  sdName: "rsidR",
26251
- encode: encode$q,
26252
- decode: decode$q
26490
+ encode: encode$r,
26491
+ decode: decode$r
26253
26492
  });
26254
- const encode$p = (attributes) => {
26493
+ const encode$q = (attributes) => {
26255
26494
  return attributes["w:rsidRPr"];
26256
26495
  };
26257
- const decode$p = (attrs) => {
26496
+ const decode$q = (attrs) => {
26258
26497
  return attrs.rsidRPr;
26259
26498
  };
26260
26499
  const attrConfig$8 = Object.freeze({
26261
26500
  xmlName: "w:rsidRPr",
26262
26501
  sdName: "rsidRPr",
26263
- encode: encode$p,
26264
- decode: decode$p
26502
+ encode: encode$q,
26503
+ decode: decode$q
26265
26504
  });
26266
- const encode$o = (attributes) => {
26505
+ const encode$p = (attributes) => {
26267
26506
  return attributes["w:rsidDel"];
26268
26507
  };
26269
- const decode$o = (attrs) => {
26508
+ const decode$p = (attrs) => {
26270
26509
  return attrs.rsidDel;
26271
26510
  };
26272
26511
  const attrConfig$7 = Object.freeze({
26273
26512
  xmlName: "w:rsidDel",
26274
26513
  sdName: "rsidDel",
26275
- encode: encode$o,
26276
- decode: decode$o
26514
+ encode: encode$p,
26515
+ decode: decode$p
26277
26516
  });
26278
- const validXmlAttributes$a = [attrConfig$9, attrConfig$8, attrConfig$7];
26279
- const XML_NODE_NAME$g = "w:r";
26517
+ const validXmlAttributes$9 = [attrConfig$9, attrConfig$8, attrConfig$7];
26518
+ const XML_NODE_NAME$h = "w:r";
26280
26519
  const SD_KEY_NAME = "run";
26281
- const encode$n = (params, encodedAttrs = {}) => {
26520
+ const encode$o = (params, encodedAttrs = {}) => {
26282
26521
  const { nodes = [], nodeListHandler } = params || {};
26283
26522
  const runNode = nodes[0];
26284
26523
  if (!runNode) return void 0;
@@ -26326,9 +26565,11 @@ const encode$n = (params, encodedAttrs = {}) => {
26326
26565
  }
26327
26566
  return runNodeResult;
26328
26567
  };
26329
- const decode$n = (params, decodedAttrs = {}) => {
26568
+ const decode$o = (params, decodedAttrs = {}) => {
26330
26569
  const { node } = params || {};
26331
26570
  if (!node) return void 0;
26571
+ const isLinkNode = node.marks?.some((m2) => m2.type === "link");
26572
+ if (isLinkNode) return translator$W.decode(params);
26332
26573
  const { runNode: runNodeForExport, trackingMarksByType } = prepareRunTrackingContext(node);
26333
26574
  const runAttrs = runNodeForExport.attrs || {};
26334
26575
  const runProperties = Array.isArray(runAttrs.runProperties) ? runAttrs.runProperties : [];
@@ -26383,7 +26624,7 @@ const decode$n = (params, decodedAttrs = {}) => {
26383
26624
  runs.push(trackedClone);
26384
26625
  return;
26385
26626
  }
26386
- const runWrapper = { name: XML_NODE_NAME$g, elements: [] };
26627
+ const runWrapper = { name: XML_NODE_NAME$h, elements: [] };
26387
26628
  applyBaseRunProps(runWrapper);
26388
26629
  if (!Array.isArray(runWrapper.elements)) runWrapper.elements = [];
26389
26630
  runWrapper.elements.push(cloneXmlNode(child));
@@ -26391,7 +26632,7 @@ const decode$n = (params, decodedAttrs = {}) => {
26391
26632
  });
26392
26633
  const trackedRuns = ensureTrackedWrapper(runs, trackingMarksByType);
26393
26634
  if (!trackedRuns.length) {
26394
- const emptyRun = { name: XML_NODE_NAME$g, elements: [] };
26635
+ const emptyRun = { name: XML_NODE_NAME$h, elements: [] };
26395
26636
  applyBaseRunProps(emptyRun);
26396
26637
  trackedRuns.push(emptyRun);
26397
26638
  }
@@ -26405,148 +26646,15 @@ const decode$n = (params, decodedAttrs = {}) => {
26405
26646
  }
26406
26647
  return trackedRuns;
26407
26648
  };
26408
- const config$e = {
26409
- xmlName: XML_NODE_NAME$g,
26649
+ const config$f = {
26650
+ xmlName: XML_NODE_NAME$h,
26410
26651
  sdNodeOrKeyName: SD_KEY_NAME,
26411
26652
  type: NodeTranslator.translatorTypes.NODE,
26412
- encode: encode$n,
26413
- decode: decode$n,
26414
- attributes: validXmlAttributes$a
26415
- };
26416
- const translator$U = NodeTranslator.from(config$e);
26417
- const generateV2HandlerEntity = (handlerName, translator2) => ({
26418
- handlerName,
26419
- handler: (params) => {
26420
- const { nodes } = params;
26421
- if (nodes.length === 0 || nodes[0].name !== translator2.xmlName) {
26422
- return { nodes: [], consumed: 0 };
26423
- }
26424
- const result = translator2.encode(params);
26425
- if (!result) return { nodes: [], consumed: 0 };
26426
- return {
26427
- nodes: Array.isArray(result) ? result : [result],
26428
- consumed: 1
26429
- };
26430
- }
26431
- });
26432
- function createSingleAttrPropertyHandler(xmlName, sdName = null, attrName = "w:val", transformEncode = null, transformDecode = null) {
26433
- if (!sdName) sdName = xmlName.split(":")[1];
26434
- if (!transformEncode) transformEncode = (v2) => v2;
26435
- if (!transformDecode) transformDecode = (v2) => v2;
26436
- return {
26437
- xmlName,
26438
- sdNodeOrKeyName: sdName,
26439
- encode: ({ nodes }) => {
26440
- return transformEncode(nodes[0].attributes[attrName]) ?? void 0;
26441
- },
26442
- decode: ({ node }) => {
26443
- const value = node.attrs?.[sdName] != null ? transformDecode(node.attrs[sdName]) : void 0;
26444
- return value != null ? { name: xmlName, attributes: { [attrName]: value } } : void 0;
26445
- }
26446
- };
26447
- }
26448
- function createMeasurementPropertyHandler(xmlName, sdName = null) {
26449
- if (!sdName) sdName = xmlName.split(":")[1];
26450
- return {
26451
- xmlName,
26452
- sdNodeOrKeyName: sdName,
26453
- attributes: [
26454
- createAttributeHandler("w:w", "value", parseInteger, integerToString),
26455
- createAttributeHandler("w:type")
26456
- ],
26457
- encode: (_2, encodedAttrs) => {
26458
- return encodedAttrs["value"] != null ? encodedAttrs : void 0;
26459
- },
26460
- decode: function({ node }) {
26461
- const decodedAttrs = this.decodeAttributes({ node: { ...node, attrs: node.attrs[sdName] || {} } });
26462
- return decodedAttrs["w:w"] != null ? { attributes: decodedAttrs } : void 0;
26463
- }
26464
- };
26465
- }
26466
- function createBorderPropertyHandler(xmlName, sdName = null) {
26467
- if (!sdName) sdName = xmlName.split(":")[1];
26468
- return {
26469
- xmlName,
26470
- sdNodeOrKeyName: sdName,
26471
- attributes: [
26472
- createAttributeHandler("w:val"),
26473
- createAttributeHandler("w:color"),
26474
- createAttributeHandler("w:themeColor"),
26475
- createAttributeHandler("w:themeTint"),
26476
- createAttributeHandler("w:themeShade"),
26477
- createAttributeHandler("w:sz", "size", parseInteger, integerToString),
26478
- createAttributeHandler("w:space", null, parseInteger, integerToString),
26479
- createAttributeHandler("w:shadow", null, parseBoolean, booleanToString),
26480
- createAttributeHandler("w:frame", null, parseBoolean, booleanToString)
26481
- ],
26482
- encode: (params, encodedAttrs) => {
26483
- return Object.keys(encodedAttrs).length > 0 ? encodedAttrs : void 0;
26484
- },
26485
- decode: function({ node }, context) {
26486
- const decodedAttrs = this.decodeAttributes({ node: { ...node, attrs: node.attrs[sdName] || {} } });
26487
- return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
26488
- }
26489
- };
26490
- }
26491
- const createAttributeHandler = (xmlName, sdName = null, transformEncode = null, transformDecode = null) => {
26492
- if (!transformEncode) transformEncode = (v2) => v2;
26493
- if (!transformDecode) transformDecode = (v2) => v2;
26494
- if (!sdName) sdName = xmlName.split(":")[1];
26495
- return {
26496
- xmlName,
26497
- sdName,
26498
- encode: (attributes) => transformEncode(attributes[xmlName]),
26499
- decode: (attributes) => transformDecode(attributes[sdName])
26500
- };
26501
- };
26502
- function encodeProperties(node, translatorsByXmlName, asArray = false) {
26503
- if (!node?.elements || node.elements.length === 0) {
26504
- return asArray ? [] : {};
26505
- }
26506
- const attributes = asArray ? [] : {};
26507
- node.elements.forEach((el) => {
26508
- const translator2 = translatorsByXmlName[el.name];
26509
- if (translator2) {
26510
- const encodedAttr = translator2.encode({ nodes: [el] });
26511
- if (encodedAttr != null) {
26512
- if (asArray) {
26513
- attributes.push({ [translator2.sdNodeOrKeyName]: encodedAttr });
26514
- } else {
26515
- attributes[translator2.sdNodeOrKeyName] = encodedAttr;
26516
- }
26517
- }
26518
- }
26519
- });
26520
- return attributes;
26521
- }
26522
- function decodeProperties(translatorsBySdName, properties) {
26523
- if (!properties || typeof properties !== "object") {
26524
- return [];
26525
- }
26526
- const elements = [];
26527
- Object.keys(properties).forEach((key) => {
26528
- const translator2 = translatorsBySdName[key];
26529
- if (translator2) {
26530
- const result = translator2.decode({ node: { attrs: { [key]: properties[key] } } });
26531
- if (result != null) {
26532
- result.name = translator2.xmlName;
26533
- elements.push(result);
26534
- }
26535
- }
26536
- });
26537
- return elements;
26538
- }
26539
- const parseBoolean = (value) => value != null ? ["1", "true"].includes(value) : void 0;
26540
- const booleanToString = (value) => value != null ? value ? "1" : "0" : void 0;
26541
- const parseInteger = (value) => {
26542
- if (value == null) return void 0;
26543
- const intValue = parseInt(value, 10);
26544
- return isNaN(intValue) ? void 0 : intValue;
26545
- };
26546
- const integerToString = (value) => {
26547
- const intValue = parseInteger(value);
26548
- return intValue != void 0 ? String(intValue) : void 0;
26653
+ encode: encode$o,
26654
+ decode: decode$o,
26655
+ attributes: validXmlAttributes$9
26549
26656
  };
26657
+ const translator$V = NodeTranslator.from(config$f);
26550
26658
  function preProcessVerticalMergeCells(table, { editorSchema }) {
26551
26659
  if (!table || !Array.isArray(table.content)) {
26552
26660
  return table;
@@ -26587,13 +26695,13 @@ function preProcessVerticalMergeCells(table, { editorSchema }) {
26587
26695
  }
26588
26696
  return table;
26589
26697
  }
26590
- const translator$T = NodeTranslator.from({
26698
+ const translator$U = NodeTranslator.from({
26591
26699
  xmlName: "w:cantSplit",
26592
26700
  sdNodeOrKeyName: "cantSplit",
26593
26701
  encode: ({ nodes }) => ["1", "true"].includes(nodes[0].attributes?.["w:val"] ?? "1"),
26594
26702
  decode: ({ node }) => node.attrs?.cantSplit ? { attributes: {} } : void 0
26595
26703
  });
26596
- const translator$S = NodeTranslator.from({
26704
+ const translator$T = NodeTranslator.from({
26597
26705
  xmlName: "w:cnfStyle",
26598
26706
  sdNodeOrKeyName: "cnfStyle",
26599
26707
  attributes: [
@@ -26619,8 +26727,8 @@ const translator$S = NodeTranslator.from({
26619
26727
  return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
26620
26728
  }
26621
26729
  });
26622
- const translator$R = NodeTranslator.from(createSingleAttrPropertyHandler("w:divId"));
26623
- const translator$Q = NodeTranslator.from(
26730
+ const translator$S = NodeTranslator.from(createSingleAttrPropertyHandler("w:divId"));
26731
+ const translator$R = NodeTranslator.from(
26624
26732
  createSingleAttrPropertyHandler(
26625
26733
  "w:gridAfter",
26626
26734
  null,
@@ -26629,7 +26737,7 @@ const translator$Q = NodeTranslator.from(
26629
26737
  (v2) => integerToString(v2)
26630
26738
  )
26631
26739
  );
26632
- const translator$P = NodeTranslator.from(
26740
+ const translator$Q = NodeTranslator.from(
26633
26741
  createSingleAttrPropertyHandler(
26634
26742
  "w:gridBefore",
26635
26743
  null,
@@ -26638,21 +26746,21 @@ const translator$P = NodeTranslator.from(
26638
26746
  (v2) => integerToString(v2)
26639
26747
  )
26640
26748
  );
26641
- const translator$O = NodeTranslator.from({
26749
+ const translator$P = NodeTranslator.from({
26642
26750
  xmlName: "w:hidden",
26643
26751
  sdNodeOrKeyName: "hidden",
26644
26752
  encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
26645
26753
  decode: ({ node }) => node.attrs.hidden ? { attributes: {} } : void 0
26646
26754
  });
26647
- const translator$N = NodeTranslator.from(createSingleAttrPropertyHandler("w:jc", "justification"));
26648
- const translator$M = NodeTranslator.from(createMeasurementPropertyHandler("w:tblCellSpacing", "tableCellSpacing"));
26649
- const translator$L = NodeTranslator.from({
26755
+ const translator$O = NodeTranslator.from(createSingleAttrPropertyHandler("w:jc", "justification"));
26756
+ const translator$N = NodeTranslator.from(createMeasurementPropertyHandler("w:tblCellSpacing", "tableCellSpacing"));
26757
+ const translator$M = NodeTranslator.from({
26650
26758
  xmlName: "w:tblHeader",
26651
26759
  sdNodeOrKeyName: "repeatHeader",
26652
26760
  encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
26653
26761
  decode: ({ node }) => node.attrs.repeatHeader ? { attributes: {} } : void 0
26654
26762
  });
26655
- const translator$K = NodeTranslator.from({
26763
+ const translator$L = NodeTranslator.from({
26656
26764
  xmlName: "w:trHeight",
26657
26765
  sdNodeOrKeyName: "rowHeight",
26658
26766
  encode: ({ nodes }) => {
@@ -26679,11 +26787,11 @@ const translator$K = NodeTranslator.from({
26679
26787
  return Object.keys(heightAttrs).length > 0 ? { attributes: heightAttrs } : void 0;
26680
26788
  }
26681
26789
  });
26682
- const translator$J = NodeTranslator.from(createMeasurementPropertyHandler("w:wAfter"));
26683
- const translator$I = NodeTranslator.from(createMeasurementPropertyHandler("w:wBefore"));
26684
- const XML_NODE_NAME$f = "w:trPr";
26790
+ const translator$K = NodeTranslator.from(createMeasurementPropertyHandler("w:wAfter"));
26791
+ const translator$J = NodeTranslator.from(createMeasurementPropertyHandler("w:wBefore"));
26792
+ const XML_NODE_NAME$g = "w:trPr";
26685
26793
  const SD_ATTR_KEY$4 = "tableRowProperties";
26686
- const encode$m = (params) => {
26794
+ const encode$n = (params) => {
26687
26795
  const { nodes } = params;
26688
26796
  const node = nodes[0];
26689
26797
  let attributes = {
@@ -26697,12 +26805,12 @@ const encode$m = (params) => {
26697
26805
  };
26698
26806
  return {
26699
26807
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
26700
- xmlName: XML_NODE_NAME$f,
26808
+ xmlName: XML_NODE_NAME$g,
26701
26809
  sdNodeOrKeyName: SD_ATTR_KEY$4,
26702
26810
  attributes
26703
26811
  };
26704
26812
  };
26705
- const decode$m = (params) => {
26813
+ const decode$n = (params) => {
26706
26814
  const { tableRowProperties = {} } = params.node.attrs || {};
26707
26815
  const elements = decodeProperties(propertyTranslatorsBySdName$2, tableRowProperties);
26708
26816
  const newNode = {
@@ -26714,6 +26822,7 @@ const decode$m = (params) => {
26714
26822
  return newNode;
26715
26823
  };
26716
26824
  const propertyTranslators$3 = [
26825
+ translator$U,
26717
26826
  translator$T,
26718
26827
  translator$S,
26719
26828
  translator$R,
@@ -26724,8 +26833,7 @@ const propertyTranslators$3 = [
26724
26833
  translator$M,
26725
26834
  translator$L,
26726
26835
  translator$K,
26727
- translator$J,
26728
- translator$I
26836
+ translator$J
26729
26837
  ];
26730
26838
  const propertyTranslatorsByXmlName$2 = {};
26731
26839
  propertyTranslators$3.forEach((translator2) => {
@@ -26735,25 +26843,25 @@ const propertyTranslatorsBySdName$2 = {};
26735
26843
  propertyTranslators$3.forEach((translator2) => {
26736
26844
  propertyTranslatorsBySdName$2[translator2.sdNodeOrKeyName] = translator2;
26737
26845
  });
26738
- const config$d = {
26739
- xmlName: XML_NODE_NAME$f,
26846
+ const config$e = {
26847
+ xmlName: XML_NODE_NAME$g,
26740
26848
  sdNodeOrKeyName: SD_ATTR_KEY$4,
26741
26849
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
26742
- encode: encode$m,
26743
- decode: decode$m
26850
+ encode: encode$n,
26851
+ decode: decode$n
26744
26852
  };
26745
- const translator$H = NodeTranslator.from(config$d);
26746
- const XML_NODE_NAME$e = "w:tr";
26747
- const SD_NODE_NAME$a = "tableRow";
26748
- const validXmlAttributes$9 = ["w:rsidDel", "w:rsidR", "w:rsidRPr", "w:rsidTr", "w14:paraId", "w14:textId"].map(
26853
+ const translator$I = NodeTranslator.from(config$e);
26854
+ const XML_NODE_NAME$f = "w:tr";
26855
+ const SD_NODE_NAME$b = "tableRow";
26856
+ const validXmlAttributes$8 = ["w:rsidDel", "w:rsidR", "w:rsidRPr", "w:rsidTr", "w14:paraId", "w14:textId"].map(
26749
26857
  (xmlName) => createAttributeHandler(xmlName)
26750
26858
  );
26751
- const encode$l = (params, encodedAttrs) => {
26859
+ const encode$m = (params, encodedAttrs) => {
26752
26860
  const { row } = params.extraParams;
26753
26861
  let tableRowProperties = {};
26754
26862
  const tPr = row.elements.find((el) => el.name === "w:trPr");
26755
26863
  if (tPr) {
26756
- ({ attributes: tableRowProperties } = translator$H.encode({
26864
+ ({ attributes: tableRowProperties } = translator$I.encode({
26757
26865
  ...params,
26758
26866
  nodes: [tPr]
26759
26867
  }));
@@ -26766,7 +26874,7 @@ const encode$l = (params, encodedAttrs) => {
26766
26874
  let currentColumnIndex = 0;
26767
26875
  const content = cellNodes?.map((n) => {
26768
26876
  let columnWidth = gridColumnWidths?.[currentColumnIndex] || null;
26769
- const result = translator$8.encode({
26877
+ const result = translator$9.encode({
26770
26878
  ...params,
26771
26879
  extraParams: {
26772
26880
  ...params.extraParams,
@@ -26788,7 +26896,7 @@ const encode$l = (params, encodedAttrs) => {
26788
26896
  };
26789
26897
  return newNode;
26790
26898
  };
26791
- const decode$l = (params, decodedAttrs) => {
26899
+ const decode$m = (params, decodedAttrs) => {
26792
26900
  const { node } = params;
26793
26901
  const elements = translateChildNodes(params);
26794
26902
  if (node.attrs?.tableRowProperties) {
@@ -26800,7 +26908,7 @@ const decode$l = (params, decodedAttrs) => {
26800
26908
  }
26801
26909
  }
26802
26910
  tableRowProperties["cantSplit"] = node.attrs["cantSplit"];
26803
- const trPr = translator$H.decode({
26911
+ const trPr = translator$I.decode({
26804
26912
  ...params,
26805
26913
  node: { ...node, attrs: { ...node.attrs, tableRowProperties } }
26806
26914
  });
@@ -26812,22 +26920,22 @@ const decode$l = (params, decodedAttrs) => {
26812
26920
  elements
26813
26921
  };
26814
26922
  };
26815
- const config$c = {
26816
- xmlName: XML_NODE_NAME$e,
26817
- sdNodeOrKeyName: SD_NODE_NAME$a,
26923
+ const config$d = {
26924
+ xmlName: XML_NODE_NAME$f,
26925
+ sdNodeOrKeyName: SD_NODE_NAME$b,
26818
26926
  type: NodeTranslator.translatorTypes.NODE,
26819
- encode: encode$l,
26820
- decode: decode$l,
26821
- attributes: validXmlAttributes$9
26927
+ encode: encode$m,
26928
+ decode: decode$m,
26929
+ attributes: validXmlAttributes$8
26822
26930
  };
26823
- const translator$G = NodeTranslator.from(config$c);
26824
- const translator$F = NodeTranslator.from({
26931
+ const translator$H = NodeTranslator.from(config$d);
26932
+ const translator$G = NodeTranslator.from({
26825
26933
  xmlName: "w:bidiVisual",
26826
26934
  sdNodeOrKeyName: "rightToLeft",
26827
26935
  encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
26828
26936
  decode: ({ node }) => node.attrs.rightToLeft ? { attributes: {} } : void 0
26829
26937
  });
26830
- const translator$E = NodeTranslator.from({
26938
+ const translator$F = NodeTranslator.from({
26831
26939
  xmlName: "w:shd",
26832
26940
  sdNodeOrKeyName: "shading",
26833
26941
  attributes: [
@@ -26849,11 +26957,11 @@ const translator$E = NodeTranslator.from({
26849
26957
  return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
26850
26958
  }
26851
26959
  });
26852
- const translator$D = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblCaption", "caption"));
26853
- const translator$C = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblDescription", "description"));
26854
- const translator$B = NodeTranslator.from(createMeasurementPropertyHandler("w:tblInd", "tableIndent"));
26855
- const translator$A = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblLayout", "tableLayout", "w:type"));
26856
- const translator$z = NodeTranslator.from({
26960
+ const translator$E = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblCaption", "caption"));
26961
+ const translator$D = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblDescription", "description"));
26962
+ const translator$C = NodeTranslator.from(createMeasurementPropertyHandler("w:tblInd", "tableIndent"));
26963
+ const translator$B = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblLayout", "tableLayout", "w:type"));
26964
+ const translator$A = NodeTranslator.from({
26857
26965
  xmlName: "w:tblLook",
26858
26966
  sdNodeOrKeyName: "tblLook",
26859
26967
  attributes: ["w:firstColumn", "w:firstRow", "w:lastColumn", "w:lastRow", "w:noHBand", "w:noVBand"].map((attr) => createAttributeHandler(attr, null, parseBoolean, booleanToString)).concat([createAttributeHandler("w:val")]),
@@ -26865,16 +26973,16 @@ const translator$z = NodeTranslator.from({
26865
26973
  return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
26866
26974
  }
26867
26975
  });
26868
- const translator$y = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblOverlap", "overlap"));
26869
- const translator$x = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblStyle", "tableStyleId"));
26870
- const translator$w = NodeTranslator.from(
26976
+ const translator$z = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblOverlap", "overlap"));
26977
+ const translator$y = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblStyle", "tableStyleId"));
26978
+ const translator$x = NodeTranslator.from(
26871
26979
  createSingleAttrPropertyHandler("w:tblStyleColBandSize", "tableStyleColBandSize")
26872
26980
  );
26873
- const translator$v = NodeTranslator.from(
26981
+ const translator$w = NodeTranslator.from(
26874
26982
  createSingleAttrPropertyHandler("w:tblStyleRowBandSize", "tableStyleRowBandSize")
26875
26983
  );
26876
- const translator$u = NodeTranslator.from(createMeasurementPropertyHandler("w:tblW", "tableWidth"));
26877
- const translator$t = NodeTranslator.from({
26984
+ const translator$v = NodeTranslator.from(createMeasurementPropertyHandler("w:tblW", "tableWidth"));
26985
+ const translator$u = NodeTranslator.from({
26878
26986
  xmlName: "w:tblpPr",
26879
26987
  sdNodeOrKeyName: "floatingTableProperties",
26880
26988
  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))),
@@ -26886,29 +26994,29 @@ const translator$t = NodeTranslator.from({
26886
26994
  return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
26887
26995
  }
26888
26996
  });
26889
- const translator$s = NodeTranslator.from(createBorderPropertyHandler("w:bottom"));
26890
- const translator$r = NodeTranslator.from(createMeasurementPropertyHandler("w:bottom", "marginBottom"));
26891
- const translator$q = NodeTranslator.from(createBorderPropertyHandler("w:end"));
26892
- const translator$p = NodeTranslator.from(createMeasurementPropertyHandler("w:end", "marginEnd"));
26893
- const translator$o = NodeTranslator.from(createBorderPropertyHandler("w:insideH"));
26894
- const translator$n = NodeTranslator.from(createBorderPropertyHandler("w:insideV"));
26895
- const translator$m = NodeTranslator.from(createBorderPropertyHandler("w:left"));
26896
- const translator$l = NodeTranslator.from(createMeasurementPropertyHandler("w:left", "marginLeft"));
26897
- const translator$k = NodeTranslator.from(createBorderPropertyHandler("w:right"));
26898
- const translator$j = NodeTranslator.from(createMeasurementPropertyHandler("w:right", "marginRight"));
26899
- const translator$i = NodeTranslator.from(createBorderPropertyHandler("w:start"));
26900
- const translator$h = NodeTranslator.from(createMeasurementPropertyHandler("w:start", "marginStart"));
26901
- const translator$g = NodeTranslator.from(createBorderPropertyHandler("w:top"));
26902
- const translator$f = NodeTranslator.from(createMeasurementPropertyHandler("w:top", "marginTop"));
26903
- const XML_NODE_NAME$d = "w:tblBorders";
26997
+ const translator$t = NodeTranslator.from(createBorderPropertyHandler("w:bottom"));
26998
+ const translator$s = NodeTranslator.from(createMeasurementPropertyHandler("w:bottom", "marginBottom"));
26999
+ const translator$r = NodeTranslator.from(createBorderPropertyHandler("w:end"));
27000
+ const translator$q = NodeTranslator.from(createMeasurementPropertyHandler("w:end", "marginEnd"));
27001
+ const translator$p = NodeTranslator.from(createBorderPropertyHandler("w:insideH"));
27002
+ const translator$o = NodeTranslator.from(createBorderPropertyHandler("w:insideV"));
27003
+ const translator$n = NodeTranslator.from(createBorderPropertyHandler("w:left"));
27004
+ const translator$m = NodeTranslator.from(createMeasurementPropertyHandler("w:left", "marginLeft"));
27005
+ const translator$l = NodeTranslator.from(createBorderPropertyHandler("w:right"));
27006
+ const translator$k = NodeTranslator.from(createMeasurementPropertyHandler("w:right", "marginRight"));
27007
+ const translator$j = NodeTranslator.from(createBorderPropertyHandler("w:start"));
27008
+ const translator$i = NodeTranslator.from(createMeasurementPropertyHandler("w:start", "marginStart"));
27009
+ const translator$h = NodeTranslator.from(createBorderPropertyHandler("w:top"));
27010
+ const translator$g = NodeTranslator.from(createMeasurementPropertyHandler("w:top", "marginTop"));
27011
+ const XML_NODE_NAME$e = "w:tblBorders";
26904
27012
  const SD_ATTR_KEY$3 = "borders";
26905
- const encode$k = (params) => {
27013
+ const encode$l = (params) => {
26906
27014
  const { nodes } = params;
26907
27015
  const node = nodes[0];
26908
27016
  const attributes = encodeProperties(node, tblBordersTranslatorsByXmlName);
26909
27017
  return Object.keys(attributes).length > 0 ? attributes : void 0;
26910
27018
  };
26911
- const decode$k = (params) => {
27019
+ const decode$l = (params) => {
26912
27020
  const { borders = {} } = params.node.attrs || {};
26913
27021
  const elements = decodeProperties(tblBordersTranslatorsBySdName, borders);
26914
27022
  const newNode = {
@@ -26920,14 +27028,14 @@ const decode$k = (params) => {
26920
27028
  return newNode;
26921
27029
  };
26922
27030
  const propertyTranslators$2 = [
26923
- translator$s,
26924
- translator$q,
27031
+ translator$t,
27032
+ translator$r,
27033
+ translator$p,
26925
27034
  translator$o,
26926
27035
  translator$n,
26927
- translator$m,
26928
- translator$k,
26929
- translator$i,
26930
- translator$g
27036
+ translator$l,
27037
+ translator$j,
27038
+ translator$h
26931
27039
  ];
26932
27040
  const tblBordersTranslatorsByXmlName = {};
26933
27041
  const tblBordersTranslatorsBySdName = {};
@@ -26935,27 +27043,27 @@ propertyTranslators$2.forEach((translator2) => {
26935
27043
  tblBordersTranslatorsByXmlName[translator2.xmlName] = translator2;
26936
27044
  tblBordersTranslatorsBySdName[translator2.sdNodeOrKeyName] = translator2;
26937
27045
  });
26938
- const translator$e = NodeTranslator.from({
26939
- xmlName: XML_NODE_NAME$d,
27046
+ const translator$f = NodeTranslator.from({
27047
+ xmlName: XML_NODE_NAME$e,
26940
27048
  sdNodeOrKeyName: SD_ATTR_KEY$3,
26941
27049
  type: NodeTranslator.translatorTypes.NODE,
26942
27050
  attributes: [],
26943
- encode: encode$k,
26944
- decode: decode$k
27051
+ encode: encode$l,
27052
+ decode: decode$l
26945
27053
  });
26946
- const XML_NODE_NAME$c = "w:tblCellMar";
27054
+ const XML_NODE_NAME$d = "w:tblCellMar";
26947
27055
  const SD_ATTR_KEY$2 = "cellMargins";
26948
- const encode$j = (params) => {
27056
+ const encode$k = (params) => {
26949
27057
  const { nodes } = params;
26950
27058
  const node = nodes[0];
26951
27059
  const attributes = encodeProperties(node, propertyTranslatorsByXmlName$1);
26952
27060
  return Object.keys(attributes).length > 0 ? attributes : void 0;
26953
27061
  };
26954
- const decode$j = (params) => {
27062
+ const decode$k = (params) => {
26955
27063
  const { cellMargins = {} } = params.node.attrs || {};
26956
27064
  const elements = decodeProperties(propertyTranslatorsBySdName$1, cellMargins);
26957
27065
  const newNode = {
26958
- name: XML_NODE_NAME$c,
27066
+ name: XML_NODE_NAME$d,
26959
27067
  type: "element",
26960
27068
  attributes: {},
26961
27069
  elements
@@ -26963,12 +27071,12 @@ const decode$j = (params) => {
26963
27071
  return newNode;
26964
27072
  };
26965
27073
  const propertyTranslators$1 = [
26966
- translator$r,
26967
- translator$p,
26968
- translator$l,
26969
- translator$j,
26970
- translator$h,
26971
- translator$f
27074
+ translator$s,
27075
+ translator$q,
27076
+ translator$m,
27077
+ translator$k,
27078
+ translator$i,
27079
+ translator$g
26972
27080
  ];
26973
27081
  const propertyTranslatorsByXmlName$1 = {};
26974
27082
  const propertyTranslatorsBySdName$1 = {};
@@ -26976,27 +27084,27 @@ propertyTranslators$1.forEach((translator2) => {
26976
27084
  propertyTranslatorsByXmlName$1[translator2.xmlName] = translator2;
26977
27085
  propertyTranslatorsBySdName$1[translator2.sdNodeOrKeyName] = translator2;
26978
27086
  });
26979
- const translator$d = NodeTranslator.from({
26980
- xmlName: XML_NODE_NAME$c,
27087
+ const translator$e = NodeTranslator.from({
27088
+ xmlName: XML_NODE_NAME$d,
26981
27089
  sdNodeOrKeyName: SD_ATTR_KEY$2,
26982
27090
  type: NodeTranslator.translatorTypes.NODE,
26983
27091
  attributes: [],
26984
- encode: encode$j,
26985
- decode: decode$j
27092
+ encode: encode$k,
27093
+ decode: decode$k
26986
27094
  });
26987
- const XML_NODE_NAME$b = "w:tblPr";
27095
+ const XML_NODE_NAME$c = "w:tblPr";
26988
27096
  const SD_ATTR_KEY$1 = "tableProperties";
26989
- const encode$i = (params) => {
27097
+ const encode$j = (params) => {
26990
27098
  const { nodes } = params;
26991
27099
  const node = nodes[0];
26992
27100
  const attributes = encodeProperties(node, propertyTranslatorsByXmlName);
26993
27101
  return {
26994
- xmlName: XML_NODE_NAME$b,
27102
+ xmlName: XML_NODE_NAME$c,
26995
27103
  sdNodeOrKeyName: SD_ATTR_KEY$1,
26996
27104
  attributes
26997
27105
  };
26998
27106
  };
26999
- const decode$i = (params) => {
27107
+ const decode$j = (params) => {
27000
27108
  const { tableProperties = {} } = params.node.attrs || {};
27001
27109
  const elements = decodeProperties(propertyTranslatorsBySdName, tableProperties);
27002
27110
  const newNode = {
@@ -27008,11 +27116,12 @@ const decode$i = (params) => {
27008
27116
  return newNode;
27009
27117
  };
27010
27118
  const propertyTranslators = [
27119
+ translator$G,
27120
+ translator$O,
27011
27121
  translator$F,
27012
- translator$N,
27013
27122
  translator$E,
27123
+ translator$N,
27014
27124
  translator$D,
27015
- translator$M,
27016
27125
  translator$C,
27017
27126
  translator$B,
27018
27127
  translator$A,
@@ -27022,24 +27131,23 @@ const propertyTranslators = [
27022
27131
  translator$w,
27023
27132
  translator$v,
27024
27133
  translator$u,
27025
- translator$t,
27026
- translator$e,
27027
- translator$d
27134
+ translator$f,
27135
+ translator$e
27028
27136
  ];
27029
27137
  const propertyTranslatorsByXmlName = {};
27030
27138
  const propertyTranslatorsBySdName = {};
27031
27139
  propertyTranslators.forEach((translator2) => {
27032
27140
  propertyTranslatorsByXmlName[translator2.xmlName] = translator2;
27033
27141
  propertyTranslatorsBySdName[translator2.sdNodeOrKeyName] = translator2;
27034
- });
27035
- const config$b = {
27036
- xmlName: XML_NODE_NAME$b,
27142
+ });
27143
+ const config$c = {
27144
+ xmlName: XML_NODE_NAME$c,
27037
27145
  sdNodeOrKeyName: SD_ATTR_KEY$1,
27038
- encode: encode$i,
27039
- decode: decode$i
27146
+ encode: encode$j,
27147
+ decode: decode$j
27040
27148
  };
27041
- const translator$c = NodeTranslator.from(config$b);
27042
- const translator$b = NodeTranslator.from(
27149
+ const translator$d = NodeTranslator.from(config$c);
27150
+ const translator$c = NodeTranslator.from(
27043
27151
  createSingleAttrPropertyHandler("w:gridCol", "col", "w:w", parseInteger, integerToString)
27044
27152
  );
27045
27153
  const DEFAULT_COLUMN_WIDTH_PX = 100;
@@ -27089,20 +27197,20 @@ const resolveFallbackColumnWidthTwips = (params, totalColumns, cellMinWidthTwips
27089
27197
  }
27090
27198
  return Math.max(fallbackWidthTwips, cellMinWidthTwips);
27091
27199
  };
27092
- const XML_NODE_NAME$a = "w:tblGrid";
27200
+ const XML_NODE_NAME$b = "w:tblGrid";
27093
27201
  const SD_ATTR_KEY = "grid";
27094
27202
  const cellMinWidth = pixelsToTwips(10);
27095
- const encode$h = (params) => {
27203
+ const encode$i = (params) => {
27096
27204
  const { nodes } = params;
27097
27205
  const node = nodes[0];
27098
- const attributes = encodeProperties(node, { [translator$b.xmlName]: translator$b }, true);
27206
+ const attributes = encodeProperties(node, { [translator$c.xmlName]: translator$c }, true);
27099
27207
  return {
27100
- xmlName: XML_NODE_NAME$a,
27208
+ xmlName: XML_NODE_NAME$b,
27101
27209
  sdNodeOrKeyName: SD_ATTR_KEY,
27102
27210
  attributes
27103
27211
  };
27104
27212
  };
27105
- const decode$h = (params) => {
27213
+ const decode$i = (params) => {
27106
27214
  const { grid: rawGrid } = params.node.attrs || {};
27107
27215
  const grid = Array.isArray(rawGrid) ? rawGrid : [];
27108
27216
  const { firstRow = {} } = params.extraParams || {};
@@ -27121,10 +27229,10 @@ const decode$h = (params) => {
27121
27229
  numericWidth = fallbackColumnWidthTwips;
27122
27230
  }
27123
27231
  numericWidth = Math.max(numericWidth, cellMinWidth);
27124
- const decoded = translator$b.decode({
27232
+ const decoded = translator$c.decode({
27125
27233
  node: { type: (
27126
27234
  /** @type {string} */
27127
- translator$b.sdNodeOrKeyName
27235
+ translator$c.sdNodeOrKeyName
27128
27236
  ), attrs: { col: numericWidth } }
27129
27237
  });
27130
27238
  if (decoded) elements.push(decoded);
@@ -27159,19 +27267,19 @@ const decode$h = (params) => {
27159
27267
  columnIndex++;
27160
27268
  }
27161
27269
  const newNode = {
27162
- name: XML_NODE_NAME$a,
27270
+ name: XML_NODE_NAME$b,
27163
27271
  attributes: {},
27164
27272
  elements
27165
27273
  };
27166
27274
  return newNode;
27167
27275
  };
27168
- const config$a = {
27169
- xmlName: XML_NODE_NAME$a,
27276
+ const config$b = {
27277
+ xmlName: XML_NODE_NAME$b,
27170
27278
  sdNodeOrKeyName: SD_ATTR_KEY,
27171
- encode: encode$h,
27172
- decode: decode$h
27279
+ encode: encode$i,
27280
+ decode: decode$i
27173
27281
  };
27174
- const translator$a = NodeTranslator.from(config$a);
27282
+ const translator$b = NodeTranslator.from(config$b);
27175
27283
  const DEFAULT_PAGE_WIDTH_TWIPS = 12240;
27176
27284
  const DEFAULT_PAGE_MARGIN_TWIPS = 1440;
27177
27285
  const DEFAULT_CONTENT_WIDTH_TWIPS = DEFAULT_PAGE_WIDTH_TWIPS - 2 * DEFAULT_PAGE_MARGIN_TWIPS;
@@ -27234,19 +27342,19 @@ const buildFallbackGridForTable = ({ params, rows, tableWidth, tableWidthMeasure
27234
27342
  columnWidths: Array(columnCount).fill(fallbackColumnWidthPx)
27235
27343
  };
27236
27344
  };
27237
- const XML_NODE_NAME$9 = "w:tbl";
27238
- const SD_NODE_NAME$9 = "table";
27239
- const encode$g = (params, encodedAttrs) => {
27345
+ const XML_NODE_NAME$a = "w:tbl";
27346
+ const SD_NODE_NAME$a = "table";
27347
+ const encode$h = (params, encodedAttrs) => {
27240
27348
  const { nodes } = params;
27241
27349
  const node = nodes[0];
27242
27350
  const tblPr = node.elements.find((el) => el.name === "w:tblPr");
27243
27351
  if (tblPr) {
27244
- const encodedProperties = translator$c.encode({ ...params, nodes: [tblPr] });
27352
+ const encodedProperties = translator$d.encode({ ...params, nodes: [tblPr] });
27245
27353
  encodedAttrs["tableProperties"] = encodedProperties?.attributes || {};
27246
27354
  }
27247
27355
  const tblGrid = node.elements.find((el) => el.name === "w:tblGrid");
27248
27356
  if (tblGrid) {
27249
- encodedAttrs["grid"] = translator$a.encode({ ...params, nodes: [tblGrid] }).attributes;
27357
+ encodedAttrs["grid"] = translator$b.encode({ ...params, nodes: [tblGrid] }).attributes;
27250
27358
  }
27251
27359
  [
27252
27360
  "tableStyleId",
@@ -27313,7 +27421,7 @@ const encode$g = (params, encodedAttrs) => {
27313
27421
  }
27314
27422
  const content = [];
27315
27423
  rows.forEach((row) => {
27316
- const result = translator$G.encode({
27424
+ const result = translator$H.encode({
27317
27425
  ...params,
27318
27426
  nodes: [row],
27319
27427
  extraParams: {
@@ -27332,13 +27440,13 @@ const encode$g = (params, encodedAttrs) => {
27332
27440
  attrs: encodedAttrs
27333
27441
  };
27334
27442
  };
27335
- const decode$g = (params, decodedAttrs) => {
27443
+ const decode$h = (params, decodedAttrs) => {
27336
27444
  params.node = preProcessVerticalMergeCells(params.node, params);
27337
27445
  const { node } = params;
27338
27446
  const elements = translateChildNodes(params);
27339
27447
  const firstRow = node.content?.find((n) => n.type === "tableRow");
27340
27448
  const properties = node.attrs.grid;
27341
- const element = translator$a.decode({
27449
+ const element = translator$b.decode({
27342
27450
  ...params,
27343
27451
  node: { ...node, attrs: { ...node.attrs, grid: properties } },
27344
27452
  extraParams: {
@@ -27348,7 +27456,7 @@ const decode$g = (params, decodedAttrs) => {
27348
27456
  if (element) elements.unshift(element);
27349
27457
  if (node.attrs?.tableProperties) {
27350
27458
  const properties2 = { ...node.attrs.tableProperties };
27351
- const element2 = translator$c.decode({
27459
+ const element2 = translator$d.decode({
27352
27460
  ...params,
27353
27461
  node: { ...node, attrs: { ...node.attrs, tableProperties: properties2 } }
27354
27462
  });
@@ -27414,7 +27522,7 @@ function _getReferencedTableStyles(tableStyleReference, params) {
27414
27522
  if (baseTblPr && baseTblPr.elements) {
27415
27523
  tblPr.elements.push(...baseTblPr.elements);
27416
27524
  }
27417
- const tableProperties = translator$c.encode({ ...params, nodes: [tblPr] }).attributes;
27525
+ const tableProperties = translator$d.encode({ ...params, nodes: [tblPr] }).attributes;
27418
27526
  const { borders, rowBorders } = _processTableBorders(tableProperties.borders || {});
27419
27527
  if (borders) stylesToReturn.borders = borders;
27420
27528
  if (rowBorders) stylesToReturn.rowBorders = rowBorders;
@@ -27431,16 +27539,16 @@ function _getReferencedTableStyles(tableStyleReference, params) {
27431
27539
  }
27432
27540
  return stylesToReturn;
27433
27541
  }
27434
- const config$9 = {
27435
- xmlName: XML_NODE_NAME$9,
27436
- sdNodeOrKeyName: SD_NODE_NAME$9,
27542
+ const config$a = {
27543
+ xmlName: XML_NODE_NAME$a,
27544
+ sdNodeOrKeyName: SD_NODE_NAME$a,
27437
27545
  type: NodeTranslator.translatorTypes.NODE,
27438
- encode: encode$g,
27439
- decode: decode$g,
27546
+ encode: encode$h,
27547
+ decode: decode$h,
27440
27548
  attributes: []
27441
27549
  };
27442
- const translator$9 = NodeTranslator.from(config$9);
27443
- const tableNodeHandlerEntity = generateV2HandlerEntity("tableNodeHandler", translator$9);
27550
+ const translator$a = NodeTranslator.from(config$a);
27551
+ const tableNodeHandlerEntity = generateV2HandlerEntity("tableNodeHandler", translator$a);
27444
27552
  function getReferencedTableStyles(tblStyleTag, docx) {
27445
27553
  if (!tblStyleTag) return null;
27446
27554
  const stylesToReturn = {};
@@ -27802,10 +27910,10 @@ function generateCellMargins(cellMargins) {
27802
27910
  if (left != null) elements.push({ name: "w:left", attributes: { "w:w": pixelsToTwips(left) } });
27803
27911
  return elements;
27804
27912
  }
27805
- const XML_NODE_NAME$8 = "w:tc";
27806
- const SD_NODE_NAME$8 = "tableCell";
27807
- const validXmlAttributes$8 = [];
27808
- function encode$f(params, encodedAttrs) {
27913
+ const XML_NODE_NAME$9 = "w:tc";
27914
+ const SD_NODE_NAME$9 = "tableCell";
27915
+ const validXmlAttributes$7 = [];
27916
+ function encode$g(params, encodedAttrs) {
27809
27917
  const {
27810
27918
  node,
27811
27919
  table,
@@ -27832,162 +27940,22 @@ function encode$f(params, encodedAttrs) {
27832
27940
  }
27833
27941
  return schemaNode;
27834
27942
  }
27835
- function decode$f(params, decodedAttrs) {
27943
+ function decode$g(params, decodedAttrs) {
27836
27944
  const translated = translateTableCell(params);
27837
27945
  if (decodedAttrs && Object.keys(decodedAttrs).length) {
27838
27946
  translated.attributes = { ...translated.attributes || {}, ...decodedAttrs };
27839
27947
  }
27840
27948
  return translated;
27841
27949
  }
27842
- const config$8 = {
27843
- xmlName: XML_NODE_NAME$8,
27844
- sdNodeOrKeyName: SD_NODE_NAME$8,
27845
- type: NodeTranslator.translatorTypes.NODE,
27846
- encode: encode$f,
27847
- decode: decode$f,
27848
- attributes: validXmlAttributes$8
27849
- };
27850
- const translator$8 = NodeTranslator.from(config$8);
27851
- const XML_NODE_NAME$7 = "w:hyperlink";
27852
- const SD_NODE_NAME$7 = "link";
27853
- const _createAttributeHandler = (xmlName, sdName) => ({
27854
- xmlName,
27855
- sdName,
27856
- encode: (attributes) => attributes[xmlName],
27857
- decode: (attributes) => attributes[sdName]
27858
- });
27859
- const validXmlAttributes$7 = [
27860
- _createAttributeHandler("w:anchor", "anchor"),
27861
- _createAttributeHandler("w:docLocation", "docLocation"),
27862
- {
27863
- xmlName: "w:history",
27864
- sdName: "history",
27865
- encode: (attributes) => attributes["w:history"] === "1" || attributes["w:history"] === "true",
27866
- decode: (attributes) => attributes["history"] ? "1" : "0"
27867
- },
27868
- _createAttributeHandler("w:tooltip", "tooltip"),
27869
- _createAttributeHandler("r:id", "rId"),
27870
- _createAttributeHandler("w:tgtFrame", "target")
27871
- ];
27872
- const encode$e = (params, encodedAttrs) => {
27873
- const { nodes, docx, nodeListHandler } = params;
27874
- const node = nodes[0];
27875
- let href = _resolveHref(docx, encodedAttrs);
27876
- const linkMark = { attrs: { ...encodedAttrs, href } };
27877
- const runNodes = node.elements.filter((el) => el.name === "w:r");
27878
- runNodes.forEach((runNode) => {
27879
- const existingRunMarks = Array.isArray(runNode.marks) ? runNode.marks : [];
27880
- const runMarksWithoutLink = existingRunMarks.filter((mark) => mark?.type !== "link");
27881
- runNode.marks = runMarksWithoutLink;
27882
- });
27883
- const updatedNode = nodeListHandler.handler({
27884
- ...params,
27885
- nodes: runNodes,
27886
- path: [...params.path || [], node]
27887
- });
27888
- const cloneMark2 = (mark) => {
27889
- if (!mark || typeof mark !== "object") return mark;
27890
- if (!mark.attrs) return { ...mark };
27891
- return { ...mark, attrs: { ...mark.attrs } };
27892
- };
27893
- const ensureLinkMark = (child) => {
27894
- if (!child || typeof child !== "object") return child;
27895
- if (Array.isArray(child.content)) {
27896
- const updatedContent = child.content.map((item) => ensureLinkMark(item));
27897
- if (updatedContent !== child.content) {
27898
- child = { ...child, content: updatedContent };
27899
- }
27900
- }
27901
- if (child.type === "run") {
27902
- const existingMarks2 = Array.isArray(child.marks) ? child.marks : [];
27903
- const filteredMarks = existingMarks2.filter((mark) => mark?.type !== "link").map((mark) => cloneMark2(mark));
27904
- if (filteredMarks.length !== existingMarks2.length) {
27905
- if (filteredMarks.length) child = { ...child, marks: filteredMarks };
27906
- else {
27907
- const { marks: _removedMarks, ...rest } = child;
27908
- child = rest;
27909
- }
27910
- }
27911
- return child;
27912
- }
27913
- if (child.type !== "text") return child;
27914
- const existingMarks = Array.isArray(child.marks) ? child.marks.map((mark) => cloneMark2(mark)) : [];
27915
- const hasLink = existingMarks.some((mark) => mark?.type === "link");
27916
- if (hasLink) return child;
27917
- const linkClone = { type: "link", attrs: { ...linkMark.attrs } };
27918
- return { ...child, marks: [...existingMarks, linkClone] };
27919
- };
27920
- if (!Array.isArray(updatedNode)) return updatedNode;
27921
- return updatedNode.map((child) => ensureLinkMark(child));
27922
- };
27923
- const _resolveHref = (docx, encodedAttrs) => {
27924
- const rels = docx["word/_rels/document.xml.rels"];
27925
- const relationships = rels.elements.find((el) => el.name === "Relationships");
27926
- const { elements } = relationships;
27927
- const { rId, anchor } = encodedAttrs;
27928
- let href;
27929
- if (!rId && anchor) {
27930
- href = `#${anchor}`;
27931
- } else if (rId) {
27932
- const rel = elements.find((el) => el.attributes["Id"] === rId) || {};
27933
- const { attributes: relAttributes = {} } = rel;
27934
- href = relAttributes["Target"];
27935
- }
27936
- return href;
27937
- };
27938
- function decode$e(params) {
27939
- const { node } = params;
27940
- const linkMark = node.marks.find((m2) => m2.type === "link");
27941
- const linkAttrs = this.decodeAttributes({ ...params, node: linkMark });
27942
- let { anchor, href: link } = linkMark.attrs;
27943
- const isExternalLink = !anchor;
27944
- if (isExternalLink) {
27945
- linkAttrs["r:id"] = _addNewLinkRelationship(params, link, linkAttrs["r:id"]);
27946
- }
27947
- node.marks = node.marks.filter((m2) => m2.type !== "link");
27948
- const outputNode = exportSchemaToJson({ ...params, node });
27949
- const newNode = {
27950
- name: "w:hyperlink",
27951
- type: "element",
27952
- attributes: {
27953
- ...linkAttrs
27954
- },
27955
- elements: [outputNode]
27956
- };
27957
- return newNode;
27958
- }
27959
- function _addNewLinkRelationship(params, link, rId) {
27960
- if (!rId) rId = generateDocxRandomId();
27961
- if (!params.relationships || !Array.isArray(params.relationships)) {
27962
- params.relationships = [];
27963
- }
27964
- const existingRel = params.relationships.find(
27965
- (rel) => rel.attributes && rel.attributes.Id === rId && rel.attributes.Target === link
27966
- );
27967
- if (existingRel) {
27968
- return rId;
27969
- }
27970
- params.relationships.push({
27971
- type: "element",
27972
- name: "Relationship",
27973
- attributes: {
27974
- Id: rId,
27975
- Type: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",
27976
- Target: link,
27977
- TargetMode: "External"
27978
- }
27979
- });
27980
- return rId;
27981
- }
27982
- const config$7 = {
27983
- xmlName: XML_NODE_NAME$7,
27984
- sdNodeOrKeyName: SD_NODE_NAME$7,
27950
+ const config$9 = {
27951
+ xmlName: XML_NODE_NAME$9,
27952
+ sdNodeOrKeyName: SD_NODE_NAME$9,
27985
27953
  type: NodeTranslator.translatorTypes.NODE,
27986
- encode: encode$e,
27987
- decode: decode$e,
27954
+ encode: encode$g,
27955
+ decode: decode$g,
27988
27956
  attributes: validXmlAttributes$7
27989
27957
  };
27990
- const translator$7 = NodeTranslator.from(config$7);
27958
+ const translator$9 = NodeTranslator.from(config$9);
27991
27959
  function parseTagValueJSON(json) {
27992
27960
  if (typeof json !== "string") {
27993
27961
  return {};
@@ -28123,12 +28091,32 @@ function handleDocPartObj(params) {
28123
28091
  }
28124
28092
  const content = node?.elements.find((el) => el.name === "w:sdtContent");
28125
28093
  const handler2 = validGalleryTypeMap[docPartGalleryType];
28126
- const result = handler2({ ...params, nodes: [content] });
28094
+ const result = handler2({
28095
+ ...params,
28096
+ nodes: [content],
28097
+ extraParams: { ...params.extraParams || {}, sdtPr }
28098
+ });
28127
28099
  return result;
28128
28100
  }
28129
28101
  const tableOfContentsHandler = (params) => {
28130
28102
  const node = params.nodes[0];
28131
- return params.nodeListHandler.handler({ ...params, nodes: node.elements });
28103
+ const translatedContent = params.nodeListHandler.handler({
28104
+ ...params,
28105
+ nodes: node.elements,
28106
+ path: [...params.path || [], node]
28107
+ });
28108
+ const sdtPr = params.extraParams.sdtPr;
28109
+ const id = sdtPr.elements?.find((el) => el.name === "w:id")?.attributes["w:val"] || "";
28110
+ const result = {
28111
+ type: "documentPartObject",
28112
+ content: translatedContent,
28113
+ attrs: {
28114
+ id,
28115
+ docPartGallery: "Table of Contents",
28116
+ docPartUnique: true
28117
+ }
28118
+ };
28119
+ return result;
28132
28120
  };
28133
28121
  const validGalleryTypeMap = {
28134
28122
  "Table of Contents": tableOfContentsHandler
@@ -28786,32 +28774,32 @@ function translateAnchorNode(params) {
28786
28774
  elements: [...anchorElements, ...elementsWithWrap]
28787
28775
  };
28788
28776
  }
28789
- const XML_NODE_NAME$6 = "wp:anchor";
28790
- const SD_NODE_NAME$6 = ["image"];
28777
+ const XML_NODE_NAME$8 = "wp:anchor";
28778
+ const SD_NODE_NAME$8 = ["image"];
28791
28779
  const validXmlAttributes$6 = ["distT", "distB", "distL", "distR"].map((xmlName) => createAttributeHandler(xmlName));
28792
- function encode$d(params) {
28780
+ function encode$f(params) {
28793
28781
  const { node } = params.extraParams;
28794
28782
  if (!node || !node.type) {
28795
28783
  return null;
28796
28784
  }
28797
28785
  return handleAnchorNode(params);
28798
28786
  }
28799
- function decode$d(params) {
28787
+ function decode$f(params) {
28800
28788
  const { node } = params;
28801
28789
  if (!node || !node.type) {
28802
28790
  return null;
28803
28791
  }
28804
28792
  return translateAnchorNode(params);
28805
28793
  }
28806
- const config$6 = {
28807
- xmlName: XML_NODE_NAME$6,
28808
- sdNodeOrKeyName: SD_NODE_NAME$6,
28794
+ const config$8 = {
28795
+ xmlName: XML_NODE_NAME$8,
28796
+ sdNodeOrKeyName: SD_NODE_NAME$8,
28809
28797
  type: NodeTranslator.translatorTypes.NODE,
28810
- encode: encode$d,
28811
- decode: decode$d,
28798
+ encode: encode$f,
28799
+ decode: decode$f,
28812
28800
  attributes: validXmlAttributes$6
28813
28801
  };
28814
- const translator$6 = NodeTranslator.from(config$6);
28802
+ const translator$8 = NodeTranslator.from(config$8);
28815
28803
  function handleInlineNode(params) {
28816
28804
  const { node } = params.extraParams;
28817
28805
  if (node.name !== "wp:inline") {
@@ -28827,41 +28815,41 @@ function translateInlineNode(params) {
28827
28815
  elements: nodeElements.elements
28828
28816
  };
28829
28817
  }
28830
- const XML_NODE_NAME$5 = "wp:inline";
28831
- const SD_NODE_NAME$5 = ["image"];
28818
+ const XML_NODE_NAME$7 = "wp:inline";
28819
+ const SD_NODE_NAME$7 = ["image"];
28832
28820
  const validXmlAttributes$5 = ["distT", "distB", "distL", "distR"].map((xmlName) => createAttributeHandler(xmlName));
28833
- function encode$c(params) {
28821
+ function encode$e(params) {
28834
28822
  const { node } = params.extraParams;
28835
28823
  if (!node || !node.type) {
28836
28824
  return null;
28837
28825
  }
28838
28826
  return handleInlineNode(params);
28839
28827
  }
28840
- function decode$c(params) {
28828
+ function decode$e(params) {
28841
28829
  const { node } = params;
28842
28830
  if (!node || !node.type) {
28843
28831
  return null;
28844
28832
  }
28845
28833
  return translateInlineNode(params);
28846
28834
  }
28847
- const config$5 = {
28848
- xmlName: XML_NODE_NAME$5,
28849
- sdNodeOrKeyName: SD_NODE_NAME$5,
28835
+ const config$7 = {
28836
+ xmlName: XML_NODE_NAME$7,
28837
+ sdNodeOrKeyName: SD_NODE_NAME$7,
28850
28838
  type: NodeTranslator.translatorTypes.NODE,
28851
- encode: encode$c,
28852
- decode: decode$c,
28839
+ encode: encode$e,
28840
+ decode: decode$e,
28853
28841
  attributes: validXmlAttributes$5
28854
28842
  };
28855
- const translator$5 = NodeTranslator.from(config$5);
28856
- const XML_NODE_NAME$4 = "w:drawing";
28857
- const SD_NODE_NAME$4 = [];
28843
+ const translator$7 = NodeTranslator.from(config$7);
28844
+ const XML_NODE_NAME$6 = "w:drawing";
28845
+ const SD_NODE_NAME$6 = [];
28858
28846
  const validXmlAttributes$4 = [];
28859
- function encode$b(params) {
28847
+ function encode$d(params) {
28860
28848
  const nodes = params.nodes;
28861
28849
  const node = nodes[0];
28862
28850
  const translatorByChildName = {
28863
- "wp:anchor": translator$6,
28864
- "wp:inline": translator$5
28851
+ "wp:anchor": translator$8,
28852
+ "wp:inline": translator$7
28865
28853
  };
28866
28854
  return node.elements.reduce((acc, child) => {
28867
28855
  if (acc) return acc;
@@ -28870,12 +28858,12 @@ function encode$b(params) {
28870
28858
  return translator2.encode({ ...params, extraParams: { node: child } }) || acc;
28871
28859
  }, null);
28872
28860
  }
28873
- function decode$b(params) {
28861
+ function decode$d(params) {
28874
28862
  const { node } = params;
28875
28863
  if (!node || !node.type) {
28876
28864
  return null;
28877
28865
  }
28878
- const childTranslator = node.attrs.isAnchor ? translator$6 : translator$5;
28866
+ const childTranslator = node.attrs.isAnchor ? translator$8 : translator$7;
28879
28867
  const resultNode = childTranslator.decode(params);
28880
28868
  return wrapTextInRun(
28881
28869
  {
@@ -28885,15 +28873,15 @@ function decode$b(params) {
28885
28873
  []
28886
28874
  );
28887
28875
  }
28888
- const config$4 = {
28889
- xmlName: XML_NODE_NAME$4,
28890
- sdNodeOrKeyName: SD_NODE_NAME$4,
28876
+ const config$6 = {
28877
+ xmlName: XML_NODE_NAME$6,
28878
+ sdNodeOrKeyName: SD_NODE_NAME$6,
28891
28879
  type: NodeTranslator.translatorTypes.NODE,
28892
- encode: encode$b,
28893
- decode: decode$b,
28880
+ encode: encode$d,
28881
+ decode: decode$d,
28894
28882
  attributes: validXmlAttributes$4
28895
28883
  };
28896
- const translator$4 = NodeTranslator.from(config$4);
28884
+ const translator$6 = NodeTranslator.from(config$6);
28897
28885
  class CommandService {
28898
28886
  /**
28899
28887
  * @param {import('./commands/types/index.js').CommandServiceOptions} props
@@ -30231,7 +30219,7 @@ function prepareTextAnnotation(params) {
30231
30219
  return getTextNodeForExport(attrs.displayLabel, [...marks, ...marksFromAttrs], params);
30232
30220
  }
30233
30221
  function prepareImageAnnotation(params, imageSize) {
30234
- return translator$4.decode({
30222
+ return translator$6.decode({
30235
30223
  ...params,
30236
30224
  imageSize
30237
30225
  });
@@ -30451,6 +30439,49 @@ const generateSdtPrTagForDocumentSection = (id, title, tag) => {
30451
30439
  ]
30452
30440
  };
30453
30441
  };
30442
+ function translateDocumentPartObj(params) {
30443
+ const { node } = params;
30444
+ const { attrs = {} } = node;
30445
+ const childContent = translateChildNodes({ ...params, nodes: node.content });
30446
+ const nodeElements = [
30447
+ {
30448
+ name: "w:sdtPr",
30449
+ elements: [
30450
+ {
30451
+ name: "w:id",
30452
+ attributes: {
30453
+ "w:val": attrs.id
30454
+ }
30455
+ },
30456
+ {
30457
+ name: "w:docPartObj",
30458
+ elements: [
30459
+ {
30460
+ name: "w:docPartGallery",
30461
+ attributes: {
30462
+ "w:val": attrs.docPartGallery
30463
+ }
30464
+ },
30465
+ ...attrs.docPartUnique ? [
30466
+ {
30467
+ name: "w:docPartUnique"
30468
+ }
30469
+ ] : []
30470
+ ]
30471
+ }
30472
+ ]
30473
+ },
30474
+ {
30475
+ name: "w:sdtContent",
30476
+ elements: childContent
30477
+ }
30478
+ ];
30479
+ const result = {
30480
+ name: "w:sdt",
30481
+ elements: nodeElements
30482
+ };
30483
+ return result;
30484
+ }
30454
30485
  function translateStructuredContent(params) {
30455
30486
  const { node } = params;
30456
30487
  const childContent = translateChildNodes({ ...params, nodes: node.content });
@@ -30502,10 +30533,10 @@ function generateSdtPrTagForStructuredContent({ node }) {
30502
30533
  };
30503
30534
  return result;
30504
30535
  }
30505
- const XML_NODE_NAME$3 = "w:sdt";
30506
- const SD_NODE_NAME$3 = ["fieldAnnotation", "structuredContent", "structuredContentBlock", "documentSection"];
30536
+ const XML_NODE_NAME$5 = "w:sdt";
30537
+ const SD_NODE_NAME$5 = ["fieldAnnotation", "structuredContent", "structuredContentBlock", "documentSection"];
30507
30538
  const validXmlAttributes$3 = [];
30508
- function encode$a(params) {
30539
+ function encode$c(params) {
30509
30540
  const nodes = params.nodes;
30510
30541
  const node = nodes[0];
30511
30542
  const { type: sdtType, handler: handler2 } = sdtNodeTypeStrategy(node);
@@ -30515,7 +30546,7 @@ function encode$a(params) {
30515
30546
  const result = handler2(params);
30516
30547
  return result;
30517
30548
  }
30518
- function decode$a(params) {
30549
+ function decode$c(params) {
30519
30550
  const { node } = params;
30520
30551
  if (!node || !node.type) {
30521
30552
  return null;
@@ -30525,91 +30556,93 @@ function decode$a(params) {
30525
30556
  structuredContent: () => translateStructuredContent(params),
30526
30557
  structuredContentBlock: () => translateStructuredContent(params),
30527
30558
  documentSection: () => translateDocumentSection(params),
30559
+ documentPartObject: () => translateDocumentPartObj(params),
30560
+ // Handled in doc-part-obj translator
30528
30561
  default: () => null
30529
30562
  };
30530
30563
  const decoder = types2[node.type] ?? types2.default;
30531
30564
  const result = decoder();
30532
30565
  return result;
30533
30566
  }
30534
- const config$3 = {
30535
- xmlName: XML_NODE_NAME$3,
30536
- sdNodeOrKeyName: SD_NODE_NAME$3,
30567
+ const config$5 = {
30568
+ xmlName: XML_NODE_NAME$5,
30569
+ sdNodeOrKeyName: SD_NODE_NAME$5,
30537
30570
  type: NodeTranslator.translatorTypes.NODE,
30538
- encode: encode$a,
30539
- decode: decode$a,
30571
+ encode: encode$c,
30572
+ decode: decode$c,
30540
30573
  attributes: validXmlAttributes$3
30541
30574
  };
30542
- const translator$3 = NodeTranslator.from(config$3);
30543
- const encode$9 = (attributes) => {
30575
+ const translator$5 = NodeTranslator.from(config$5);
30576
+ const encode$b = (attributes) => {
30544
30577
  return attributes["w:id"];
30545
30578
  };
30546
- const decode$9 = (attrs) => {
30579
+ const decode$b = (attrs) => {
30547
30580
  return attrs.id;
30548
30581
  };
30549
30582
  const attrConfig$6 = Object.freeze({
30550
30583
  xmlName: "w:id",
30551
30584
  sdName: "id",
30552
- encode: encode$9,
30553
- decode: decode$9
30585
+ encode: encode$b,
30586
+ decode: decode$b
30554
30587
  });
30555
- const encode$8 = (attributes) => {
30588
+ const encode$a = (attributes) => {
30556
30589
  return attributes["w:name"];
30557
30590
  };
30558
- const decode$8 = (attrs) => {
30591
+ const decode$a = (attrs) => {
30559
30592
  return attrs.name;
30560
30593
  };
30561
30594
  const attrConfig$5 = Object.freeze({
30562
30595
  xmlName: "w:name",
30563
30596
  sdName: "name",
30564
- encode: encode$8,
30565
- decode: decode$8
30597
+ encode: encode$a,
30598
+ decode: decode$a
30566
30599
  });
30567
- const encode$7 = (attributes) => {
30600
+ const encode$9 = (attributes) => {
30568
30601
  return attributes["w:colFirst"];
30569
30602
  };
30570
- const decode$7 = (attrs) => {
30603
+ const decode$9 = (attrs) => {
30571
30604
  return attrs.colFirst;
30572
30605
  };
30573
30606
  const attrConfig$4 = Object.freeze({
30574
30607
  xmlName: "w:colFirst",
30575
30608
  sdName: "colFirst",
30576
- encode: encode$7,
30577
- decode: decode$7
30609
+ encode: encode$9,
30610
+ decode: decode$9
30578
30611
  });
30579
- const encode$6 = (attributes) => {
30612
+ const encode$8 = (attributes) => {
30580
30613
  return attributes["w:colLast"];
30581
30614
  };
30582
- const decode$6 = (attrs) => {
30615
+ const decode$8 = (attrs) => {
30583
30616
  return attrs.colLast;
30584
30617
  };
30585
30618
  const attrConfig$3 = Object.freeze({
30586
30619
  xmlName: "w:colLast",
30587
30620
  sdName: "colLast",
30588
- encode: encode$6,
30589
- decode: decode$6
30621
+ encode: encode$8,
30622
+ decode: decode$8
30590
30623
  });
30591
- const encode$5 = (attributes) => {
30624
+ const encode$7 = (attributes) => {
30592
30625
  return attributes["w:displacedByCustomXml"];
30593
30626
  };
30594
- const decode$5 = (attrs) => {
30627
+ const decode$7 = (attrs) => {
30595
30628
  return attrs.displacedByCustomXml;
30596
30629
  };
30597
30630
  const attrConfig$2 = Object.freeze({
30598
30631
  xmlName: "w:displacedByCustomXml",
30599
30632
  sdName: "displacedByCustomXml",
30600
- encode: encode$5,
30601
- decode: decode$5
30633
+ encode: encode$7,
30634
+ decode: decode$7
30602
30635
  });
30603
30636
  const validXmlAttributes$2 = [attrConfig$6, attrConfig$5, attrConfig$4, attrConfig$3, attrConfig$2];
30604
- const XML_NODE_NAME$2 = "w:bookmarkStart";
30605
- const SD_NODE_NAME$2 = "bookmarkStart";
30606
- const encode$4 = (params, encodedAttrs = {}) => {
30637
+ const XML_NODE_NAME$4 = "w:bookmarkStart";
30638
+ const SD_NODE_NAME$4 = "bookmarkStart";
30639
+ const encode$6 = (params, encodedAttrs = {}) => {
30607
30640
  return {
30608
30641
  type: "bookmarkStart",
30609
30642
  attrs: encodedAttrs
30610
30643
  };
30611
30644
  };
30612
- const decode$4 = (params, decodedAttrs = {}) => {
30645
+ const decode$6 = (params, decodedAttrs = {}) => {
30613
30646
  const result = {
30614
30647
  name: "w:bookmarkStart",
30615
30648
  elements: []
@@ -30619,49 +30652,49 @@ const decode$4 = (params, decodedAttrs = {}) => {
30619
30652
  }
30620
30653
  return result;
30621
30654
  };
30622
- const config$2 = {
30623
- xmlName: XML_NODE_NAME$2,
30624
- sdNodeOrKeyName: SD_NODE_NAME$2,
30655
+ const config$4 = {
30656
+ xmlName: XML_NODE_NAME$4,
30657
+ sdNodeOrKeyName: SD_NODE_NAME$4,
30625
30658
  type: NodeTranslator.translatorTypes.NODE,
30626
- encode: encode$4,
30627
- decode: decode$4,
30659
+ encode: encode$6,
30660
+ decode: decode$6,
30628
30661
  attributes: validXmlAttributes$2
30629
30662
  };
30630
- const translator$2 = NodeTranslator.from(config$2);
30631
- const encode$3 = (attributes) => {
30663
+ const translator$4 = NodeTranslator.from(config$4);
30664
+ const encode$5 = (attributes) => {
30632
30665
  return attributes["w:id"];
30633
30666
  };
30634
- const decode$3 = (attrs) => {
30667
+ const decode$5 = (attrs) => {
30635
30668
  return attrs.id;
30636
30669
  };
30637
30670
  const attrConfig$1 = Object.freeze({
30638
30671
  xmlName: "w:id",
30639
30672
  sdName: "id",
30640
- encode: encode$3,
30641
- decode: decode$3
30673
+ encode: encode$5,
30674
+ decode: decode$5
30642
30675
  });
30643
- const encode$2 = (attributes) => {
30676
+ const encode$4 = (attributes) => {
30644
30677
  return attributes["w:displacedByCustomXml"];
30645
30678
  };
30646
- const decode$2 = (attrs) => {
30679
+ const decode$4 = (attrs) => {
30647
30680
  return attrs.displacedByCustomXml;
30648
30681
  };
30649
30682
  const attrConfig = Object.freeze({
30650
30683
  xmlName: "w:displacedByCustomXml",
30651
30684
  sdName: "displacedByCustomXml",
30652
- encode: encode$2,
30653
- decode: decode$2
30685
+ encode: encode$4,
30686
+ decode: decode$4
30654
30687
  });
30655
30688
  const validXmlAttributes$1 = [attrConfig$1, attrConfig];
30656
- const XML_NODE_NAME$1 = "w:bookmarkEnd";
30657
- const SD_NODE_NAME$1 = "bookmarkEnd";
30658
- const encode$1 = (params, encodedAttrs = {}) => {
30689
+ const XML_NODE_NAME$3 = "w:bookmarkEnd";
30690
+ const SD_NODE_NAME$3 = "bookmarkEnd";
30691
+ const encode$3 = (params, encodedAttrs = {}) => {
30659
30692
  return {
30660
30693
  type: "bookmarkEnd",
30661
30694
  attrs: encodedAttrs
30662
30695
  };
30663
30696
  };
30664
- const decode$1 = (params, decodedAttrs = {}) => {
30697
+ const decode$3 = (params, decodedAttrs = {}) => {
30665
30698
  const result = {
30666
30699
  name: "w:bookmarkEnd",
30667
30700
  elements: []
@@ -30671,19 +30704,19 @@ const decode$1 = (params, decodedAttrs = {}) => {
30671
30704
  }
30672
30705
  return result;
30673
30706
  };
30674
- const config$1 = {
30675
- xmlName: XML_NODE_NAME$1,
30676
- sdNodeOrKeyName: SD_NODE_NAME$1,
30707
+ const config$3 = {
30708
+ xmlName: XML_NODE_NAME$3,
30709
+ sdNodeOrKeyName: SD_NODE_NAME$3,
30677
30710
  type: NodeTranslator.translatorTypes.NODE,
30678
- encode: encode$1,
30679
- decode: decode$1,
30711
+ encode: encode$3,
30712
+ decode: decode$3,
30680
30713
  attributes: validXmlAttributes$1
30681
30714
  };
30682
- const translator$1 = NodeTranslator.from(config$1);
30683
- const XML_NODE_NAME = "mc:AlternateContent";
30684
- const SD_NODE_NAME = [];
30715
+ const translator$3 = NodeTranslator.from(config$3);
30716
+ const XML_NODE_NAME$2 = "mc:AlternateContent";
30717
+ const SD_NODE_NAME$2 = [];
30685
30718
  const validXmlAttributes = [];
30686
- function encode(params) {
30719
+ function encode$2(params) {
30687
30720
  const { nodeListHandler } = params;
30688
30721
  const { node } = params.extraParams;
30689
30722
  if (!node || !node.type) {
@@ -30703,7 +30736,7 @@ function encode(params) {
30703
30736
  path: [...params.path || [], wpsNode]
30704
30737
  });
30705
30738
  }
30706
- function decode(params) {
30739
+ function decode$2(params) {
30707
30740
  const { node } = params;
30708
30741
  const { drawingContent } = node.attrs;
30709
30742
  const drawing = {
@@ -30720,13 +30753,186 @@ function decode(params) {
30720
30753
  elements: [choice]
30721
30754
  };
30722
30755
  }
30756
+ const config$2 = {
30757
+ xmlName: XML_NODE_NAME$2,
30758
+ sdNodeOrKeyName: SD_NODE_NAME$2,
30759
+ type: NodeTranslator.translatorTypes.NODE,
30760
+ encode: encode$2,
30761
+ decode: decode$2,
30762
+ attributes: validXmlAttributes
30763
+ };
30764
+ const translator$2 = NodeTranslator.from(config$2);
30765
+ const XML_NODE_NAME$1 = "sd:pageReference";
30766
+ const SD_NODE_NAME$1 = "pageReference";
30767
+ const encode$1 = (params, _2) => {
30768
+ const { nodes = [], nodeListHandler } = params || {};
30769
+ const node = nodes[0];
30770
+ const processedText = nodeListHandler.handler({
30771
+ ...params,
30772
+ nodes: node.elements
30773
+ });
30774
+ const processedNode = {
30775
+ type: "pageReference",
30776
+ attrs: {
30777
+ instruction: node.attributes?.instruction || "",
30778
+ marksAsAttrs: node.marks || []
30779
+ },
30780
+ content: processedText
30781
+ };
30782
+ return processedNode;
30783
+ };
30784
+ const decode$1 = (params, _2) => {
30785
+ const { node } = params;
30786
+ const outputMarks = processOutputMarks(node.attrs?.marksAsAttrs || []);
30787
+ const contentNodes = (node.content ?? []).flatMap((n) => exportSchemaToJson({ ...params, node: n }));
30788
+ const translated = [
30789
+ {
30790
+ name: "w:r",
30791
+ elements: [
30792
+ {
30793
+ name: "w:rPr",
30794
+ elements: outputMarks
30795
+ },
30796
+ {
30797
+ name: "w:fldChar",
30798
+ attributes: {
30799
+ "w:fldCharType": "begin"
30800
+ }
30801
+ }
30802
+ ]
30803
+ },
30804
+ {
30805
+ name: "w:r",
30806
+ elements: [
30807
+ {
30808
+ name: "w:rPr",
30809
+ elements: outputMarks
30810
+ },
30811
+ {
30812
+ name: "w:instrText",
30813
+ attributes: { "xml:space": "preserve" },
30814
+ elements: [
30815
+ {
30816
+ type: "text",
30817
+ text: `${node.attrs.instruction}`
30818
+ }
30819
+ ]
30820
+ }
30821
+ ]
30822
+ },
30823
+ {
30824
+ name: "w:r",
30825
+ elements: [
30826
+ {
30827
+ name: "w:rPr",
30828
+ elements: outputMarks
30829
+ },
30830
+ {
30831
+ name: "w:fldChar",
30832
+ attributes: {
30833
+ "w:fldCharType": "separate"
30834
+ }
30835
+ }
30836
+ ]
30837
+ },
30838
+ ...contentNodes,
30839
+ {
30840
+ name: "w:r",
30841
+ elements: [
30842
+ {
30843
+ name: "w:rPr",
30844
+ elements: outputMarks
30845
+ },
30846
+ {
30847
+ name: "w:fldChar",
30848
+ attributes: {
30849
+ "w:fldCharType": "end"
30850
+ }
30851
+ }
30852
+ ]
30853
+ }
30854
+ ];
30855
+ return translated;
30856
+ };
30857
+ const config$1 = {
30858
+ xmlName: XML_NODE_NAME$1,
30859
+ sdNodeOrKeyName: SD_NODE_NAME$1,
30860
+ type: NodeTranslator.translatorTypes.NODE,
30861
+ encode: encode$1,
30862
+ decode: decode$1
30863
+ };
30864
+ const translator$1 = NodeTranslator.from(config$1);
30865
+ const XML_NODE_NAME = "sd:tableOfContents";
30866
+ const SD_NODE_NAME = "tableOfContents";
30867
+ const encode = (params, _2) => {
30868
+ const { nodes = [], nodeListHandler } = params || {};
30869
+ const node = nodes[0];
30870
+ const processedContent = nodeListHandler.handler({
30871
+ ...params,
30872
+ nodes: node.elements || []
30873
+ });
30874
+ const processedNode = {
30875
+ type: "tableOfContents",
30876
+ attrs: {
30877
+ instruction: node.attributes?.instruction || ""
30878
+ },
30879
+ content: processedContent
30880
+ };
30881
+ return processedNode;
30882
+ };
30883
+ const decode = (params, _2) => {
30884
+ const { node } = params;
30885
+ const contentNodes = node.content.map((n) => exportSchemaToJson({ ...params, node: n }));
30886
+ const tocBeginElements = [
30887
+ {
30888
+ name: "w:r",
30889
+ elements: [{ name: "w:fldChar", attributes: { "w:fldCharType": "begin" }, elements: [] }]
30890
+ },
30891
+ {
30892
+ name: "w:r",
30893
+ elements: [
30894
+ {
30895
+ name: "w:instrText",
30896
+ attributes: { "xml:space": "preserve" },
30897
+ elements: [{ text: node.attrs?.instruction || "", type: "text", name: "#text", elements: [] }]
30898
+ }
30899
+ ]
30900
+ },
30901
+ { name: "w:r", elements: [{ name: "w:fldChar", attributes: { "w:fldCharType": "separate" }, elements: [] }] }
30902
+ ];
30903
+ if (contentNodes.length > 0) {
30904
+ const firstParagraph = contentNodes[0];
30905
+ let insertIndex = 0;
30906
+ if (firstParagraph.elements) {
30907
+ const pPrIndex = firstParagraph.elements.findIndex((el) => el.name === "w:pPr");
30908
+ insertIndex = pPrIndex >= 0 ? pPrIndex + 1 : 0;
30909
+ } else {
30910
+ firstParagraph.elements = [];
30911
+ }
30912
+ firstParagraph.elements.splice(insertIndex, 0, ...tocBeginElements);
30913
+ } else {
30914
+ contentNodes.push({
30915
+ name: "w:p",
30916
+ elements: tocBeginElements
30917
+ });
30918
+ }
30919
+ const tocEndElements = [
30920
+ { name: "w:r", elements: [{ name: "w:fldChar", attributes: { "w:fldCharType": "end" }, elements: [] }] }
30921
+ ];
30922
+ const lastParagraph = contentNodes[contentNodes.length - 1];
30923
+ if (lastParagraph.elements) {
30924
+ lastParagraph.elements.push(...tocEndElements);
30925
+ } else {
30926
+ lastParagraph.elements = [...tocEndElements];
30927
+ }
30928
+ return contentNodes;
30929
+ };
30723
30930
  const config = {
30724
30931
  xmlName: XML_NODE_NAME,
30725
30932
  sdNodeOrKeyName: SD_NODE_NAME,
30726
30933
  type: NodeTranslator.translatorTypes.NODE,
30727
30934
  encode,
30728
- decode,
30729
- attributes: validXmlAttributes
30935
+ decode
30730
30936
  };
30731
30937
  const translator = NodeTranslator.from(config);
30732
30938
  const DEFAULT_SECTION_PROPS_TWIPS = Object.freeze({
@@ -30800,32 +31006,35 @@ function exportSchemaToJson(params) {
30800
31006
  doc: translateDocumentNode,
30801
31007
  body: translateBodyNode,
30802
31008
  heading: translateHeadingNode,
30803
- paragraph: translator$13,
30804
- run: translator$U,
31009
+ paragraph: translator$16,
31010
+ run: translator$V,
30805
31011
  text: translateTextNode,
30806
31012
  bulletList: translateList,
30807
31013
  orderedList: translateList,
30808
- lineBreak: translator$16,
30809
- table: translator$9,
30810
- tableRow: translator$G,
30811
- tableCell: translator$8,
30812
- bookmarkStart: translator$2,
30813
- bookmarkEnd: translator$1,
30814
- fieldAnnotation: translator$3,
30815
- tab: translator$14,
30816
- image: translator$4,
30817
- hardBreak: translator$16,
31014
+ lineBreak: translator$19,
31015
+ table: translator$a,
31016
+ tableRow: translator$H,
31017
+ tableCell: translator$9,
31018
+ bookmarkStart: translator$4,
31019
+ bookmarkEnd: translator$3,
31020
+ fieldAnnotation: translator$5,
31021
+ tab: translator$17,
31022
+ image: translator$6,
31023
+ hardBreak: translator$19,
30818
31024
  commentRangeStart: () => translateCommentNode(params, "Start"),
30819
31025
  commentRangeEnd: () => translateCommentNode(params, "End"),
30820
31026
  commentReference: () => null,
30821
31027
  shapeContainer: translateShapeContainer,
30822
31028
  shapeTextbox: translateShapeTextbox,
30823
31029
  contentBlock: translateContentBlock,
30824
- structuredContent: translator$3,
30825
- structuredContentBlock: translator$3,
30826
- documentSection: translator$3,
31030
+ structuredContent: translator$5,
31031
+ structuredContentBlock: translator$5,
31032
+ documentPartObject: translator$5,
31033
+ documentSection: translator$5,
30827
31034
  "page-number": translatePageNumberNode,
30828
- "total-page-number": translateTotalPageNumberNode
31035
+ "total-page-number": translateTotalPageNumberNode,
31036
+ pageReference: translator$1,
31037
+ tableOfContents: translator
30829
31038
  };
30830
31039
  let handler2 = router[type2];
30831
31040
  if (handler2 && "decode" in handler2 && typeof handler2.decode === "function") {
@@ -31163,8 +31372,6 @@ function translateTextNode(params) {
31163
31372
  const trackedMarks = [TrackInsertMarkName, TrackDeleteMarkName];
31164
31373
  const isTrackedNode = node.marks?.some((m2) => trackedMarks.includes(m2.type));
31165
31374
  if (isTrackedNode) return translateTrackedNode(params);
31166
- const isLinkNode = node.marks?.some((m2) => m2.type === "link");
31167
- if (isLinkNode) return translator$7.decode(params);
31168
31375
  const { text, marks = [] } = node;
31169
31376
  return getTextNodeForExport(text, marks, params);
31170
31377
  }
@@ -31470,7 +31677,7 @@ function translateMark(mark) {
31470
31677
  markElement.type = "element";
31471
31678
  break;
31472
31679
  case "underline": {
31473
- const translated = translator$10.decode({
31680
+ const translated = translator$13.decode({
31474
31681
  node: {
31475
31682
  attrs: {
31476
31683
  underlineType: attrs.underlineType ?? attrs.underline ?? null,
@@ -31534,7 +31741,7 @@ function translateMark(mark) {
31534
31741
  break;
31535
31742
  case "highlight": {
31536
31743
  const highlightValue = attrs.color ?? attrs.highlight ?? null;
31537
- const translated = translator$15.decode({ node: { attrs: { highlight: highlightValue } } });
31744
+ const translated = translator$18.decode({ node: { attrs: { highlight: highlightValue } } });
31538
31745
  return translated || {};
31539
31746
  }
31540
31747
  }
@@ -31594,7 +31801,7 @@ function translateContentBlock(params) {
31594
31801
  if (vmlAttributes || horizontalRule) {
31595
31802
  return translateVRectContentBlock(params);
31596
31803
  }
31597
- const alternateContent = translator.decode(params);
31804
+ const alternateContent = translator$2.decode(params);
31598
31805
  return wrapTextInRun(alternateContent);
31599
31806
  }
31600
31807
  function translateVRectContentBlock(params) {
@@ -31740,6 +31947,7 @@ const getAutoPageJson = (type2, outputMarks = []) => {
31740
31947
  },
31741
31948
  {
31742
31949
  name: "w:instrText",
31950
+ attributes: { "xml:space": "preserve" },
31743
31951
  elements: [
31744
31952
  {
31745
31953
  type: "text",
@@ -31799,7 +32007,7 @@ const handleDrawingNode = (params) => {
31799
32007
  if (mainNode.name === "w:drawing") node = mainNode;
31800
32008
  else node = mainNode.elements.find((el) => el.name === "w:drawing");
31801
32009
  if (!node) return { nodes: [], consumed: 0 };
31802
- const schemaNode = translator$4.encode(params);
32010
+ const schemaNode = translator$6.encode(params);
31803
32011
  const newNodes = schemaNode ? [schemaNode] : [];
31804
32012
  return { nodes: newNodes, consumed: 1 };
31805
32013
  };
@@ -31901,8 +32109,8 @@ const trackChangeNodeHandlerEntity = {
31901
32109
  handlerName: "trackChangeNodeHandler",
31902
32110
  handler: handleTrackChangeNode
31903
32111
  };
31904
- const hyperlinkNodeHandlerEntity = generateV2HandlerEntity("hyperlinkNodeHandler", translator$7);
31905
- const runNodeHandlerEntity = generateV2HandlerEntity("runNodeHandler", translator$U);
32112
+ const hyperlinkNodeHandlerEntity = generateV2HandlerEntity("hyperlinkNodeHandler", translator$W);
32113
+ const runNodeHandlerEntity = generateV2HandlerEntity("runNodeHandler", translator$V);
31906
32114
  const handleTextNode = (params) => {
31907
32115
  const { nodes, insideTrackChange } = params;
31908
32116
  if (nodes.length === 0 || !(nodes[0].name === "w:t" || insideTrackChange && nodes[0].name === "w:delText")) {
@@ -31943,7 +32151,7 @@ const handleParagraphNode = (params) => {
31943
32151
  if (nodes.length === 0 || nodes[0].name !== "w:p") {
31944
32152
  return { nodes: [], consumed: 0 };
31945
32153
  }
31946
- const schemaNode = translator$13.encode(params);
32154
+ const schemaNode = translator$16.encode(params);
31947
32155
  const newNodes = schemaNode ? [schemaNode] : [];
31948
32156
  return { nodes: newNodes, consumed: 1 };
31949
32157
  };
@@ -31956,7 +32164,7 @@ const handleSdtNode = (params) => {
31956
32164
  if (nodes.length === 0 || nodes[0].name !== "w:sdt") {
31957
32165
  return { nodes: [], consumed: 0 };
31958
32166
  }
31959
- const result = translator$3.encode(params);
32167
+ const result = translator$5.encode(params);
31960
32168
  if (!result) {
31961
32169
  return { nodes: [], consumed: 0 };
31962
32170
  }
@@ -32046,7 +32254,7 @@ const handler = (params) => {
32046
32254
  if (nodes.length === 0 || nodes[0].name !== "w:br") {
32047
32255
  return { nodes: [], consumed: 0 };
32048
32256
  }
32049
- const result = translator$16.encode(params);
32257
+ const result = translator$19.encode(params);
32050
32258
  if (!result) return { nodes: [], consumed: 0 };
32051
32259
  return {
32052
32260
  nodes: [result],
@@ -32118,7 +32326,7 @@ const handleBookmarkStartNode = (params) => {
32118
32326
  if (isCustomMarkBookmark(nodes[0], params.editor)) {
32119
32327
  return handleBookmarkNode(params);
32120
32328
  }
32121
- const node = translator$2.encode(params);
32329
+ const node = translator$4.encode(params);
32122
32330
  if (!node) return { nodes: [], consumed: 0 };
32123
32331
  return { nodes: [node], consumed: 1 };
32124
32332
  };
@@ -32150,7 +32358,7 @@ const handleBookmarkEndNode = (params) => {
32150
32358
  if (!nodes.length || nodes[0].name !== "w:bookmarkEnd") {
32151
32359
  return { nodes: [], consumed: 0 };
32152
32360
  }
32153
- const node = translator$1.encode(params);
32361
+ const node = translator$3.encode(params);
32154
32362
  if (!node) return { nodes: [], consumed: 0 };
32155
32363
  return { nodes: [node], consumed: 1 };
32156
32364
  };
@@ -32283,6 +32491,7 @@ const autoTotalPageCountEntity = {
32283
32491
  handlerName: "autoTotalPageCountEntity",
32284
32492
  handler: handleAutoTotalPageNumber
32285
32493
  };
32494
+ const pageReferenceEntity = generateV2HandlerEntity("pageReferenceNodeHandler", translator$1);
32286
32495
  const handlePictNode = (params) => {
32287
32496
  const { nodes } = params;
32288
32497
  if (!nodes.length || nodes[0].name !== "w:p") {
@@ -32781,6 +32990,7 @@ const getDefaultStyleDefinition = (defaultStyleId, docx) => {
32781
32990
  const spacing = pPr?.elements?.find((el) => el.name === "w:spacing");
32782
32991
  const justify = pPr?.elements?.find((el) => el.name === "w:jc");
32783
32992
  const indent = pPr?.elements?.find((el) => el.name === "w:ind");
32993
+ const tabs = pPr?.elements?.find((el) => el.name === "w:tabs");
32784
32994
  let lineSpaceBefore, lineSpaceAfter, line;
32785
32995
  if (spacing) {
32786
32996
  lineSpaceBefore = twipsToPixels(spacing?.attributes["w:before"]);
@@ -32794,6 +33004,22 @@ const getDefaultStyleDefinition = (defaultStyleId, docx) => {
32794
33004
  rightIndent = twipsToPixels(indent?.attributes["w:right"]);
32795
33005
  firstLine = twipsToPixels(indent?.attributes["w:firstLine"]);
32796
33006
  }
33007
+ let tabStops = [];
33008
+ if (tabs) {
33009
+ tabStops = (tabs.elements || []).filter((el) => el.name === "w:tab").map((tab) => {
33010
+ let val = tab.attributes["w:val"];
33011
+ if (val == "left") {
33012
+ val = "start";
33013
+ } else if (val == "right") {
33014
+ val = "end";
33015
+ }
33016
+ return {
33017
+ val,
33018
+ pos: twipsToPixels(tab.attributes["w:pos"]),
33019
+ leader: tab.attributes["w:leader"]
33020
+ };
33021
+ });
33022
+ }
32797
33023
  const keepNext = pPr?.elements?.find((el) => el.name === "w:keepNext");
32798
33024
  const keepLines = pPr?.elements?.find((el) => el.name === "w:keepLines");
32799
33025
  const outlineLevel = pPr?.elements?.find((el) => el.name === "w:outlineLvl");
@@ -32826,7 +33052,8 @@ const getDefaultStyleDefinition = (defaultStyleId, docx) => {
32826
33052
  const parsedStyles = {
32827
33053
  spacing: { lineSpaceAfter, lineSpaceBefore, line },
32828
33054
  textAlign,
32829
- indent: { leftIndent, rightIndent, firstLine }
33055
+ indent: { leftIndent, rightIndent, firstLine },
33056
+ tabStops: tabStops.length > 0 ? tabStops : null
32830
33057
  };
32831
33058
  parsedMarks.forEach((mark) => {
32832
33059
  const { type: type2, attrs } = mark;
@@ -32850,13 +33077,213 @@ const handleTabNode = (params) => {
32850
33077
  if (!nodes.length || nodes[0].name !== "w:tab") {
32851
33078
  return { nodes: [], consumed: 0 };
32852
33079
  }
32853
- const node = translator$14.encode(params);
33080
+ const node = translator$17.encode(params);
32854
33081
  return { nodes: [node], consumed: 1 };
32855
33082
  };
32856
33083
  const tabNodeEntityHandler = {
32857
33084
  handlerName: "w:tabTranslator",
32858
33085
  handler: handleTabNode
32859
33086
  };
33087
+ const tableOfContentsHandlerEntity = generateV2HandlerEntity("tableOfContentsHandler", translator);
33088
+ function preProcessPageInstruction(nodesToCombine, _2, __) {
33089
+ const pageNumNode = {
33090
+ name: "sd:autoPageNumber",
33091
+ type: "element"
33092
+ };
33093
+ nodesToCombine.forEach((n) => {
33094
+ const rPrNode = n.elements.find((el) => el.name === "w:rPr");
33095
+ if (rPrNode) pageNumNode.elements = [rPrNode];
33096
+ });
33097
+ return [pageNumNode];
33098
+ }
33099
+ function preProcessNumPagesInstruction(nodesToCombine, _2, __) {
33100
+ const totalPageNumNode = {
33101
+ name: "sd:totalPageNumber",
33102
+ type: "element"
33103
+ };
33104
+ nodesToCombine.forEach((n) => {
33105
+ const rPrNode = n.elements?.find((el) => el.name === "w:rPr");
33106
+ if (rPrNode) totalPageNumNode.elements = [rPrNode];
33107
+ });
33108
+ return [totalPageNumNode];
33109
+ }
33110
+ function preProcessPageRefInstruction(nodesToCombine, instrText, _2) {
33111
+ const pageRefNode = {
33112
+ name: "sd:pageReference",
33113
+ type: "element",
33114
+ attributes: {
33115
+ instruction: instrText
33116
+ },
33117
+ elements: nodesToCombine
33118
+ };
33119
+ return [pageRefNode];
33120
+ }
33121
+ function preProcessHyperlinkInstruction(nodesToCombine, instruction, docx) {
33122
+ const urlMatch = instruction.match(/HYPERLINK\s+"([^"]+)"/);
33123
+ let linkAttributes;
33124
+ if (urlMatch && urlMatch.length >= 2) {
33125
+ const url = urlMatch[1];
33126
+ const rels = docx["word/_rels/document.xml.rels"];
33127
+ const relationships = rels?.elements.find((el) => el.name === "Relationships");
33128
+ if (relationships) {
33129
+ const rId = generateDocxRandomId();
33130
+ relationships.elements.push({
33131
+ type: "element",
33132
+ name: "Relationship",
33133
+ attributes: {
33134
+ Id: rId,
33135
+ Type: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",
33136
+ Target: url,
33137
+ TargetMode: "External"
33138
+ }
33139
+ });
33140
+ linkAttributes = { "r:id": rId };
33141
+ } else {
33142
+ linkAttributes = { "w:anchor": url };
33143
+ }
33144
+ } else {
33145
+ const availableSwitches = {
33146
+ "w:anchor": `l "(?<value>[^"]+)"`,
33147
+ new_window: `
33148
+ `,
33149
+ "w:tgtFrame": ` "(?<value>[^"]+)"`,
33150
+ "w:tooltip": `o "(?<value>[^"]+)"`
33151
+ };
33152
+ const parsedSwitches = {};
33153
+ for (const [key, regex] of Object.entries(availableSwitches)) {
33154
+ const match = instruction.match(new RegExp(regex));
33155
+ if (match) {
33156
+ parsedSwitches[key] = match.groups?.value || true;
33157
+ }
33158
+ }
33159
+ if (parsedSwitches.new_window) {
33160
+ parsedSwitches["w:tgtFrame"] = "_blank";
33161
+ delete parsedSwitches.new_window;
33162
+ }
33163
+ linkAttributes = { ...parsedSwitches };
33164
+ }
33165
+ return [
33166
+ {
33167
+ name: "w:hyperlink",
33168
+ type: "element",
33169
+ attributes: linkAttributes,
33170
+ elements: nodesToCombine
33171
+ }
33172
+ ];
33173
+ }
33174
+ function preProcessTocInstruction(nodesToCombine, instrText) {
33175
+ return [
33176
+ {
33177
+ name: "sd:tableOfContents",
33178
+ type: "element",
33179
+ attributes: {
33180
+ instruction: instrText
33181
+ },
33182
+ elements: nodesToCombine
33183
+ }
33184
+ ];
33185
+ }
33186
+ const getInstructionPreProcessor = (instruction) => {
33187
+ const instructionType = instruction.split(" ")[0];
33188
+ switch (instructionType) {
33189
+ case "PAGE":
33190
+ return preProcessPageInstruction;
33191
+ case "NUMPAGES":
33192
+ return preProcessNumPagesInstruction;
33193
+ case "PAGEREF":
33194
+ return preProcessPageRefInstruction;
33195
+ case "HYPERLINK":
33196
+ return preProcessHyperlinkInstruction;
33197
+ case "TOC":
33198
+ return preProcessTocInstruction;
33199
+ default:
33200
+ return null;
33201
+ }
33202
+ };
33203
+ const preProcessNodesForFldChar = (nodes = [], docx) => {
33204
+ const processedNodes = [];
33205
+ let collectedNodesStack = [];
33206
+ let currentFieldStack = [];
33207
+ let unpairedEnd = null;
33208
+ let collecting = false;
33209
+ const finalizeField = () => {
33210
+ if (collecting) {
33211
+ const collectedNodes = collectedNodesStack.pop().filter((n) => n !== null);
33212
+ const currentField = currentFieldStack.pop();
33213
+ const combined = _processCombinedNodesForFldChar(collectedNodes, currentField.instrText.trim(), docx);
33214
+ if (collectedNodesStack.length === 0) {
33215
+ processedNodes.push(...combined);
33216
+ } else {
33217
+ collectedNodesStack[collectedNodesStack.length - 1].push(...combined);
33218
+ }
33219
+ } else {
33220
+ unpairedEnd = true;
33221
+ }
33222
+ };
33223
+ for (const node of nodes) {
33224
+ const fldCharEl = node.elements?.find((el) => el.name === "w:fldChar");
33225
+ const fldType = fldCharEl?.attributes?.["w:fldCharType"];
33226
+ const instrTextEl = node.elements?.find((el) => el.name === "w:instrText");
33227
+ collecting = collectedNodesStack.length > 0;
33228
+ if (fldType === "begin") {
33229
+ collectedNodesStack.push([null]);
33230
+ currentFieldStack.push({ instrText: "" });
33231
+ continue;
33232
+ }
33233
+ if (instrTextEl && collecting && currentFieldStack.length > 0) {
33234
+ currentFieldStack[currentFieldStack.length - 1].instrText += (instrTextEl.elements?.[0]?.text || "") + " ";
33235
+ continue;
33236
+ }
33237
+ if (fldType === "end") {
33238
+ finalizeField();
33239
+ continue;
33240
+ } else if (fldType === "separate") {
33241
+ continue;
33242
+ }
33243
+ if (Array.isArray(node.elements)) {
33244
+ const childResult = preProcessNodesForFldChar(node.elements, docx);
33245
+ node.elements = childResult.processedNodes;
33246
+ if (childResult.unpairedBegin) {
33247
+ childResult.unpairedBegin.forEach((pendingField) => {
33248
+ currentFieldStack.push(pendingField.fieldInfo);
33249
+ collectedNodesStack.push([node]);
33250
+ });
33251
+ } else if (childResult.unpairedEnd) {
33252
+ collectedNodesStack[collectedNodesStack.length - 1].push(node);
33253
+ finalizeField();
33254
+ } else if (collecting) {
33255
+ collectedNodesStack[collectedNodesStack.length - 1].push(node);
33256
+ } else {
33257
+ processedNodes.push(node);
33258
+ }
33259
+ } else if (collecting) {
33260
+ collectedNodesStack[collectedNodesStack.length - 1].push(node);
33261
+ } else {
33262
+ processedNodes.push(node);
33263
+ }
33264
+ }
33265
+ let unpairedBegin = null;
33266
+ if (collectedNodesStack.length > 0) {
33267
+ unpairedBegin = [];
33268
+ for (let i = 0; i < collectedNodesStack.length; i++) {
33269
+ processedNodes.push(...collectedNodesStack[i].filter((n) => n !== null));
33270
+ unpairedBegin.push({
33271
+ nodes: collectedNodesStack[i],
33272
+ fieldInfo: currentFieldStack[i]
33273
+ });
33274
+ }
33275
+ }
33276
+ return { processedNodes, unpairedBegin, unpairedEnd };
33277
+ };
33278
+ const _processCombinedNodesForFldChar = (nodesToCombine = [], instrText, docx) => {
33279
+ const instructionType = instrText.trim().split(" ")[0];
33280
+ const instructionPreProcessor = getInstructionPreProcessor(instructionType);
33281
+ if (instructionPreProcessor) {
33282
+ return instructionPreProcessor(nodesToCombine, instrText, docx);
33283
+ } else {
33284
+ return nodesToCombine;
33285
+ }
33286
+ };
32860
33287
  const createDocumentJson = (docx, converter, editor) => {
32861
33288
  const json = carbonCopy(getInitialJSON(docx));
32862
33289
  if (!json) return null;
@@ -32886,6 +33313,8 @@ const createDocumentJson = (docx, converter, editor) => {
32886
33313
  if (bodyNode) {
32887
33314
  ensureSectionProperties(bodyNode);
32888
33315
  const node = bodyNode;
33316
+ const { processedNodes } = preProcessNodesForFldChar(node.elements ?? [], docx);
33317
+ node.elements = processedNodes;
32889
33318
  const contentElements = node.elements?.filter((n) => n.name !== "w:sectPr") ?? [];
32890
33319
  const content = pruneIgnoredNodes(contentElements);
32891
33320
  const comments = importCommentData({ docx, converter, editor });
@@ -32941,8 +33370,10 @@ const defaultNodeListHandler = () => {
32941
33370
  trackChangeNodeHandlerEntity,
32942
33371
  tableNodeHandlerEntity,
32943
33372
  tabNodeEntityHandler,
33373
+ tableOfContentsHandlerEntity,
32944
33374
  autoPageHandlerEntity,
32945
33375
  autoTotalPageCountEntity,
33376
+ pageReferenceEntity,
32946
33377
  standardNodeHandlerEntity
32947
33378
  ];
32948
33379
  const handler2 = createNodeListHandler(entities);
@@ -34043,7 +34474,7 @@ export {
34043
34474
  objectIncludes as Z,
34044
34475
  AddMarkStep as _,
34045
34476
  Plugin as a,
34046
- translator$a as a$,
34477
+ translator$b as a$,
34047
34478
  twipsToLines as a0,
34048
34479
  pixelsToTwips as a1,
34049
34480
  helpers as a2,
@@ -34060,27 +34491,27 @@ export {
34060
34491
  handleClipboardPaste as aD,
34061
34492
  getFileObject as aE,
34062
34493
  runPropertyTranslators as aF,
34063
- translator$5 as aG,
34064
- translator$6 as aH,
34065
- translator$I as aI,
34066
- translator$J as aJ,
34067
- translator$10 as aK,
34068
- translator$H as aL,
34069
- translator$K as aM,
34070
- translator$G as aN,
34071
- translator$g as aO,
34072
- translator$8 as aP,
34073
- translator$t as aQ,
34074
- translator$u as aR,
34075
- translator$v as aS,
34076
- translator$w as aT,
34077
- translator$x as aU,
34078
- translator$c as aV,
34079
- translator$y as aW,
34080
- translator$z as aX,
34081
- translator$A as aY,
34082
- translator$B as aZ,
34083
- translator$L as a_,
34494
+ translator$7 as aG,
34495
+ translator$8 as aH,
34496
+ translator$J as aI,
34497
+ translator$K as aJ,
34498
+ translator$13 as aK,
34499
+ translator$I as aL,
34500
+ translator$L as aM,
34501
+ translator$H as aN,
34502
+ translator$h as aO,
34503
+ translator$9 as aP,
34504
+ translator$u as aQ,
34505
+ translator$v as aR,
34506
+ translator$w as aS,
34507
+ translator$x as aT,
34508
+ translator$y as aU,
34509
+ translator$d as aV,
34510
+ translator$z as aW,
34511
+ translator$A as aX,
34512
+ translator$B as aY,
34513
+ translator$C as aZ,
34514
+ translator$M as a_,
34084
34515
  hasSomeParentWithClass as aa,
34085
34516
  isActive as ab,
34086
34517
  unflattenListsInHtml as ac,
@@ -34108,50 +34539,52 @@ export {
34108
34539
  getContentTypesFromXml as ay,
34109
34540
  xmljs as az,
34110
34541
  Slice as b,
34111
- translator$C as b0,
34112
- translator$M as b1,
34113
- translator$d as b2,
34114
- translator$D as b3,
34115
- translator$e as b4,
34116
- translator$9 as b5,
34117
- translator$14 as b6,
34118
- translator$W as b7,
34119
- translator$X as b8,
34120
- translator$$ as b9,
34121
- translator$16 as bA,
34122
- translator$s as bB,
34123
- translator$2 as bC,
34124
- translator$1 as bD,
34125
- translator$F as bE,
34126
- translator$12 as bF,
34542
+ translator$D as b0,
34543
+ translator$N as b1,
34544
+ translator$e as b2,
34545
+ translator$E as b3,
34546
+ translator$f as b4,
34547
+ translator$a as b5,
34548
+ translator$17 as b6,
34549
+ translator$Z as b7,
34550
+ translator$_ as b8,
34551
+ translator$12 as b9,
34552
+ translator$19 as bA,
34553
+ translator$t as bB,
34554
+ translator$4 as bC,
34555
+ translator$3 as bD,
34556
+ translator$G as bE,
34557
+ translator$15 as bF,
34127
34558
  translator as bG,
34128
- _sfc_main as bH,
34129
- translator$i as ba,
34130
- translator$E as bb,
34131
- translator$3 as bc,
34132
- translator$k as bd,
34133
- translator$Y as be,
34134
- translator$V as bf,
34135
- translator$Z as bg,
34136
- translator$U as bh,
34137
- translator$13 as bi,
34138
- translator$m as bj,
34139
- translator$N as bk,
34140
- translator$n as bl,
34141
- translator$o as bm,
34142
- translator$11 as bn,
34143
- translator$7 as bo,
34144
- translator$15 as bp,
34145
- translator$O as bq,
34146
- translator$b as br,
34147
- translator$P as bs,
34148
- translator$Q as bt,
34149
- translator$q as bu,
34150
- translator$4 as bv,
34151
- translator$R as bw,
34152
- translator$_ as bx,
34153
- translator$S as by,
34154
- translator$T as bz,
34559
+ translator$1 as bH,
34560
+ translator$2 as bI,
34561
+ _sfc_main as bJ,
34562
+ translator$j as ba,
34563
+ translator$F as bb,
34564
+ translator$5 as bc,
34565
+ translator$l as bd,
34566
+ translator$$ as be,
34567
+ translator$X as bf,
34568
+ translator$10 as bg,
34569
+ translator$V as bh,
34570
+ translator$16 as bi,
34571
+ translator$n as bj,
34572
+ translator$O as bk,
34573
+ translator$o as bl,
34574
+ translator$p as bm,
34575
+ translator$14 as bn,
34576
+ translator$W as bo,
34577
+ translator$18 as bp,
34578
+ translator$P as bq,
34579
+ translator$c as br,
34580
+ translator$Q as bs,
34581
+ translator$R as bt,
34582
+ translator$r as bu,
34583
+ translator$6 as bv,
34584
+ translator$S as bw,
34585
+ translator$11 as bx,
34586
+ translator$T as by,
34587
+ translator$U as bz,
34155
34588
  DOMParser$1 as c,
34156
34589
  Mark as d,
34157
34590
  dropPoint as e,