@harbour-enterprises/superdoc 0.22.0-next.10 → 0.22.0-next.11

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 (61) hide show
  1. package/dist/chunks/{PdfViewer-CJdQmuIm.es.js → PdfViewer-CS3pY_UR.es.js} +1 -1
  2. package/dist/chunks/{PdfViewer-DE1NR4Ve.cjs → PdfViewer-Cz3fT1qt.cjs} +1 -1
  3. package/dist/chunks/{index-B9sHxXr_.es.js → index-Bbqhu9ev.es.js} +2 -2
  4. package/dist/chunks/{index-nfoifSpX.cjs → index-p73XAt11.cjs} +2 -2
  5. package/dist/chunks/{super-editor.es-DAP-fnHo.cjs → super-editor.es-CFD0lcOY.cjs} +1620 -1044
  6. package/dist/chunks/{super-editor.es-_iVPQ8J8.es.js → super-editor.es-DK3l03fz.es.js} +1620 -1044
  7. package/dist/core/types/index.d.ts.map +1 -1
  8. package/dist/style.css +3 -0
  9. package/dist/super-editor/ai-writer.es.js +2 -2
  10. package/dist/super-editor/chunks/{converter-DK1NMJZB.js → converter-DFDRdFEB.js} +1482 -1041
  11. package/dist/super-editor/chunks/{docx-zipper-CmK8TyNb.js → docx-zipper-CplUdgI9.js} +1 -1
  12. package/dist/super-editor/chunks/{editor-YR4uV-dp.js → editor-BnpIdTLI.js} +155 -19
  13. package/dist/super-editor/chunks/{toolbar-DzJyRvb0.js → toolbar-5h-ljJ_h.js} +2 -2
  14. package/dist/super-editor/converter.es.js +1 -1
  15. package/dist/super-editor/docx-zipper.es.js +2 -2
  16. package/dist/super-editor/editor.es.js +3 -3
  17. package/dist/super-editor/file-zipper.es.js +1 -1
  18. package/dist/super-editor/src/core/helpers/generateDocxRandomId.d.ts +5 -0
  19. package/dist/super-editor/src/core/super-converter/exporter.d.ts +4 -4
  20. package/dist/super-editor/src/core/super-converter/field-references/fld-preprocessors/hyperlink-preprocessor.d.ts +9 -0
  21. package/dist/super-editor/src/core/super-converter/field-references/fld-preprocessors/index.d.ts +2 -0
  22. package/dist/super-editor/src/core/super-converter/field-references/fld-preprocessors/num-pages-preprocessor.d.ts +9 -0
  23. package/dist/super-editor/src/core/super-converter/field-references/fld-preprocessors/page-preprocessor.d.ts +9 -0
  24. package/dist/super-editor/src/core/super-converter/field-references/fld-preprocessors/page-ref-preprocessor.d.ts +9 -0
  25. package/dist/super-editor/src/core/super-converter/field-references/fld-preprocessors/toc-preprocessor.d.ts +8 -0
  26. package/dist/super-editor/src/core/super-converter/field-references/index.d.ts +1 -0
  27. package/dist/super-editor/src/core/super-converter/field-references/preProcessNodesForFldChar.d.ts +21 -0
  28. package/dist/super-editor/src/core/super-converter/v2/exporter/helpers/translateChildNodes.d.ts +3 -3
  29. package/dist/super-editor/src/core/super-converter/v2/importer/pageReferenceImporter.d.ts +4 -0
  30. package/dist/super-editor/src/core/super-converter/v2/importer/tableOfContentsImporter.d.ts +4 -0
  31. package/dist/super-editor/src/core/super-converter/v2/types/index.d.ts +7 -1
  32. package/dist/super-editor/src/core/super-converter/v3/handlers/sd/pageReference/index.d.ts +1 -0
  33. package/dist/super-editor/src/core/super-converter/v3/handlers/sd/pageReference/pageReference-translator.d.ts +7 -0
  34. package/dist/super-editor/src/core/super-converter/v3/handlers/sd/tableOfContents/index.d.ts +1 -0
  35. package/dist/super-editor/src/core/super-converter/v3/handlers/sd/tableOfContents/tableOfContents-translator.d.ts +10 -0
  36. package/dist/super-editor/src/core/super-converter/v3/handlers/w/caps/caps-translator.d.ts +7 -0
  37. package/dist/super-editor/src/core/super-converter/v3/handlers/w/p/helpers/w-p-helpers.d.ts +0 -2
  38. package/dist/super-editor/src/core/super-converter/v3/handlers/w/sdt/helpers/handle-doc-part-obj.d.ts +9 -1
  39. package/dist/super-editor/src/core/super-converter/v3/handlers/w/sdt/helpers/translate-document-part-obj.d.ts +6 -0
  40. package/dist/super-editor/src/core/super-converter/v3/node-translator/node-translator.d.ts +2 -2
  41. package/dist/super-editor/src/extensions/page-reference/index.d.ts +1 -0
  42. package/dist/super-editor/src/extensions/page-reference/page-reference.d.ts +2 -0
  43. package/dist/super-editor/src/extensions/structured-content/document-part-object.d.ts +2 -0
  44. package/dist/super-editor/src/extensions/structured-content/index.d.ts +1 -0
  45. package/dist/super-editor/src/extensions/structured-content/structuredContentHelpers/getStructuredContentBlockTags.d.ts +2 -3
  46. package/dist/super-editor/src/extensions/structured-content/structuredContentHelpers/getStructuredContentInlineTags.d.ts +2 -3
  47. package/dist/super-editor/src/extensions/structured-content/structuredContentHelpers/getStructuredContentTags.d.ts +2 -3
  48. package/dist/super-editor/src/extensions/structured-content/structuredContentHelpers/getStructuredContentTagsById.d.ts +2 -3
  49. package/dist/super-editor/src/extensions/tab/helpers/tabDecorations.d.ts +2 -2
  50. package/dist/super-editor/src/extensions/table-of-contents/index.d.ts +1 -0
  51. package/dist/super-editor/src/extensions/table-of-contents/table-of-contents.d.ts +2 -0
  52. package/dist/super-editor/style.css +3 -0
  53. package/dist/super-editor/super-editor.es.js +10 -8
  54. package/dist/super-editor/toolbar.es.js +2 -2
  55. package/dist/super-editor.cjs +1 -1
  56. package/dist/super-editor.es.js +1 -1
  57. package/dist/superdoc.cjs +2 -2
  58. package/dist/superdoc.es.js +2 -2
  59. package/dist/superdoc.umd.js +1620 -1044
  60. package/dist/superdoc.umd.js.map +1 -1
  61. package/package.json +1 -1
@@ -14988,6 +14988,10 @@ function generateDocxRandomId(length2 = 8) {
14988
14988
  }
14989
14989
  return id.join("");
14990
14990
  }
14991
+ function generateRandomSigned32BitIntStrId() {
14992
+ const val = Math.floor(Math.random() * 2147483647);
14993
+ return val.toString();
14994
+ }
14991
14995
  function generateRandom32BitHex() {
14992
14996
  const val = Math.floor(Math.random() * 2147483647);
14993
14997
  return val.toString(16).toUpperCase().padStart(8, "0");
@@ -22566,6 +22570,7 @@ const helpers = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePrope
22566
22570
  generateDocxListAttributes,
22567
22571
  generateDocxRandomId,
22568
22572
  generateRandom32BitHex,
22573
+ generateRandomSigned32BitIntStrId,
22569
22574
  getActiveFormatting,
22570
22575
  getExtensionConfigField,
22571
22576
  getMarkRange,
@@ -22963,13 +22968,56 @@ function translateChildNodes(params2) {
22963
22968
  const { content: nodes } = params2.node;
22964
22969
  if (!nodes) return [];
22965
22970
  const translatedNodes = [];
22966
- nodes.forEach((node) => {
22971
+ const hyperlinkGroup = [];
22972
+ let index2 = 0;
22973
+ while (index2 < nodes.length) {
22974
+ const node = nodes[index2];
22975
+ const linkMark = _isLinkNode(node);
22976
+ if (linkMark) {
22977
+ hyperlinkGroup.push(node);
22978
+ const nextNode = index2 + 1 < nodes.length ? nodes[index2 + 1] : null;
22979
+ const nextIsLink = _isLinkNode(nextNode, linkMark);
22980
+ if (nextIsLink) {
22981
+ index2++;
22982
+ continue;
22983
+ } else {
22984
+ let translatedLinkGroup = exportSchemaToJson({
22985
+ ...params2,
22986
+ node: hyperlinkGroup[0],
22987
+ extraParams: { ...params2.extraParams || {}, hyperlinkGroup: hyperlinkGroup.slice() }
22988
+ });
22989
+ if (translatedLinkGroup instanceof Array) translatedNodes.push(...translatedLinkGroup);
22990
+ else translatedNodes.push(translatedLinkGroup);
22991
+ hyperlinkGroup.length = 0;
22992
+ index2++;
22993
+ continue;
22994
+ }
22995
+ }
22967
22996
  let translatedNode = exportSchemaToJson({ ...params2, node });
22968
22997
  if (translatedNode instanceof Array) translatedNodes.push(...translatedNode);
22969
22998
  else translatedNodes.push(translatedNode);
22970
- });
22999
+ index2++;
23000
+ }
22971
23001
  return translatedNodes.filter((n) => n);
22972
23002
  }
23003
+ function _isLinkNode(node, referenceMark = null) {
23004
+ if (!node || !node.marks && !node.attrs?.marksAsAttrs) return null;
23005
+ const marks = node.marks || node.attrs.marksAsAttrs;
23006
+ const linkMark = marks.find((mark) => mark.type === "link");
23007
+ if (!linkMark) return null;
23008
+ if (referenceMark) {
23009
+ return _isSameLinkMark(linkMark.attrs, referenceMark.attrs) ? linkMark : null;
23010
+ }
23011
+ return linkMark;
23012
+ }
23013
+ function _isSameLinkMark(attrsA, attrsB) {
23014
+ for (let key2 of ["anchor", "docLocation", "history", "href", "rId", "target"]) {
23015
+ if (attrsA[key2] != attrsB[key2]) {
23016
+ return false;
23017
+ }
23018
+ }
23019
+ return true;
23020
+ }
22973
23021
  const baseNumbering = {
22974
23022
  declaration: {
22975
23023
  attributes: {
@@ -24316,37 +24364,37 @@ const _NodeTranslator = class _NodeTranslator2 {
24316
24364
  };
24317
24365
  __publicField$2(_NodeTranslator, "translatorTypes", TranslatorTypes);
24318
24366
  let NodeTranslator = _NodeTranslator;
24319
- const encode$18 = (attributes) => {
24367
+ const encode$1b = (attributes) => {
24320
24368
  return attributes["w:type"];
24321
24369
  };
24322
- const decode$$ = (attrs) => {
24370
+ const decode$11 = (attrs) => {
24323
24371
  const { lineBreakType } = attrs;
24324
24372
  return lineBreakType;
24325
24373
  };
24326
24374
  const attrConfig$F = Object.freeze({
24327
24375
  xmlName: "w:type",
24328
24376
  sdName: "lineBreakType",
24329
- encode: encode$18,
24330
- decode: decode$$
24377
+ encode: encode$1b,
24378
+ decode: decode$11
24331
24379
  });
24332
- const encode$17 = (attributes) => {
24380
+ const encode$1a = (attributes) => {
24333
24381
  const xmlAttrValue = attributes["w:clear"];
24334
24382
  return xmlAttrValue;
24335
24383
  };
24336
- const decode$_ = (attrs) => {
24384
+ const decode$10 = (attrs) => {
24337
24385
  const { clear } = attrs;
24338
24386
  return clear;
24339
24387
  };
24340
24388
  const attrConfig$E = Object.freeze({
24341
24389
  xmlName: "w:clear",
24342
24390
  sdName: "clear",
24343
- encode: encode$17,
24344
- decode: decode$_
24391
+ encode: encode$1a,
24392
+ decode: decode$10
24345
24393
  });
24346
24394
  const validXmlAttributes$m = [attrConfig$F, attrConfig$E];
24347
- const XML_NODE_NAME$u = "w:br";
24348
- const SD_NODE_NAME$d = "lineBreak";
24349
- const encode$16 = (_2, encodedAttrs) => {
24395
+ const XML_NODE_NAME$x = "w:br";
24396
+ const SD_NODE_NAME$f = "lineBreak";
24397
+ const encode$19 = (_2, encodedAttrs) => {
24350
24398
  const isPageBreak = encodedAttrs?.lineBreakType === "page";
24351
24399
  const translated = {
24352
24400
  type: isPageBreak ? "hardBreak" : "lineBreak"
@@ -24356,7 +24404,7 @@ const encode$16 = (_2, encodedAttrs) => {
24356
24404
  }
24357
24405
  return translated;
24358
24406
  };
24359
- const decode$Z = (params2, decodedAttrs) => {
24407
+ const decode$$ = (params2, decodedAttrs) => {
24360
24408
  const { node } = params2;
24361
24409
  if (!node) return;
24362
24410
  const wBreak = { name: "w:br" };
@@ -24373,39 +24421,39 @@ const decode$Z = (params2, decodedAttrs) => {
24373
24421
  };
24374
24422
  return translated;
24375
24423
  };
24376
- const config$s = {
24377
- xmlName: XML_NODE_NAME$u,
24378
- sdNodeOrKeyName: SD_NODE_NAME$d,
24424
+ const config$v = {
24425
+ xmlName: XML_NODE_NAME$x,
24426
+ sdNodeOrKeyName: SD_NODE_NAME$f,
24379
24427
  type: NodeTranslator.translatorTypes.NODE,
24380
- encode: encode$16,
24381
- decode: decode$Z,
24428
+ encode: encode$19,
24429
+ decode: decode$$,
24382
24430
  attributes: validXmlAttributes$m
24383
24431
  };
24384
- const translator$16 = NodeTranslator.from(config$s);
24385
- const encode$15 = (attributes) => attributes?.["w:val"];
24386
- const decode$Y = (attrs) => attrs?.highlight;
24432
+ const translator$19 = NodeTranslator.from(config$v);
24433
+ const encode$18 = (attributes) => attributes?.["w:val"];
24434
+ const decode$_ = (attrs) => attrs?.highlight;
24387
24435
  const attrConfig$D = Object.freeze({
24388
24436
  xmlName: "w:val",
24389
24437
  sdName: "highlight",
24390
- encode: encode$15,
24391
- decode: decode$Y
24438
+ encode: encode$18,
24439
+ decode: decode$_
24392
24440
  });
24393
24441
  const validXmlAttributes$l = [attrConfig$D];
24394
- const XML_NODE_NAME$t = "w:highlight";
24395
- const SD_ATTR_KEY$f = "highlight";
24442
+ const XML_NODE_NAME$w = "w:highlight";
24443
+ const SD_ATTR_KEY$g = "highlight";
24396
24444
  const DISABLED_TOKENS = /* @__PURE__ */ new Set(["transparent", "none", "inherit"]);
24397
- const encode$14 = (params2, encodedAttrs = {}) => {
24445
+ const encode$17 = (params2, encodedAttrs = {}) => {
24398
24446
  const { nodes } = params2;
24399
24447
  const node = nodes?.[0];
24400
24448
  const value = encodedAttrs.highlight ?? node?.attributes?.["w:val"];
24401
24449
  return {
24402
24450
  type: "attr",
24403
- xmlName: XML_NODE_NAME$t,
24404
- sdNodeOrKeyName: SD_ATTR_KEY$f,
24451
+ xmlName: XML_NODE_NAME$w,
24452
+ sdNodeOrKeyName: SD_ATTR_KEY$g,
24405
24453
  attributes: { "w:val": value ?? null }
24406
24454
  };
24407
24455
  };
24408
- const decode$X = (params2) => {
24456
+ const decode$Z = (params2) => {
24409
24457
  const attrs = params2?.node?.attrs || {};
24410
24458
  const highlightValue = attrs.highlight ?? attrs.color ?? null;
24411
24459
  if (!highlightValue) return void 0;
@@ -24413,14 +24461,14 @@ const decode$X = (params2) => {
24413
24461
  if (!normalizedValue) return void 0;
24414
24462
  if (DISABLED_TOKENS.has(normalizedValue)) {
24415
24463
  return {
24416
- name: XML_NODE_NAME$t,
24464
+ name: XML_NODE_NAME$w,
24417
24465
  attributes: { "w:val": "none" }
24418
24466
  };
24419
24467
  }
24420
24468
  const keyword = getDocxHighlightKeywordFromHex(highlightValue);
24421
24469
  if (keyword) {
24422
24470
  return {
24423
- name: XML_NODE_NAME$t,
24471
+ name: XML_NODE_NAME$w,
24424
24472
  attributes: { "w:val": keyword }
24425
24473
  };
24426
24474
  }
@@ -24435,63 +24483,63 @@ const decode$X = (params2) => {
24435
24483
  }
24436
24484
  };
24437
24485
  };
24438
- const config$r = {
24439
- xmlName: XML_NODE_NAME$t,
24440
- sdNodeOrKeyName: SD_ATTR_KEY$f,
24486
+ const config$u = {
24487
+ xmlName: XML_NODE_NAME$w,
24488
+ sdNodeOrKeyName: SD_ATTR_KEY$g,
24441
24489
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
24442
- encode: encode$14,
24443
- decode: decode$X,
24490
+ encode: encode$17,
24491
+ decode: decode$Z,
24444
24492
  attributes: validXmlAttributes$l
24445
24493
  };
24446
- const translator$15 = NodeTranslator.from(config$r);
24447
- const encode$13 = (attributes) => {
24494
+ const translator$18 = NodeTranslator.from(config$u);
24495
+ const encode$16 = (attributes) => {
24448
24496
  return attributes["w:val"];
24449
24497
  };
24450
- const decode$W = (attrs) => {
24498
+ const decode$Y = (attrs) => {
24451
24499
  const { tabSize } = attrs || {};
24452
24500
  return tabSize;
24453
24501
  };
24454
24502
  const attrConfig$C = Object.freeze({
24455
24503
  xmlName: "w:val",
24456
24504
  sdName: "tabSize",
24457
- encode: encode$13,
24458
- decode: decode$W
24505
+ encode: encode$16,
24506
+ decode: decode$Y
24459
24507
  });
24460
- const encode$12 = (attributes) => {
24508
+ const encode$15 = (attributes) => {
24461
24509
  return attributes["w:leader"];
24462
24510
  };
24463
- const decode$V = (attrs) => {
24511
+ const decode$X = (attrs) => {
24464
24512
  const { leader } = attrs || {};
24465
24513
  return leader;
24466
24514
  };
24467
24515
  const attrConfig$B = Object.freeze({
24468
24516
  xmlName: "w:leader",
24469
24517
  sdName: "leader",
24470
- encode: encode$12,
24471
- decode: decode$V
24518
+ encode: encode$15,
24519
+ decode: decode$X
24472
24520
  });
24473
- const encode$11 = (attributes) => {
24521
+ const encode$14 = (attributes) => {
24474
24522
  return attributes["w:pos"];
24475
24523
  };
24476
- const decode$U = (attrs) => {
24524
+ const decode$W = (attrs) => {
24477
24525
  const { pos } = attrs || {};
24478
24526
  return pos;
24479
24527
  };
24480
24528
  const attrConfig$A = Object.freeze({
24481
24529
  xmlName: "w:pos",
24482
24530
  sdName: "pos",
24483
- encode: encode$11,
24484
- decode: decode$U
24531
+ encode: encode$14,
24532
+ decode: decode$W
24485
24533
  });
24486
24534
  const validXmlAttributes$k = [attrConfig$C, attrConfig$A, attrConfig$B];
24487
- const XML_NODE_NAME$s = "w:tab";
24488
- const SD_NODE_NAME$c = "tab";
24489
- const encode$10 = (_2, encodedAttrs = {}) => {
24535
+ const XML_NODE_NAME$v = "w:tab";
24536
+ const SD_NODE_NAME$e = "tab";
24537
+ const encode$13 = (_2, encodedAttrs = {}) => {
24490
24538
  const translated = { type: "tab" };
24491
24539
  if (encodedAttrs) translated.attrs = { ...encodedAttrs };
24492
24540
  return translated;
24493
24541
  };
24494
- const decode$T = (params2, decodedAttrs = {}) => {
24542
+ const decode$V = (params2, decodedAttrs = {}) => {
24495
24543
  const { node } = params2 || {};
24496
24544
  if (!node) return;
24497
24545
  const wTab = { name: "w:tab" };
@@ -24507,15 +24555,15 @@ const decode$T = (params2, decodedAttrs = {}) => {
24507
24555
  }
24508
24556
  return translated;
24509
24557
  };
24510
- const config$q = {
24511
- xmlName: XML_NODE_NAME$s,
24512
- sdNodeOrKeyName: SD_NODE_NAME$c,
24558
+ const config$t = {
24559
+ xmlName: XML_NODE_NAME$v,
24560
+ sdNodeOrKeyName: SD_NODE_NAME$e,
24513
24561
  type: NodeTranslator.translatorTypes.NODE,
24514
- encode: encode$10,
24515
- decode: decode$T,
24562
+ encode: encode$13,
24563
+ decode: decode$V,
24516
24564
  attributes: validXmlAttributes$k
24517
24565
  };
24518
- const translator$14 = NodeTranslator.from(config$q);
24566
+ const translator$17 = NodeTranslator.from(config$t);
24519
24567
  const mergeTextNodes = (nodes) => {
24520
24568
  if (!nodes || !Array.isArray(nodes)) {
24521
24569
  return nodes;
@@ -24889,104 +24937,10 @@ const getDefaultParagraphStyle = (docx, styleId = "") => {
24889
24937
  justify: pPrByIdJcAttr
24890
24938
  };
24891
24939
  };
24892
- const preProcessNodesForFldChar = (nodes = []) => {
24893
- const processedNodes = [];
24894
- let buffer2 = [];
24895
- let collecting = false;
24896
- for (const node of nodes) {
24897
- const fldCharEl = node.elements?.find((el) => el.name === "w:fldChar");
24898
- const fldType = fldCharEl?.attributes?.["w:fldCharType"];
24899
- if (fldType === "begin") {
24900
- buffer2 = [node];
24901
- collecting = true;
24902
- continue;
24903
- }
24904
- if (fldType === "separate" && collecting) {
24905
- buffer2.push(node);
24906
- continue;
24907
- }
24908
- if (fldType === "end" && collecting) {
24909
- buffer2.push(node);
24910
- processedNodes.push(...processCombinedNodesForFldChar(buffer2));
24911
- buffer2 = [];
24912
- collecting = false;
24913
- continue;
24914
- }
24915
- if (collecting) {
24916
- buffer2.push(node);
24917
- } else {
24918
- processedNodes.push(node);
24919
- }
24920
- }
24921
- if (buffer2.length) {
24922
- processedNodes.push(...buffer2);
24923
- }
24924
- return processedNodes;
24925
- };
24926
- const processCombinedNodesForFldChar = (nodesToCombine = []) => {
24927
- let processedNodes = [];
24928
- let hasPageMarker = false;
24929
- let isNumPages = false;
24930
- const textStart = nodesToCombine.findIndex(
24931
- (n) => n.elements?.some((el) => el.name === "w:fldChar" && el.attributes["w:fldCharType"] === "separate")
24932
- );
24933
- const textEnd = nodesToCombine.findIndex(
24934
- (n) => n.elements?.some((el) => el.name === "w:fldChar" && el.attributes["w:fldCharType"] === "end")
24935
- );
24936
- const textNodes = nodesToCombine.slice(textStart + 1, textEnd);
24937
- const instrTextContainer = nodesToCombine.find((n) => n.elements?.some((el) => el.name === "w:instrText"));
24938
- const instrTextNode = instrTextContainer?.elements?.find((el) => el.name === "w:instrText");
24939
- const instrText = instrTextNode?.elements[0].text;
24940
- if (!hasPageMarker) hasPageMarker = instrText?.trim().startsWith("PAGE");
24941
- if (!isNumPages) isNumPages = instrText?.trim().startsWith("NUMPAGES");
24942
- const urlMatch = instrText?.match(/HYPERLINK\s+"([^"]+)"/);
24943
- if (hasPageMarker) {
24944
- const pageNumNode = {
24945
- name: "sd:autoPageNumber",
24946
- type: "element"
24947
- };
24948
- nodesToCombine.forEach((n) => {
24949
- const rPrNode = n.elements.find((el) => el.name === "w:rPr");
24950
- if (rPrNode) pageNumNode.elements = [rPrNode];
24951
- });
24952
- processedNodes.push(pageNumNode);
24953
- } else if (isNumPages) {
24954
- const totalPageNumNode = {
24955
- name: "sd:totalPageNumber",
24956
- type: "element"
24957
- };
24958
- nodesToCombine.forEach((n) => {
24959
- const rPrNode = n.elements.find((el) => el.name === "w:rPr");
24960
- if (rPrNode) totalPageNumNode.elements = [rPrNode];
24961
- });
24962
- processedNodes.push(totalPageNumNode);
24963
- } else if (urlMatch && urlMatch?.length >= 2) {
24964
- const url = urlMatch[1];
24965
- const textMarks = [];
24966
- textNodes.forEach((n) => {
24967
- const rPr2 = n.elements.find((el) => el.name === "w:rPr");
24968
- if (!rPr2) return;
24969
- const { elements } = rPr2;
24970
- elements.forEach((el) => {
24971
- textMarks.push(el);
24972
- });
24973
- });
24974
- const linkMark = { name: "link", attributes: { href: url } };
24975
- const rPr = { name: "w:rPr", type: "element", elements: [linkMark, ...textMarks] };
24976
- processedNodes.push({
24977
- name: "w:r",
24978
- type: "element",
24979
- elements: [rPr, ...textNodes]
24980
- });
24981
- }
24982
- return processedNodes;
24983
- };
24984
24940
  const handleParagraphNode$1 = (params2) => {
24985
24941
  const { nodes, docx, nodeListHandler, filename } = params2;
24986
24942
  const node = carbonCopy(nodes[0]);
24987
24943
  let schemaNode;
24988
- let processedElements = preProcessNodesForFldChar(node.elements);
24989
- node.elements = processedElements;
24990
24944
  const handleStandardNode2 = nodeListHandler.handlerEntities.find(
24991
24945
  (e) => e.handlerName === "standardNodeHandler"
24992
24946
  )?.handler;
@@ -25127,89 +25081,89 @@ const handleParagraphNode$1 = (params2) => {
25127
25081
  }
25128
25082
  return schemaNode;
25129
25083
  };
25130
- const encode$$ = (attributes) => {
25084
+ const encode$12 = (attributes) => {
25131
25085
  return attributes["w:rsidDel"];
25132
25086
  };
25133
- const decode$S = (attrs) => {
25087
+ const decode$U = (attrs) => {
25134
25088
  return attrs.rsidDel;
25135
25089
  };
25136
25090
  const attrConfig$z = Object.freeze({
25137
25091
  xmlName: "w:rsidDel",
25138
25092
  sdName: "rsidDel",
25139
- encode: encode$$,
25140
- decode: decode$S
25093
+ encode: encode$12,
25094
+ decode: decode$U
25141
25095
  });
25142
- const encode$_ = (attributes) => {
25096
+ const encode$11 = (attributes) => {
25143
25097
  return attributes["w:rsidP"];
25144
25098
  };
25145
- const decode$R = (attrs) => {
25099
+ const decode$T = (attrs) => {
25146
25100
  return attrs.rsidP;
25147
25101
  };
25148
25102
  const attrConfig$y = Object.freeze({
25149
25103
  xmlName: "w:rsidP",
25150
25104
  sdName: "rsidP",
25151
- encode: encode$_,
25152
- decode: decode$R
25105
+ encode: encode$11,
25106
+ decode: decode$T
25153
25107
  });
25154
- const encode$Z = (attributes) => {
25108
+ const encode$10 = (attributes) => {
25155
25109
  return attributes["w:rsidR"];
25156
25110
  };
25157
- const decode$Q = (attrs) => {
25111
+ const decode$S = (attrs) => {
25158
25112
  return attrs.rsidR;
25159
25113
  };
25160
25114
  const attrConfig$x = Object.freeze({
25161
25115
  xmlName: "w:rsidR",
25162
25116
  sdName: "rsidR",
25163
- encode: encode$Z,
25164
- decode: decode$Q
25117
+ encode: encode$10,
25118
+ decode: decode$S
25165
25119
  });
25166
- const encode$Y = (attributes) => {
25120
+ const encode$$ = (attributes) => {
25167
25121
  return attributes["w:rsidRPr"];
25168
25122
  };
25169
- const decode$P = (attrs) => {
25123
+ const decode$R = (attrs) => {
25170
25124
  return attrs.rsidRPr;
25171
25125
  };
25172
25126
  const attrConfig$w = Object.freeze({
25173
25127
  xmlName: "w:rsidRPr",
25174
25128
  sdName: "rsidRPr",
25175
- encode: encode$Y,
25176
- decode: decode$P
25129
+ encode: encode$$,
25130
+ decode: decode$R
25177
25131
  });
25178
- const encode$X = (attributes) => {
25132
+ const encode$_ = (attributes) => {
25179
25133
  return attributes["w:rsidRDefault"];
25180
25134
  };
25181
- const decode$O = (attrs) => {
25135
+ const decode$Q = (attrs) => {
25182
25136
  return attrs.rsidRDefault;
25183
25137
  };
25184
25138
  const attrConfig$v = Object.freeze({
25185
25139
  xmlName: "w:rsidRDefault",
25186
25140
  sdName: "rsidRDefault",
25187
- encode: encode$X,
25188
- decode: decode$O
25141
+ encode: encode$_,
25142
+ decode: decode$Q
25189
25143
  });
25190
- const encode$W = (attributes) => {
25144
+ const encode$Z = (attributes) => {
25191
25145
  return attributes["w14:paraId"];
25192
25146
  };
25193
- const decode$N = (attrs) => {
25147
+ const decode$P = (attrs) => {
25194
25148
  return attrs.paraId;
25195
25149
  };
25196
25150
  const attrConfig$u = Object.freeze({
25197
25151
  xmlName: "w14:paraId",
25198
25152
  sdName: "paraId",
25199
- encode: encode$W,
25200
- decode: decode$N
25153
+ encode: encode$Z,
25154
+ decode: decode$P
25201
25155
  });
25202
- const encode$V = (attributes) => {
25156
+ const encode$Y = (attributes) => {
25203
25157
  return attributes["w14:textId"];
25204
25158
  };
25205
- const decode$M = (attrs) => {
25159
+ const decode$O = (attrs) => {
25206
25160
  return attrs.textId;
25207
25161
  };
25208
25162
  const attrConfig$t = Object.freeze({
25209
25163
  xmlName: "w14:textId",
25210
25164
  sdName: "textId",
25211
- encode: encode$V,
25212
- decode: decode$M
25165
+ encode: encode$Y,
25166
+ decode: decode$O
25213
25167
  });
25214
25168
  const validXmlAttributes$j = [
25215
25169
  attrConfig$u,
@@ -25220,9 +25174,9 @@ const validXmlAttributes$j = [
25220
25174
  attrConfig$w,
25221
25175
  attrConfig$z
25222
25176
  ];
25223
- const XML_NODE_NAME$r = "w:p";
25224
- const SD_NODE_NAME$b = "paragraph";
25225
- const encode$U = (params2, encodedAttrs = {}) => {
25177
+ const XML_NODE_NAME$u = "w:p";
25178
+ const SD_NODE_NAME$d = "paragraph";
25179
+ const encode$X = (params2, encodedAttrs = {}) => {
25226
25180
  const node = handleParagraphNode$1(params2);
25227
25181
  if (!node) return void 0;
25228
25182
  if (encodedAttrs && Object.keys(encodedAttrs).length) {
@@ -25230,7 +25184,7 @@ const encode$U = (params2, encodedAttrs = {}) => {
25230
25184
  }
25231
25185
  return node;
25232
25186
  };
25233
- const decode$L = (params2, decodedAttrs = {}) => {
25187
+ const decode$N = (params2, decodedAttrs = {}) => {
25234
25188
  const translated = translateParagraphNode(params2);
25235
25189
  if (!translated) return void 0;
25236
25190
  if (decodedAttrs && Object.keys(decodedAttrs).length) {
@@ -25238,16 +25192,16 @@ const decode$L = (params2, decodedAttrs = {}) => {
25238
25192
  }
25239
25193
  return translated;
25240
25194
  };
25241
- const config$p = {
25242
- xmlName: XML_NODE_NAME$r,
25243
- sdNodeOrKeyName: SD_NODE_NAME$b,
25195
+ const config$s = {
25196
+ xmlName: XML_NODE_NAME$u,
25197
+ sdNodeOrKeyName: SD_NODE_NAME$d,
25244
25198
  type: NodeTranslator.translatorTypes.NODE,
25245
- encode: encode$U,
25246
- decode: decode$L,
25199
+ encode: encode$X,
25200
+ decode: decode$N,
25247
25201
  attributes: validXmlAttributes$j
25248
25202
  };
25249
- const translator$13 = NodeTranslator.from(config$p);
25250
- const encode$T = (attributes) => {
25203
+ const translator$16 = NodeTranslator.from(config$s);
25204
+ const encode$W = (attributes) => {
25251
25205
  const raw = attributes?.["w:val"];
25252
25206
  if (raw === void 0 || raw === null) return void 0;
25253
25207
  if (typeof raw === "boolean") return raw;
@@ -25257,24 +25211,24 @@ const encode$T = (attributes) => {
25257
25211
  if (val === "1" || val === "true" || val === "on") return true;
25258
25212
  return void 0;
25259
25213
  };
25260
- const decode$K = (runProps) => {
25214
+ const decode$M = (runProps) => {
25261
25215
  if (runProps?.bold === false) return "0";
25262
25216
  return void 0;
25263
25217
  };
25264
25218
  const attrConfig$s = Object.freeze({
25265
25219
  xmlName: "w:val",
25266
25220
  sdName: "bold",
25267
- encode: encode$T,
25268
- decode: decode$K
25221
+ encode: encode$W,
25222
+ decode: decode$M
25269
25223
  });
25270
25224
  const validXmlAttributes$i = [attrConfig$s];
25271
- const XML_NODE_NAME$q = "w:b";
25272
- const SD_ATTR_KEY$e = "bold";
25273
- const encode$S = (params2, encodedAttrs = {}) => {
25225
+ const XML_NODE_NAME$t = "w:b";
25226
+ const SD_ATTR_KEY$f = "bold";
25227
+ const encode$V = (params2, encodedAttrs = {}) => {
25274
25228
  const { nodes } = params2;
25275
25229
  const node = nodes[0];
25276
25230
  if (!node) return void 0;
25277
- const val = encodedAttrs?.[SD_ATTR_KEY$e];
25231
+ const val = encodedAttrs?.[SD_ATTR_KEY$f];
25278
25232
  let attributes;
25279
25233
  if (val === false) attributes = { "w:val": "0" };
25280
25234
  else if (val === true)
@@ -25282,85 +25236,85 @@ const encode$S = (params2, encodedAttrs = {}) => {
25282
25236
  else attributes = node.attributes || {};
25283
25237
  return {
25284
25238
  type: "attr",
25285
- xmlName: XML_NODE_NAME$q,
25286
- sdNodeOrKeyName: SD_ATTR_KEY$e,
25239
+ xmlName: XML_NODE_NAME$t,
25240
+ sdNodeOrKeyName: SD_ATTR_KEY$f,
25287
25241
  attributes
25288
25242
  };
25289
25243
  };
25290
- const config$o = {
25291
- xmlName: XML_NODE_NAME$q,
25292
- sdNodeOrKeyName: SD_ATTR_KEY$e,
25244
+ const config$r = {
25245
+ xmlName: XML_NODE_NAME$t,
25246
+ sdNodeOrKeyName: SD_ATTR_KEY$f,
25293
25247
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25294
- encode: encode$S,
25248
+ encode: encode$V,
25295
25249
  attributes: validXmlAttributes$i
25296
25250
  };
25297
- const translator$12 = NodeTranslator.from(config$o);
25298
- const XML_NODE_NAME$p = "w:i";
25299
- const SD_ATTR_KEY$d = "italic";
25300
- const encode$R = (params2) => {
25251
+ const translator$15 = NodeTranslator.from(config$r);
25252
+ const XML_NODE_NAME$s = "w:i";
25253
+ const SD_ATTR_KEY$e = "italic";
25254
+ const encode$U = (params2) => {
25301
25255
  const { nodes } = params2;
25302
25256
  const node = nodes?.[0];
25303
25257
  if (!node) return void 0;
25304
25258
  return {
25305
25259
  type: "attr",
25306
- xmlName: XML_NODE_NAME$p,
25307
- sdNodeOrKeyName: SD_ATTR_KEY$d,
25260
+ xmlName: XML_NODE_NAME$s,
25261
+ sdNodeOrKeyName: SD_ATTR_KEY$e,
25308
25262
  attributes: {
25309
25263
  "w:val": node.attributes?.["w:val"] ?? null
25310
25264
  }
25311
25265
  };
25312
25266
  };
25313
- const config$n = {
25314
- xmlName: XML_NODE_NAME$p,
25315
- sdNodeOrKeyName: SD_ATTR_KEY$d,
25267
+ const config$q = {
25268
+ xmlName: XML_NODE_NAME$s,
25269
+ sdNodeOrKeyName: SD_ATTR_KEY$e,
25316
25270
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25317
- encode: encode$R
25271
+ encode: encode$U
25318
25272
  };
25319
- const translator$11 = NodeTranslator.from(config$n);
25320
- const encode$Q = (attributes) => attributes?.["w:val"];
25321
- const decode$J = (attrs) => attrs?.underline;
25273
+ const translator$14 = NodeTranslator.from(config$q);
25274
+ const encode$T = (attributes) => attributes?.["w:val"];
25275
+ const decode$L = (attrs) => attrs?.underline;
25322
25276
  const attrConfig$r = Object.freeze({
25323
25277
  xmlName: "w:val",
25324
25278
  sdName: "underline",
25325
- encode: encode$Q,
25326
- decode: decode$J
25279
+ encode: encode$T,
25280
+ decode: decode$L
25327
25281
  });
25328
- const encode$P = (attributes) => attributes?.["w:color"];
25329
- const decode$I = (attrs) => attrs?.color;
25282
+ const encode$S = (attributes) => attributes?.["w:color"];
25283
+ const decode$K = (attrs) => attrs?.color;
25330
25284
  const attrConfig$q = Object.freeze({
25331
25285
  xmlName: "w:color",
25332
25286
  sdName: "color",
25333
- encode: encode$P,
25334
- decode: decode$I
25287
+ encode: encode$S,
25288
+ decode: decode$K
25335
25289
  });
25336
- const encode$O = (attributes) => attributes?.["w:themeColor"];
25337
- const decode$H = (attrs) => attrs?.themeColor;
25290
+ const encode$R = (attributes) => attributes?.["w:themeColor"];
25291
+ const decode$J = (attrs) => attrs?.themeColor;
25338
25292
  const attrConfig$p = Object.freeze({
25339
25293
  xmlName: "w:themeColor",
25340
25294
  sdName: "themeColor",
25341
- encode: encode$O,
25342
- decode: decode$H
25295
+ encode: encode$R,
25296
+ decode: decode$J
25343
25297
  });
25344
- const encode$N = (attributes) => attributes?.["w:themeTint"];
25345
- const decode$G = (attrs) => attrs?.themeTint;
25298
+ const encode$Q = (attributes) => attributes?.["w:themeTint"];
25299
+ const decode$I = (attrs) => attrs?.themeTint;
25346
25300
  const attrConfig$o = Object.freeze({
25347
25301
  xmlName: "w:themeTint",
25348
25302
  sdName: "themeTint",
25349
- encode: encode$N,
25350
- decode: decode$G
25303
+ encode: encode$Q,
25304
+ decode: decode$I
25351
25305
  });
25352
- const encode$M = (attributes) => attributes?.["w:themeShade"];
25353
- const decode$F = (attrs) => attrs?.themeShade;
25306
+ const encode$P = (attributes) => attributes?.["w:themeShade"];
25307
+ const decode$H = (attrs) => attrs?.themeShade;
25354
25308
  const attrConfig$n = Object.freeze({
25355
25309
  xmlName: "w:themeShade",
25356
25310
  sdName: "themeShade",
25357
- encode: encode$M,
25358
- decode: decode$F
25311
+ encode: encode$P,
25312
+ decode: decode$H
25359
25313
  });
25360
25314
  const validXmlAttributes$h = [attrConfig$r, attrConfig$q, attrConfig$p, attrConfig$o, attrConfig$n];
25361
- const XML_NODE_NAME$o = "w:u";
25362
- const SD_ATTR_KEY$c = "underline";
25363
- const encode$L = (params2, encodedAttrs = {}) => {
25315
+ const XML_NODE_NAME$r = "w:u";
25316
+ const SD_ATTR_KEY$d = "underline";
25317
+ const encode$O = (params2, encodedAttrs = {}) => {
25364
25318
  const { nodes } = params2;
25365
25319
  const node = nodes?.[0];
25366
25320
  const sourceAttrs = node?.attributes || {};
@@ -25376,12 +25330,12 @@ const encode$L = (params2, encodedAttrs = {}) => {
25376
25330
  if (themeShade !== void 0 && themeShade !== null) attributes["w:themeShade"] = themeShade;
25377
25331
  return {
25378
25332
  type: "attr",
25379
- xmlName: XML_NODE_NAME$o,
25380
- sdNodeOrKeyName: SD_ATTR_KEY$c,
25333
+ xmlName: XML_NODE_NAME$r,
25334
+ sdNodeOrKeyName: SD_ATTR_KEY$d,
25381
25335
  attributes
25382
25336
  };
25383
25337
  };
25384
- const decode$E = (params2) => {
25338
+ const decode$G = (params2) => {
25385
25339
  const attrs = params2?.node?.attrs || {};
25386
25340
  const underlineType = attrs.underlineType ?? attrs.underline ?? null;
25387
25341
  const color = attrs.underlineColor ?? attrs.color ?? null;
@@ -25399,20 +25353,20 @@ const decode$E = (params2) => {
25399
25353
  if (themeTint) attributes["w:themeTint"] = themeTint;
25400
25354
  if (themeShade) attributes["w:themeShade"] = themeShade;
25401
25355
  return {
25402
- name: XML_NODE_NAME$o,
25356
+ name: XML_NODE_NAME$r,
25403
25357
  attributes
25404
25358
  };
25405
25359
  };
25406
- const config$m = {
25407
- xmlName: XML_NODE_NAME$o,
25408
- sdNodeOrKeyName: SD_ATTR_KEY$c,
25360
+ const config$p = {
25361
+ xmlName: XML_NODE_NAME$r,
25362
+ sdNodeOrKeyName: SD_ATTR_KEY$d,
25409
25363
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25410
- encode: encode$L,
25411
- decode: decode$E,
25364
+ encode: encode$O,
25365
+ decode: decode$G,
25412
25366
  attributes: validXmlAttributes$h
25413
25367
  };
25414
- const translator$10 = NodeTranslator.from(config$m);
25415
- const encode$K = (attributes) => {
25368
+ const translator$13 = NodeTranslator.from(config$p);
25369
+ const encode$N = (attributes) => {
25416
25370
  const raw = attributes?.["w:val"];
25417
25371
  if (raw === void 0 || raw === null) return void 0;
25418
25372
  if (typeof raw === "boolean") return raw;
@@ -25422,24 +25376,24 @@ const encode$K = (attributes) => {
25422
25376
  if (val === "1" || val === "true" || val === "on") return true;
25423
25377
  return void 0;
25424
25378
  };
25425
- const decode$D = (attrs) => {
25379
+ const decode$F = (attrs) => {
25426
25380
  if (attrs?.strike === false) return "0";
25427
25381
  return void 0;
25428
25382
  };
25429
25383
  const attrConfig$m = Object.freeze({
25430
25384
  xmlName: "w:val",
25431
25385
  sdName: "strike",
25432
- encode: encode$K,
25433
- decode: decode$D
25386
+ encode: encode$N,
25387
+ decode: decode$F
25434
25388
  });
25435
25389
  const validXmlAttributes$g = [attrConfig$m];
25436
- const XML_NODE_NAME$n = "w:strike";
25437
- const SD_ATTR_KEY$b = "strike";
25438
- const encode$J = (params2, encodedAttrs = {}) => {
25390
+ const XML_NODE_NAME$q = "w:strike";
25391
+ const SD_ATTR_KEY$c = "strike";
25392
+ const encode$M = (params2, encodedAttrs = {}) => {
25439
25393
  const { nodes } = params2;
25440
25394
  const node = nodes?.[0];
25441
25395
  if (!node) return void 0;
25442
- const val = encodedAttrs?.[SD_ATTR_KEY$b];
25396
+ const val = encodedAttrs?.[SD_ATTR_KEY$c];
25443
25397
  let attributes;
25444
25398
  if (val === false) attributes = { "w:val": "0" };
25445
25399
  else if (val === true) attributes = {};
@@ -25448,55 +25402,55 @@ const encode$J = (params2, encodedAttrs = {}) => {
25448
25402
  else if (val === true && attributes["w:val"] === void 0) delete attributes["w:val"];
25449
25403
  return {
25450
25404
  type: "attr",
25451
- xmlName: XML_NODE_NAME$n,
25452
- sdNodeOrKeyName: SD_ATTR_KEY$b,
25405
+ xmlName: XML_NODE_NAME$q,
25406
+ sdNodeOrKeyName: SD_ATTR_KEY$c,
25453
25407
  attributes
25454
25408
  };
25455
25409
  };
25456
- const config$l = {
25457
- xmlName: XML_NODE_NAME$n,
25458
- sdNodeOrKeyName: SD_ATTR_KEY$b,
25410
+ const config$o = {
25411
+ xmlName: XML_NODE_NAME$q,
25412
+ sdNodeOrKeyName: SD_ATTR_KEY$c,
25459
25413
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25460
- encode: encode$J,
25414
+ encode: encode$M,
25461
25415
  attributes: validXmlAttributes$g
25462
25416
  };
25463
- const translator$$ = NodeTranslator.from(config$l);
25464
- const encode$I = (attributes) => attributes?.["w:val"];
25465
- const decode$C = (attrs) => attrs?.color;
25417
+ const translator$12 = NodeTranslator.from(config$o);
25418
+ const encode$L = (attributes) => attributes?.["w:val"];
25419
+ const decode$E = (attrs) => attrs?.color;
25466
25420
  const attrConfig$l = Object.freeze({
25467
25421
  xmlName: "w:val",
25468
25422
  sdName: "color",
25469
- encode: encode$I,
25470
- decode: decode$C
25423
+ encode: encode$L,
25424
+ decode: decode$E
25471
25425
  });
25472
- const encode$H = (attributes) => attributes?.["w:themeColor"];
25473
- const decode$B = (attrs) => attrs?.themeColor;
25426
+ const encode$K = (attributes) => attributes?.["w:themeColor"];
25427
+ const decode$D = (attrs) => attrs?.themeColor;
25474
25428
  const attrConfig$k = Object.freeze({
25475
25429
  xmlName: "w:themeColor",
25476
25430
  sdName: "themeColor",
25477
- encode: encode$H,
25478
- decode: decode$B
25431
+ encode: encode$K,
25432
+ decode: decode$D
25479
25433
  });
25480
- const encode$G = (attributes) => attributes?.["w:themeTint"];
25481
- const decode$A = (attrs) => attrs?.themeTint;
25434
+ const encode$J = (attributes) => attributes?.["w:themeTint"];
25435
+ const decode$C = (attrs) => attrs?.themeTint;
25482
25436
  const attrConfig$j = Object.freeze({
25483
25437
  xmlName: "w:themeTint",
25484
25438
  sdName: "themeTint",
25485
- encode: encode$G,
25486
- decode: decode$A
25439
+ encode: encode$J,
25440
+ decode: decode$C
25487
25441
  });
25488
- const encode$F = (attributes) => attributes?.["w:themeShade"];
25489
- const decode$z = (attrs) => attrs?.themeShade;
25442
+ const encode$I = (attributes) => attributes?.["w:themeShade"];
25443
+ const decode$B = (attrs) => attrs?.themeShade;
25490
25444
  const attrConfig$i = Object.freeze({
25491
25445
  xmlName: "w:themeShade",
25492
25446
  sdName: "themeShade",
25493
- encode: encode$F,
25494
- decode: decode$z
25447
+ encode: encode$I,
25448
+ decode: decode$B
25495
25449
  });
25496
25450
  const validXmlAttributes$f = [attrConfig$l, attrConfig$k, attrConfig$j, attrConfig$i];
25497
- const XML_NODE_NAME$m = "w:color";
25498
- const SD_ATTR_KEY$a = "color";
25499
- const encode$E = (params2, encodedAttrs = {}) => {
25451
+ const XML_NODE_NAME$p = "w:color";
25452
+ const SD_ATTR_KEY$b = "color";
25453
+ const encode$H = (params2, encodedAttrs = {}) => {
25500
25454
  const { nodes } = params2;
25501
25455
  const node = nodes?.[0];
25502
25456
  const sourceAttrs = node?.attributes || {};
@@ -25511,63 +25465,63 @@ const encode$E = (params2, encodedAttrs = {}) => {
25511
25465
  if (themeShade !== void 0 && themeShade !== null) attributes["w:themeShade"] = themeShade;
25512
25466
  return {
25513
25467
  type: "attr",
25514
- xmlName: XML_NODE_NAME$m,
25515
- sdNodeOrKeyName: SD_ATTR_KEY$a,
25468
+ xmlName: XML_NODE_NAME$p,
25469
+ sdNodeOrKeyName: SD_ATTR_KEY$b,
25516
25470
  attributes
25517
25471
  };
25518
25472
  };
25519
- const config$k = {
25520
- xmlName: XML_NODE_NAME$m,
25521
- sdNodeOrKeyName: SD_ATTR_KEY$a,
25473
+ const config$n = {
25474
+ xmlName: XML_NODE_NAME$p,
25475
+ sdNodeOrKeyName: SD_ATTR_KEY$b,
25522
25476
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25523
- encode: encode$E,
25477
+ encode: encode$H,
25524
25478
  attributes: validXmlAttributes$f
25525
25479
  };
25526
- const translator$_ = NodeTranslator.from(config$k);
25527
- const encode$D = (attributes) => attributes?.["w:eastAsia"];
25528
- const decode$y = (attrs) => attrs?.eastAsia;
25480
+ const translator$11 = NodeTranslator.from(config$n);
25481
+ const encode$G = (attributes) => attributes?.["w:eastAsia"];
25482
+ const decode$A = (attrs) => attrs?.eastAsia;
25529
25483
  const attrConfig$h = Object.freeze({
25530
25484
  xmlName: "w:eastAsia",
25531
25485
  sdName: "eastAsia",
25532
- encode: encode$D,
25533
- decode: decode$y
25486
+ encode: encode$G,
25487
+ decode: decode$A
25534
25488
  });
25535
- const encode$C = (attributes) => attributes?.["w:ascii"];
25536
- const decode$x = (attrs) => attrs?.ascii;
25489
+ const encode$F = (attributes) => attributes?.["w:ascii"];
25490
+ const decode$z = (attrs) => attrs?.ascii;
25537
25491
  const attrConfig$g = Object.freeze({
25538
25492
  xmlName: "w:ascii",
25539
25493
  sdName: "ascii",
25540
- encode: encode$C,
25541
- decode: decode$x
25494
+ encode: encode$F,
25495
+ decode: decode$z
25542
25496
  });
25543
- const encode$B = (attributes) => attributes?.["w:hAnsi"];
25544
- const decode$w = (attrs) => attrs?.hAnsi;
25497
+ const encode$E = (attributes) => attributes?.["w:hAnsi"];
25498
+ const decode$y = (attrs) => attrs?.hAnsi;
25545
25499
  const attrConfig$f = Object.freeze({
25546
25500
  xmlName: "w:hAnsi",
25547
25501
  sdName: "hAnsi",
25548
- encode: encode$B,
25549
- decode: decode$w
25502
+ encode: encode$E,
25503
+ decode: decode$y
25550
25504
  });
25551
- const encode$A = (attributes) => attributes?.["w:cs"];
25552
- const decode$v = (attrs) => attrs?.cs;
25505
+ const encode$D = (attributes) => attributes?.["w:cs"];
25506
+ const decode$x = (attrs) => attrs?.cs;
25553
25507
  const attrConfig$e = Object.freeze({
25554
25508
  xmlName: "w:cs",
25555
25509
  sdName: "cs",
25556
- encode: encode$A,
25557
- decode: decode$v
25510
+ encode: encode$D,
25511
+ decode: decode$x
25558
25512
  });
25559
- const encode$z = (attributes) => attributes?.["w:val"];
25560
- const decode$u = (attrs) => attrs?.value;
25513
+ const encode$C = (attributes) => attributes?.["w:val"];
25514
+ const decode$w = (attrs) => attrs?.value;
25561
25515
  const attrConfig$d = Object.freeze({
25562
25516
  xmlName: "w:val",
25563
25517
  sdName: "value",
25564
- encode: encode$z,
25565
- decode: decode$u
25518
+ encode: encode$C,
25519
+ decode: decode$w
25566
25520
  });
25567
25521
  const validXmlAttributes$e = [attrConfig$h, attrConfig$g, attrConfig$f, attrConfig$e, attrConfig$d];
25568
- const XML_NODE_NAME$l = "w:rFonts";
25569
- const SD_ATTR_KEY$9 = "fontFamily";
25570
- const encode$y = (params2, encodedAttrs = {}) => {
25522
+ const XML_NODE_NAME$o = "w:rFonts";
25523
+ const SD_ATTR_KEY$a = "fontFamily";
25524
+ const encode$B = (params2, encodedAttrs = {}) => {
25571
25525
  const { nodes } = params2;
25572
25526
  const node = nodes?.[0];
25573
25527
  const sourceAttrs = node?.attributes || {};
@@ -25593,120 +25547,281 @@ const encode$y = (params2, encodedAttrs = {}) => {
25593
25547
  if (attributes["w:val"] === void 0) delete attributes["w:val"];
25594
25548
  return {
25595
25549
  type: "attr",
25596
- xmlName: XML_NODE_NAME$l,
25597
- sdNodeOrKeyName: SD_ATTR_KEY$9,
25550
+ xmlName: XML_NODE_NAME$o,
25551
+ sdNodeOrKeyName: SD_ATTR_KEY$a,
25598
25552
  attributes
25599
25553
  };
25600
25554
  };
25601
- const config$j = {
25602
- xmlName: XML_NODE_NAME$l,
25603
- sdNodeOrKeyName: SD_ATTR_KEY$9,
25555
+ const config$m = {
25556
+ xmlName: XML_NODE_NAME$o,
25557
+ sdNodeOrKeyName: SD_ATTR_KEY$a,
25604
25558
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25605
- encode: encode$y,
25559
+ encode: encode$B,
25606
25560
  attributes: validXmlAttributes$e
25607
25561
  };
25608
- const translator$Z = NodeTranslator.from(config$j);
25609
- const encode$x = (attributes) => attributes?.["w:val"];
25610
- const decode$t = (attrs) => attrs?.styleId;
25562
+ const translator$10 = NodeTranslator.from(config$m);
25563
+ const encode$A = (attributes) => attributes?.["w:val"];
25564
+ const decode$v = (attrs) => attrs?.styleId;
25611
25565
  const attrConfig$c = Object.freeze({
25612
25566
  xmlName: "w:val",
25613
25567
  sdName: "styleId",
25614
- encode: encode$x,
25615
- decode: decode$t
25568
+ encode: encode$A,
25569
+ decode: decode$v
25616
25570
  });
25617
25571
  const validXmlAttributes$d = [attrConfig$c];
25618
- const XML_NODE_NAME$k = "w:rStyle";
25619
- const SD_ATTR_KEY$8 = "styleId";
25620
- const encode$w = (params2, encodedAttrs = {}) => {
25572
+ const XML_NODE_NAME$n = "w:rStyle";
25573
+ const SD_ATTR_KEY$9 = "styleId";
25574
+ const encode$z = (params2, encodedAttrs = {}) => {
25621
25575
  const { nodes } = params2;
25622
25576
  const node = nodes?.[0];
25623
25577
  const value = encodedAttrs.styleId ?? node?.attributes?.["w:val"];
25624
25578
  return {
25625
25579
  type: "attr",
25626
- xmlName: XML_NODE_NAME$k,
25627
- sdNodeOrKeyName: SD_ATTR_KEY$8,
25580
+ xmlName: XML_NODE_NAME$n,
25581
+ sdNodeOrKeyName: SD_ATTR_KEY$9,
25628
25582
  attributes: { "w:val": value ?? null }
25629
25583
  };
25630
25584
  };
25631
- const config$i = {
25632
- xmlName: XML_NODE_NAME$k,
25633
- sdNodeOrKeyName: SD_ATTR_KEY$8,
25585
+ const config$l = {
25586
+ xmlName: XML_NODE_NAME$n,
25587
+ sdNodeOrKeyName: SD_ATTR_KEY$9,
25634
25588
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25635
- encode: encode$w,
25589
+ encode: encode$z,
25636
25590
  attributes: validXmlAttributes$d
25637
25591
  };
25638
- const translator$Y = NodeTranslator.from(config$i);
25639
- const encode$v = (attributes) => attributes?.["w:val"];
25640
- const decode$s = (attrs) => attrs?.fontSize;
25592
+ const translator$$ = NodeTranslator.from(config$l);
25593
+ const encode$y = (attributes) => attributes?.["w:val"];
25594
+ const decode$u = (attrs) => attrs?.fontSize;
25641
25595
  const attrConfig$b = Object.freeze({
25642
25596
  xmlName: "w:val",
25643
25597
  sdName: "fontSize",
25644
- encode: encode$v,
25645
- decode: decode$s
25598
+ encode: encode$y,
25599
+ decode: decode$u
25646
25600
  });
25647
25601
  const validXmlAttributes$c = [attrConfig$b];
25648
- const XML_NODE_NAME$j = "w:sz";
25649
- const SD_ATTR_KEY$7 = "fontSize";
25650
- const encode$u = (params2, encodedAttrs = {}) => {
25602
+ const XML_NODE_NAME$m = "w:sz";
25603
+ const SD_ATTR_KEY$8 = "fontSize";
25604
+ const encode$x = (params2, encodedAttrs = {}) => {
25651
25605
  const { nodes } = params2;
25652
25606
  const node = nodes?.[0];
25653
25607
  const value = encodedAttrs.fontSize ?? node?.attributes?.["w:val"];
25654
25608
  return {
25655
25609
  type: "attr",
25656
- xmlName: XML_NODE_NAME$j,
25657
- sdNodeOrKeyName: SD_ATTR_KEY$7,
25610
+ xmlName: XML_NODE_NAME$m,
25611
+ sdNodeOrKeyName: SD_ATTR_KEY$8,
25658
25612
  attributes: { "w:val": value ?? null }
25659
25613
  };
25660
25614
  };
25661
- const config$h = {
25662
- xmlName: XML_NODE_NAME$j,
25663
- sdNodeOrKeyName: SD_ATTR_KEY$7,
25615
+ const config$k = {
25616
+ xmlName: XML_NODE_NAME$m,
25617
+ sdNodeOrKeyName: SD_ATTR_KEY$8,
25664
25618
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25665
- encode: encode$u,
25619
+ encode: encode$x,
25666
25620
  attributes: validXmlAttributes$c
25667
25621
  };
25668
- const translator$X = NodeTranslator.from(config$h);
25669
- const encode$t = (attributes) => attributes?.["w:val"];
25670
- const decode$r = (attrs) => attrs?.fontSizeCs;
25622
+ const translator$_ = NodeTranslator.from(config$k);
25623
+ const encode$w = (attributes) => attributes?.["w:val"];
25624
+ const decode$t = (attrs) => attrs?.fontSizeCs;
25671
25625
  const attrConfig$a = Object.freeze({
25672
25626
  xmlName: "w:val",
25673
25627
  sdName: "fontSizeCs",
25674
- encode: encode$t,
25675
- decode: decode$r
25628
+ encode: encode$w,
25629
+ decode: decode$t
25676
25630
  });
25677
25631
  const validXmlAttributes$b = [attrConfig$a];
25678
- const XML_NODE_NAME$i = "w:szCs";
25679
- const SD_ATTR_KEY$6 = "fontSizeCs";
25680
- const encode$s = (params2, encodedAttrs = {}) => {
25632
+ const XML_NODE_NAME$l = "w:szCs";
25633
+ const SD_ATTR_KEY$7 = "fontSizeCs";
25634
+ const encode$v = (params2, encodedAttrs = {}) => {
25681
25635
  const { nodes } = params2;
25682
25636
  const node = nodes?.[0];
25683
25637
  const value = encodedAttrs.fontSizeCs ?? node?.attributes?.["w:val"];
25684
25638
  return {
25685
25639
  type: "attr",
25686
- xmlName: XML_NODE_NAME$i,
25687
- sdNodeOrKeyName: SD_ATTR_KEY$6,
25640
+ xmlName: XML_NODE_NAME$l,
25641
+ sdNodeOrKeyName: SD_ATTR_KEY$7,
25688
25642
  attributes: { "w:val": value ?? null }
25689
25643
  };
25690
25644
  };
25691
- const config$g = {
25692
- xmlName: XML_NODE_NAME$i,
25693
- sdNodeOrKeyName: SD_ATTR_KEY$6,
25645
+ const config$j = {
25646
+ xmlName: XML_NODE_NAME$l,
25647
+ sdNodeOrKeyName: SD_ATTR_KEY$7,
25694
25648
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25695
- encode: encode$s,
25649
+ encode: encode$v,
25696
25650
  attributes: validXmlAttributes$b
25697
25651
  };
25698
- const translator$W = NodeTranslator.from(config$g);
25652
+ const translator$Z = NodeTranslator.from(config$j);
25653
+ const generateV2HandlerEntity = (handlerName, translator2) => ({
25654
+ handlerName,
25655
+ handler: (params2) => {
25656
+ const { nodes } = params2;
25657
+ if (nodes.length === 0 || nodes[0].name !== translator2.xmlName) {
25658
+ return { nodes: [], consumed: 0 };
25659
+ }
25660
+ const result = translator2.encode(params2);
25661
+ if (!result) return { nodes: [], consumed: 0 };
25662
+ return {
25663
+ nodes: Array.isArray(result) ? result : [result],
25664
+ consumed: 1
25665
+ };
25666
+ }
25667
+ });
25668
+ function createSingleAttrPropertyHandler(xmlName, sdName = null, attrName = "w:val", transformEncode = null, transformDecode = null) {
25669
+ if (!sdName) sdName = xmlName.split(":")[1];
25670
+ if (!transformEncode) transformEncode = (v2) => v2;
25671
+ if (!transformDecode) transformDecode = (v2) => v2;
25672
+ return {
25673
+ xmlName,
25674
+ sdNodeOrKeyName: sdName,
25675
+ encode: ({ nodes }) => {
25676
+ return transformEncode(nodes[0].attributes[attrName]) ?? void 0;
25677
+ },
25678
+ decode: ({ node }) => {
25679
+ const value = node.attrs?.[sdName] != null ? transformDecode(node.attrs[sdName]) : void 0;
25680
+ return value != null ? { name: xmlName, attributes: { [attrName]: value } } : void 0;
25681
+ }
25682
+ };
25683
+ }
25684
+ function createMeasurementPropertyHandler(xmlName, sdName = null) {
25685
+ if (!sdName) sdName = xmlName.split(":")[1];
25686
+ return {
25687
+ xmlName,
25688
+ sdNodeOrKeyName: sdName,
25689
+ attributes: [
25690
+ createAttributeHandler("w:w", "value", parseInteger, integerToString),
25691
+ createAttributeHandler("w:type")
25692
+ ],
25693
+ encode: (_2, encodedAttrs) => {
25694
+ return encodedAttrs["value"] != null ? encodedAttrs : void 0;
25695
+ },
25696
+ decode: function({ node }) {
25697
+ const decodedAttrs = this.decodeAttributes({ node: { ...node, attrs: node.attrs[sdName] || {} } });
25698
+ return decodedAttrs["w:w"] != null ? { attributes: decodedAttrs } : void 0;
25699
+ }
25700
+ };
25701
+ }
25702
+ function createBorderPropertyHandler(xmlName, sdName = null) {
25703
+ if (!sdName) sdName = xmlName.split(":")[1];
25704
+ return {
25705
+ xmlName,
25706
+ sdNodeOrKeyName: sdName,
25707
+ attributes: [
25708
+ createAttributeHandler("w:val"),
25709
+ createAttributeHandler("w:color"),
25710
+ createAttributeHandler("w:themeColor"),
25711
+ createAttributeHandler("w:themeTint"),
25712
+ createAttributeHandler("w:themeShade"),
25713
+ createAttributeHandler("w:sz", "size", parseInteger, integerToString),
25714
+ createAttributeHandler("w:space", null, parseInteger, integerToString),
25715
+ createAttributeHandler("w:shadow", null, parseBoolean, booleanToString),
25716
+ createAttributeHandler("w:frame", null, parseBoolean, booleanToString)
25717
+ ],
25718
+ encode: (params2, encodedAttrs) => {
25719
+ return Object.keys(encodedAttrs).length > 0 ? encodedAttrs : void 0;
25720
+ },
25721
+ decode: function({ node }, context) {
25722
+ const decodedAttrs = this.decodeAttributes({ node: { ...node, attrs: node.attrs[sdName] || {} } });
25723
+ return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
25724
+ }
25725
+ };
25726
+ }
25727
+ const createAttributeHandler = (xmlName, sdName = null, transformEncode = null, transformDecode = null) => {
25728
+ if (!transformEncode) transformEncode = (v2) => v2;
25729
+ if (!transformDecode) transformDecode = (v2) => v2;
25730
+ if (!sdName) sdName = xmlName.split(":")[1];
25731
+ return {
25732
+ xmlName,
25733
+ sdName,
25734
+ encode: (attributes) => transformEncode(attributes[xmlName]),
25735
+ decode: (attributes) => transformDecode(attributes[sdName])
25736
+ };
25737
+ };
25738
+ function encodeProperties(node, translatorsByXmlName, asArray = false) {
25739
+ if (!node?.elements || node.elements.length === 0) {
25740
+ return asArray ? [] : {};
25741
+ }
25742
+ const attributes = asArray ? [] : {};
25743
+ node.elements.forEach((el) => {
25744
+ const translator2 = translatorsByXmlName[el.name];
25745
+ if (translator2) {
25746
+ const encodedAttr = translator2.encode({ nodes: [el] });
25747
+ if (encodedAttr != null) {
25748
+ if (asArray) {
25749
+ attributes.push({ [translator2.sdNodeOrKeyName]: encodedAttr });
25750
+ } else {
25751
+ attributes[translator2.sdNodeOrKeyName] = encodedAttr;
25752
+ }
25753
+ }
25754
+ }
25755
+ });
25756
+ return attributes;
25757
+ }
25758
+ function decodeProperties(translatorsBySdName, properties) {
25759
+ if (!properties || typeof properties !== "object") {
25760
+ return [];
25761
+ }
25762
+ const elements = [];
25763
+ Object.keys(properties).forEach((key2) => {
25764
+ const translator2 = translatorsBySdName[key2];
25765
+ if (translator2) {
25766
+ const result = translator2.decode({ node: { attrs: { [key2]: properties[key2] } } });
25767
+ if (result != null) {
25768
+ result.name = translator2.xmlName;
25769
+ elements.push(result);
25770
+ }
25771
+ }
25772
+ });
25773
+ return elements;
25774
+ }
25775
+ const parseBoolean = (value) => value != null ? ["1", "true"].includes(value) : void 0;
25776
+ const booleanToString = (value) => value != null ? value ? "1" : "0" : void 0;
25777
+ const parseInteger = (value) => {
25778
+ if (value == null) return void 0;
25779
+ const intValue = parseInt(value, 10);
25780
+ return isNaN(intValue) ? void 0 : intValue;
25781
+ };
25782
+ const integerToString = (value) => {
25783
+ const intValue = parseInteger(value);
25784
+ return intValue != void 0 ? String(intValue) : void 0;
25785
+ };
25786
+ const XML_NODE_NAME$k = "w:caps";
25787
+ const SD_ATTR_KEY$6 = "textTransform";
25788
+ const encode$u = (params2, encodedAttrs = {}) => {
25789
+ const { nodes } = params2;
25790
+ const node = nodes[0];
25791
+ if (!node) return void 0;
25792
+ let result;
25793
+ if (!["false", "0"].includes(encodedAttrs.val)) {
25794
+ result = "uppercase";
25795
+ } else {
25796
+ return void 0;
25797
+ }
25798
+ return {
25799
+ type: "attr",
25800
+ xmlName: XML_NODE_NAME$k,
25801
+ sdNodeOrKeyName: SD_ATTR_KEY$6,
25802
+ attributes: { [SD_ATTR_KEY$6]: result }
25803
+ };
25804
+ };
25805
+ const config$i = {
25806
+ xmlName: XML_NODE_NAME$k,
25807
+ sdNodeOrKeyName: SD_ATTR_KEY$6,
25808
+ type: NodeTranslator.translatorTypes.ATTRIBUTE,
25809
+ encode: encode$u,
25810
+ attributes: [createAttributeHandler("w:val")]
25811
+ };
25812
+ const translator$Y = NodeTranslator.from(config$i);
25699
25813
  const runPropertyTranslators = Object.freeze({
25700
- "w:b": translator$12,
25701
- "w:i": translator$11,
25702
- "w:u": translator$10,
25703
- "w:strike": translator$$,
25704
- "w:color": translator$_,
25705
- "w:highlight": translator$15,
25706
- "w:rFonts": translator$Z,
25707
- "w:rStyle": translator$Y,
25708
- "w:sz": translator$X,
25709
- "w:szCs": translator$W
25814
+ "w:b": translator$15,
25815
+ "w:i": translator$14,
25816
+ "w:u": translator$13,
25817
+ "w:strike": translator$12,
25818
+ "w:color": translator$11,
25819
+ "w:highlight": translator$18,
25820
+ "w:rFonts": translator$10,
25821
+ "w:rStyle": translator$$,
25822
+ "w:sz": translator$_,
25823
+ "w:szCs": translator$Z,
25824
+ "w:caps": translator$Y
25710
25825
  });
25711
25826
  const rawRunPropertyXmlNames = Object.freeze(["w:lang", "w:shd"]);
25712
25827
  const RAW_CHILD_NAME_SET = new Set(rawRunPropertyXmlNames);
@@ -25720,9 +25835,9 @@ const toRunPropertyEntry = (candidate) => {
25720
25835
  attributes: { ...candidate.attributes || {} }
25721
25836
  };
25722
25837
  };
25723
- const XML_NODE_NAME$h = "w:rPr";
25838
+ const XML_NODE_NAME$j = "w:rPr";
25724
25839
  const SD_ATTR_KEY$5 = "runProperties";
25725
- const encode$r = (params2) => {
25840
+ const encode$t = (params2) => {
25726
25841
  const { nodes } = params2;
25727
25842
  const node = nodes?.[0] || {};
25728
25843
  const contents = Array.isArray(node.elements) ? node.elements : [];
@@ -25756,16 +25871,16 @@ const encode$r = (params2) => {
25756
25871
  attributes: runPropsArray
25757
25872
  };
25758
25873
  };
25759
- const config$f = {
25760
- xmlName: XML_NODE_NAME$h,
25874
+ const config$h = {
25875
+ xmlName: XML_NODE_NAME$j,
25761
25876
  sdNodeOrKeyName: SD_ATTR_KEY$5,
25762
25877
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25763
- encode: encode$r
25878
+ encode: encode$t
25764
25879
  };
25765
- const translator$V = NodeTranslator.from(config$f);
25880
+ const translator$X = NodeTranslator.from(config$h);
25766
25881
  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;
25767
25882
  const containsEastAsianCharacters = (text) => EAST_ASIAN_CHARACTER_REGEX.test(text);
25768
- const collectRunProperties = (params2, rPrNode, translator2 = translator$V) => {
25883
+ const collectRunProperties = (params2, rPrNode, translator2 = translator$X) => {
25769
25884
  if (!rPrNode) return { entries: [], hadRPr: false, styleChangeMarks: [] };
25770
25885
  const result = translator2.encode({ ...params2, nodes: [rPrNode] }) || {};
25771
25886
  let entries = [];
@@ -25834,7 +25949,10 @@ const applyRunMarks = (node, inlineMarks, textStyleAttrs) => {
25834
25949
  };
25835
25950
  const deriveStyleMarks = ({ docx, paragraphStyleId, runStyleId }) => {
25836
25951
  const paragraphStyleMarks = collectStyleMarks(paragraphStyleId, docx);
25837
- const runStyleMarks = collectStyleMarks(runStyleId, docx);
25952
+ if (paragraphStyleId?.startsWith("TOC")) {
25953
+ return paragraphStyleMarks;
25954
+ }
25955
+ let runStyleMarks = collectStyleMarks(runStyleId, docx);
25838
25956
  const inlineMarks = mergeInlineMarkSets(paragraphStyleMarks.inlineMarks, runStyleMarks.inlineMarks);
25839
25957
  const textStyleAttrs = mergeTextStyleAttrs(paragraphStyleMarks.textStyleAttrs, runStyleMarks.textStyleAttrs);
25840
25958
  return { inlineMarks, textStyleAttrs };
@@ -26060,6 +26178,13 @@ const splitRunProperties = (entries = [], docx = null) => {
26060
26178
  }
26061
26179
  break;
26062
26180
  }
26181
+ case "w:caps": {
26182
+ if (attributes["textTransform"] != null) {
26183
+ hasTextStyle = true;
26184
+ textStyleAttrs.textTransform = attributes["textTransform"];
26185
+ }
26186
+ break;
26187
+ }
26063
26188
  case "w:rFonts": {
26064
26189
  const asciiFamily = attributes["w:ascii"] || attributes["w:hAnsi"] || (attributes["w:eastAsia"] ? void 0 : attributes["w:val"]);
26065
26190
  const eastAsiaFamily = attributes["w:eastAsia"];
@@ -26079,9 +26204,10 @@ const splitRunProperties = (entries = [], docx = null) => {
26079
26204
  case "w:sz":
26080
26205
  case "w:szCs": {
26081
26206
  const rawSize = Number(attributes["w:val"]);
26207
+ const attrName = entry.xmlName === "w:sz" ? "fontSize" : "fontSizeCs";
26082
26208
  if (Number.isFinite(rawSize) && rawSize > 0) {
26083
26209
  hasTextStyle = true;
26084
- textStyleAttrs.fontSize = `${rawSize / 2}pt`;
26210
+ textStyleAttrs[attrName] = `${rawSize / 2}pt`;
26085
26211
  }
26086
26212
  break;
26087
26213
  }
@@ -26227,46 +26353,166 @@ const ensureTrackedWrapper = (runs, trackingMarksByType = /* @__PURE__ */ new Ma
26227
26353
  }
26228
26354
  return runs;
26229
26355
  };
26230
- const encode$q = (attributes) => {
26356
+ const XML_NODE_NAME$i = "w:hyperlink";
26357
+ const SD_NODE_NAME$c = "link";
26358
+ const _createAttributeHandler = (xmlName, sdName) => ({
26359
+ xmlName,
26360
+ sdName,
26361
+ encode: (attributes) => attributes[xmlName],
26362
+ decode: (attributes) => attributes[sdName]
26363
+ });
26364
+ const validXmlAttributes$a = [
26365
+ _createAttributeHandler("w:anchor", "anchor"),
26366
+ _createAttributeHandler("w:docLocation", "docLocation"),
26367
+ {
26368
+ xmlName: "w:history",
26369
+ sdName: "history",
26370
+ encode: (attributes) => attributes["w:history"] === "1" || attributes["w:history"] === "true",
26371
+ decode: (attributes) => attributes["history"] ? "1" : "0"
26372
+ },
26373
+ _createAttributeHandler("w:tooltip", "tooltip"),
26374
+ _createAttributeHandler("r:id", "rId"),
26375
+ _createAttributeHandler("w:tgtFrame", "target")
26376
+ ];
26377
+ const encode$s = (params2, encodedAttrs) => {
26378
+ const { nodes, docx, nodeListHandler } = params2;
26379
+ const node = nodes[0];
26380
+ let href = _resolveHref(docx, encodedAttrs);
26381
+ const linkMark = { type: "link", attrs: { ...encodedAttrs, href } };
26382
+ const referenceNodeTypes = ["sd:pageReference", "sd:autoPageNumber", "sd:totalPageNumber"];
26383
+ const contentNodes = node.elements.filter((el) => el.name === "w:r" || referenceNodeTypes.includes(el.name));
26384
+ contentNodes.forEach((contentNode) => {
26385
+ const existingMarks = Array.isArray(contentNode.marks) ? contentNode.marks : [];
26386
+ const marksWithoutLink = existingMarks.filter((mark) => mark?.type !== "link");
26387
+ contentNode.marks = [...marksWithoutLink, linkMark];
26388
+ });
26389
+ const updatedNode = nodeListHandler.handler({
26390
+ ...params2,
26391
+ nodes: contentNodes,
26392
+ path: [...params2.path || [], node]
26393
+ });
26394
+ return updatedNode;
26395
+ };
26396
+ const _resolveHref = (docx, encodedAttrs) => {
26397
+ const rels = docx["word/_rels/document.xml.rels"];
26398
+ const relationships = rels.elements.find((el) => el.name === "Relationships");
26399
+ const { elements } = relationships;
26400
+ const { rId, anchor } = encodedAttrs;
26401
+ let href;
26402
+ if (!rId && anchor) {
26403
+ href = `#${anchor}`;
26404
+ } else if (rId) {
26405
+ const rel = elements.find((el) => el.attributes["Id"] === rId) || {};
26406
+ const { attributes: relAttributes = {} } = rel;
26407
+ href = relAttributes["Target"];
26408
+ }
26409
+ return href;
26410
+ };
26411
+ function decode$s(params2) {
26412
+ const { hyperlinkGroup = [params2.node] } = params2.extraParams || {};
26413
+ const node = hyperlinkGroup[0];
26414
+ const linkMark = node.marks.find((m2) => m2.type === "link");
26415
+ const linkAttrs = this.decodeAttributes({ ...params2, node: linkMark });
26416
+ let { anchor, href: link } = linkMark.attrs;
26417
+ const isExternalLink = !anchor;
26418
+ if (isExternalLink) {
26419
+ linkAttrs["r:id"] = _addNewLinkRelationship(params2, link, linkAttrs["r:id"]);
26420
+ }
26421
+ let contentNodes = [];
26422
+ hyperlinkGroup.forEach((linkNode) => {
26423
+ if ("marks" in linkNode) {
26424
+ linkNode.marks = linkNode.marks.filter((m2) => m2.type !== "link");
26425
+ } else {
26426
+ linkNode.attrs.marksAsAttrs = linkNode.attrs.marksAsAttrs.filter((m2) => m2.type !== "link");
26427
+ }
26428
+ const outputNode = exportSchemaToJson({ ...params2, node: linkNode });
26429
+ if (outputNode) {
26430
+ if (outputNode instanceof Array) contentNodes.push(...outputNode);
26431
+ else contentNodes.push(outputNode);
26432
+ }
26433
+ });
26434
+ const newNode = {
26435
+ name: "w:hyperlink",
26436
+ type: "element",
26437
+ attributes: {
26438
+ ...linkAttrs
26439
+ },
26440
+ elements: contentNodes
26441
+ };
26442
+ return newNode;
26443
+ }
26444
+ function _addNewLinkRelationship(params2, link, rId) {
26445
+ if (!rId) rId = generateDocxRandomId();
26446
+ if (!params2.relationships || !Array.isArray(params2.relationships)) {
26447
+ params2.relationships = [];
26448
+ }
26449
+ const existingRel = params2.relationships.find(
26450
+ (rel) => rel.attributes && rel.attributes.Id === rId && rel.attributes.Target === link
26451
+ );
26452
+ if (existingRel) {
26453
+ return rId;
26454
+ }
26455
+ params2.relationships.push({
26456
+ type: "element",
26457
+ name: "Relationship",
26458
+ attributes: {
26459
+ Id: rId,
26460
+ Type: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",
26461
+ Target: link,
26462
+ TargetMode: "External"
26463
+ }
26464
+ });
26465
+ return rId;
26466
+ }
26467
+ const config$g = {
26468
+ xmlName: XML_NODE_NAME$i,
26469
+ sdNodeOrKeyName: SD_NODE_NAME$c,
26470
+ type: NodeTranslator.translatorTypes.NODE,
26471
+ encode: encode$s,
26472
+ decode: decode$s,
26473
+ attributes: validXmlAttributes$a
26474
+ };
26475
+ const translator$W = NodeTranslator.from(config$g);
26476
+ const encode$r = (attributes) => {
26231
26477
  return attributes["w:rsidR"];
26232
26478
  };
26233
- const decode$q = (attrs) => {
26479
+ const decode$r = (attrs) => {
26234
26480
  return attrs.rsidR;
26235
26481
  };
26236
26482
  const attrConfig$9 = Object.freeze({
26237
26483
  xmlName: "w:rsidR",
26238
26484
  sdName: "rsidR",
26239
- encode: encode$q,
26240
- decode: decode$q
26485
+ encode: encode$r,
26486
+ decode: decode$r
26241
26487
  });
26242
- const encode$p = (attributes) => {
26488
+ const encode$q = (attributes) => {
26243
26489
  return attributes["w:rsidRPr"];
26244
26490
  };
26245
- const decode$p = (attrs) => {
26491
+ const decode$q = (attrs) => {
26246
26492
  return attrs.rsidRPr;
26247
26493
  };
26248
26494
  const attrConfig$8 = Object.freeze({
26249
26495
  xmlName: "w:rsidRPr",
26250
26496
  sdName: "rsidRPr",
26251
- encode: encode$p,
26252
- decode: decode$p
26497
+ encode: encode$q,
26498
+ decode: decode$q
26253
26499
  });
26254
- const encode$o = (attributes) => {
26500
+ const encode$p = (attributes) => {
26255
26501
  return attributes["w:rsidDel"];
26256
26502
  };
26257
- const decode$o = (attrs) => {
26503
+ const decode$p = (attrs) => {
26258
26504
  return attrs.rsidDel;
26259
26505
  };
26260
26506
  const attrConfig$7 = Object.freeze({
26261
26507
  xmlName: "w:rsidDel",
26262
26508
  sdName: "rsidDel",
26263
- encode: encode$o,
26264
- decode: decode$o
26509
+ encode: encode$p,
26510
+ decode: decode$p
26265
26511
  });
26266
- const validXmlAttributes$a = [attrConfig$9, attrConfig$8, attrConfig$7];
26267
- const XML_NODE_NAME$g = "w:r";
26512
+ const validXmlAttributes$9 = [attrConfig$9, attrConfig$8, attrConfig$7];
26513
+ const XML_NODE_NAME$h = "w:r";
26268
26514
  const SD_KEY_NAME = "run";
26269
- const encode$n = (params2, encodedAttrs = {}) => {
26515
+ const encode$o = (params2, encodedAttrs = {}) => {
26270
26516
  const { nodes = [], nodeListHandler } = params2 || {};
26271
26517
  const runNode = nodes[0];
26272
26518
  if (!runNode) return void 0;
@@ -26314,9 +26560,11 @@ const encode$n = (params2, encodedAttrs = {}) => {
26314
26560
  }
26315
26561
  return runNodeResult;
26316
26562
  };
26317
- const decode$n = (params2, decodedAttrs = {}) => {
26563
+ const decode$o = (params2, decodedAttrs = {}) => {
26318
26564
  const { node } = params2 || {};
26319
26565
  if (!node) return void 0;
26566
+ const isLinkNode = node.marks?.some((m2) => m2.type === "link");
26567
+ if (isLinkNode) return translator$W.decode(params2);
26320
26568
  const { runNode: runNodeForExport, trackingMarksByType } = prepareRunTrackingContext(node);
26321
26569
  const runAttrs = runNodeForExport.attrs || {};
26322
26570
  const runProperties = Array.isArray(runAttrs.runProperties) ? runAttrs.runProperties : [];
@@ -26371,7 +26619,7 @@ const decode$n = (params2, decodedAttrs = {}) => {
26371
26619
  runs.push(trackedClone);
26372
26620
  return;
26373
26621
  }
26374
- const runWrapper = { name: XML_NODE_NAME$g, elements: [] };
26622
+ const runWrapper = { name: XML_NODE_NAME$h, elements: [] };
26375
26623
  applyBaseRunProps(runWrapper);
26376
26624
  if (!Array.isArray(runWrapper.elements)) runWrapper.elements = [];
26377
26625
  runWrapper.elements.push(cloneXmlNode(child));
@@ -26379,7 +26627,7 @@ const decode$n = (params2, decodedAttrs = {}) => {
26379
26627
  });
26380
26628
  const trackedRuns = ensureTrackedWrapper(runs, trackingMarksByType);
26381
26629
  if (!trackedRuns.length) {
26382
- const emptyRun = { name: XML_NODE_NAME$g, elements: [] };
26630
+ const emptyRun = { name: XML_NODE_NAME$h, elements: [] };
26383
26631
  applyBaseRunProps(emptyRun);
26384
26632
  trackedRuns.push(emptyRun);
26385
26633
  }
@@ -26393,148 +26641,15 @@ const decode$n = (params2, decodedAttrs = {}) => {
26393
26641
  }
26394
26642
  return trackedRuns;
26395
26643
  };
26396
- const config$e = {
26397
- xmlName: XML_NODE_NAME$g,
26644
+ const config$f = {
26645
+ xmlName: XML_NODE_NAME$h,
26398
26646
  sdNodeOrKeyName: SD_KEY_NAME,
26399
26647
  type: NodeTranslator.translatorTypes.NODE,
26400
- encode: encode$n,
26401
- decode: decode$n,
26402
- attributes: validXmlAttributes$a
26403
- };
26404
- const translator$U = NodeTranslator.from(config$e);
26405
- const generateV2HandlerEntity = (handlerName, translator2) => ({
26406
- handlerName,
26407
- handler: (params2) => {
26408
- const { nodes } = params2;
26409
- if (nodes.length === 0 || nodes[0].name !== translator2.xmlName) {
26410
- return { nodes: [], consumed: 0 };
26411
- }
26412
- const result = translator2.encode(params2);
26413
- if (!result) return { nodes: [], consumed: 0 };
26414
- return {
26415
- nodes: Array.isArray(result) ? result : [result],
26416
- consumed: 1
26417
- };
26418
- }
26419
- });
26420
- function createSingleAttrPropertyHandler(xmlName, sdName = null, attrName = "w:val", transformEncode = null, transformDecode = null) {
26421
- if (!sdName) sdName = xmlName.split(":")[1];
26422
- if (!transformEncode) transformEncode = (v2) => v2;
26423
- if (!transformDecode) transformDecode = (v2) => v2;
26424
- return {
26425
- xmlName,
26426
- sdNodeOrKeyName: sdName,
26427
- encode: ({ nodes }) => {
26428
- return transformEncode(nodes[0].attributes[attrName]) ?? void 0;
26429
- },
26430
- decode: ({ node }) => {
26431
- const value = node.attrs?.[sdName] != null ? transformDecode(node.attrs[sdName]) : void 0;
26432
- return value != null ? { name: xmlName, attributes: { [attrName]: value } } : void 0;
26433
- }
26434
- };
26435
- }
26436
- function createMeasurementPropertyHandler(xmlName, sdName = null) {
26437
- if (!sdName) sdName = xmlName.split(":")[1];
26438
- return {
26439
- xmlName,
26440
- sdNodeOrKeyName: sdName,
26441
- attributes: [
26442
- createAttributeHandler("w:w", "value", parseInteger, integerToString),
26443
- createAttributeHandler("w:type")
26444
- ],
26445
- encode: (_2, encodedAttrs) => {
26446
- return encodedAttrs["value"] != null ? encodedAttrs : void 0;
26447
- },
26448
- decode: function({ node }) {
26449
- const decodedAttrs = this.decodeAttributes({ node: { ...node, attrs: node.attrs[sdName] || {} } });
26450
- return decodedAttrs["w:w"] != null ? { attributes: decodedAttrs } : void 0;
26451
- }
26452
- };
26453
- }
26454
- function createBorderPropertyHandler(xmlName, sdName = null) {
26455
- if (!sdName) sdName = xmlName.split(":")[1];
26456
- return {
26457
- xmlName,
26458
- sdNodeOrKeyName: sdName,
26459
- attributes: [
26460
- createAttributeHandler("w:val"),
26461
- createAttributeHandler("w:color"),
26462
- createAttributeHandler("w:themeColor"),
26463
- createAttributeHandler("w:themeTint"),
26464
- createAttributeHandler("w:themeShade"),
26465
- createAttributeHandler("w:sz", "size", parseInteger, integerToString),
26466
- createAttributeHandler("w:space", null, parseInteger, integerToString),
26467
- createAttributeHandler("w:shadow", null, parseBoolean, booleanToString),
26468
- createAttributeHandler("w:frame", null, parseBoolean, booleanToString)
26469
- ],
26470
- encode: (params2, encodedAttrs) => {
26471
- return Object.keys(encodedAttrs).length > 0 ? encodedAttrs : void 0;
26472
- },
26473
- decode: function({ node }, context) {
26474
- const decodedAttrs = this.decodeAttributes({ node: { ...node, attrs: node.attrs[sdName] || {} } });
26475
- return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
26476
- }
26477
- };
26478
- }
26479
- const createAttributeHandler = (xmlName, sdName = null, transformEncode = null, transformDecode = null) => {
26480
- if (!transformEncode) transformEncode = (v2) => v2;
26481
- if (!transformDecode) transformDecode = (v2) => v2;
26482
- if (!sdName) sdName = xmlName.split(":")[1];
26483
- return {
26484
- xmlName,
26485
- sdName,
26486
- encode: (attributes) => transformEncode(attributes[xmlName]),
26487
- decode: (attributes) => transformDecode(attributes[sdName])
26488
- };
26489
- };
26490
- function encodeProperties(node, translatorsByXmlName, asArray = false) {
26491
- if (!node?.elements || node.elements.length === 0) {
26492
- return asArray ? [] : {};
26493
- }
26494
- const attributes = asArray ? [] : {};
26495
- node.elements.forEach((el) => {
26496
- const translator2 = translatorsByXmlName[el.name];
26497
- if (translator2) {
26498
- const encodedAttr = translator2.encode({ nodes: [el] });
26499
- if (encodedAttr != null) {
26500
- if (asArray) {
26501
- attributes.push({ [translator2.sdNodeOrKeyName]: encodedAttr });
26502
- } else {
26503
- attributes[translator2.sdNodeOrKeyName] = encodedAttr;
26504
- }
26505
- }
26506
- }
26507
- });
26508
- return attributes;
26509
- }
26510
- function decodeProperties(translatorsBySdName, properties) {
26511
- if (!properties || typeof properties !== "object") {
26512
- return [];
26513
- }
26514
- const elements = [];
26515
- Object.keys(properties).forEach((key2) => {
26516
- const translator2 = translatorsBySdName[key2];
26517
- if (translator2) {
26518
- const result = translator2.decode({ node: { attrs: { [key2]: properties[key2] } } });
26519
- if (result != null) {
26520
- result.name = translator2.xmlName;
26521
- elements.push(result);
26522
- }
26523
- }
26524
- });
26525
- return elements;
26526
- }
26527
- const parseBoolean = (value) => value != null ? ["1", "true"].includes(value) : void 0;
26528
- const booleanToString = (value) => value != null ? value ? "1" : "0" : void 0;
26529
- const parseInteger = (value) => {
26530
- if (value == null) return void 0;
26531
- const intValue = parseInt(value, 10);
26532
- return isNaN(intValue) ? void 0 : intValue;
26533
- };
26534
- const integerToString = (value) => {
26535
- const intValue = parseInteger(value);
26536
- return intValue != void 0 ? String(intValue) : void 0;
26648
+ encode: encode$o,
26649
+ decode: decode$o,
26650
+ attributes: validXmlAttributes$9
26537
26651
  };
26652
+ const translator$V = NodeTranslator.from(config$f);
26538
26653
  function preProcessVerticalMergeCells(table, { editorSchema }) {
26539
26654
  if (!table || !Array.isArray(table.content)) {
26540
26655
  return table;
@@ -26575,13 +26690,13 @@ function preProcessVerticalMergeCells(table, { editorSchema }) {
26575
26690
  }
26576
26691
  return table;
26577
26692
  }
26578
- const translator$T = NodeTranslator.from({
26693
+ const translator$U = NodeTranslator.from({
26579
26694
  xmlName: "w:cantSplit",
26580
26695
  sdNodeOrKeyName: "cantSplit",
26581
26696
  encode: ({ nodes }) => ["1", "true"].includes(nodes[0].attributes?.["w:val"] ?? "1"),
26582
26697
  decode: ({ node }) => node.attrs?.cantSplit ? { attributes: {} } : void 0
26583
26698
  });
26584
- const translator$S = NodeTranslator.from({
26699
+ const translator$T = NodeTranslator.from({
26585
26700
  xmlName: "w:cnfStyle",
26586
26701
  sdNodeOrKeyName: "cnfStyle",
26587
26702
  attributes: [
@@ -26607,8 +26722,8 @@ const translator$S = NodeTranslator.from({
26607
26722
  return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
26608
26723
  }
26609
26724
  });
26610
- const translator$R = NodeTranslator.from(createSingleAttrPropertyHandler("w:divId"));
26611
- const translator$Q = NodeTranslator.from(
26725
+ const translator$S = NodeTranslator.from(createSingleAttrPropertyHandler("w:divId"));
26726
+ const translator$R = NodeTranslator.from(
26612
26727
  createSingleAttrPropertyHandler(
26613
26728
  "w:gridAfter",
26614
26729
  null,
@@ -26617,7 +26732,7 @@ const translator$Q = NodeTranslator.from(
26617
26732
  (v2) => integerToString(v2)
26618
26733
  )
26619
26734
  );
26620
- const translator$P = NodeTranslator.from(
26735
+ const translator$Q = NodeTranslator.from(
26621
26736
  createSingleAttrPropertyHandler(
26622
26737
  "w:gridBefore",
26623
26738
  null,
@@ -26626,21 +26741,21 @@ const translator$P = NodeTranslator.from(
26626
26741
  (v2) => integerToString(v2)
26627
26742
  )
26628
26743
  );
26629
- const translator$O = NodeTranslator.from({
26744
+ const translator$P = NodeTranslator.from({
26630
26745
  xmlName: "w:hidden",
26631
26746
  sdNodeOrKeyName: "hidden",
26632
26747
  encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
26633
26748
  decode: ({ node }) => node.attrs.hidden ? { attributes: {} } : void 0
26634
26749
  });
26635
- const translator$N = NodeTranslator.from(createSingleAttrPropertyHandler("w:jc", "justification"));
26636
- const translator$M = NodeTranslator.from(createMeasurementPropertyHandler("w:tblCellSpacing", "tableCellSpacing"));
26637
- const translator$L = NodeTranslator.from({
26750
+ const translator$O = NodeTranslator.from(createSingleAttrPropertyHandler("w:jc", "justification"));
26751
+ const translator$N = NodeTranslator.from(createMeasurementPropertyHandler("w:tblCellSpacing", "tableCellSpacing"));
26752
+ const translator$M = NodeTranslator.from({
26638
26753
  xmlName: "w:tblHeader",
26639
26754
  sdNodeOrKeyName: "repeatHeader",
26640
26755
  encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
26641
26756
  decode: ({ node }) => node.attrs.repeatHeader ? { attributes: {} } : void 0
26642
26757
  });
26643
- const translator$K = NodeTranslator.from({
26758
+ const translator$L = NodeTranslator.from({
26644
26759
  xmlName: "w:trHeight",
26645
26760
  sdNodeOrKeyName: "rowHeight",
26646
26761
  encode: ({ nodes }) => {
@@ -26667,11 +26782,11 @@ const translator$K = NodeTranslator.from({
26667
26782
  return Object.keys(heightAttrs).length > 0 ? { attributes: heightAttrs } : void 0;
26668
26783
  }
26669
26784
  });
26670
- const translator$J = NodeTranslator.from(createMeasurementPropertyHandler("w:wAfter"));
26671
- const translator$I = NodeTranslator.from(createMeasurementPropertyHandler("w:wBefore"));
26672
- const XML_NODE_NAME$f = "w:trPr";
26785
+ const translator$K = NodeTranslator.from(createMeasurementPropertyHandler("w:wAfter"));
26786
+ const translator$J = NodeTranslator.from(createMeasurementPropertyHandler("w:wBefore"));
26787
+ const XML_NODE_NAME$g = "w:trPr";
26673
26788
  const SD_ATTR_KEY$4 = "tableRowProperties";
26674
- const encode$m = (params2) => {
26789
+ const encode$n = (params2) => {
26675
26790
  const { nodes } = params2;
26676
26791
  const node = nodes[0];
26677
26792
  let attributes = {
@@ -26685,12 +26800,12 @@ const encode$m = (params2) => {
26685
26800
  };
26686
26801
  return {
26687
26802
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
26688
- xmlName: XML_NODE_NAME$f,
26803
+ xmlName: XML_NODE_NAME$g,
26689
26804
  sdNodeOrKeyName: SD_ATTR_KEY$4,
26690
26805
  attributes
26691
26806
  };
26692
26807
  };
26693
- const decode$m = (params2) => {
26808
+ const decode$n = (params2) => {
26694
26809
  const { tableRowProperties = {} } = params2.node.attrs || {};
26695
26810
  const elements = decodeProperties(propertyTranslatorsBySdName$2, tableRowProperties);
26696
26811
  const newNode = {
@@ -26702,6 +26817,7 @@ const decode$m = (params2) => {
26702
26817
  return newNode;
26703
26818
  };
26704
26819
  const propertyTranslators$3 = [
26820
+ translator$U,
26705
26821
  translator$T,
26706
26822
  translator$S,
26707
26823
  translator$R,
@@ -26712,8 +26828,7 @@ const propertyTranslators$3 = [
26712
26828
  translator$M,
26713
26829
  translator$L,
26714
26830
  translator$K,
26715
- translator$J,
26716
- translator$I
26831
+ translator$J
26717
26832
  ];
26718
26833
  const propertyTranslatorsByXmlName$2 = {};
26719
26834
  propertyTranslators$3.forEach((translator2) => {
@@ -26723,25 +26838,25 @@ const propertyTranslatorsBySdName$2 = {};
26723
26838
  propertyTranslators$3.forEach((translator2) => {
26724
26839
  propertyTranslatorsBySdName$2[translator2.sdNodeOrKeyName] = translator2;
26725
26840
  });
26726
- const config$d = {
26727
- xmlName: XML_NODE_NAME$f,
26841
+ const config$e = {
26842
+ xmlName: XML_NODE_NAME$g,
26728
26843
  sdNodeOrKeyName: SD_ATTR_KEY$4,
26729
26844
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
26730
- encode: encode$m,
26731
- decode: decode$m
26845
+ encode: encode$n,
26846
+ decode: decode$n
26732
26847
  };
26733
- const translator$H = NodeTranslator.from(config$d);
26734
- const XML_NODE_NAME$e = "w:tr";
26735
- const SD_NODE_NAME$a = "tableRow";
26736
- const validXmlAttributes$9 = ["w:rsidDel", "w:rsidR", "w:rsidRPr", "w:rsidTr", "w14:paraId", "w14:textId"].map(
26848
+ const translator$I = NodeTranslator.from(config$e);
26849
+ const XML_NODE_NAME$f = "w:tr";
26850
+ const SD_NODE_NAME$b = "tableRow";
26851
+ const validXmlAttributes$8 = ["w:rsidDel", "w:rsidR", "w:rsidRPr", "w:rsidTr", "w14:paraId", "w14:textId"].map(
26737
26852
  (xmlName) => createAttributeHandler(xmlName)
26738
26853
  );
26739
- const encode$l = (params2, encodedAttrs) => {
26854
+ const encode$m = (params2, encodedAttrs) => {
26740
26855
  const { row } = params2.extraParams;
26741
26856
  let tableRowProperties = {};
26742
26857
  const tPr = row.elements.find((el) => el.name === "w:trPr");
26743
26858
  if (tPr) {
26744
- ({ attributes: tableRowProperties } = translator$H.encode({
26859
+ ({ attributes: tableRowProperties } = translator$I.encode({
26745
26860
  ...params2,
26746
26861
  nodes: [tPr]
26747
26862
  }));
@@ -26754,7 +26869,7 @@ const encode$l = (params2, encodedAttrs) => {
26754
26869
  let currentColumnIndex = 0;
26755
26870
  const content = cellNodes?.map((n) => {
26756
26871
  let columnWidth = gridColumnWidths?.[currentColumnIndex] || null;
26757
- const result = translator$8.encode({
26872
+ const result = translator$9.encode({
26758
26873
  ...params2,
26759
26874
  extraParams: {
26760
26875
  ...params2.extraParams,
@@ -26776,7 +26891,7 @@ const encode$l = (params2, encodedAttrs) => {
26776
26891
  };
26777
26892
  return newNode;
26778
26893
  };
26779
- const decode$l = (params2, decodedAttrs) => {
26894
+ const decode$m = (params2, decodedAttrs) => {
26780
26895
  const { node } = params2;
26781
26896
  const elements = translateChildNodes(params2);
26782
26897
  if (node.attrs?.tableRowProperties) {
@@ -26788,7 +26903,7 @@ const decode$l = (params2, decodedAttrs) => {
26788
26903
  }
26789
26904
  }
26790
26905
  tableRowProperties["cantSplit"] = node.attrs["cantSplit"];
26791
- const trPr = translator$H.decode({
26906
+ const trPr = translator$I.decode({
26792
26907
  ...params2,
26793
26908
  node: { ...node, attrs: { ...node.attrs, tableRowProperties } }
26794
26909
  });
@@ -26800,22 +26915,22 @@ const decode$l = (params2, decodedAttrs) => {
26800
26915
  elements
26801
26916
  };
26802
26917
  };
26803
- const config$c = {
26804
- xmlName: XML_NODE_NAME$e,
26805
- sdNodeOrKeyName: SD_NODE_NAME$a,
26918
+ const config$d = {
26919
+ xmlName: XML_NODE_NAME$f,
26920
+ sdNodeOrKeyName: SD_NODE_NAME$b,
26806
26921
  type: NodeTranslator.translatorTypes.NODE,
26807
- encode: encode$l,
26808
- decode: decode$l,
26809
- attributes: validXmlAttributes$9
26922
+ encode: encode$m,
26923
+ decode: decode$m,
26924
+ attributes: validXmlAttributes$8
26810
26925
  };
26811
- const translator$G = NodeTranslator.from(config$c);
26812
- const translator$F = NodeTranslator.from({
26926
+ const translator$H = NodeTranslator.from(config$d);
26927
+ const translator$G = NodeTranslator.from({
26813
26928
  xmlName: "w:bidiVisual",
26814
26929
  sdNodeOrKeyName: "rightToLeft",
26815
26930
  encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
26816
26931
  decode: ({ node }) => node.attrs.rightToLeft ? { attributes: {} } : void 0
26817
26932
  });
26818
- const translator$E = NodeTranslator.from({
26933
+ const translator$F = NodeTranslator.from({
26819
26934
  xmlName: "w:shd",
26820
26935
  sdNodeOrKeyName: "shading",
26821
26936
  attributes: [
@@ -26837,11 +26952,11 @@ const translator$E = NodeTranslator.from({
26837
26952
  return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
26838
26953
  }
26839
26954
  });
26840
- const translator$D = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblCaption", "caption"));
26841
- const translator$C = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblDescription", "description"));
26842
- const translator$B = NodeTranslator.from(createMeasurementPropertyHandler("w:tblInd", "tableIndent"));
26843
- const translator$A = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblLayout", "tableLayout", "w:type"));
26844
- const translator$z = NodeTranslator.from({
26955
+ const translator$E = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblCaption", "caption"));
26956
+ const translator$D = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblDescription", "description"));
26957
+ const translator$C = NodeTranslator.from(createMeasurementPropertyHandler("w:tblInd", "tableIndent"));
26958
+ const translator$B = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblLayout", "tableLayout", "w:type"));
26959
+ const translator$A = NodeTranslator.from({
26845
26960
  xmlName: "w:tblLook",
26846
26961
  sdNodeOrKeyName: "tblLook",
26847
26962
  attributes: ["w:firstColumn", "w:firstRow", "w:lastColumn", "w:lastRow", "w:noHBand", "w:noVBand"].map((attr) => createAttributeHandler(attr, null, parseBoolean, booleanToString)).concat([createAttributeHandler("w:val")]),
@@ -26853,16 +26968,16 @@ const translator$z = NodeTranslator.from({
26853
26968
  return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
26854
26969
  }
26855
26970
  });
26856
- const translator$y = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblOverlap", "overlap"));
26857
- const translator$x = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblStyle", "tableStyleId"));
26858
- const translator$w = NodeTranslator.from(
26971
+ const translator$z = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblOverlap", "overlap"));
26972
+ const translator$y = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblStyle", "tableStyleId"));
26973
+ const translator$x = NodeTranslator.from(
26859
26974
  createSingleAttrPropertyHandler("w:tblStyleColBandSize", "tableStyleColBandSize")
26860
26975
  );
26861
- const translator$v = NodeTranslator.from(
26976
+ const translator$w = NodeTranslator.from(
26862
26977
  createSingleAttrPropertyHandler("w:tblStyleRowBandSize", "tableStyleRowBandSize")
26863
26978
  );
26864
- const translator$u = NodeTranslator.from(createMeasurementPropertyHandler("w:tblW", "tableWidth"));
26865
- const translator$t = NodeTranslator.from({
26979
+ const translator$v = NodeTranslator.from(createMeasurementPropertyHandler("w:tblW", "tableWidth"));
26980
+ const translator$u = NodeTranslator.from({
26866
26981
  xmlName: "w:tblpPr",
26867
26982
  sdNodeOrKeyName: "floatingTableProperties",
26868
26983
  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))),
@@ -26874,29 +26989,29 @@ const translator$t = NodeTranslator.from({
26874
26989
  return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
26875
26990
  }
26876
26991
  });
26877
- const translator$s = NodeTranslator.from(createBorderPropertyHandler("w:bottom"));
26878
- const translator$r = NodeTranslator.from(createMeasurementPropertyHandler("w:bottom", "marginBottom"));
26879
- const translator$q = NodeTranslator.from(createBorderPropertyHandler("w:end"));
26880
- const translator$p = NodeTranslator.from(createMeasurementPropertyHandler("w:end", "marginEnd"));
26881
- const translator$o = NodeTranslator.from(createBorderPropertyHandler("w:insideH"));
26882
- const translator$n = NodeTranslator.from(createBorderPropertyHandler("w:insideV"));
26883
- const translator$m = NodeTranslator.from(createBorderPropertyHandler("w:left"));
26884
- const translator$l = NodeTranslator.from(createMeasurementPropertyHandler("w:left", "marginLeft"));
26885
- const translator$k = NodeTranslator.from(createBorderPropertyHandler("w:right"));
26886
- const translator$j = NodeTranslator.from(createMeasurementPropertyHandler("w:right", "marginRight"));
26887
- const translator$i = NodeTranslator.from(createBorderPropertyHandler("w:start"));
26888
- const translator$h = NodeTranslator.from(createMeasurementPropertyHandler("w:start", "marginStart"));
26889
- const translator$g = NodeTranslator.from(createBorderPropertyHandler("w:top"));
26890
- const translator$f = NodeTranslator.from(createMeasurementPropertyHandler("w:top", "marginTop"));
26891
- const XML_NODE_NAME$d = "w:tblBorders";
26992
+ const translator$t = NodeTranslator.from(createBorderPropertyHandler("w:bottom"));
26993
+ const translator$s = NodeTranslator.from(createMeasurementPropertyHandler("w:bottom", "marginBottom"));
26994
+ const translator$r = NodeTranslator.from(createBorderPropertyHandler("w:end"));
26995
+ const translator$q = NodeTranslator.from(createMeasurementPropertyHandler("w:end", "marginEnd"));
26996
+ const translator$p = NodeTranslator.from(createBorderPropertyHandler("w:insideH"));
26997
+ const translator$o = NodeTranslator.from(createBorderPropertyHandler("w:insideV"));
26998
+ const translator$n = NodeTranslator.from(createBorderPropertyHandler("w:left"));
26999
+ const translator$m = NodeTranslator.from(createMeasurementPropertyHandler("w:left", "marginLeft"));
27000
+ const translator$l = NodeTranslator.from(createBorderPropertyHandler("w:right"));
27001
+ const translator$k = NodeTranslator.from(createMeasurementPropertyHandler("w:right", "marginRight"));
27002
+ const translator$j = NodeTranslator.from(createBorderPropertyHandler("w:start"));
27003
+ const translator$i = NodeTranslator.from(createMeasurementPropertyHandler("w:start", "marginStart"));
27004
+ const translator$h = NodeTranslator.from(createBorderPropertyHandler("w:top"));
27005
+ const translator$g = NodeTranslator.from(createMeasurementPropertyHandler("w:top", "marginTop"));
27006
+ const XML_NODE_NAME$e = "w:tblBorders";
26892
27007
  const SD_ATTR_KEY$3 = "borders";
26893
- const encode$k = (params2) => {
27008
+ const encode$l = (params2) => {
26894
27009
  const { nodes } = params2;
26895
27010
  const node = nodes[0];
26896
27011
  const attributes = encodeProperties(node, tblBordersTranslatorsByXmlName);
26897
27012
  return Object.keys(attributes).length > 0 ? attributes : void 0;
26898
27013
  };
26899
- const decode$k = (params2) => {
27014
+ const decode$l = (params2) => {
26900
27015
  const { borders = {} } = params2.node.attrs || {};
26901
27016
  const elements = decodeProperties(tblBordersTranslatorsBySdName, borders);
26902
27017
  const newNode = {
@@ -26908,14 +27023,14 @@ const decode$k = (params2) => {
26908
27023
  return newNode;
26909
27024
  };
26910
27025
  const propertyTranslators$2 = [
26911
- translator$s,
26912
- translator$q,
27026
+ translator$t,
27027
+ translator$r,
27028
+ translator$p,
26913
27029
  translator$o,
26914
27030
  translator$n,
26915
- translator$m,
26916
- translator$k,
26917
- translator$i,
26918
- translator$g
27031
+ translator$l,
27032
+ translator$j,
27033
+ translator$h
26919
27034
  ];
26920
27035
  const tblBordersTranslatorsByXmlName = {};
26921
27036
  const tblBordersTranslatorsBySdName = {};
@@ -26923,27 +27038,27 @@ propertyTranslators$2.forEach((translator2) => {
26923
27038
  tblBordersTranslatorsByXmlName[translator2.xmlName] = translator2;
26924
27039
  tblBordersTranslatorsBySdName[translator2.sdNodeOrKeyName] = translator2;
26925
27040
  });
26926
- const translator$e = NodeTranslator.from({
26927
- xmlName: XML_NODE_NAME$d,
27041
+ const translator$f = NodeTranslator.from({
27042
+ xmlName: XML_NODE_NAME$e,
26928
27043
  sdNodeOrKeyName: SD_ATTR_KEY$3,
26929
27044
  type: NodeTranslator.translatorTypes.NODE,
26930
27045
  attributes: [],
26931
- encode: encode$k,
26932
- decode: decode$k
27046
+ encode: encode$l,
27047
+ decode: decode$l
26933
27048
  });
26934
- const XML_NODE_NAME$c = "w:tblCellMar";
27049
+ const XML_NODE_NAME$d = "w:tblCellMar";
26935
27050
  const SD_ATTR_KEY$2 = "cellMargins";
26936
- const encode$j = (params2) => {
27051
+ const encode$k = (params2) => {
26937
27052
  const { nodes } = params2;
26938
27053
  const node = nodes[0];
26939
27054
  const attributes = encodeProperties(node, propertyTranslatorsByXmlName$1);
26940
27055
  return Object.keys(attributes).length > 0 ? attributes : void 0;
26941
27056
  };
26942
- const decode$j = (params2) => {
27057
+ const decode$k = (params2) => {
26943
27058
  const { cellMargins = {} } = params2.node.attrs || {};
26944
27059
  const elements = decodeProperties(propertyTranslatorsBySdName$1, cellMargins);
26945
27060
  const newNode = {
26946
- name: XML_NODE_NAME$c,
27061
+ name: XML_NODE_NAME$d,
26947
27062
  type: "element",
26948
27063
  attributes: {},
26949
27064
  elements
@@ -26951,12 +27066,12 @@ const decode$j = (params2) => {
26951
27066
  return newNode;
26952
27067
  };
26953
27068
  const propertyTranslators$1 = [
26954
- translator$r,
26955
- translator$p,
26956
- translator$l,
26957
- translator$j,
26958
- translator$h,
26959
- translator$f
27069
+ translator$s,
27070
+ translator$q,
27071
+ translator$m,
27072
+ translator$k,
27073
+ translator$i,
27074
+ translator$g
26960
27075
  ];
26961
27076
  const propertyTranslatorsByXmlName$1 = {};
26962
27077
  const propertyTranslatorsBySdName$1 = {};
@@ -26964,27 +27079,27 @@ propertyTranslators$1.forEach((translator2) => {
26964
27079
  propertyTranslatorsByXmlName$1[translator2.xmlName] = translator2;
26965
27080
  propertyTranslatorsBySdName$1[translator2.sdNodeOrKeyName] = translator2;
26966
27081
  });
26967
- const translator$d = NodeTranslator.from({
26968
- xmlName: XML_NODE_NAME$c,
27082
+ const translator$e = NodeTranslator.from({
27083
+ xmlName: XML_NODE_NAME$d,
26969
27084
  sdNodeOrKeyName: SD_ATTR_KEY$2,
26970
27085
  type: NodeTranslator.translatorTypes.NODE,
26971
27086
  attributes: [],
26972
- encode: encode$j,
26973
- decode: decode$j
27087
+ encode: encode$k,
27088
+ decode: decode$k
26974
27089
  });
26975
- const XML_NODE_NAME$b = "w:tblPr";
27090
+ const XML_NODE_NAME$c = "w:tblPr";
26976
27091
  const SD_ATTR_KEY$1 = "tableProperties";
26977
- const encode$i = (params2) => {
27092
+ const encode$j = (params2) => {
26978
27093
  const { nodes } = params2;
26979
27094
  const node = nodes[0];
26980
27095
  const attributes = encodeProperties(node, propertyTranslatorsByXmlName);
26981
27096
  return {
26982
- xmlName: XML_NODE_NAME$b,
27097
+ xmlName: XML_NODE_NAME$c,
26983
27098
  sdNodeOrKeyName: SD_ATTR_KEY$1,
26984
27099
  attributes
26985
27100
  };
26986
27101
  };
26987
- const decode$i = (params2) => {
27102
+ const decode$j = (params2) => {
26988
27103
  const { tableProperties = {} } = params2.node.attrs || {};
26989
27104
  const elements = decodeProperties(propertyTranslatorsBySdName, tableProperties);
26990
27105
  const newNode = {
@@ -26996,11 +27111,12 @@ const decode$i = (params2) => {
26996
27111
  return newNode;
26997
27112
  };
26998
27113
  const propertyTranslators = [
27114
+ translator$G,
27115
+ translator$O,
26999
27116
  translator$F,
27000
- translator$N,
27001
27117
  translator$E,
27118
+ translator$N,
27002
27119
  translator$D,
27003
- translator$M,
27004
27120
  translator$C,
27005
27121
  translator$B,
27006
27122
  translator$A,
@@ -27010,9 +27126,8 @@ const propertyTranslators = [
27010
27126
  translator$w,
27011
27127
  translator$v,
27012
27128
  translator$u,
27013
- translator$t,
27014
- translator$e,
27015
- translator$d
27129
+ translator$f,
27130
+ translator$e
27016
27131
  ];
27017
27132
  const propertyTranslatorsByXmlName = {};
27018
27133
  const propertyTranslatorsBySdName = {};
@@ -27020,14 +27135,14 @@ propertyTranslators.forEach((translator2) => {
27020
27135
  propertyTranslatorsByXmlName[translator2.xmlName] = translator2;
27021
27136
  propertyTranslatorsBySdName[translator2.sdNodeOrKeyName] = translator2;
27022
27137
  });
27023
- const config$b = {
27024
- xmlName: XML_NODE_NAME$b,
27138
+ const config$c = {
27139
+ xmlName: XML_NODE_NAME$c,
27025
27140
  sdNodeOrKeyName: SD_ATTR_KEY$1,
27026
- encode: encode$i,
27027
- decode: decode$i
27141
+ encode: encode$j,
27142
+ decode: decode$j
27028
27143
  };
27029
- const translator$c = NodeTranslator.from(config$b);
27030
- const translator$b = NodeTranslator.from(
27144
+ const translator$d = NodeTranslator.from(config$c);
27145
+ const translator$c = NodeTranslator.from(
27031
27146
  createSingleAttrPropertyHandler("w:gridCol", "col", "w:w", parseInteger, integerToString)
27032
27147
  );
27033
27148
  const DEFAULT_COLUMN_WIDTH_PX = 100;
@@ -27077,20 +27192,20 @@ const resolveFallbackColumnWidthTwips = (params2, totalColumns, cellMinWidthTwip
27077
27192
  }
27078
27193
  return Math.max(fallbackWidthTwips, cellMinWidthTwips);
27079
27194
  };
27080
- const XML_NODE_NAME$a = "w:tblGrid";
27195
+ const XML_NODE_NAME$b = "w:tblGrid";
27081
27196
  const SD_ATTR_KEY = "grid";
27082
27197
  const cellMinWidth = pixelsToTwips(10);
27083
- const encode$h = (params2) => {
27198
+ const encode$i = (params2) => {
27084
27199
  const { nodes } = params2;
27085
27200
  const node = nodes[0];
27086
- const attributes = encodeProperties(node, { [translator$b.xmlName]: translator$b }, true);
27201
+ const attributes = encodeProperties(node, { [translator$c.xmlName]: translator$c }, true);
27087
27202
  return {
27088
- xmlName: XML_NODE_NAME$a,
27203
+ xmlName: XML_NODE_NAME$b,
27089
27204
  sdNodeOrKeyName: SD_ATTR_KEY,
27090
27205
  attributes
27091
27206
  };
27092
27207
  };
27093
- const decode$h = (params2) => {
27208
+ const decode$i = (params2) => {
27094
27209
  const { grid: rawGrid } = params2.node.attrs || {};
27095
27210
  const grid = Array.isArray(rawGrid) ? rawGrid : [];
27096
27211
  const { firstRow = {} } = params2.extraParams || {};
@@ -27109,10 +27224,10 @@ const decode$h = (params2) => {
27109
27224
  numericWidth = fallbackColumnWidthTwips;
27110
27225
  }
27111
27226
  numericWidth = Math.max(numericWidth, cellMinWidth);
27112
- const decoded = translator$b.decode({
27227
+ const decoded = translator$c.decode({
27113
27228
  node: { type: (
27114
27229
  /** @type {string} */
27115
- translator$b.sdNodeOrKeyName
27230
+ translator$c.sdNodeOrKeyName
27116
27231
  ), attrs: { col: numericWidth } }
27117
27232
  });
27118
27233
  if (decoded) elements.push(decoded);
@@ -27147,19 +27262,19 @@ const decode$h = (params2) => {
27147
27262
  columnIndex++;
27148
27263
  }
27149
27264
  const newNode = {
27150
- name: XML_NODE_NAME$a,
27265
+ name: XML_NODE_NAME$b,
27151
27266
  attributes: {},
27152
27267
  elements
27153
27268
  };
27154
27269
  return newNode;
27155
27270
  };
27156
- const config$a = {
27157
- xmlName: XML_NODE_NAME$a,
27271
+ const config$b = {
27272
+ xmlName: XML_NODE_NAME$b,
27158
27273
  sdNodeOrKeyName: SD_ATTR_KEY,
27159
- encode: encode$h,
27160
- decode: decode$h
27274
+ encode: encode$i,
27275
+ decode: decode$i
27161
27276
  };
27162
- const translator$a = NodeTranslator.from(config$a);
27277
+ const translator$b = NodeTranslator.from(config$b);
27163
27278
  const DEFAULT_PAGE_WIDTH_TWIPS = 12240;
27164
27279
  const DEFAULT_PAGE_MARGIN_TWIPS = 1440;
27165
27280
  const DEFAULT_CONTENT_WIDTH_TWIPS = DEFAULT_PAGE_WIDTH_TWIPS - 2 * DEFAULT_PAGE_MARGIN_TWIPS;
@@ -27222,19 +27337,19 @@ const buildFallbackGridForTable = ({ params: params2, rows, tableWidth, tableWid
27222
27337
  columnWidths: Array(columnCount).fill(fallbackColumnWidthPx)
27223
27338
  };
27224
27339
  };
27225
- const XML_NODE_NAME$9 = "w:tbl";
27226
- const SD_NODE_NAME$9 = "table";
27227
- const encode$g = (params2, encodedAttrs) => {
27340
+ const XML_NODE_NAME$a = "w:tbl";
27341
+ const SD_NODE_NAME$a = "table";
27342
+ const encode$h = (params2, encodedAttrs) => {
27228
27343
  const { nodes } = params2;
27229
27344
  const node = nodes[0];
27230
27345
  const tblPr = node.elements.find((el) => el.name === "w:tblPr");
27231
27346
  if (tblPr) {
27232
- const encodedProperties = translator$c.encode({ ...params2, nodes: [tblPr] });
27347
+ const encodedProperties = translator$d.encode({ ...params2, nodes: [tblPr] });
27233
27348
  encodedAttrs["tableProperties"] = encodedProperties?.attributes || {};
27234
27349
  }
27235
27350
  const tblGrid = node.elements.find((el) => el.name === "w:tblGrid");
27236
27351
  if (tblGrid) {
27237
- encodedAttrs["grid"] = translator$a.encode({ ...params2, nodes: [tblGrid] }).attributes;
27352
+ encodedAttrs["grid"] = translator$b.encode({ ...params2, nodes: [tblGrid] }).attributes;
27238
27353
  }
27239
27354
  [
27240
27355
  "tableStyleId",
@@ -27301,7 +27416,7 @@ const encode$g = (params2, encodedAttrs) => {
27301
27416
  }
27302
27417
  const content = [];
27303
27418
  rows.forEach((row) => {
27304
- const result = translator$G.encode({
27419
+ const result = translator$H.encode({
27305
27420
  ...params2,
27306
27421
  nodes: [row],
27307
27422
  extraParams: {
@@ -27320,13 +27435,13 @@ const encode$g = (params2, encodedAttrs) => {
27320
27435
  attrs: encodedAttrs
27321
27436
  };
27322
27437
  };
27323
- const decode$g = (params2, decodedAttrs) => {
27438
+ const decode$h = (params2, decodedAttrs) => {
27324
27439
  params2.node = preProcessVerticalMergeCells(params2.node, params2);
27325
27440
  const { node } = params2;
27326
27441
  const elements = translateChildNodes(params2);
27327
27442
  const firstRow = node.content?.find((n) => n.type === "tableRow");
27328
27443
  const properties = node.attrs.grid;
27329
- const element = translator$a.decode({
27444
+ const element = translator$b.decode({
27330
27445
  ...params2,
27331
27446
  node: { ...node, attrs: { ...node.attrs, grid: properties } },
27332
27447
  extraParams: {
@@ -27336,7 +27451,7 @@ const decode$g = (params2, decodedAttrs) => {
27336
27451
  if (element) elements.unshift(element);
27337
27452
  if (node.attrs?.tableProperties) {
27338
27453
  const properties2 = { ...node.attrs.tableProperties };
27339
- const element2 = translator$c.decode({
27454
+ const element2 = translator$d.decode({
27340
27455
  ...params2,
27341
27456
  node: { ...node, attrs: { ...node.attrs, tableProperties: properties2 } }
27342
27457
  });
@@ -27402,7 +27517,7 @@ function _getReferencedTableStyles(tableStyleReference, params2) {
27402
27517
  if (baseTblPr && baseTblPr.elements) {
27403
27518
  tblPr.elements.push(...baseTblPr.elements);
27404
27519
  }
27405
- const tableProperties = translator$c.encode({ ...params2, nodes: [tblPr] }).attributes;
27520
+ const tableProperties = translator$d.encode({ ...params2, nodes: [tblPr] }).attributes;
27406
27521
  const { borders, rowBorders } = _processTableBorders(tableProperties.borders || {});
27407
27522
  if (borders) stylesToReturn.borders = borders;
27408
27523
  if (rowBorders) stylesToReturn.rowBorders = rowBorders;
@@ -27419,16 +27534,16 @@ function _getReferencedTableStyles(tableStyleReference, params2) {
27419
27534
  }
27420
27535
  return stylesToReturn;
27421
27536
  }
27422
- const config$9 = {
27423
- xmlName: XML_NODE_NAME$9,
27424
- sdNodeOrKeyName: SD_NODE_NAME$9,
27537
+ const config$a = {
27538
+ xmlName: XML_NODE_NAME$a,
27539
+ sdNodeOrKeyName: SD_NODE_NAME$a,
27425
27540
  type: NodeTranslator.translatorTypes.NODE,
27426
- encode: encode$g,
27427
- decode: decode$g,
27541
+ encode: encode$h,
27542
+ decode: decode$h,
27428
27543
  attributes: []
27429
27544
  };
27430
- const translator$9 = NodeTranslator.from(config$9);
27431
- const tableNodeHandlerEntity = generateV2HandlerEntity("tableNodeHandler", translator$9);
27545
+ const translator$a = NodeTranslator.from(config$a);
27546
+ const tableNodeHandlerEntity = generateV2HandlerEntity("tableNodeHandler", translator$a);
27432
27547
  function getReferencedTableStyles(tblStyleTag, docx) {
27433
27548
  if (!tblStyleTag) return null;
27434
27549
  const stylesToReturn = {};
@@ -27790,10 +27905,10 @@ function generateCellMargins(cellMargins) {
27790
27905
  if (left2 != null) elements.push({ name: "w:left", attributes: { "w:w": pixelsToTwips(left2) } });
27791
27906
  return elements;
27792
27907
  }
27793
- const XML_NODE_NAME$8 = "w:tc";
27794
- const SD_NODE_NAME$8 = "tableCell";
27795
- const validXmlAttributes$8 = [];
27796
- function encode$f(params2, encodedAttrs) {
27908
+ const XML_NODE_NAME$9 = "w:tc";
27909
+ const SD_NODE_NAME$9 = "tableCell";
27910
+ const validXmlAttributes$7 = [];
27911
+ function encode$g(params2, encodedAttrs) {
27797
27912
  const {
27798
27913
  node,
27799
27914
  table,
@@ -27820,162 +27935,22 @@ function encode$f(params2, encodedAttrs) {
27820
27935
  }
27821
27936
  return schemaNode;
27822
27937
  }
27823
- function decode$f(params2, decodedAttrs) {
27938
+ function decode$g(params2, decodedAttrs) {
27824
27939
  const translated = translateTableCell(params2);
27825
27940
  if (decodedAttrs && Object.keys(decodedAttrs).length) {
27826
27941
  translated.attributes = { ...translated.attributes || {}, ...decodedAttrs };
27827
27942
  }
27828
27943
  return translated;
27829
27944
  }
27830
- const config$8 = {
27831
- xmlName: XML_NODE_NAME$8,
27832
- sdNodeOrKeyName: SD_NODE_NAME$8,
27833
- type: NodeTranslator.translatorTypes.NODE,
27834
- encode: encode$f,
27835
- decode: decode$f,
27836
- attributes: validXmlAttributes$8
27837
- };
27838
- const translator$8 = NodeTranslator.from(config$8);
27839
- const XML_NODE_NAME$7 = "w:hyperlink";
27840
- const SD_NODE_NAME$7 = "link";
27841
- const _createAttributeHandler = (xmlName, sdName) => ({
27842
- xmlName,
27843
- sdName,
27844
- encode: (attributes) => attributes[xmlName],
27845
- decode: (attributes) => attributes[sdName]
27846
- });
27847
- const validXmlAttributes$7 = [
27848
- _createAttributeHandler("w:anchor", "anchor"),
27849
- _createAttributeHandler("w:docLocation", "docLocation"),
27850
- {
27851
- xmlName: "w:history",
27852
- sdName: "history",
27853
- encode: (attributes) => attributes["w:history"] === "1" || attributes["w:history"] === "true",
27854
- decode: (attributes) => attributes["history"] ? "1" : "0"
27855
- },
27856
- _createAttributeHandler("w:tooltip", "tooltip"),
27857
- _createAttributeHandler("r:id", "rId"),
27858
- _createAttributeHandler("w:tgtFrame", "target")
27859
- ];
27860
- const encode$e = (params2, encodedAttrs) => {
27861
- const { nodes, docx, nodeListHandler } = params2;
27862
- const node = nodes[0];
27863
- let href = _resolveHref(docx, encodedAttrs);
27864
- const linkMark = { attrs: { ...encodedAttrs, href } };
27865
- const runNodes = node.elements.filter((el) => el.name === "w:r");
27866
- runNodes.forEach((runNode) => {
27867
- const existingRunMarks = Array.isArray(runNode.marks) ? runNode.marks : [];
27868
- const runMarksWithoutLink = existingRunMarks.filter((mark) => mark?.type !== "link");
27869
- runNode.marks = runMarksWithoutLink;
27870
- });
27871
- const updatedNode = nodeListHandler.handler({
27872
- ...params2,
27873
- nodes: runNodes,
27874
- path: [...params2.path || [], node]
27875
- });
27876
- const cloneMark2 = (mark) => {
27877
- if (!mark || typeof mark !== "object") return mark;
27878
- if (!mark.attrs) return { ...mark };
27879
- return { ...mark, attrs: { ...mark.attrs } };
27880
- };
27881
- const ensureLinkMark = (child) => {
27882
- if (!child || typeof child !== "object") return child;
27883
- if (Array.isArray(child.content)) {
27884
- const updatedContent = child.content.map((item) => ensureLinkMark(item));
27885
- if (updatedContent !== child.content) {
27886
- child = { ...child, content: updatedContent };
27887
- }
27888
- }
27889
- if (child.type === "run") {
27890
- const existingMarks2 = Array.isArray(child.marks) ? child.marks : [];
27891
- const filteredMarks = existingMarks2.filter((mark) => mark?.type !== "link").map((mark) => cloneMark2(mark));
27892
- if (filteredMarks.length !== existingMarks2.length) {
27893
- if (filteredMarks.length) child = { ...child, marks: filteredMarks };
27894
- else {
27895
- const { marks: _removedMarks, ...rest } = child;
27896
- child = rest;
27897
- }
27898
- }
27899
- return child;
27900
- }
27901
- if (child.type !== "text") return child;
27902
- const existingMarks = Array.isArray(child.marks) ? child.marks.map((mark) => cloneMark2(mark)) : [];
27903
- const hasLink = existingMarks.some((mark) => mark?.type === "link");
27904
- if (hasLink) return child;
27905
- const linkClone = { type: "link", attrs: { ...linkMark.attrs } };
27906
- return { ...child, marks: [...existingMarks, linkClone] };
27907
- };
27908
- if (!Array.isArray(updatedNode)) return updatedNode;
27909
- return updatedNode.map((child) => ensureLinkMark(child));
27910
- };
27911
- const _resolveHref = (docx, encodedAttrs) => {
27912
- const rels = docx["word/_rels/document.xml.rels"];
27913
- const relationships = rels.elements.find((el) => el.name === "Relationships");
27914
- const { elements } = relationships;
27915
- const { rId, anchor } = encodedAttrs;
27916
- let href;
27917
- if (!rId && anchor) {
27918
- href = `#${anchor}`;
27919
- } else if (rId) {
27920
- const rel = elements.find((el) => el.attributes["Id"] === rId) || {};
27921
- const { attributes: relAttributes = {} } = rel;
27922
- href = relAttributes["Target"];
27923
- }
27924
- return href;
27925
- };
27926
- function decode$e(params2) {
27927
- const { node } = params2;
27928
- const linkMark = node.marks.find((m2) => m2.type === "link");
27929
- const linkAttrs = this.decodeAttributes({ ...params2, node: linkMark });
27930
- let { anchor, href: link } = linkMark.attrs;
27931
- const isExternalLink = !anchor;
27932
- if (isExternalLink) {
27933
- linkAttrs["r:id"] = _addNewLinkRelationship(params2, link, linkAttrs["r:id"]);
27934
- }
27935
- node.marks = node.marks.filter((m2) => m2.type !== "link");
27936
- const outputNode = exportSchemaToJson({ ...params2, node });
27937
- const newNode = {
27938
- name: "w:hyperlink",
27939
- type: "element",
27940
- attributes: {
27941
- ...linkAttrs
27942
- },
27943
- elements: [outputNode]
27944
- };
27945
- return newNode;
27946
- }
27947
- function _addNewLinkRelationship(params2, link, rId) {
27948
- if (!rId) rId = generateDocxRandomId();
27949
- if (!params2.relationships || !Array.isArray(params2.relationships)) {
27950
- params2.relationships = [];
27951
- }
27952
- const existingRel = params2.relationships.find(
27953
- (rel) => rel.attributes && rel.attributes.Id === rId && rel.attributes.Target === link
27954
- );
27955
- if (existingRel) {
27956
- return rId;
27957
- }
27958
- params2.relationships.push({
27959
- type: "element",
27960
- name: "Relationship",
27961
- attributes: {
27962
- Id: rId,
27963
- Type: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",
27964
- Target: link,
27965
- TargetMode: "External"
27966
- }
27967
- });
27968
- return rId;
27969
- }
27970
- const config$7 = {
27971
- xmlName: XML_NODE_NAME$7,
27972
- sdNodeOrKeyName: SD_NODE_NAME$7,
27945
+ const config$9 = {
27946
+ xmlName: XML_NODE_NAME$9,
27947
+ sdNodeOrKeyName: SD_NODE_NAME$9,
27973
27948
  type: NodeTranslator.translatorTypes.NODE,
27974
- encode: encode$e,
27975
- decode: decode$e,
27949
+ encode: encode$g,
27950
+ decode: decode$g,
27976
27951
  attributes: validXmlAttributes$7
27977
27952
  };
27978
- const translator$7 = NodeTranslator.from(config$7);
27953
+ const translator$9 = NodeTranslator.from(config$9);
27979
27954
  function parseTagValueJSON(json) {
27980
27955
  if (typeof json !== "string") {
27981
27956
  return {};
@@ -28111,12 +28086,32 @@ function handleDocPartObj(params2) {
28111
28086
  }
28112
28087
  const content = node?.elements.find((el) => el.name === "w:sdtContent");
28113
28088
  const handler2 = validGalleryTypeMap[docPartGalleryType];
28114
- const result = handler2({ ...params2, nodes: [content] });
28089
+ const result = handler2({
28090
+ ...params2,
28091
+ nodes: [content],
28092
+ extraParams: { ...params2.extraParams || {}, sdtPr }
28093
+ });
28115
28094
  return result;
28116
28095
  }
28117
28096
  const tableOfContentsHandler = (params2) => {
28118
28097
  const node = params2.nodes[0];
28119
- return params2.nodeListHandler.handler({ ...params2, nodes: node.elements });
28098
+ const translatedContent = params2.nodeListHandler.handler({
28099
+ ...params2,
28100
+ nodes: node.elements,
28101
+ path: [...params2.path || [], node]
28102
+ });
28103
+ const sdtPr = params2.extraParams.sdtPr;
28104
+ const id = sdtPr.elements?.find((el) => el.name === "w:id")?.attributes["w:val"] || "";
28105
+ const result = {
28106
+ type: "documentPartObject",
28107
+ content: translatedContent,
28108
+ attrs: {
28109
+ id,
28110
+ docPartGallery: "Table of Contents",
28111
+ docPartUnique: true
28112
+ }
28113
+ };
28114
+ return result;
28120
28115
  };
28121
28116
  const validGalleryTypeMap = {
28122
28117
  "Table of Contents": tableOfContentsHandler
@@ -28774,32 +28769,32 @@ function translateAnchorNode(params2) {
28774
28769
  elements: [...anchorElements, ...elementsWithWrap]
28775
28770
  };
28776
28771
  }
28777
- const XML_NODE_NAME$6 = "wp:anchor";
28778
- const SD_NODE_NAME$6 = ["image"];
28772
+ const XML_NODE_NAME$8 = "wp:anchor";
28773
+ const SD_NODE_NAME$8 = ["image"];
28779
28774
  const validXmlAttributes$6 = ["distT", "distB", "distL", "distR"].map((xmlName) => createAttributeHandler(xmlName));
28780
- function encode$d(params2) {
28775
+ function encode$f(params2) {
28781
28776
  const { node } = params2.extraParams;
28782
28777
  if (!node || !node.type) {
28783
28778
  return null;
28784
28779
  }
28785
28780
  return handleAnchorNode(params2);
28786
28781
  }
28787
- function decode$d(params2) {
28782
+ function decode$f(params2) {
28788
28783
  const { node } = params2;
28789
28784
  if (!node || !node.type) {
28790
28785
  return null;
28791
28786
  }
28792
28787
  return translateAnchorNode(params2);
28793
28788
  }
28794
- const config$6 = {
28795
- xmlName: XML_NODE_NAME$6,
28796
- sdNodeOrKeyName: SD_NODE_NAME$6,
28789
+ const config$8 = {
28790
+ xmlName: XML_NODE_NAME$8,
28791
+ sdNodeOrKeyName: SD_NODE_NAME$8,
28797
28792
  type: NodeTranslator.translatorTypes.NODE,
28798
- encode: encode$d,
28799
- decode: decode$d,
28793
+ encode: encode$f,
28794
+ decode: decode$f,
28800
28795
  attributes: validXmlAttributes$6
28801
28796
  };
28802
- const translator$6 = NodeTranslator.from(config$6);
28797
+ const translator$8 = NodeTranslator.from(config$8);
28803
28798
  function handleInlineNode(params2) {
28804
28799
  const { node } = params2.extraParams;
28805
28800
  if (node.name !== "wp:inline") {
@@ -28815,41 +28810,41 @@ function translateInlineNode(params2) {
28815
28810
  elements: nodeElements.elements
28816
28811
  };
28817
28812
  }
28818
- const XML_NODE_NAME$5 = "wp:inline";
28819
- const SD_NODE_NAME$5 = ["image"];
28813
+ const XML_NODE_NAME$7 = "wp:inline";
28814
+ const SD_NODE_NAME$7 = ["image"];
28820
28815
  const validXmlAttributes$5 = ["distT", "distB", "distL", "distR"].map((xmlName) => createAttributeHandler(xmlName));
28821
- function encode$c(params2) {
28816
+ function encode$e(params2) {
28822
28817
  const { node } = params2.extraParams;
28823
28818
  if (!node || !node.type) {
28824
28819
  return null;
28825
28820
  }
28826
28821
  return handleInlineNode(params2);
28827
28822
  }
28828
- function decode$c(params2) {
28823
+ function decode$e(params2) {
28829
28824
  const { node } = params2;
28830
28825
  if (!node || !node.type) {
28831
28826
  return null;
28832
28827
  }
28833
28828
  return translateInlineNode(params2);
28834
28829
  }
28835
- const config$5 = {
28836
- xmlName: XML_NODE_NAME$5,
28837
- sdNodeOrKeyName: SD_NODE_NAME$5,
28830
+ const config$7 = {
28831
+ xmlName: XML_NODE_NAME$7,
28832
+ sdNodeOrKeyName: SD_NODE_NAME$7,
28838
28833
  type: NodeTranslator.translatorTypes.NODE,
28839
- encode: encode$c,
28840
- decode: decode$c,
28834
+ encode: encode$e,
28835
+ decode: decode$e,
28841
28836
  attributes: validXmlAttributes$5
28842
28837
  };
28843
- const translator$5 = NodeTranslator.from(config$5);
28844
- const XML_NODE_NAME$4 = "w:drawing";
28845
- const SD_NODE_NAME$4 = [];
28838
+ const translator$7 = NodeTranslator.from(config$7);
28839
+ const XML_NODE_NAME$6 = "w:drawing";
28840
+ const SD_NODE_NAME$6 = [];
28846
28841
  const validXmlAttributes$4 = [];
28847
- function encode$b(params2) {
28842
+ function encode$d(params2) {
28848
28843
  const nodes = params2.nodes;
28849
28844
  const node = nodes[0];
28850
28845
  const translatorByChildName = {
28851
- "wp:anchor": translator$6,
28852
- "wp:inline": translator$5
28846
+ "wp:anchor": translator$8,
28847
+ "wp:inline": translator$7
28853
28848
  };
28854
28849
  return node.elements.reduce((acc, child) => {
28855
28850
  if (acc) return acc;
@@ -28858,12 +28853,12 @@ function encode$b(params2) {
28858
28853
  return translator2.encode({ ...params2, extraParams: { node: child } }) || acc;
28859
28854
  }, null);
28860
28855
  }
28861
- function decode$b(params2) {
28856
+ function decode$d(params2) {
28862
28857
  const { node } = params2;
28863
28858
  if (!node || !node.type) {
28864
28859
  return null;
28865
28860
  }
28866
- const childTranslator = node.attrs.isAnchor ? translator$6 : translator$5;
28861
+ const childTranslator = node.attrs.isAnchor ? translator$8 : translator$7;
28867
28862
  const resultNode = childTranslator.decode(params2);
28868
28863
  return wrapTextInRun(
28869
28864
  {
@@ -28873,15 +28868,15 @@ function decode$b(params2) {
28873
28868
  []
28874
28869
  );
28875
28870
  }
28876
- const config$4 = {
28877
- xmlName: XML_NODE_NAME$4,
28878
- sdNodeOrKeyName: SD_NODE_NAME$4,
28871
+ const config$6 = {
28872
+ xmlName: XML_NODE_NAME$6,
28873
+ sdNodeOrKeyName: SD_NODE_NAME$6,
28879
28874
  type: NodeTranslator.translatorTypes.NODE,
28880
- encode: encode$b,
28881
- decode: decode$b,
28875
+ encode: encode$d,
28876
+ decode: decode$d,
28882
28877
  attributes: validXmlAttributes$4
28883
28878
  };
28884
- const translator$4 = NodeTranslator.from(config$4);
28879
+ const translator$6 = NodeTranslator.from(config$6);
28885
28880
  class CommandService {
28886
28881
  /**
28887
28882
  * @param {import('./commands/types/index.js').CommandServiceOptions} props
@@ -30219,7 +30214,7 @@ function prepareTextAnnotation(params2) {
30219
30214
  return getTextNodeForExport(attrs.displayLabel, [...marks, ...marksFromAttrs], params2);
30220
30215
  }
30221
30216
  function prepareImageAnnotation(params2, imageSize) {
30222
- return translator$4.decode({
30217
+ return translator$6.decode({
30223
30218
  ...params2,
30224
30219
  imageSize
30225
30220
  });
@@ -30439,6 +30434,49 @@ const generateSdtPrTagForDocumentSection = (id, title, tag) => {
30439
30434
  ]
30440
30435
  };
30441
30436
  };
30437
+ function translateDocumentPartObj(params2) {
30438
+ const { node } = params2;
30439
+ const { attrs = {} } = node;
30440
+ const childContent = translateChildNodes({ ...params2, nodes: node.content });
30441
+ const nodeElements = [
30442
+ {
30443
+ name: "w:sdtPr",
30444
+ elements: [
30445
+ {
30446
+ name: "w:id",
30447
+ attributes: {
30448
+ "w:val": attrs.id
30449
+ }
30450
+ },
30451
+ {
30452
+ name: "w:docPartObj",
30453
+ elements: [
30454
+ {
30455
+ name: "w:docPartGallery",
30456
+ attributes: {
30457
+ "w:val": attrs.docPartGallery
30458
+ }
30459
+ },
30460
+ ...attrs.docPartUnique ? [
30461
+ {
30462
+ name: "w:docPartUnique"
30463
+ }
30464
+ ] : []
30465
+ ]
30466
+ }
30467
+ ]
30468
+ },
30469
+ {
30470
+ name: "w:sdtContent",
30471
+ elements: childContent
30472
+ }
30473
+ ];
30474
+ const result = {
30475
+ name: "w:sdt",
30476
+ elements: nodeElements
30477
+ };
30478
+ return result;
30479
+ }
30442
30480
  function translateStructuredContent(params2) {
30443
30481
  const { node } = params2;
30444
30482
  const childContent = translateChildNodes({ ...params2, nodes: node.content });
@@ -30490,10 +30528,10 @@ function generateSdtPrTagForStructuredContent({ node }) {
30490
30528
  };
30491
30529
  return result;
30492
30530
  }
30493
- const XML_NODE_NAME$3 = "w:sdt";
30494
- const SD_NODE_NAME$3 = ["fieldAnnotation", "structuredContent", "structuredContentBlock", "documentSection"];
30531
+ const XML_NODE_NAME$5 = "w:sdt";
30532
+ const SD_NODE_NAME$5 = ["fieldAnnotation", "structuredContent", "structuredContentBlock", "documentSection"];
30495
30533
  const validXmlAttributes$3 = [];
30496
- function encode$a(params2) {
30534
+ function encode$c(params2) {
30497
30535
  const nodes = params2.nodes;
30498
30536
  const node = nodes[0];
30499
30537
  const { type: sdtType, handler: handler2 } = sdtNodeTypeStrategy(node);
@@ -30503,7 +30541,7 @@ function encode$a(params2) {
30503
30541
  const result = handler2(params2);
30504
30542
  return result;
30505
30543
  }
30506
- function decode$a(params2) {
30544
+ function decode$c(params2) {
30507
30545
  const { node } = params2;
30508
30546
  if (!node || !node.type) {
30509
30547
  return null;
@@ -30513,91 +30551,93 @@ function decode$a(params2) {
30513
30551
  structuredContent: () => translateStructuredContent(params2),
30514
30552
  structuredContentBlock: () => translateStructuredContent(params2),
30515
30553
  documentSection: () => translateDocumentSection(params2),
30554
+ documentPartObject: () => translateDocumentPartObj(params2),
30555
+ // Handled in doc-part-obj translator
30516
30556
  default: () => null
30517
30557
  };
30518
30558
  const decoder = types2[node.type] ?? types2.default;
30519
30559
  const result = decoder();
30520
30560
  return result;
30521
30561
  }
30522
- const config$3 = {
30523
- xmlName: XML_NODE_NAME$3,
30524
- sdNodeOrKeyName: SD_NODE_NAME$3,
30562
+ const config$5 = {
30563
+ xmlName: XML_NODE_NAME$5,
30564
+ sdNodeOrKeyName: SD_NODE_NAME$5,
30525
30565
  type: NodeTranslator.translatorTypes.NODE,
30526
- encode: encode$a,
30527
- decode: decode$a,
30566
+ encode: encode$c,
30567
+ decode: decode$c,
30528
30568
  attributes: validXmlAttributes$3
30529
30569
  };
30530
- const translator$3 = NodeTranslator.from(config$3);
30531
- const encode$9 = (attributes) => {
30570
+ const translator$5 = NodeTranslator.from(config$5);
30571
+ const encode$b = (attributes) => {
30532
30572
  return attributes["w:id"];
30533
30573
  };
30534
- const decode$9 = (attrs) => {
30574
+ const decode$b = (attrs) => {
30535
30575
  return attrs.id;
30536
30576
  };
30537
30577
  const attrConfig$6 = Object.freeze({
30538
30578
  xmlName: "w:id",
30539
30579
  sdName: "id",
30540
- encode: encode$9,
30541
- decode: decode$9
30580
+ encode: encode$b,
30581
+ decode: decode$b
30542
30582
  });
30543
- const encode$8 = (attributes) => {
30583
+ const encode$a = (attributes) => {
30544
30584
  return attributes["w:name"];
30545
30585
  };
30546
- const decode$8 = (attrs) => {
30586
+ const decode$a = (attrs) => {
30547
30587
  return attrs.name;
30548
30588
  };
30549
30589
  const attrConfig$5 = Object.freeze({
30550
30590
  xmlName: "w:name",
30551
30591
  sdName: "name",
30552
- encode: encode$8,
30553
- decode: decode$8
30592
+ encode: encode$a,
30593
+ decode: decode$a
30554
30594
  });
30555
- const encode$7 = (attributes) => {
30595
+ const encode$9 = (attributes) => {
30556
30596
  return attributes["w:colFirst"];
30557
30597
  };
30558
- const decode$7 = (attrs) => {
30598
+ const decode$9 = (attrs) => {
30559
30599
  return attrs.colFirst;
30560
30600
  };
30561
30601
  const attrConfig$4 = Object.freeze({
30562
30602
  xmlName: "w:colFirst",
30563
30603
  sdName: "colFirst",
30564
- encode: encode$7,
30565
- decode: decode$7
30604
+ encode: encode$9,
30605
+ decode: decode$9
30566
30606
  });
30567
- const encode$6 = (attributes) => {
30607
+ const encode$8 = (attributes) => {
30568
30608
  return attributes["w:colLast"];
30569
30609
  };
30570
- const decode$6 = (attrs) => {
30610
+ const decode$8 = (attrs) => {
30571
30611
  return attrs.colLast;
30572
30612
  };
30573
30613
  const attrConfig$3 = Object.freeze({
30574
30614
  xmlName: "w:colLast",
30575
30615
  sdName: "colLast",
30576
- encode: encode$6,
30577
- decode: decode$6
30616
+ encode: encode$8,
30617
+ decode: decode$8
30578
30618
  });
30579
- const encode$5 = (attributes) => {
30619
+ const encode$7 = (attributes) => {
30580
30620
  return attributes["w:displacedByCustomXml"];
30581
30621
  };
30582
- const decode$5 = (attrs) => {
30622
+ const decode$7 = (attrs) => {
30583
30623
  return attrs.displacedByCustomXml;
30584
30624
  };
30585
30625
  const attrConfig$2 = Object.freeze({
30586
30626
  xmlName: "w:displacedByCustomXml",
30587
30627
  sdName: "displacedByCustomXml",
30588
- encode: encode$5,
30589
- decode: decode$5
30628
+ encode: encode$7,
30629
+ decode: decode$7
30590
30630
  });
30591
30631
  const validXmlAttributes$2 = [attrConfig$6, attrConfig$5, attrConfig$4, attrConfig$3, attrConfig$2];
30592
- const XML_NODE_NAME$2 = "w:bookmarkStart";
30593
- const SD_NODE_NAME$2 = "bookmarkStart";
30594
- const encode$4 = (params2, encodedAttrs = {}) => {
30632
+ const XML_NODE_NAME$4 = "w:bookmarkStart";
30633
+ const SD_NODE_NAME$4 = "bookmarkStart";
30634
+ const encode$6 = (params2, encodedAttrs = {}) => {
30595
30635
  return {
30596
30636
  type: "bookmarkStart",
30597
30637
  attrs: encodedAttrs
30598
30638
  };
30599
30639
  };
30600
- const decode$4 = (params2, decodedAttrs = {}) => {
30640
+ const decode$6 = (params2, decodedAttrs = {}) => {
30601
30641
  const result = {
30602
30642
  name: "w:bookmarkStart",
30603
30643
  elements: []
@@ -30607,49 +30647,49 @@ const decode$4 = (params2, decodedAttrs = {}) => {
30607
30647
  }
30608
30648
  return result;
30609
30649
  };
30610
- const config$2 = {
30611
- xmlName: XML_NODE_NAME$2,
30612
- sdNodeOrKeyName: SD_NODE_NAME$2,
30650
+ const config$4 = {
30651
+ xmlName: XML_NODE_NAME$4,
30652
+ sdNodeOrKeyName: SD_NODE_NAME$4,
30613
30653
  type: NodeTranslator.translatorTypes.NODE,
30614
- encode: encode$4,
30615
- decode: decode$4,
30654
+ encode: encode$6,
30655
+ decode: decode$6,
30616
30656
  attributes: validXmlAttributes$2
30617
30657
  };
30618
- const translator$2 = NodeTranslator.from(config$2);
30619
- const encode$3 = (attributes) => {
30658
+ const translator$4 = NodeTranslator.from(config$4);
30659
+ const encode$5 = (attributes) => {
30620
30660
  return attributes["w:id"];
30621
30661
  };
30622
- const decode$3 = (attrs) => {
30662
+ const decode$5 = (attrs) => {
30623
30663
  return attrs.id;
30624
30664
  };
30625
30665
  const attrConfig$1 = Object.freeze({
30626
30666
  xmlName: "w:id",
30627
30667
  sdName: "id",
30628
- encode: encode$3,
30629
- decode: decode$3
30668
+ encode: encode$5,
30669
+ decode: decode$5
30630
30670
  });
30631
- const encode$2 = (attributes) => {
30671
+ const encode$4 = (attributes) => {
30632
30672
  return attributes["w:displacedByCustomXml"];
30633
30673
  };
30634
- const decode$2 = (attrs) => {
30674
+ const decode$4 = (attrs) => {
30635
30675
  return attrs.displacedByCustomXml;
30636
30676
  };
30637
30677
  const attrConfig = Object.freeze({
30638
30678
  xmlName: "w:displacedByCustomXml",
30639
30679
  sdName: "displacedByCustomXml",
30640
- encode: encode$2,
30641
- decode: decode$2
30680
+ encode: encode$4,
30681
+ decode: decode$4
30642
30682
  });
30643
30683
  const validXmlAttributes$1 = [attrConfig$1, attrConfig];
30644
- const XML_NODE_NAME$1 = "w:bookmarkEnd";
30645
- const SD_NODE_NAME$1 = "bookmarkEnd";
30646
- const encode$1 = (params2, encodedAttrs = {}) => {
30684
+ const XML_NODE_NAME$3 = "w:bookmarkEnd";
30685
+ const SD_NODE_NAME$3 = "bookmarkEnd";
30686
+ const encode$3 = (params2, encodedAttrs = {}) => {
30647
30687
  return {
30648
30688
  type: "bookmarkEnd",
30649
30689
  attrs: encodedAttrs
30650
30690
  };
30651
30691
  };
30652
- const decode$1 = (params2, decodedAttrs = {}) => {
30692
+ const decode$3 = (params2, decodedAttrs = {}) => {
30653
30693
  const result = {
30654
30694
  name: "w:bookmarkEnd",
30655
30695
  elements: []
@@ -30659,19 +30699,19 @@ const decode$1 = (params2, decodedAttrs = {}) => {
30659
30699
  }
30660
30700
  return result;
30661
30701
  };
30662
- const config$1 = {
30663
- xmlName: XML_NODE_NAME$1,
30664
- sdNodeOrKeyName: SD_NODE_NAME$1,
30702
+ const config$3 = {
30703
+ xmlName: XML_NODE_NAME$3,
30704
+ sdNodeOrKeyName: SD_NODE_NAME$3,
30665
30705
  type: NodeTranslator.translatorTypes.NODE,
30666
- encode: encode$1,
30667
- decode: decode$1,
30706
+ encode: encode$3,
30707
+ decode: decode$3,
30668
30708
  attributes: validXmlAttributes$1
30669
30709
  };
30670
- const translator$1 = NodeTranslator.from(config$1);
30671
- const XML_NODE_NAME = "mc:AlternateContent";
30672
- const SD_NODE_NAME = [];
30710
+ const translator$3 = NodeTranslator.from(config$3);
30711
+ const XML_NODE_NAME$2 = "mc:AlternateContent";
30712
+ const SD_NODE_NAME$2 = [];
30673
30713
  const validXmlAttributes = [];
30674
- function encode$19(params2) {
30714
+ function encode$2(params2) {
30675
30715
  const { nodeListHandler } = params2;
30676
30716
  const { node } = params2.extraParams;
30677
30717
  if (!node || !node.type) {
@@ -30691,7 +30731,7 @@ function encode$19(params2) {
30691
30731
  path: [...params2.path || [], wpsNode]
30692
30732
  });
30693
30733
  }
30694
- function decode(params2) {
30734
+ function decode$2(params2) {
30695
30735
  const { node } = params2;
30696
30736
  const { drawingContent } = node.attrs;
30697
30737
  const drawing = {
@@ -30708,13 +30748,186 @@ function decode(params2) {
30708
30748
  elements: [choice]
30709
30749
  };
30710
30750
  }
30751
+ const config$2 = {
30752
+ xmlName: XML_NODE_NAME$2,
30753
+ sdNodeOrKeyName: SD_NODE_NAME$2,
30754
+ type: NodeTranslator.translatorTypes.NODE,
30755
+ encode: encode$2,
30756
+ decode: decode$2,
30757
+ attributes: validXmlAttributes
30758
+ };
30759
+ const translator$2 = NodeTranslator.from(config$2);
30760
+ const XML_NODE_NAME$1 = "sd:pageReference";
30761
+ const SD_NODE_NAME$1 = "pageReference";
30762
+ const encode$1 = (params2, _2) => {
30763
+ const { nodes = [], nodeListHandler } = params2 || {};
30764
+ const node = nodes[0];
30765
+ const processedText = nodeListHandler.handler({
30766
+ ...params2,
30767
+ nodes: node.elements
30768
+ });
30769
+ const processedNode = {
30770
+ type: "pageReference",
30771
+ attrs: {
30772
+ instruction: node.attributes?.instruction || "",
30773
+ marksAsAttrs: node.marks || []
30774
+ },
30775
+ content: processedText
30776
+ };
30777
+ return processedNode;
30778
+ };
30779
+ const decode$1 = (params2, _2) => {
30780
+ const { node } = params2;
30781
+ const outputMarks = processOutputMarks(node.attrs?.marksAsAttrs || []);
30782
+ const contentNodes = (node.content ?? []).flatMap((n) => exportSchemaToJson({ ...params2, node: n }));
30783
+ const translated = [
30784
+ {
30785
+ name: "w:r",
30786
+ elements: [
30787
+ {
30788
+ name: "w:rPr",
30789
+ elements: outputMarks
30790
+ },
30791
+ {
30792
+ name: "w:fldChar",
30793
+ attributes: {
30794
+ "w:fldCharType": "begin"
30795
+ }
30796
+ }
30797
+ ]
30798
+ },
30799
+ {
30800
+ name: "w:r",
30801
+ elements: [
30802
+ {
30803
+ name: "w:rPr",
30804
+ elements: outputMarks
30805
+ },
30806
+ {
30807
+ name: "w:instrText",
30808
+ attributes: { "xml:space": "preserve" },
30809
+ elements: [
30810
+ {
30811
+ type: "text",
30812
+ text: `${node.attrs.instruction}`
30813
+ }
30814
+ ]
30815
+ }
30816
+ ]
30817
+ },
30818
+ {
30819
+ name: "w:r",
30820
+ elements: [
30821
+ {
30822
+ name: "w:rPr",
30823
+ elements: outputMarks
30824
+ },
30825
+ {
30826
+ name: "w:fldChar",
30827
+ attributes: {
30828
+ "w:fldCharType": "separate"
30829
+ }
30830
+ }
30831
+ ]
30832
+ },
30833
+ ...contentNodes,
30834
+ {
30835
+ name: "w:r",
30836
+ elements: [
30837
+ {
30838
+ name: "w:rPr",
30839
+ elements: outputMarks
30840
+ },
30841
+ {
30842
+ name: "w:fldChar",
30843
+ attributes: {
30844
+ "w:fldCharType": "end"
30845
+ }
30846
+ }
30847
+ ]
30848
+ }
30849
+ ];
30850
+ return translated;
30851
+ };
30852
+ const config$1 = {
30853
+ xmlName: XML_NODE_NAME$1,
30854
+ sdNodeOrKeyName: SD_NODE_NAME$1,
30855
+ type: NodeTranslator.translatorTypes.NODE,
30856
+ encode: encode$1,
30857
+ decode: decode$1
30858
+ };
30859
+ const translator$1 = NodeTranslator.from(config$1);
30860
+ const XML_NODE_NAME = "sd:tableOfContents";
30861
+ const SD_NODE_NAME = "tableOfContents";
30862
+ const encode$1c = (params2, _2) => {
30863
+ const { nodes = [], nodeListHandler } = params2 || {};
30864
+ const node = nodes[0];
30865
+ const processedContent = nodeListHandler.handler({
30866
+ ...params2,
30867
+ nodes: node.elements || []
30868
+ });
30869
+ const processedNode = {
30870
+ type: "tableOfContents",
30871
+ attrs: {
30872
+ instruction: node.attributes?.instruction || ""
30873
+ },
30874
+ content: processedContent
30875
+ };
30876
+ return processedNode;
30877
+ };
30878
+ const decode = (params2, _2) => {
30879
+ const { node } = params2;
30880
+ const contentNodes = node.content.map((n) => exportSchemaToJson({ ...params2, node: n }));
30881
+ const tocBeginElements = [
30882
+ {
30883
+ name: "w:r",
30884
+ elements: [{ name: "w:fldChar", attributes: { "w:fldCharType": "begin" }, elements: [] }]
30885
+ },
30886
+ {
30887
+ name: "w:r",
30888
+ elements: [
30889
+ {
30890
+ name: "w:instrText",
30891
+ attributes: { "xml:space": "preserve" },
30892
+ elements: [{ text: node.attrs?.instruction || "", type: "text", name: "#text", elements: [] }]
30893
+ }
30894
+ ]
30895
+ },
30896
+ { name: "w:r", elements: [{ name: "w:fldChar", attributes: { "w:fldCharType": "separate" }, elements: [] }] }
30897
+ ];
30898
+ if (contentNodes.length > 0) {
30899
+ const firstParagraph = contentNodes[0];
30900
+ let insertIndex = 0;
30901
+ if (firstParagraph.elements) {
30902
+ const pPrIndex = firstParagraph.elements.findIndex((el) => el.name === "w:pPr");
30903
+ insertIndex = pPrIndex >= 0 ? pPrIndex + 1 : 0;
30904
+ } else {
30905
+ firstParagraph.elements = [];
30906
+ }
30907
+ firstParagraph.elements.splice(insertIndex, 0, ...tocBeginElements);
30908
+ } else {
30909
+ contentNodes.push({
30910
+ name: "w:p",
30911
+ elements: tocBeginElements
30912
+ });
30913
+ }
30914
+ const tocEndElements = [
30915
+ { name: "w:r", elements: [{ name: "w:fldChar", attributes: { "w:fldCharType": "end" }, elements: [] }] }
30916
+ ];
30917
+ const lastParagraph = contentNodes[contentNodes.length - 1];
30918
+ if (lastParagraph.elements) {
30919
+ lastParagraph.elements.push(...tocEndElements);
30920
+ } else {
30921
+ lastParagraph.elements = [...tocEndElements];
30922
+ }
30923
+ return contentNodes;
30924
+ };
30711
30925
  const config = {
30712
30926
  xmlName: XML_NODE_NAME,
30713
30927
  sdNodeOrKeyName: SD_NODE_NAME,
30714
30928
  type: NodeTranslator.translatorTypes.NODE,
30715
- encode: encode$19,
30716
- decode,
30717
- attributes: validXmlAttributes
30929
+ encode: encode$1c,
30930
+ decode
30718
30931
  };
30719
30932
  const translator = NodeTranslator.from(config);
30720
30933
  const DEFAULT_SECTION_PROPS_TWIPS = Object.freeze({
@@ -30788,32 +31001,35 @@ function exportSchemaToJson(params2) {
30788
31001
  doc: translateDocumentNode,
30789
31002
  body: translateBodyNode,
30790
31003
  heading: translateHeadingNode,
30791
- paragraph: translator$13,
30792
- run: translator$U,
31004
+ paragraph: translator$16,
31005
+ run: translator$V,
30793
31006
  text: translateTextNode,
30794
31007
  bulletList: translateList,
30795
31008
  orderedList: translateList,
30796
- lineBreak: translator$16,
30797
- table: translator$9,
30798
- tableRow: translator$G,
30799
- tableCell: translator$8,
30800
- bookmarkStart: translator$2,
30801
- bookmarkEnd: translator$1,
30802
- fieldAnnotation: translator$3,
30803
- tab: translator$14,
30804
- image: translator$4,
30805
- hardBreak: translator$16,
31009
+ lineBreak: translator$19,
31010
+ table: translator$a,
31011
+ tableRow: translator$H,
31012
+ tableCell: translator$9,
31013
+ bookmarkStart: translator$4,
31014
+ bookmarkEnd: translator$3,
31015
+ fieldAnnotation: translator$5,
31016
+ tab: translator$17,
31017
+ image: translator$6,
31018
+ hardBreak: translator$19,
30806
31019
  commentRangeStart: () => translateCommentNode(params2, "Start"),
30807
31020
  commentRangeEnd: () => translateCommentNode(params2, "End"),
30808
31021
  commentReference: () => null,
30809
31022
  shapeContainer: translateShapeContainer,
30810
31023
  shapeTextbox: translateShapeTextbox,
30811
31024
  contentBlock: translateContentBlock,
30812
- structuredContent: translator$3,
30813
- structuredContentBlock: translator$3,
30814
- documentSection: translator$3,
31025
+ structuredContent: translator$5,
31026
+ structuredContentBlock: translator$5,
31027
+ documentPartObject: translator$5,
31028
+ documentSection: translator$5,
30815
31029
  "page-number": translatePageNumberNode,
30816
- "total-page-number": translateTotalPageNumberNode
31030
+ "total-page-number": translateTotalPageNumberNode,
31031
+ pageReference: translator$1,
31032
+ tableOfContents: translator
30817
31033
  };
30818
31034
  let handler2 = router[type2];
30819
31035
  if (handler2 && "decode" in handler2 && typeof handler2.decode === "function") {
@@ -31151,8 +31367,6 @@ function translateTextNode(params2) {
31151
31367
  const trackedMarks = [TrackInsertMarkName, TrackDeleteMarkName];
31152
31368
  const isTrackedNode = node.marks?.some((m2) => trackedMarks.includes(m2.type));
31153
31369
  if (isTrackedNode) return translateTrackedNode(params2);
31154
- const isLinkNode = node.marks?.some((m2) => m2.type === "link");
31155
- if (isLinkNode) return translator$7.decode(params2);
31156
31370
  const { text, marks = [] } = node;
31157
31371
  return getTextNodeForExport(text, marks, params2);
31158
31372
  }
@@ -31458,7 +31672,7 @@ function translateMark(mark) {
31458
31672
  markElement.type = "element";
31459
31673
  break;
31460
31674
  case "underline": {
31461
- const translated = translator$10.decode({
31675
+ const translated = translator$13.decode({
31462
31676
  node: {
31463
31677
  attrs: {
31464
31678
  underlineType: attrs.underlineType ?? attrs.underline ?? null,
@@ -31522,7 +31736,7 @@ function translateMark(mark) {
31522
31736
  break;
31523
31737
  case "highlight": {
31524
31738
  const highlightValue = attrs.color ?? attrs.highlight ?? null;
31525
- const translated = translator$15.decode({ node: { attrs: { highlight: highlightValue } } });
31739
+ const translated = translator$18.decode({ node: { attrs: { highlight: highlightValue } } });
31526
31740
  return translated || {};
31527
31741
  }
31528
31742
  }
@@ -31550,7 +31764,7 @@ function translateShapeContainer(params2) {
31550
31764
  const pict = {
31551
31765
  name: "w:pict",
31552
31766
  attributes: {
31553
- "w14:anchorId": Math.floor(Math.random() * 4294967295).toString()
31767
+ "w14:anchorId": generateRandomSigned32BitIntStrId()
31554
31768
  },
31555
31769
  elements: [shape]
31556
31770
  };
@@ -31582,7 +31796,7 @@ function translateContentBlock(params2) {
31582
31796
  if (vmlAttributes || horizontalRule) {
31583
31797
  return translateVRectContentBlock(params2);
31584
31798
  }
31585
- const alternateContent = translator.decode(params2);
31799
+ const alternateContent = translator$2.decode(params2);
31586
31800
  return wrapTextInRun(alternateContent);
31587
31801
  }
31588
31802
  function translateVRectContentBlock(params2) {
@@ -31617,7 +31831,7 @@ function translateVRectContentBlock(params2) {
31617
31831
  const pict = {
31618
31832
  name: "w:pict",
31619
31833
  attributes: {
31620
- "w14:anchorId": Math.floor(Math.random() * 4294967295).toString()
31834
+ "w14:anchorId": generateRandomSigned32BitIntStrId()
31621
31835
  },
31622
31836
  elements: [rect]
31623
31837
  };
@@ -31727,6 +31941,7 @@ const getAutoPageJson = (type2, outputMarks = []) => {
31727
31941
  },
31728
31942
  {
31729
31943
  name: "w:instrText",
31944
+ attributes: { "xml:space": "preserve" },
31730
31945
  elements: [
31731
31946
  {
31732
31947
  type: "text",
@@ -31786,7 +32001,7 @@ const handleDrawingNode = (params2) => {
31786
32001
  if (mainNode.name === "w:drawing") node = mainNode;
31787
32002
  else node = mainNode.elements.find((el) => el.name === "w:drawing");
31788
32003
  if (!node) return { nodes: [], consumed: 0 };
31789
- const schemaNode = translator$4.encode(params2);
32004
+ const schemaNode = translator$6.encode(params2);
31790
32005
  const newNodes = schemaNode ? [schemaNode] : [];
31791
32006
  return { nodes: newNodes, consumed: 1 };
31792
32007
  };
@@ -31888,8 +32103,8 @@ const trackChangeNodeHandlerEntity = {
31888
32103
  handlerName: "trackChangeNodeHandler",
31889
32104
  handler: handleTrackChangeNode
31890
32105
  };
31891
- const hyperlinkNodeHandlerEntity = generateV2HandlerEntity("hyperlinkNodeHandler", translator$7);
31892
- const runNodeHandlerEntity = generateV2HandlerEntity("runNodeHandler", translator$U);
32106
+ const hyperlinkNodeHandlerEntity = generateV2HandlerEntity("hyperlinkNodeHandler", translator$W);
32107
+ const runNodeHandlerEntity = generateV2HandlerEntity("runNodeHandler", translator$V);
31893
32108
  const handleTextNode = (params2) => {
31894
32109
  const { nodes, insideTrackChange } = params2;
31895
32110
  if (nodes.length === 0 || !(nodes[0].name === "w:t" || insideTrackChange && nodes[0].name === "w:delText")) {
@@ -31930,7 +32145,7 @@ const handleParagraphNode = (params2) => {
31930
32145
  if (nodes.length === 0 || nodes[0].name !== "w:p") {
31931
32146
  return { nodes: [], consumed: 0 };
31932
32147
  }
31933
- const schemaNode = translator$13.encode(params2);
32148
+ const schemaNode = translator$16.encode(params2);
31934
32149
  const newNodes = schemaNode ? [schemaNode] : [];
31935
32150
  return { nodes: newNodes, consumed: 1 };
31936
32151
  };
@@ -31943,7 +32158,7 @@ const handleSdtNode = (params2) => {
31943
32158
  if (nodes.length === 0 || nodes[0].name !== "w:sdt") {
31944
32159
  return { nodes: [], consumed: 0 };
31945
32160
  }
31946
- const result = translator$3.encode(params2);
32161
+ const result = translator$5.encode(params2);
31947
32162
  if (!result) {
31948
32163
  return { nodes: [], consumed: 0 };
31949
32164
  }
@@ -32033,7 +32248,7 @@ const handler = (params2) => {
32033
32248
  if (nodes.length === 0 || nodes[0].name !== "w:br") {
32034
32249
  return { nodes: [], consumed: 0 };
32035
32250
  }
32036
- const result = translator$16.encode(params2);
32251
+ const result = translator$19.encode(params2);
32037
32252
  if (!result) return { nodes: [], consumed: 0 };
32038
32253
  return {
32039
32254
  nodes: [result],
@@ -32105,7 +32320,7 @@ const handleBookmarkStartNode = (params2) => {
32105
32320
  if (isCustomMarkBookmark(nodes[0], params2.editor)) {
32106
32321
  return handleBookmarkNode(params2);
32107
32322
  }
32108
- const node = translator$2.encode(params2);
32323
+ const node = translator$4.encode(params2);
32109
32324
  if (!node) return { nodes: [], consumed: 0 };
32110
32325
  return { nodes: [node], consumed: 1 };
32111
32326
  };
@@ -32137,7 +32352,7 @@ const handleBookmarkEndNode = (params2) => {
32137
32352
  if (!nodes.length || nodes[0].name !== "w:bookmarkEnd") {
32138
32353
  return { nodes: [], consumed: 0 };
32139
32354
  }
32140
- const node = translator$1.encode(params2);
32355
+ const node = translator$3.encode(params2);
32141
32356
  if (!node) return { nodes: [], consumed: 0 };
32142
32357
  return { nodes: [node], consumed: 1 };
32143
32358
  };
@@ -32270,6 +32485,7 @@ const autoTotalPageCountEntity = {
32270
32485
  handlerName: "autoTotalPageCountEntity",
32271
32486
  handler: handleAutoTotalPageNumber
32272
32487
  };
32488
+ const pageReferenceEntity = generateV2HandlerEntity("pageReferenceNodeHandler", translator$1);
32273
32489
  const handlePictNode = (params2) => {
32274
32490
  const { nodes } = params2;
32275
32491
  if (!nodes.length || nodes[0].name !== "w:p") {
@@ -32768,6 +32984,7 @@ const getDefaultStyleDefinition = (defaultStyleId, docx) => {
32768
32984
  const spacing = pPr?.elements?.find((el) => el.name === "w:spacing");
32769
32985
  const justify = pPr?.elements?.find((el) => el.name === "w:jc");
32770
32986
  const indent = pPr?.elements?.find((el) => el.name === "w:ind");
32987
+ const tabs = pPr?.elements?.find((el) => el.name === "w:tabs");
32771
32988
  let lineSpaceBefore, lineSpaceAfter, line;
32772
32989
  if (spacing) {
32773
32990
  lineSpaceBefore = twipsToPixels(spacing?.attributes["w:before"]);
@@ -32781,6 +32998,22 @@ const getDefaultStyleDefinition = (defaultStyleId, docx) => {
32781
32998
  rightIndent = twipsToPixels(indent?.attributes["w:right"]);
32782
32999
  firstLine = twipsToPixels(indent?.attributes["w:firstLine"]);
32783
33000
  }
33001
+ let tabStops = [];
33002
+ if (tabs) {
33003
+ tabStops = (tabs.elements || []).filter((el) => el.name === "w:tab").map((tab) => {
33004
+ let val = tab.attributes["w:val"];
33005
+ if (val == "left") {
33006
+ val = "start";
33007
+ } else if (val == "right") {
33008
+ val = "end";
33009
+ }
33010
+ return {
33011
+ val,
33012
+ pos: twipsToPixels(tab.attributes["w:pos"]),
33013
+ leader: tab.attributes["w:leader"]
33014
+ };
33015
+ });
33016
+ }
32784
33017
  const keepNext = pPr?.elements?.find((el) => el.name === "w:keepNext");
32785
33018
  const keepLines = pPr?.elements?.find((el) => el.name === "w:keepLines");
32786
33019
  const outlineLevel = pPr?.elements?.find((el) => el.name === "w:outlineLvl");
@@ -32813,7 +33046,8 @@ const getDefaultStyleDefinition = (defaultStyleId, docx) => {
32813
33046
  const parsedStyles = {
32814
33047
  spacing: { lineSpaceAfter, lineSpaceBefore, line },
32815
33048
  textAlign,
32816
- indent: { leftIndent, rightIndent, firstLine }
33049
+ indent: { leftIndent, rightIndent, firstLine },
33050
+ tabStops: tabStops.length > 0 ? tabStops : null
32817
33051
  };
32818
33052
  parsedMarks.forEach((mark) => {
32819
33053
  const { type: type2, attrs } = mark;
@@ -32837,13 +33071,213 @@ const handleTabNode = (params2) => {
32837
33071
  if (!nodes.length || nodes[0].name !== "w:tab") {
32838
33072
  return { nodes: [], consumed: 0 };
32839
33073
  }
32840
- const node = translator$14.encode(params2);
33074
+ const node = translator$17.encode(params2);
32841
33075
  return { nodes: [node], consumed: 1 };
32842
33076
  };
32843
33077
  const tabNodeEntityHandler = {
32844
33078
  handlerName: "w:tabTranslator",
32845
33079
  handler: handleTabNode
32846
33080
  };
33081
+ const tableOfContentsHandlerEntity = generateV2HandlerEntity("tableOfContentsHandler", translator);
33082
+ function preProcessPageInstruction(nodesToCombine, _2, __) {
33083
+ const pageNumNode = {
33084
+ name: "sd:autoPageNumber",
33085
+ type: "element"
33086
+ };
33087
+ nodesToCombine.forEach((n) => {
33088
+ const rPrNode = n.elements.find((el) => el.name === "w:rPr");
33089
+ if (rPrNode) pageNumNode.elements = [rPrNode];
33090
+ });
33091
+ return [pageNumNode];
33092
+ }
33093
+ function preProcessNumPagesInstruction(nodesToCombine, _2, __) {
33094
+ const totalPageNumNode = {
33095
+ name: "sd:totalPageNumber",
33096
+ type: "element"
33097
+ };
33098
+ nodesToCombine.forEach((n) => {
33099
+ const rPrNode = n.elements?.find((el) => el.name === "w:rPr");
33100
+ if (rPrNode) totalPageNumNode.elements = [rPrNode];
33101
+ });
33102
+ return [totalPageNumNode];
33103
+ }
33104
+ function preProcessPageRefInstruction(nodesToCombine, instrText, _2) {
33105
+ const pageRefNode = {
33106
+ name: "sd:pageReference",
33107
+ type: "element",
33108
+ attributes: {
33109
+ instruction: instrText
33110
+ },
33111
+ elements: nodesToCombine
33112
+ };
33113
+ return [pageRefNode];
33114
+ }
33115
+ function preProcessHyperlinkInstruction(nodesToCombine, instruction, docx) {
33116
+ const urlMatch = instruction.match(/HYPERLINK\s+"([^"]+)"/);
33117
+ let linkAttributes;
33118
+ if (urlMatch && urlMatch.length >= 2) {
33119
+ const url = urlMatch[1];
33120
+ const rels = docx["word/_rels/document.xml.rels"];
33121
+ const relationships = rels?.elements.find((el) => el.name === "Relationships");
33122
+ if (relationships) {
33123
+ const rId = generateDocxRandomId();
33124
+ relationships.elements.push({
33125
+ type: "element",
33126
+ name: "Relationship",
33127
+ attributes: {
33128
+ Id: rId,
33129
+ Type: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",
33130
+ Target: url,
33131
+ TargetMode: "External"
33132
+ }
33133
+ });
33134
+ linkAttributes = { "r:id": rId };
33135
+ } else {
33136
+ linkAttributes = { "w:anchor": url };
33137
+ }
33138
+ } else {
33139
+ const availableSwitches = {
33140
+ "w:anchor": `l "(?<value>[^"]+)"`,
33141
+ new_window: `
33142
+ `,
33143
+ "w:tgtFrame": ` "(?<value>[^"]+)"`,
33144
+ "w:tooltip": `o "(?<value>[^"]+)"`
33145
+ };
33146
+ const parsedSwitches = {};
33147
+ for (const [key2, regex] of Object.entries(availableSwitches)) {
33148
+ const match = instruction.match(new RegExp(regex));
33149
+ if (match) {
33150
+ parsedSwitches[key2] = match.groups?.value || true;
33151
+ }
33152
+ }
33153
+ if (parsedSwitches.new_window) {
33154
+ parsedSwitches["w:tgtFrame"] = "_blank";
33155
+ delete parsedSwitches.new_window;
33156
+ }
33157
+ linkAttributes = { ...parsedSwitches };
33158
+ }
33159
+ return [
33160
+ {
33161
+ name: "w:hyperlink",
33162
+ type: "element",
33163
+ attributes: linkAttributes,
33164
+ elements: nodesToCombine
33165
+ }
33166
+ ];
33167
+ }
33168
+ function preProcessTocInstruction(nodesToCombine, instrText) {
33169
+ return [
33170
+ {
33171
+ name: "sd:tableOfContents",
33172
+ type: "element",
33173
+ attributes: {
33174
+ instruction: instrText
33175
+ },
33176
+ elements: nodesToCombine
33177
+ }
33178
+ ];
33179
+ }
33180
+ const getInstructionPreProcessor = (instruction) => {
33181
+ const instructionType = instruction.split(" ")[0];
33182
+ switch (instructionType) {
33183
+ case "PAGE":
33184
+ return preProcessPageInstruction;
33185
+ case "NUMPAGES":
33186
+ return preProcessNumPagesInstruction;
33187
+ case "PAGEREF":
33188
+ return preProcessPageRefInstruction;
33189
+ case "HYPERLINK":
33190
+ return preProcessHyperlinkInstruction;
33191
+ case "TOC":
33192
+ return preProcessTocInstruction;
33193
+ default:
33194
+ return null;
33195
+ }
33196
+ };
33197
+ const preProcessNodesForFldChar = (nodes = [], docx) => {
33198
+ const processedNodes = [];
33199
+ let collectedNodesStack = [];
33200
+ let currentFieldStack = [];
33201
+ let unpairedEnd = null;
33202
+ let collecting = false;
33203
+ const finalizeField = () => {
33204
+ if (collecting) {
33205
+ const collectedNodes = collectedNodesStack.pop().filter((n) => n !== null);
33206
+ const currentField = currentFieldStack.pop();
33207
+ const combined = _processCombinedNodesForFldChar(collectedNodes, currentField.instrText.trim(), docx);
33208
+ if (collectedNodesStack.length === 0) {
33209
+ processedNodes.push(...combined);
33210
+ } else {
33211
+ collectedNodesStack[collectedNodesStack.length - 1].push(...combined);
33212
+ }
33213
+ } else {
33214
+ unpairedEnd = true;
33215
+ }
33216
+ };
33217
+ for (const node of nodes) {
33218
+ const fldCharEl = node.elements?.find((el) => el.name === "w:fldChar");
33219
+ const fldType = fldCharEl?.attributes?.["w:fldCharType"];
33220
+ const instrTextEl = node.elements?.find((el) => el.name === "w:instrText");
33221
+ collecting = collectedNodesStack.length > 0;
33222
+ if (fldType === "begin") {
33223
+ collectedNodesStack.push([null]);
33224
+ currentFieldStack.push({ instrText: "" });
33225
+ continue;
33226
+ }
33227
+ if (instrTextEl && collecting && currentFieldStack.length > 0) {
33228
+ currentFieldStack[currentFieldStack.length - 1].instrText += (instrTextEl.elements?.[0]?.text || "") + " ";
33229
+ continue;
33230
+ }
33231
+ if (fldType === "end") {
33232
+ finalizeField();
33233
+ continue;
33234
+ } else if (fldType === "separate") {
33235
+ continue;
33236
+ }
33237
+ if (Array.isArray(node.elements)) {
33238
+ const childResult = preProcessNodesForFldChar(node.elements, docx);
33239
+ node.elements = childResult.processedNodes;
33240
+ if (childResult.unpairedBegin) {
33241
+ childResult.unpairedBegin.forEach((pendingField) => {
33242
+ currentFieldStack.push(pendingField.fieldInfo);
33243
+ collectedNodesStack.push([node]);
33244
+ });
33245
+ } else if (childResult.unpairedEnd) {
33246
+ collectedNodesStack[collectedNodesStack.length - 1].push(node);
33247
+ finalizeField();
33248
+ } else if (collecting) {
33249
+ collectedNodesStack[collectedNodesStack.length - 1].push(node);
33250
+ } else {
33251
+ processedNodes.push(node);
33252
+ }
33253
+ } else if (collecting) {
33254
+ collectedNodesStack[collectedNodesStack.length - 1].push(node);
33255
+ } else {
33256
+ processedNodes.push(node);
33257
+ }
33258
+ }
33259
+ let unpairedBegin = null;
33260
+ if (collectedNodesStack.length > 0) {
33261
+ unpairedBegin = [];
33262
+ for (let i = 0; i < collectedNodesStack.length; i++) {
33263
+ processedNodes.push(...collectedNodesStack[i].filter((n) => n !== null));
33264
+ unpairedBegin.push({
33265
+ nodes: collectedNodesStack[i],
33266
+ fieldInfo: currentFieldStack[i]
33267
+ });
33268
+ }
33269
+ }
33270
+ return { processedNodes, unpairedBegin, unpairedEnd };
33271
+ };
33272
+ const _processCombinedNodesForFldChar = (nodesToCombine = [], instrText, docx) => {
33273
+ const instructionType = instrText.trim().split(" ")[0];
33274
+ const instructionPreProcessor = getInstructionPreProcessor(instructionType);
33275
+ if (instructionPreProcessor) {
33276
+ return instructionPreProcessor(nodesToCombine, instrText, docx);
33277
+ } else {
33278
+ return nodesToCombine;
33279
+ }
33280
+ };
32847
33281
  const createDocumentJson = (docx, converter, editor) => {
32848
33282
  const json = carbonCopy(getInitialJSON(docx));
32849
33283
  if (!json) return null;
@@ -32873,6 +33307,8 @@ const createDocumentJson = (docx, converter, editor) => {
32873
33307
  if (bodyNode) {
32874
33308
  ensureSectionProperties(bodyNode);
32875
33309
  const node = bodyNode;
33310
+ const { processedNodes } = preProcessNodesForFldChar(node.elements ?? [], docx);
33311
+ node.elements = processedNodes;
32876
33312
  const contentElements = node.elements?.filter((n) => n.name !== "w:sectPr") ?? [];
32877
33313
  const content = pruneIgnoredNodes(contentElements);
32878
33314
  const comments = importCommentData({ docx, converter, editor });
@@ -32928,8 +33364,10 @@ const defaultNodeListHandler = () => {
32928
33364
  trackChangeNodeHandlerEntity,
32929
33365
  tableNodeHandlerEntity,
32930
33366
  tabNodeEntityHandler,
33367
+ tableOfContentsHandlerEntity,
32931
33368
  autoPageHandlerEntity,
32932
33369
  autoTotalPageCountEntity,
33370
+ pageReferenceEntity,
32933
33371
  standardNodeHandlerEntity
32934
33372
  ];
32935
33373
  const handler2 = createNodeListHandler(entities);
@@ -33117,7 +33555,7 @@ const DEFAULT_SECTION_PROPS = Object.freeze({
33117
33555
  gutter: "0"
33118
33556
  })
33119
33557
  });
33120
- function ensureSectionProperties(bodyNode, converter) {
33558
+ function ensureSectionProperties(bodyNode) {
33121
33559
  if (!bodyNode.elements) bodyNode.elements = [];
33122
33560
  let sectPr = bodyNode.elements.find((el) => el.name === "w:sectPr");
33123
33561
  if (!sectPr) {
@@ -48691,7 +49129,7 @@ const handleTrackedChangeTransaction = (trackedChangeMeta, trackedChanges, newEd
48691
49129
  if (emitParams) editor.emit("commentsUpdate", emitParams);
48692
49130
  return newTrackedChanges;
48693
49131
  };
48694
- const getTrackedChangeText = ({ state: state2, nodes, mark, marks, trackedChangeType, isDeletionInsertion }) => {
49132
+ const getTrackedChangeText = ({ nodes, mark, trackedChangeType, isDeletionInsertion }) => {
48695
49133
  let trackedChangeText = "";
48696
49134
  let deletionText = "";
48697
49135
  if (trackedChangeType === TrackInsertMarkName) {
@@ -48733,10 +49171,8 @@ const createOrUpdateTrackedChangeComment = ({ event, marks, deletionNodes, nodes
48733
49171
  if (hasMatchingId) nodesWithMark.push(node2);
48734
49172
  });
48735
49173
  const { deletionText, trackedChangeText } = getTrackedChangeText({
48736
- state: newEditorState,
48737
49174
  nodes: nodesWithMark.length ? nodesWithMark : [node],
48738
49175
  mark: trackedMark,
48739
- marks,
48740
49176
  trackedChangeType,
48741
49177
  isDeletionInsertion
48742
49178
  });
@@ -53834,7 +54270,7 @@ const StructuredContentCommands = Extension.create({
53834
54270
  }
53835
54271
  const attrs = {
53836
54272
  ...options.attrs,
53837
- id: options.attrs?.id || randomId(),
54273
+ id: options.attrs?.id || generateRandomSigned32BitIntStrId(),
53838
54274
  tag: "inline_text_sdt",
53839
54275
  alias: options.attrs?.alias || "Structured content"
53840
54276
  };
@@ -53875,7 +54311,7 @@ const StructuredContentCommands = Extension.create({
53875
54311
  }
53876
54312
  const attrs = {
53877
54313
  ...options.attrs,
53878
- id: options.attrs?.id || randomId(),
54314
+ id: options.attrs?.id || generateRandomSigned32BitIntStrId(),
53879
54315
  tag: "block_table_sdt",
53880
54316
  alias: options.attrs?.alias || "Structured content"
53881
54317
  };
@@ -53982,7 +54418,7 @@ const StructuredContentCommands = Extension.create({
53982
54418
  * Removes a structured content at cursor, preserving its content.
53983
54419
  * @category Command
53984
54420
  */
53985
- deleteStructuredContentAtSelection: () => ({ editor, dispatch, state: state2, tr }) => {
54421
+ deleteStructuredContentAtSelection: () => ({ dispatch, state: state2, tr }) => {
53986
54422
  const predicate = (node) => STRUCTURED_CONTENT_NAMES.includes(node.type.name);
53987
54423
  const structuredContent = findParentNode(predicate)(state2.selection);
53988
54424
  if (!structuredContent) {
@@ -54005,9 +54441,6 @@ const StructuredContentCommands = Extension.create({
54005
54441
  };
54006
54442
  }
54007
54443
  });
54008
- const randomId = () => {
54009
- return Math.floor(Math.random() * 4294967295).toString();
54010
- };
54011
54444
  class DocumentSectionView {
54012
54445
  constructor(node, getPos, decorations, editor) {
54013
54446
  __privateAdd$1(this, _DocumentSectionView_instances);
@@ -54389,6 +54822,48 @@ const DocumentSection = Node$1.create({
54389
54822
  };
54390
54823
  }
54391
54824
  });
54825
+ const DocumentPartObject = Node$1.create({
54826
+ name: "documentPartObject",
54827
+ group: "block",
54828
+ content: "block*",
54829
+ isolating: true,
54830
+ addOptions() {
54831
+ return {
54832
+ htmlAttributes: {
54833
+ class: "sd-document-part-object-block",
54834
+ "aria-label": "Structured document part block"
54835
+ }
54836
+ };
54837
+ },
54838
+ parseDOM() {
54839
+ return [
54840
+ {
54841
+ tag: "div.sd-document-part-object-block",
54842
+ priority: 60
54843
+ }
54844
+ ];
54845
+ },
54846
+ renderDOM({ htmlAttributes }) {
54847
+ return ["div", Attribute2.mergeAttributes(this.options.htmlAttributes, htmlAttributes), 0];
54848
+ },
54849
+ addAttributes() {
54850
+ return {
54851
+ sdBlockId: {
54852
+ default: null,
54853
+ keepOnSplit: false,
54854
+ parseDOM: (elem) => elem.getAttribute("data-sd-block-id"),
54855
+ renderDOM: (attrs) => {
54856
+ return attrs.sdBlockId ? { "data-sd-block-id": attrs.sdBlockId } : {};
54857
+ }
54858
+ },
54859
+ id: {},
54860
+ docPartGallery: {},
54861
+ docPartUnique: {
54862
+ default: true
54863
+ }
54864
+ };
54865
+ }
54866
+ });
54392
54867
  const Document = Node$1.create({
54393
54868
  name: "doc",
54394
54869
  topNode: true,
@@ -55525,7 +56000,12 @@ const generateDecorations = (state2, styles) => {
55525
56000
  return { ...base2, ...linkedStyle.definition?.styles || {} };
55526
56001
  };
55527
56002
  const pMap = buildStyleMap(paragraphStyleId);
55528
- const tMap = buildStyleMap(inlineTextStyleId);
56003
+ let tMap;
56004
+ if (paragraphStyleId?.startsWith("TOC")) {
56005
+ tMap = {};
56006
+ } else {
56007
+ tMap = buildStyleMap(inlineTextStyleId);
56008
+ }
55529
56009
  const rMap = buildStyleMap(runStyleId);
55530
56010
  const finalStyles = { ...pMap, ...tMap, ...rMap };
55531
56011
  if (Object.keys(finalStyles).length === 0) return;
@@ -56822,7 +57302,7 @@ const CommentsMark = Mark2.create({
56822
57302
  });
56823
57303
  const defaultTabDistance = 48;
56824
57304
  const defaultLineLength = 816;
56825
- const getTabDecorations = (doc2, view, from2 = 0, to = null) => {
57305
+ const getTabDecorations = (doc2, view, helpers2, from2 = 0, to = null) => {
56826
57306
  const decorations = [];
56827
57307
  const paragraphCache = /* @__PURE__ */ new Map();
56828
57308
  const end2 = to ?? doc2.content.size;
@@ -56830,7 +57310,7 @@ const getTabDecorations = (doc2, view, from2 = 0, to = null) => {
56830
57310
  if (node.type.name !== "tab") return;
56831
57311
  let extraStyles = "";
56832
57312
  const $pos = doc2.resolve(pos);
56833
- const paragraphContext = getParagraphContext($pos, paragraphCache);
57313
+ const paragraphContext = getParagraphContext($pos, paragraphCache, helpers2);
56834
57314
  if (!paragraphContext) return;
56835
57315
  try {
56836
57316
  const { tabStops, flattened, startPos } = paragraphContext;
@@ -56885,18 +57365,27 @@ const getTabDecorations = (doc2, view, from2 = 0, to = null) => {
56885
57365
  });
56886
57366
  return decorations;
56887
57367
  };
56888
- function getParagraphContext($pos, cache2) {
57368
+ function getParagraphContext($pos, cache2, helpers2) {
56889
57369
  for (let depth = $pos.depth; depth >= 0; depth--) {
56890
57370
  const node = $pos.node(depth);
56891
57371
  if (node?.type?.name === "paragraph") {
56892
57372
  const startPos = $pos.start(depth);
56893
57373
  if (!cache2.has(startPos)) {
57374
+ let tabStops = [];
57375
+ if (Array.isArray(node.attrs?.tabStops)) {
57376
+ tabStops = node.attrs.tabStops;
57377
+ } else {
57378
+ const style2 = helpers2.linkedStyles.getStyleById(node.attrs?.styleId);
57379
+ if (Array.isArray(style2?.definition?.styles?.tabStops)) {
57380
+ tabStops = style2.definition.styles.tabStops;
57381
+ }
57382
+ }
56894
57383
  cache2.set(startPos, {
56895
57384
  paragraph: node,
56896
57385
  paragraphDepth: depth,
56897
57386
  startPos,
56898
57387
  indent: node.attrs?.indent || {},
56899
- tabStops: Array.isArray(node.attrs?.tabStops) ? node.attrs.tabStops : [],
57388
+ tabStops,
56900
57389
  flattened: flattenParagraph(node, startPos),
56901
57390
  accumulatedTabWidth: 0
56902
57391
  });
@@ -57062,7 +57551,7 @@ const TabNode = Node$1.create({
57062
57551
  };
57063
57552
  },
57064
57553
  addPmPlugins() {
57065
- const { view } = this.editor;
57554
+ const { view, helpers: helpers2 } = this.editor;
57066
57555
  const tabPlugin = new Plugin({
57067
57556
  name: "tabPlugin",
57068
57557
  key: new PluginKey("tabPlugin"),
@@ -57072,7 +57561,7 @@ const TabNode = Node$1.create({
57072
57561
  },
57073
57562
  apply(tr, { decorations }, _oldState, newState) {
57074
57563
  if (!decorations) {
57075
- decorations = DecorationSet.create(newState.doc, getTabDecorations(newState.doc, view));
57564
+ decorations = DecorationSet.create(newState.doc, getTabDecorations(newState.doc, view, helpers2));
57076
57565
  }
57077
57566
  if (!tr.docChanged) {
57078
57567
  return { decorations };
@@ -57112,7 +57601,7 @@ const TabNode = Node$1.create({
57112
57601
  rangesToRecalculate.forEach(([start2, end2]) => {
57113
57602
  const oldDecorations = decorations.find(start2, end2);
57114
57603
  decorations = decorations.remove(oldDecorations);
57115
- const newDecorations = getTabDecorations(newState.doc, view, start2, end2);
57604
+ const newDecorations = getTabDecorations(newState.doc, view, helpers2, start2, end2);
57116
57605
  decorations = decorations.add(newState.doc, newDecorations);
57117
57606
  });
57118
57607
  return { decorations };
@@ -63393,6 +63882,43 @@ const processMarks = (marks) => {
63393
63882
  });
63394
63883
  return styles;
63395
63884
  };
63885
+ const PageReference = Node$1.create({
63886
+ name: "pageReference",
63887
+ group: "inline",
63888
+ inline: true,
63889
+ atom: true,
63890
+ draggable: false,
63891
+ selectable: false,
63892
+ content: "inline*",
63893
+ addOptions() {
63894
+ return {
63895
+ htmlAttributes: {
63896
+ contenteditable: false,
63897
+ "data-id": "auto-page-reference",
63898
+ "aria-label": "Page reference node",
63899
+ class: "sd-editor-page-reference"
63900
+ }
63901
+ };
63902
+ },
63903
+ addAttributes() {
63904
+ return {
63905
+ marksAsAttrs: {
63906
+ default: null,
63907
+ rendered: false
63908
+ },
63909
+ instruction: {
63910
+ default: "",
63911
+ rendered: false
63912
+ }
63913
+ };
63914
+ },
63915
+ parseDOM() {
63916
+ return [{ tag: 'span[data-id="auto-page-reference"]' }];
63917
+ },
63918
+ renderDOM({ htmlAttributes }) {
63919
+ return ["span", Attribute2.mergeAttributes(this.options.htmlAttributes, htmlAttributes), 0];
63920
+ }
63921
+ });
63396
63922
  const ShapeContainer = Node$1.create({
63397
63923
  name: "shapeContainer",
63398
63924
  group: "block",
@@ -63806,6 +64332,51 @@ const checkForNewBlockNodesInTrs = (transactions) => {
63806
64332
  });
63807
64333
  });
63808
64334
  };
64335
+ const TableOfContents = Node$1.create({
64336
+ name: "tableOfContents",
64337
+ group: "block",
64338
+ content: "paragraph+",
64339
+ inline: false,
64340
+ addOptions() {
64341
+ return {
64342
+ htmlAttributes: {
64343
+ "data-id": "table-of-contents",
64344
+ "aria-label": "Table of Contents"
64345
+ }
64346
+ };
64347
+ },
64348
+ parseDOM() {
64349
+ return [
64350
+ {
64351
+ tag: 'div[data-id="table-of-contents"]'
64352
+ }
64353
+ ];
64354
+ },
64355
+ renderDOM({ htmlAttributes }) {
64356
+ return ["div", Attribute2.mergeAttributes(this.options.htmlAttributes, htmlAttributes), 0];
64357
+ },
64358
+ addAttributes() {
64359
+ return {
64360
+ instruction: {
64361
+ default: null,
64362
+ rendered: false
64363
+ },
64364
+ /**
64365
+ * @private
64366
+ * @category Attribute
64367
+ * @param {string} [sdBlockId] - Internal block tracking ID (not user-configurable)
64368
+ */
64369
+ sdBlockId: {
64370
+ default: null,
64371
+ keepOnSplit: false,
64372
+ parseDOM: (elem) => elem.getAttribute("data-sd-block-id"),
64373
+ renderDOM: (attrs) => {
64374
+ return attrs.sdBlockId ? { "data-sd-block-id": attrs.sdBlockId } : {};
64375
+ }
64376
+ }
64377
+ };
64378
+ }
64379
+ });
63809
64380
  const TextStyle = Mark2.create({
63810
64381
  name: "textStyle",
63811
64382
  addOptions() {
@@ -70412,6 +70983,7 @@ const getStarterExtensions = () => {
70412
70983
  SlashMenu,
70413
70984
  Strike,
70414
70985
  TabNode,
70986
+ TableOfContents,
70415
70987
  Text,
70416
70988
  TextAlign,
70417
70989
  TextIndent,
@@ -70446,6 +71018,7 @@ const getStarterExtensions = () => {
70446
71018
  AiLoaderNode,
70447
71019
  PageNumber,
70448
71020
  TotalPageCount,
71021
+ PageReference,
70449
71022
  ShapeContainer,
70450
71023
  ShapeTextbox,
70451
71024
  ContentBlock,
@@ -70454,6 +71027,7 @@ const getStarterExtensions = () => {
70454
71027
  StructuredContentBlock,
70455
71028
  StructuredContentCommands,
70456
71029
  DocumentSection,
71030
+ DocumentPartObject,
70457
71031
  NodeResizer,
70458
71032
  CustomSelection,
70459
71033
  TextTransform
@@ -85990,71 +86564,73 @@ const _sfc_main = {
85990
86564
  };
85991
86565
  const SuperInput = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-4d5cff52"]]);
85992
86566
  const additionalHandlers = Object.freeze({
85993
- "mc:AlternateContent": translator,
85994
- "w:b": translator$12,
85995
- "w:bidiVisual": translator$F,
85996
- "w:bookmarkEnd": translator$1,
85997
- "w:bookmarkStart": translator$2,
85998
- "w:bottom": translator$s,
85999
- "w:br": translator$16,
86000
- "w:cantSplit": translator$T,
86001
- "w:cnfStyle": translator$S,
86002
- "w:color": translator$_,
86003
- "w:divId": translator$R,
86004
- "w:drawing": translator$4,
86005
- "w:end": translator$q,
86006
- "w:gridAfter": translator$Q,
86007
- "w:gridBefore": translator$P,
86008
- "w:gridCol": translator$b,
86009
- "w:hidden": translator$O,
86010
- "w:highlight": translator$15,
86011
- "w:hyperlink": translator$7,
86012
- "w:i": translator$11,
86013
- "w:insideH": translator$o,
86014
- "w:insideV": translator$n,
86015
- "w:jc": translator$N,
86016
- "w:left": translator$m,
86017
- "w:p": translator$13,
86018
- "w:r": translator$U,
86019
- "w:rFonts": translator$Z,
86020
- "w:rPr": translator$V,
86021
- "w:rStyle": translator$Y,
86022
- "w:right": translator$k,
86023
- "w:sdt": translator$3,
86024
- "w:shd": translator$E,
86025
- "w:start": translator$i,
86026
- "w:strike": translator$$,
86027
- "w:sz": translator$X,
86028
- "w:szCs": translator$W,
86029
- "w:tab": translator$14,
86030
- "w:tbl": translator$9,
86031
- "w:tblBorders": translator$e,
86032
- "w:tblCaption": translator$D,
86033
- "w:tblCellMar": translator$d,
86034
- "w:tblCellSpacing": translator$M,
86035
- "w:tblDescription": translator$C,
86036
- "w:tblGrid": translator$a,
86037
- "w:tblHeader": translator$L,
86038
- "w:tblInd": translator$B,
86039
- "w:tblLayout": translator$A,
86040
- "w:tblLook": translator$z,
86041
- "w:tblOverlap": translator$y,
86042
- "w:tblPr": translator$c,
86043
- "w:tblStyle": translator$x,
86044
- "w:tblStyleColBandSize": translator$w,
86045
- "w:tblStyleRowBandSize": translator$v,
86046
- "w:tblW": translator$u,
86047
- "w:tblpPr": translator$t,
86048
- "w:tc": translator$8,
86049
- "w:top": translator$g,
86050
- "w:tr": translator$G,
86051
- "w:trHeight": translator$K,
86052
- "w:trPr": translator$H,
86053
- "w:u": translator$10,
86054
- "w:wAfter": translator$J,
86055
- "w:wBefore": translator$I,
86056
- "wp:anchor": translator$6,
86057
- "wp:inline": translator$5
86567
+ "mc:AlternateContent": translator$2,
86568
+ "sd:pageReference": translator$1,
86569
+ "sd:tableOfContents": translator,
86570
+ "w:b": translator$15,
86571
+ "w:bidiVisual": translator$G,
86572
+ "w:bookmarkEnd": translator$3,
86573
+ "w:bookmarkStart": translator$4,
86574
+ "w:bottom": translator$t,
86575
+ "w:br": translator$19,
86576
+ "w:cantSplit": translator$U,
86577
+ "w:cnfStyle": translator$T,
86578
+ "w:color": translator$11,
86579
+ "w:divId": translator$S,
86580
+ "w:drawing": translator$6,
86581
+ "w:end": translator$r,
86582
+ "w:gridAfter": translator$R,
86583
+ "w:gridBefore": translator$Q,
86584
+ "w:gridCol": translator$c,
86585
+ "w:hidden": translator$P,
86586
+ "w:highlight": translator$18,
86587
+ "w:hyperlink": translator$W,
86588
+ "w:i": translator$14,
86589
+ "w:insideH": translator$p,
86590
+ "w:insideV": translator$o,
86591
+ "w:jc": translator$O,
86592
+ "w:left": translator$n,
86593
+ "w:p": translator$16,
86594
+ "w:r": translator$V,
86595
+ "w:rFonts": translator$10,
86596
+ "w:rPr": translator$X,
86597
+ "w:rStyle": translator$$,
86598
+ "w:right": translator$l,
86599
+ "w:sdt": translator$5,
86600
+ "w:shd": translator$F,
86601
+ "w:start": translator$j,
86602
+ "w:strike": translator$12,
86603
+ "w:sz": translator$_,
86604
+ "w:szCs": translator$Z,
86605
+ "w:tab": translator$17,
86606
+ "w:tbl": translator$a,
86607
+ "w:tblBorders": translator$f,
86608
+ "w:tblCaption": translator$E,
86609
+ "w:tblCellMar": translator$e,
86610
+ "w:tblCellSpacing": translator$N,
86611
+ "w:tblDescription": translator$D,
86612
+ "w:tblGrid": translator$b,
86613
+ "w:tblHeader": translator$M,
86614
+ "w:tblInd": translator$C,
86615
+ "w:tblLayout": translator$B,
86616
+ "w:tblLook": translator$A,
86617
+ "w:tblOverlap": translator$z,
86618
+ "w:tblPr": translator$d,
86619
+ "w:tblStyle": translator$y,
86620
+ "w:tblStyleColBandSize": translator$x,
86621
+ "w:tblStyleRowBandSize": translator$w,
86622
+ "w:tblW": translator$v,
86623
+ "w:tblpPr": translator$u,
86624
+ "w:tc": translator$9,
86625
+ "w:top": translator$h,
86626
+ "w:tr": translator$H,
86627
+ "w:trHeight": translator$L,
86628
+ "w:trPr": translator$I,
86629
+ "w:u": translator$13,
86630
+ "w:wAfter": translator$K,
86631
+ "w:wBefore": translator$J,
86632
+ "wp:anchor": translator$8,
86633
+ "wp:inline": translator$7
86058
86634
  });
86059
86635
  const baseHandlers = {
86060
86636
  ...runPropertyTranslators,