@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
@@ -22730,6 +22730,10 @@
22730
22730
  }
22731
22731
  return id.join("");
22732
22732
  }
22733
+ function generateRandomSigned32BitIntStrId() {
22734
+ const val = Math.floor(Math.random() * 2147483647);
22735
+ return val.toString();
22736
+ }
22733
22737
  function generateRandom32BitHex() {
22734
22738
  const val = Math.floor(Math.random() * 2147483647);
22735
22739
  return val.toString(16).toUpperCase().padStart(8, "0");
@@ -30308,6 +30312,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
30308
30312
  generateDocxListAttributes,
30309
30313
  generateDocxRandomId,
30310
30314
  generateRandom32BitHex,
30315
+ generateRandomSigned32BitIntStrId,
30311
30316
  getActiveFormatting,
30312
30317
  getExtensionConfigField,
30313
30318
  getMarkRange,
@@ -30705,13 +30710,56 @@ Please report this to https://github.com/markedjs/marked.`, e) {
30705
30710
  const { content: nodes } = params2.node;
30706
30711
  if (!nodes) return [];
30707
30712
  const translatedNodes = [];
30708
- nodes.forEach((node) => {
30713
+ const hyperlinkGroup = [];
30714
+ let index2 = 0;
30715
+ while (index2 < nodes.length) {
30716
+ const node = nodes[index2];
30717
+ const linkMark = _isLinkNode(node);
30718
+ if (linkMark) {
30719
+ hyperlinkGroup.push(node);
30720
+ const nextNode = index2 + 1 < nodes.length ? nodes[index2 + 1] : null;
30721
+ const nextIsLink = _isLinkNode(nextNode, linkMark);
30722
+ if (nextIsLink) {
30723
+ index2++;
30724
+ continue;
30725
+ } else {
30726
+ let translatedLinkGroup = exportSchemaToJson({
30727
+ ...params2,
30728
+ node: hyperlinkGroup[0],
30729
+ extraParams: { ...params2.extraParams || {}, hyperlinkGroup: hyperlinkGroup.slice() }
30730
+ });
30731
+ if (translatedLinkGroup instanceof Array) translatedNodes.push(...translatedLinkGroup);
30732
+ else translatedNodes.push(translatedLinkGroup);
30733
+ hyperlinkGroup.length = 0;
30734
+ index2++;
30735
+ continue;
30736
+ }
30737
+ }
30709
30738
  let translatedNode = exportSchemaToJson({ ...params2, node });
30710
30739
  if (translatedNode instanceof Array) translatedNodes.push(...translatedNode);
30711
30740
  else translatedNodes.push(translatedNode);
30712
- });
30741
+ index2++;
30742
+ }
30713
30743
  return translatedNodes.filter((n) => n);
30714
30744
  }
30745
+ function _isLinkNode(node, referenceMark = null) {
30746
+ if (!node || !node.marks && !node.attrs?.marksAsAttrs) return null;
30747
+ const marks = node.marks || node.attrs.marksAsAttrs;
30748
+ const linkMark = marks.find((mark) => mark.type === "link");
30749
+ if (!linkMark) return null;
30750
+ if (referenceMark) {
30751
+ return _isSameLinkMark(linkMark.attrs, referenceMark.attrs) ? linkMark : null;
30752
+ }
30753
+ return linkMark;
30754
+ }
30755
+ function _isSameLinkMark(attrsA, attrsB) {
30756
+ for (let key2 of ["anchor", "docLocation", "history", "href", "rId", "target"]) {
30757
+ if (attrsA[key2] != attrsB[key2]) {
30758
+ return false;
30759
+ }
30760
+ }
30761
+ return true;
30762
+ }
30715
30763
  const baseNumbering = {
30716
30764
  declaration: {
30717
30765
  attributes: {
@@ -32058,37 +32106,37 @@ Please report this to https://github.com/markedjs/marked.`, e) {
32058
32106
  };
32059
32107
  __publicField$2(_NodeTranslator, "translatorTypes", TranslatorTypes);
32060
32108
  let NodeTranslator = _NodeTranslator;
32061
- const encode$18 = (attributes) => {
32109
+ const encode$1b = (attributes) => {
32062
32110
  return attributes["w:type"];
32063
32111
  };
32064
- const decode$$ = (attrs) => {
32112
+ const decode$11 = (attrs) => {
32065
32113
  const { lineBreakType } = attrs;
32066
32114
  return lineBreakType;
32067
32115
  };
32068
32116
  const attrConfig$F = Object.freeze({
32069
32117
  xmlName: "w:type",
32070
32118
  sdName: "lineBreakType",
32071
- encode: encode$18,
32072
- decode: decode$$
32119
+ encode: encode$1b,
32120
+ decode: decode$11
32073
32121
  });
32074
- const encode$17 = (attributes) => {
32122
+ const encode$1a = (attributes) => {
32075
32123
  const xmlAttrValue = attributes["w:clear"];
32076
32124
  return xmlAttrValue;
32077
32125
  };
32078
- const decode$_ = (attrs) => {
32126
+ const decode$10 = (attrs) => {
32079
32127
  const { clear } = attrs;
32080
32128
  return clear;
32081
32129
  };
32082
32130
  const attrConfig$E = Object.freeze({
32083
32131
  xmlName: "w:clear",
32084
32132
  sdName: "clear",
32085
- encode: encode$17,
32086
- decode: decode$_
32133
+ encode: encode$1a,
32134
+ decode: decode$10
32087
32135
  });
32088
32136
  const validXmlAttributes$m = [attrConfig$F, attrConfig$E];
32089
- const XML_NODE_NAME$u = "w:br";
32090
- const SD_NODE_NAME$d = "lineBreak";
32091
- const encode$16 = (_2, encodedAttrs) => {
32137
+ const XML_NODE_NAME$x = "w:br";
32138
+ const SD_NODE_NAME$f = "lineBreak";
32139
+ const encode$19 = (_2, encodedAttrs) => {
32092
32140
  const isPageBreak = encodedAttrs?.lineBreakType === "page";
32093
32141
  const translated = {
32094
32142
  type: isPageBreak ? "hardBreak" : "lineBreak"
@@ -32098,7 +32146,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
32098
32146
  }
32099
32147
  return translated;
32100
32148
  };
32101
- const decode$Z = (params2, decodedAttrs) => {
32149
+ const decode$$ = (params2, decodedAttrs) => {
32102
32150
  const { node } = params2;
32103
32151
  if (!node) return;
32104
32152
  const wBreak = { name: "w:br" };
@@ -32115,39 +32163,39 @@ Please report this to https://github.com/markedjs/marked.`, e) {
32115
32163
  };
32116
32164
  return translated;
32117
32165
  };
32118
- const config$s = {
32119
- xmlName: XML_NODE_NAME$u,
32120
- sdNodeOrKeyName: SD_NODE_NAME$d,
32166
+ const config$v = {
32167
+ xmlName: XML_NODE_NAME$x,
32168
+ sdNodeOrKeyName: SD_NODE_NAME$f,
32121
32169
  type: NodeTranslator.translatorTypes.NODE,
32122
- encode: encode$16,
32123
- decode: decode$Z,
32170
+ encode: encode$19,
32171
+ decode: decode$$,
32124
32172
  attributes: validXmlAttributes$m
32125
32173
  };
32126
- const translator$16 = NodeTranslator.from(config$s);
32127
- const encode$15 = (attributes) => attributes?.["w:val"];
32128
- const decode$Y = (attrs) => attrs?.highlight;
32174
+ const translator$19 = NodeTranslator.from(config$v);
32175
+ const encode$18 = (attributes) => attributes?.["w:val"];
32176
+ const decode$_ = (attrs) => attrs?.highlight;
32129
32177
  const attrConfig$D = Object.freeze({
32130
32178
  xmlName: "w:val",
32131
32179
  sdName: "highlight",
32132
- encode: encode$15,
32133
- decode: decode$Y
32180
+ encode: encode$18,
32181
+ decode: decode$_
32134
32182
  });
32135
32183
  const validXmlAttributes$l = [attrConfig$D];
32136
- const XML_NODE_NAME$t = "w:highlight";
32137
- const SD_ATTR_KEY$f = "highlight";
32184
+ const XML_NODE_NAME$w = "w:highlight";
32185
+ const SD_ATTR_KEY$g = "highlight";
32138
32186
  const DISABLED_TOKENS = /* @__PURE__ */ new Set(["transparent", "none", "inherit"]);
32139
- const encode$14 = (params2, encodedAttrs = {}) => {
32187
+ const encode$17 = (params2, encodedAttrs = {}) => {
32140
32188
  const { nodes } = params2;
32141
32189
  const node = nodes?.[0];
32142
32190
  const value = encodedAttrs.highlight ?? node?.attributes?.["w:val"];
32143
32191
  return {
32144
32192
  type: "attr",
32145
- xmlName: XML_NODE_NAME$t,
32146
- sdNodeOrKeyName: SD_ATTR_KEY$f,
32193
+ xmlName: XML_NODE_NAME$w,
32194
+ sdNodeOrKeyName: SD_ATTR_KEY$g,
32147
32195
  attributes: { "w:val": value ?? null }
32148
32196
  };
32149
32197
  };
32150
- const decode$X = (params2) => {
32198
+ const decode$Z = (params2) => {
32151
32199
  const attrs = params2?.node?.attrs || {};
32152
32200
  const highlightValue = attrs.highlight ?? attrs.color ?? null;
32153
32201
  if (!highlightValue) return void 0;
@@ -32155,14 +32203,14 @@ Please report this to https://github.com/markedjs/marked.`, e) {
32155
32203
  if (!normalizedValue) return void 0;
32156
32204
  if (DISABLED_TOKENS.has(normalizedValue)) {
32157
32205
  return {
32158
- name: XML_NODE_NAME$t,
32206
+ name: XML_NODE_NAME$w,
32159
32207
  attributes: { "w:val": "none" }
32160
32208
  };
32161
32209
  }
32162
32210
  const keyword = getDocxHighlightKeywordFromHex(highlightValue);
32163
32211
  if (keyword) {
32164
32212
  return {
32165
- name: XML_NODE_NAME$t,
32213
+ name: XML_NODE_NAME$w,
32166
32214
  attributes: { "w:val": keyword }
32167
32215
  };
32168
32216
  }
@@ -32177,63 +32225,63 @@ Please report this to https://github.com/markedjs/marked.`, e) {
32177
32225
  }
32178
32226
  };
32179
32227
  };
32180
- const config$r = {
32181
- xmlName: XML_NODE_NAME$t,
32182
- sdNodeOrKeyName: SD_ATTR_KEY$f,
32228
+ const config$u = {
32229
+ xmlName: XML_NODE_NAME$w,
32230
+ sdNodeOrKeyName: SD_ATTR_KEY$g,
32183
32231
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
32184
- encode: encode$14,
32185
- decode: decode$X,
32232
+ encode: encode$17,
32233
+ decode: decode$Z,
32186
32234
  attributes: validXmlAttributes$l
32187
32235
  };
32188
- const translator$15 = NodeTranslator.from(config$r);
32189
- const encode$13 = (attributes) => {
32236
+ const translator$18 = NodeTranslator.from(config$u);
32237
+ const encode$16 = (attributes) => {
32190
32238
  return attributes["w:val"];
32191
32239
  };
32192
- const decode$W = (attrs) => {
32240
+ const decode$Y = (attrs) => {
32193
32241
  const { tabSize } = attrs || {};
32194
32242
  return tabSize;
32195
32243
  };
32196
32244
  const attrConfig$C = Object.freeze({
32197
32245
  xmlName: "w:val",
32198
32246
  sdName: "tabSize",
32199
- encode: encode$13,
32200
- decode: decode$W
32247
+ encode: encode$16,
32248
+ decode: decode$Y
32201
32249
  });
32202
- const encode$12 = (attributes) => {
32250
+ const encode$15 = (attributes) => {
32203
32251
  return attributes["w:leader"];
32204
32252
  };
32205
- const decode$V = (attrs) => {
32253
+ const decode$X = (attrs) => {
32206
32254
  const { leader } = attrs || {};
32207
32255
  return leader;
32208
32256
  };
32209
32257
  const attrConfig$B = Object.freeze({
32210
32258
  xmlName: "w:leader",
32211
32259
  sdName: "leader",
32212
- encode: encode$12,
32213
- decode: decode$V
32260
+ encode: encode$15,
32261
+ decode: decode$X
32214
32262
  });
32215
- const encode$11 = (attributes) => {
32263
+ const encode$14 = (attributes) => {
32216
32264
  return attributes["w:pos"];
32217
32265
  };
32218
- const decode$U = (attrs) => {
32266
+ const decode$W = (attrs) => {
32219
32267
  const { pos } = attrs || {};
32220
32268
  return pos;
32221
32269
  };
32222
32270
  const attrConfig$A = Object.freeze({
32223
32271
  xmlName: "w:pos",
32224
32272
  sdName: "pos",
32225
- encode: encode$11,
32226
- decode: decode$U
32273
+ encode: encode$14,
32274
+ decode: decode$W
32227
32275
  });
32228
32276
  const validXmlAttributes$k = [attrConfig$C, attrConfig$A, attrConfig$B];
32229
- const XML_NODE_NAME$s = "w:tab";
32230
- const SD_NODE_NAME$c = "tab";
32231
- const encode$10 = (_2, encodedAttrs = {}) => {
32277
+ const XML_NODE_NAME$v = "w:tab";
32278
+ const SD_NODE_NAME$e = "tab";
32279
+ const encode$13 = (_2, encodedAttrs = {}) => {
32232
32280
  const translated = { type: "tab" };
32233
32281
  if (encodedAttrs) translated.attrs = { ...encodedAttrs };
32234
32282
  return translated;
32235
32283
  };
32236
- const decode$T = (params2, decodedAttrs = {}) => {
32284
+ const decode$V = (params2, decodedAttrs = {}) => {
32237
32285
  const { node } = params2 || {};
32238
32286
  if (!node) return;
32239
32287
  const wTab = { name: "w:tab" };
@@ -32249,15 +32297,15 @@ Please report this to https://github.com/markedjs/marked.`, e) {
32249
32297
  }
32250
32298
  return translated;
32251
32299
  };
32252
- const config$q = {
32253
- xmlName: XML_NODE_NAME$s,
32254
- sdNodeOrKeyName: SD_NODE_NAME$c,
32300
+ const config$t = {
32301
+ xmlName: XML_NODE_NAME$v,
32302
+ sdNodeOrKeyName: SD_NODE_NAME$e,
32255
32303
  type: NodeTranslator.translatorTypes.NODE,
32256
- encode: encode$10,
32257
- decode: decode$T,
32304
+ encode: encode$13,
32305
+ decode: decode$V,
32258
32306
  attributes: validXmlAttributes$k
32259
32307
  };
32260
- const translator$14 = NodeTranslator.from(config$q);
32308
+ const translator$17 = NodeTranslator.from(config$t);
32261
32309
  const mergeTextNodes = (nodes) => {
32262
32310
  if (!nodes || !Array.isArray(nodes)) {
32263
32311
  return nodes;
@@ -32631,104 +32679,10 @@ Please report this to https://github.com/markedjs/marked.`, e) {
32631
32679
  justify: pPrByIdJcAttr
32632
32680
  };
32633
32681
  };
32634
- const preProcessNodesForFldChar = (nodes = []) => {
32635
- const processedNodes = [];
32636
- let buffer2 = [];
32637
- let collecting = false;
32638
- for (const node of nodes) {
32639
- const fldCharEl = node.elements?.find((el) => el.name === "w:fldChar");
32640
- const fldType = fldCharEl?.attributes?.["w:fldCharType"];
32641
- if (fldType === "begin") {
32642
- buffer2 = [node];
32643
- collecting = true;
32644
- continue;
32645
- }
32646
- if (fldType === "separate" && collecting) {
32647
- buffer2.push(node);
32648
- continue;
32649
- }
32650
- if (fldType === "end" && collecting) {
32651
- buffer2.push(node);
32652
- processedNodes.push(...processCombinedNodesForFldChar(buffer2));
32653
- buffer2 = [];
32654
- collecting = false;
32655
- continue;
32656
- }
32657
- if (collecting) {
32658
- buffer2.push(node);
32659
- } else {
32660
- processedNodes.push(node);
32661
- }
32662
- }
32663
- if (buffer2.length) {
32664
- processedNodes.push(...buffer2);
32665
- }
32666
- return processedNodes;
32667
- };
32668
- const processCombinedNodesForFldChar = (nodesToCombine = []) => {
32669
- let processedNodes = [];
32670
- let hasPageMarker = false;
32671
- let isNumPages = false;
32672
- const textStart = nodesToCombine.findIndex(
32673
- (n) => n.elements?.some((el) => el.name === "w:fldChar" && el.attributes["w:fldCharType"] === "separate")
32674
- );
32675
- const textEnd = nodesToCombine.findIndex(
32676
- (n) => n.elements?.some((el) => el.name === "w:fldChar" && el.attributes["w:fldCharType"] === "end")
32677
- );
32678
- const textNodes = nodesToCombine.slice(textStart + 1, textEnd);
32679
- const instrTextContainer = nodesToCombine.find((n) => n.elements?.some((el) => el.name === "w:instrText"));
32680
- const instrTextNode = instrTextContainer?.elements?.find((el) => el.name === "w:instrText");
32681
- const instrText = instrTextNode?.elements[0].text;
32682
- if (!hasPageMarker) hasPageMarker = instrText?.trim().startsWith("PAGE");
32683
- if (!isNumPages) isNumPages = instrText?.trim().startsWith("NUMPAGES");
32684
- const urlMatch = instrText?.match(/HYPERLINK\s+"([^"]+)"/);
32685
- if (hasPageMarker) {
32686
- const pageNumNode = {
32687
- name: "sd:autoPageNumber",
32688
- type: "element"
32689
- };
32690
- nodesToCombine.forEach((n) => {
32691
- const rPrNode = n.elements.find((el) => el.name === "w:rPr");
32692
- if (rPrNode) pageNumNode.elements = [rPrNode];
32693
- });
32694
- processedNodes.push(pageNumNode);
32695
- } else if (isNumPages) {
32696
- const totalPageNumNode = {
32697
- name: "sd:totalPageNumber",
32698
- type: "element"
32699
- };
32700
- nodesToCombine.forEach((n) => {
32701
- const rPrNode = n.elements.find((el) => el.name === "w:rPr");
32702
- if (rPrNode) totalPageNumNode.elements = [rPrNode];
32703
- });
32704
- processedNodes.push(totalPageNumNode);
32705
- } else if (urlMatch && urlMatch?.length >= 2) {
32706
- const url = urlMatch[1];
32707
- const textMarks = [];
32708
- textNodes.forEach((n) => {
32709
- const rPr2 = n.elements.find((el) => el.name === "w:rPr");
32710
- if (!rPr2) return;
32711
- const { elements } = rPr2;
32712
- elements.forEach((el) => {
32713
- textMarks.push(el);
32714
- });
32715
- });
32716
- const linkMark = { name: "link", attributes: { href: url } };
32717
- const rPr = { name: "w:rPr", type: "element", elements: [linkMark, ...textMarks] };
32718
- processedNodes.push({
32719
- name: "w:r",
32720
- type: "element",
32721
- elements: [rPr, ...textNodes]
32722
- });
32723
- }
32724
- return processedNodes;
32725
- };
32726
32682
  const handleParagraphNode$1 = (params2) => {
32727
32683
  const { nodes, docx, nodeListHandler, filename } = params2;
32728
32684
  const node = carbonCopy(nodes[0]);
32729
32685
  let schemaNode;
32730
- let processedElements = preProcessNodesForFldChar(node.elements);
32731
- node.elements = processedElements;
32732
32686
  const handleStandardNode2 = nodeListHandler.handlerEntities.find(
32733
32687
  (e) => e.handlerName === "standardNodeHandler"
32734
32688
  )?.handler;
@@ -32869,89 +32823,89 @@ Please report this to https://github.com/markedjs/marked.`, e) {
32869
32823
  }
32870
32824
  return schemaNode;
32871
32825
  };
32872
- const encode$$ = (attributes) => {
32826
+ const encode$12 = (attributes) => {
32873
32827
  return attributes["w:rsidDel"];
32874
32828
  };
32875
- const decode$S = (attrs) => {
32829
+ const decode$U = (attrs) => {
32876
32830
  return attrs.rsidDel;
32877
32831
  };
32878
32832
  const attrConfig$z = Object.freeze({
32879
32833
  xmlName: "w:rsidDel",
32880
32834
  sdName: "rsidDel",
32881
- encode: encode$$,
32882
- decode: decode$S
32835
+ encode: encode$12,
32836
+ decode: decode$U
32883
32837
  });
32884
- const encode$_ = (attributes) => {
32838
+ const encode$11 = (attributes) => {
32885
32839
  return attributes["w:rsidP"];
32886
32840
  };
32887
- const decode$R = (attrs) => {
32841
+ const decode$T = (attrs) => {
32888
32842
  return attrs.rsidP;
32889
32843
  };
32890
32844
  const attrConfig$y = Object.freeze({
32891
32845
  xmlName: "w:rsidP",
32892
32846
  sdName: "rsidP",
32893
- encode: encode$_,
32894
- decode: decode$R
32847
+ encode: encode$11,
32848
+ decode: decode$T
32895
32849
  });
32896
- const encode$Z = (attributes) => {
32850
+ const encode$10 = (attributes) => {
32897
32851
  return attributes["w:rsidR"];
32898
32852
  };
32899
- const decode$Q = (attrs) => {
32853
+ const decode$S = (attrs) => {
32900
32854
  return attrs.rsidR;
32901
32855
  };
32902
32856
  const attrConfig$x = Object.freeze({
32903
32857
  xmlName: "w:rsidR",
32904
32858
  sdName: "rsidR",
32905
- encode: encode$Z,
32906
- decode: decode$Q
32859
+ encode: encode$10,
32860
+ decode: decode$S
32907
32861
  });
32908
- const encode$Y = (attributes) => {
32862
+ const encode$$ = (attributes) => {
32909
32863
  return attributes["w:rsidRPr"];
32910
32864
  };
32911
- const decode$P = (attrs) => {
32865
+ const decode$R = (attrs) => {
32912
32866
  return attrs.rsidRPr;
32913
32867
  };
32914
32868
  const attrConfig$w = Object.freeze({
32915
32869
  xmlName: "w:rsidRPr",
32916
32870
  sdName: "rsidRPr",
32917
- encode: encode$Y,
32918
- decode: decode$P
32871
+ encode: encode$$,
32872
+ decode: decode$R
32919
32873
  });
32920
- const encode$X = (attributes) => {
32874
+ const encode$_ = (attributes) => {
32921
32875
  return attributes["w:rsidRDefault"];
32922
32876
  };
32923
- const decode$O = (attrs) => {
32877
+ const decode$Q = (attrs) => {
32924
32878
  return attrs.rsidRDefault;
32925
32879
  };
32926
32880
  const attrConfig$v = Object.freeze({
32927
32881
  xmlName: "w:rsidRDefault",
32928
32882
  sdName: "rsidRDefault",
32929
- encode: encode$X,
32930
- decode: decode$O
32883
+ encode: encode$_,
32884
+ decode: decode$Q
32931
32885
  });
32932
- const encode$W = (attributes) => {
32886
+ const encode$Z = (attributes) => {
32933
32887
  return attributes["w14:paraId"];
32934
32888
  };
32935
- const decode$N = (attrs) => {
32889
+ const decode$P = (attrs) => {
32936
32890
  return attrs.paraId;
32937
32891
  };
32938
32892
  const attrConfig$u = Object.freeze({
32939
32893
  xmlName: "w14:paraId",
32940
32894
  sdName: "paraId",
32941
- encode: encode$W,
32942
- decode: decode$N
32895
+ encode: encode$Z,
32896
+ decode: decode$P
32943
32897
  });
32944
- const encode$V = (attributes) => {
32898
+ const encode$Y = (attributes) => {
32945
32899
  return attributes["w14:textId"];
32946
32900
  };
32947
- const decode$M = (attrs) => {
32901
+ const decode$O = (attrs) => {
32948
32902
  return attrs.textId;
32949
32903
  };
32950
32904
  const attrConfig$t = Object.freeze({
32951
32905
  xmlName: "w14:textId",
32952
32906
  sdName: "textId",
32953
- encode: encode$V,
32954
- decode: decode$M
32907
+ encode: encode$Y,
32908
+ decode: decode$O
32955
32909
  });
32956
32910
  const validXmlAttributes$j = [
32957
32911
  attrConfig$u,
@@ -32962,9 +32916,9 @@ Please report this to https://github.com/markedjs/marked.`, e) {
32962
32916
  attrConfig$w,
32963
32917
  attrConfig$z
32964
32918
  ];
32965
- const XML_NODE_NAME$r = "w:p";
32966
- const SD_NODE_NAME$b = "paragraph";
32967
- const encode$U = (params2, encodedAttrs = {}) => {
32919
+ const XML_NODE_NAME$u = "w:p";
32920
+ const SD_NODE_NAME$d = "paragraph";
32921
+ const encode$X = (params2, encodedAttrs = {}) => {
32968
32922
  const node = handleParagraphNode$1(params2);
32969
32923
  if (!node) return void 0;
32970
32924
  if (encodedAttrs && Object.keys(encodedAttrs).length) {
@@ -32972,7 +32926,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
32972
32926
  }
32973
32927
  return node;
32974
32928
  };
32975
- const decode$L = (params2, decodedAttrs = {}) => {
32929
+ const decode$N = (params2, decodedAttrs = {}) => {
32976
32930
  const translated = translateParagraphNode(params2);
32977
32931
  if (!translated) return void 0;
32978
32932
  if (decodedAttrs && Object.keys(decodedAttrs).length) {
@@ -32980,16 +32934,16 @@ Please report this to https://github.com/markedjs/marked.`, e) {
32980
32934
  }
32981
32935
  return translated;
32982
32936
  };
32983
- const config$p = {
32984
- xmlName: XML_NODE_NAME$r,
32985
- sdNodeOrKeyName: SD_NODE_NAME$b,
32937
+ const config$s = {
32938
+ xmlName: XML_NODE_NAME$u,
32939
+ sdNodeOrKeyName: SD_NODE_NAME$d,
32986
32940
  type: NodeTranslator.translatorTypes.NODE,
32987
- encode: encode$U,
32988
- decode: decode$L,
32941
+ encode: encode$X,
32942
+ decode: decode$N,
32989
32943
  attributes: validXmlAttributes$j
32990
32944
  };
32991
- const translator$13 = NodeTranslator.from(config$p);
32992
- const encode$T = (attributes) => {
32945
+ const translator$16 = NodeTranslator.from(config$s);
32946
+ const encode$W = (attributes) => {
32993
32947
  const raw = attributes?.["w:val"];
32994
32948
  if (raw === void 0 || raw === null) return void 0;
32995
32949
  if (typeof raw === "boolean") return raw;
@@ -32999,24 +32953,24 @@ Please report this to https://github.com/markedjs/marked.`, e) {
32999
32953
  if (val === "1" || val === "true" || val === "on") return true;
33000
32954
  return void 0;
33001
32955
  };
33002
- const decode$K = (runProps) => {
32956
+ const decode$M = (runProps) => {
33003
32957
  if (runProps?.bold === false) return "0";
33004
32958
  return void 0;
33005
32959
  };
33006
32960
  const attrConfig$s = Object.freeze({
33007
32961
  xmlName: "w:val",
33008
32962
  sdName: "bold",
33009
- encode: encode$T,
33010
- decode: decode$K
32963
+ encode: encode$W,
32964
+ decode: decode$M
33011
32965
  });
33012
32966
  const validXmlAttributes$i = [attrConfig$s];
33013
- const XML_NODE_NAME$q = "w:b";
33014
- const SD_ATTR_KEY$e = "bold";
33015
- const encode$S = (params2, encodedAttrs = {}) => {
32967
+ const XML_NODE_NAME$t = "w:b";
32968
+ const SD_ATTR_KEY$f = "bold";
32969
+ const encode$V = (params2, encodedAttrs = {}) => {
33016
32970
  const { nodes } = params2;
33017
32971
  const node = nodes[0];
33018
32972
  if (!node) return void 0;
33019
- const val = encodedAttrs?.[SD_ATTR_KEY$e];
32973
+ const val = encodedAttrs?.[SD_ATTR_KEY$f];
33020
32974
  let attributes;
33021
32975
  if (val === false) attributes = { "w:val": "0" };
33022
32976
  else if (val === true)
@@ -33024,85 +32978,85 @@ Please report this to https://github.com/markedjs/marked.`, e) {
33024
32978
  else attributes = node.attributes || {};
33025
32979
  return {
33026
32980
  type: "attr",
33027
- xmlName: XML_NODE_NAME$q,
33028
- sdNodeOrKeyName: SD_ATTR_KEY$e,
32981
+ xmlName: XML_NODE_NAME$t,
32982
+ sdNodeOrKeyName: SD_ATTR_KEY$f,
33029
32983
  attributes
33030
32984
  };
33031
32985
  };
33032
- const config$o = {
33033
- xmlName: XML_NODE_NAME$q,
33034
- sdNodeOrKeyName: SD_ATTR_KEY$e,
32986
+ const config$r = {
32987
+ xmlName: XML_NODE_NAME$t,
32988
+ sdNodeOrKeyName: SD_ATTR_KEY$f,
33035
32989
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
33036
- encode: encode$S,
32990
+ encode: encode$V,
33037
32991
  attributes: validXmlAttributes$i
33038
32992
  };
33039
- const translator$12 = NodeTranslator.from(config$o);
33040
- const XML_NODE_NAME$p = "w:i";
33041
- const SD_ATTR_KEY$d = "italic";
33042
- const encode$R = (params2) => {
32993
+ const translator$15 = NodeTranslator.from(config$r);
32994
+ const XML_NODE_NAME$s = "w:i";
32995
+ const SD_ATTR_KEY$e = "italic";
32996
+ const encode$U = (params2) => {
33043
32997
  const { nodes } = params2;
33044
32998
  const node = nodes?.[0];
33045
32999
  if (!node) return void 0;
33046
33000
  return {
33047
33001
  type: "attr",
33048
- xmlName: XML_NODE_NAME$p,
33049
- sdNodeOrKeyName: SD_ATTR_KEY$d,
33002
+ xmlName: XML_NODE_NAME$s,
33003
+ sdNodeOrKeyName: SD_ATTR_KEY$e,
33050
33004
  attributes: {
33051
33005
  "w:val": node.attributes?.["w:val"] ?? null
33052
33006
  }
33053
33007
  };
33054
33008
  };
33055
- const config$n = {
33056
- xmlName: XML_NODE_NAME$p,
33057
- sdNodeOrKeyName: SD_ATTR_KEY$d,
33009
+ const config$q = {
33010
+ xmlName: XML_NODE_NAME$s,
33011
+ sdNodeOrKeyName: SD_ATTR_KEY$e,
33058
33012
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
33059
- encode: encode$R
33013
+ encode: encode$U
33060
33014
  };
33061
- const translator$11 = NodeTranslator.from(config$n);
33062
- const encode$Q = (attributes) => attributes?.["w:val"];
33063
- const decode$J = (attrs) => attrs?.underline;
33015
+ const translator$14 = NodeTranslator.from(config$q);
33016
+ const encode$T = (attributes) => attributes?.["w:val"];
33017
+ const decode$L = (attrs) => attrs?.underline;
33064
33018
  const attrConfig$r = Object.freeze({
33065
33019
  xmlName: "w:val",
33066
33020
  sdName: "underline",
33067
- encode: encode$Q,
33068
- decode: decode$J
33021
+ encode: encode$T,
33022
+ decode: decode$L
33069
33023
  });
33070
- const encode$P = (attributes) => attributes?.["w:color"];
33071
- const decode$I = (attrs) => attrs?.color;
33024
+ const encode$S = (attributes) => attributes?.["w:color"];
33025
+ const decode$K = (attrs) => attrs?.color;
33072
33026
  const attrConfig$q = Object.freeze({
33073
33027
  xmlName: "w:color",
33074
33028
  sdName: "color",
33075
- encode: encode$P,
33076
- decode: decode$I
33029
+ encode: encode$S,
33030
+ decode: decode$K
33077
33031
  });
33078
- const encode$O = (attributes) => attributes?.["w:themeColor"];
33079
- const decode$H = (attrs) => attrs?.themeColor;
33032
+ const encode$R = (attributes) => attributes?.["w:themeColor"];
33033
+ const decode$J = (attrs) => attrs?.themeColor;
33080
33034
  const attrConfig$p = Object.freeze({
33081
33035
  xmlName: "w:themeColor",
33082
33036
  sdName: "themeColor",
33083
- encode: encode$O,
33084
- decode: decode$H
33037
+ encode: encode$R,
33038
+ decode: decode$J
33085
33039
  });
33086
- const encode$N = (attributes) => attributes?.["w:themeTint"];
33087
- const decode$G = (attrs) => attrs?.themeTint;
33040
+ const encode$Q = (attributes) => attributes?.["w:themeTint"];
33041
+ const decode$I = (attrs) => attrs?.themeTint;
33088
33042
  const attrConfig$o = Object.freeze({
33089
33043
  xmlName: "w:themeTint",
33090
33044
  sdName: "themeTint",
33091
- encode: encode$N,
33092
- decode: decode$G
33045
+ encode: encode$Q,
33046
+ decode: decode$I
33093
33047
  });
33094
- const encode$M = (attributes) => attributes?.["w:themeShade"];
33095
- const decode$F = (attrs) => attrs?.themeShade;
33048
+ const encode$P = (attributes) => attributes?.["w:themeShade"];
33049
+ const decode$H = (attrs) => attrs?.themeShade;
33096
33050
  const attrConfig$n = Object.freeze({
33097
33051
  xmlName: "w:themeShade",
33098
33052
  sdName: "themeShade",
33099
- encode: encode$M,
33100
- decode: decode$F
33053
+ encode: encode$P,
33054
+ decode: decode$H
33101
33055
  });
33102
33056
  const validXmlAttributes$h = [attrConfig$r, attrConfig$q, attrConfig$p, attrConfig$o, attrConfig$n];
33103
- const XML_NODE_NAME$o = "w:u";
33104
- const SD_ATTR_KEY$c = "underline";
33105
- const encode$L = (params2, encodedAttrs = {}) => {
33057
+ const XML_NODE_NAME$r = "w:u";
33058
+ const SD_ATTR_KEY$d = "underline";
33059
+ const encode$O = (params2, encodedAttrs = {}) => {
33106
33060
  const { nodes } = params2;
33107
33061
  const node = nodes?.[0];
33108
33062
  const sourceAttrs = node?.attributes || {};
@@ -33118,12 +33072,12 @@ Please report this to https://github.com/markedjs/marked.`, e) {
33118
33072
  if (themeShade !== void 0 && themeShade !== null) attributes["w:themeShade"] = themeShade;
33119
33073
  return {
33120
33074
  type: "attr",
33121
- xmlName: XML_NODE_NAME$o,
33122
- sdNodeOrKeyName: SD_ATTR_KEY$c,
33075
+ xmlName: XML_NODE_NAME$r,
33076
+ sdNodeOrKeyName: SD_ATTR_KEY$d,
33123
33077
  attributes
33124
33078
  };
33125
33079
  };
33126
- const decode$E = (params2) => {
33080
+ const decode$G = (params2) => {
33127
33081
  const attrs = params2?.node?.attrs || {};
33128
33082
  const underlineType = attrs.underlineType ?? attrs.underline ?? null;
33129
33083
  const color = attrs.underlineColor ?? attrs.color ?? null;
@@ -33141,20 +33095,20 @@ Please report this to https://github.com/markedjs/marked.`, e) {
33141
33095
  if (themeTint) attributes["w:themeTint"] = themeTint;
33142
33096
  if (themeShade) attributes["w:themeShade"] = themeShade;
33143
33097
  return {
33144
- name: XML_NODE_NAME$o,
33098
+ name: XML_NODE_NAME$r,
33145
33099
  attributes
33146
33100
  };
33147
33101
  };
33148
- const config$m = {
33149
- xmlName: XML_NODE_NAME$o,
33150
- sdNodeOrKeyName: SD_ATTR_KEY$c,
33102
+ const config$p = {
33103
+ xmlName: XML_NODE_NAME$r,
33104
+ sdNodeOrKeyName: SD_ATTR_KEY$d,
33151
33105
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
33152
- encode: encode$L,
33153
- decode: decode$E,
33106
+ encode: encode$O,
33107
+ decode: decode$G,
33154
33108
  attributes: validXmlAttributes$h
33155
33109
  };
33156
- const translator$10 = NodeTranslator.from(config$m);
33157
- const encode$K = (attributes) => {
33110
+ const translator$13 = NodeTranslator.from(config$p);
33111
+ const encode$N = (attributes) => {
33158
33112
  const raw = attributes?.["w:val"];
33159
33113
  if (raw === void 0 || raw === null) return void 0;
33160
33114
  if (typeof raw === "boolean") return raw;
@@ -33164,24 +33118,24 @@ Please report this to https://github.com/markedjs/marked.`, e) {
33164
33118
  if (val === "1" || val === "true" || val === "on") return true;
33165
33119
  return void 0;
33166
33120
  };
33167
- const decode$D = (attrs) => {
33121
+ const decode$F = (attrs) => {
33168
33122
  if (attrs?.strike === false) return "0";
33169
33123
  return void 0;
33170
33124
  };
33171
33125
  const attrConfig$m = Object.freeze({
33172
33126
  xmlName: "w:val",
33173
33127
  sdName: "strike",
33174
- encode: encode$K,
33175
- decode: decode$D
33128
+ encode: encode$N,
33129
+ decode: decode$F
33176
33130
  });
33177
33131
  const validXmlAttributes$g = [attrConfig$m];
33178
- const XML_NODE_NAME$n = "w:strike";
33179
- const SD_ATTR_KEY$b = "strike";
33180
- const encode$J = (params2, encodedAttrs = {}) => {
33132
+ const XML_NODE_NAME$q = "w:strike";
33133
+ const SD_ATTR_KEY$c = "strike";
33134
+ const encode$M = (params2, encodedAttrs = {}) => {
33181
33135
  const { nodes } = params2;
33182
33136
  const node = nodes?.[0];
33183
33137
  if (!node) return void 0;
33184
- const val = encodedAttrs?.[SD_ATTR_KEY$b];
33138
+ const val = encodedAttrs?.[SD_ATTR_KEY$c];
33185
33139
  let attributes;
33186
33140
  if (val === false) attributes = { "w:val": "0" };
33187
33141
  else if (val === true) attributes = {};
@@ -33190,55 +33144,55 @@ Please report this to https://github.com/markedjs/marked.`, e) {
33190
33144
  else if (val === true && attributes["w:val"] === void 0) delete attributes["w:val"];
33191
33145
  return {
33192
33146
  type: "attr",
33193
- xmlName: XML_NODE_NAME$n,
33194
- sdNodeOrKeyName: SD_ATTR_KEY$b,
33147
+ xmlName: XML_NODE_NAME$q,
33148
+ sdNodeOrKeyName: SD_ATTR_KEY$c,
33195
33149
  attributes
33196
33150
  };
33197
33151
  };
33198
- const config$l = {
33199
- xmlName: XML_NODE_NAME$n,
33200
- sdNodeOrKeyName: SD_ATTR_KEY$b,
33152
+ const config$o = {
33153
+ xmlName: XML_NODE_NAME$q,
33154
+ sdNodeOrKeyName: SD_ATTR_KEY$c,
33201
33155
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
33202
- encode: encode$J,
33156
+ encode: encode$M,
33203
33157
  attributes: validXmlAttributes$g
33204
33158
  };
33205
- const translator$$ = NodeTranslator.from(config$l);
33206
- const encode$I = (attributes) => attributes?.["w:val"];
33207
- const decode$C = (attrs) => attrs?.color;
33159
+ const translator$12 = NodeTranslator.from(config$o);
33160
+ const encode$L = (attributes) => attributes?.["w:val"];
33161
+ const decode$E = (attrs) => attrs?.color;
33208
33162
  const attrConfig$l = Object.freeze({
33209
33163
  xmlName: "w:val",
33210
33164
  sdName: "color",
33211
- encode: encode$I,
33212
- decode: decode$C
33165
+ encode: encode$L,
33166
+ decode: decode$E
33213
33167
  });
33214
- const encode$H = (attributes) => attributes?.["w:themeColor"];
33215
- const decode$B = (attrs) => attrs?.themeColor;
33168
+ const encode$K = (attributes) => attributes?.["w:themeColor"];
33169
+ const decode$D = (attrs) => attrs?.themeColor;
33216
33170
  const attrConfig$k = Object.freeze({
33217
33171
  xmlName: "w:themeColor",
33218
33172
  sdName: "themeColor",
33219
- encode: encode$H,
33220
- decode: decode$B
33173
+ encode: encode$K,
33174
+ decode: decode$D
33221
33175
  });
33222
- const encode$G = (attributes) => attributes?.["w:themeTint"];
33223
- const decode$A = (attrs) => attrs?.themeTint;
33176
+ const encode$J = (attributes) => attributes?.["w:themeTint"];
33177
+ const decode$C = (attrs) => attrs?.themeTint;
33224
33178
  const attrConfig$j = Object.freeze({
33225
33179
  xmlName: "w:themeTint",
33226
33180
  sdName: "themeTint",
33227
- encode: encode$G,
33228
- decode: decode$A
33181
+ encode: encode$J,
33182
+ decode: decode$C
33229
33183
  });
33230
- const encode$F = (attributes) => attributes?.["w:themeShade"];
33231
- const decode$z = (attrs) => attrs?.themeShade;
33184
+ const encode$I = (attributes) => attributes?.["w:themeShade"];
33185
+ const decode$B = (attrs) => attrs?.themeShade;
33232
33186
  const attrConfig$i = Object.freeze({
33233
33187
  xmlName: "w:themeShade",
33234
33188
  sdName: "themeShade",
33235
- encode: encode$F,
33236
- decode: decode$z
33189
+ encode: encode$I,
33190
+ decode: decode$B
33237
33191
  });
33238
33192
  const validXmlAttributes$f = [attrConfig$l, attrConfig$k, attrConfig$j, attrConfig$i];
33239
- const XML_NODE_NAME$m = "w:color";
33240
- const SD_ATTR_KEY$a = "color";
33241
- const encode$E = (params2, encodedAttrs = {}) => {
33193
+ const XML_NODE_NAME$p = "w:color";
33194
+ const SD_ATTR_KEY$b = "color";
33195
+ const encode$H = (params2, encodedAttrs = {}) => {
33242
33196
  const { nodes } = params2;
33243
33197
  const node = nodes?.[0];
33244
33198
  const sourceAttrs = node?.attributes || {};
@@ -33253,63 +33207,63 @@ Please report this to https://github.com/markedjs/marked.`, e) {
33253
33207
  if (themeShade !== void 0 && themeShade !== null) attributes["w:themeShade"] = themeShade;
33254
33208
  return {
33255
33209
  type: "attr",
33256
- xmlName: XML_NODE_NAME$m,
33257
- sdNodeOrKeyName: SD_ATTR_KEY$a,
33210
+ xmlName: XML_NODE_NAME$p,
33211
+ sdNodeOrKeyName: SD_ATTR_KEY$b,
33258
33212
  attributes
33259
33213
  };
33260
33214
  };
33261
- const config$k = {
33262
- xmlName: XML_NODE_NAME$m,
33263
- sdNodeOrKeyName: SD_ATTR_KEY$a,
33215
+ const config$n = {
33216
+ xmlName: XML_NODE_NAME$p,
33217
+ sdNodeOrKeyName: SD_ATTR_KEY$b,
33264
33218
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
33265
- encode: encode$E,
33219
+ encode: encode$H,
33266
33220
  attributes: validXmlAttributes$f
33267
33221
  };
33268
- const translator$_ = NodeTranslator.from(config$k);
33269
- const encode$D = (attributes) => attributes?.["w:eastAsia"];
33270
- const decode$y = (attrs) => attrs?.eastAsia;
33222
+ const translator$11 = NodeTranslator.from(config$n);
33223
+ const encode$G = (attributes) => attributes?.["w:eastAsia"];
33224
+ const decode$A = (attrs) => attrs?.eastAsia;
33271
33225
  const attrConfig$h = Object.freeze({
33272
33226
  xmlName: "w:eastAsia",
33273
33227
  sdName: "eastAsia",
33274
- encode: encode$D,
33275
- decode: decode$y
33228
+ encode: encode$G,
33229
+ decode: decode$A
33276
33230
  });
33277
- const encode$C = (attributes) => attributes?.["w:ascii"];
33278
- const decode$x = (attrs) => attrs?.ascii;
33231
+ const encode$F = (attributes) => attributes?.["w:ascii"];
33232
+ const decode$z = (attrs) => attrs?.ascii;
33279
33233
  const attrConfig$g = Object.freeze({
33280
33234
  xmlName: "w:ascii",
33281
33235
  sdName: "ascii",
33282
- encode: encode$C,
33283
- decode: decode$x
33236
+ encode: encode$F,
33237
+ decode: decode$z
33284
33238
  });
33285
- const encode$B = (attributes) => attributes?.["w:hAnsi"];
33286
- const decode$w = (attrs) => attrs?.hAnsi;
33239
+ const encode$E = (attributes) => attributes?.["w:hAnsi"];
33240
+ const decode$y = (attrs) => attrs?.hAnsi;
33287
33241
  const attrConfig$f = Object.freeze({
33288
33242
  xmlName: "w:hAnsi",
33289
33243
  sdName: "hAnsi",
33290
- encode: encode$B,
33291
- decode: decode$w
33244
+ encode: encode$E,
33245
+ decode: decode$y
33292
33246
  });
33293
- const encode$A = (attributes) => attributes?.["w:cs"];
33294
- const decode$v = (attrs) => attrs?.cs;
33247
+ const encode$D = (attributes) => attributes?.["w:cs"];
33248
+ const decode$x = (attrs) => attrs?.cs;
33295
33249
  const attrConfig$e = Object.freeze({
33296
33250
  xmlName: "w:cs",
33297
33251
  sdName: "cs",
33298
- encode: encode$A,
33299
- decode: decode$v
33252
+ encode: encode$D,
33253
+ decode: decode$x
33300
33254
  });
33301
- const encode$z = (attributes) => attributes?.["w:val"];
33302
- const decode$u = (attrs) => attrs?.value;
33255
+ const encode$C = (attributes) => attributes?.["w:val"];
33256
+ const decode$w = (attrs) => attrs?.value;
33303
33257
  const attrConfig$d = Object.freeze({
33304
33258
  xmlName: "w:val",
33305
33259
  sdName: "value",
33306
- encode: encode$z,
33307
- decode: decode$u
33260
+ encode: encode$C,
33261
+ decode: decode$w
33308
33262
  });
33309
33263
  const validXmlAttributes$e = [attrConfig$h, attrConfig$g, attrConfig$f, attrConfig$e, attrConfig$d];
33310
- const XML_NODE_NAME$l = "w:rFonts";
33311
- const SD_ATTR_KEY$9 = "fontFamily";
33312
- const encode$y = (params2, encodedAttrs = {}) => {
33264
+ const XML_NODE_NAME$o = "w:rFonts";
33265
+ const SD_ATTR_KEY$a = "fontFamily";
33266
+ const encode$B = (params2, encodedAttrs = {}) => {
33313
33267
  const { nodes } = params2;
33314
33268
  const node = nodes?.[0];
33315
33269
  const sourceAttrs = node?.attributes || {};
@@ -33335,120 +33289,281 @@ Please report this to https://github.com/markedjs/marked.`, e) {
33335
33289
  if (attributes["w:val"] === void 0) delete attributes["w:val"];
33336
33290
  return {
33337
33291
  type: "attr",
33338
- xmlName: XML_NODE_NAME$l,
33339
- sdNodeOrKeyName: SD_ATTR_KEY$9,
33292
+ xmlName: XML_NODE_NAME$o,
33293
+ sdNodeOrKeyName: SD_ATTR_KEY$a,
33340
33294
  attributes
33341
33295
  };
33342
33296
  };
33343
- const config$j = {
33344
- xmlName: XML_NODE_NAME$l,
33345
- sdNodeOrKeyName: SD_ATTR_KEY$9,
33297
+ const config$m = {
33298
+ xmlName: XML_NODE_NAME$o,
33299
+ sdNodeOrKeyName: SD_ATTR_KEY$a,
33346
33300
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
33347
- encode: encode$y,
33301
+ encode: encode$B,
33348
33302
  attributes: validXmlAttributes$e
33349
33303
  };
33350
- const translator$Z = NodeTranslator.from(config$j);
33351
- const encode$x = (attributes) => attributes?.["w:val"];
33352
- const decode$t = (attrs) => attrs?.styleId;
33304
+ const translator$10 = NodeTranslator.from(config$m);
33305
+ const encode$A = (attributes) => attributes?.["w:val"];
33306
+ const decode$v = (attrs) => attrs?.styleId;
33353
33307
  const attrConfig$c = Object.freeze({
33354
33308
  xmlName: "w:val",
33355
33309
  sdName: "styleId",
33356
- encode: encode$x,
33357
- decode: decode$t
33310
+ encode: encode$A,
33311
+ decode: decode$v
33358
33312
  });
33359
33313
  const validXmlAttributes$d = [attrConfig$c];
33360
- const XML_NODE_NAME$k = "w:rStyle";
33361
- const SD_ATTR_KEY$8 = "styleId";
33362
- const encode$w = (params2, encodedAttrs = {}) => {
33314
+ const XML_NODE_NAME$n = "w:rStyle";
33315
+ const SD_ATTR_KEY$9 = "styleId";
33316
+ const encode$z = (params2, encodedAttrs = {}) => {
33363
33317
  const { nodes } = params2;
33364
33318
  const node = nodes?.[0];
33365
33319
  const value = encodedAttrs.styleId ?? node?.attributes?.["w:val"];
33366
33320
  return {
33367
33321
  type: "attr",
33368
- xmlName: XML_NODE_NAME$k,
33369
- sdNodeOrKeyName: SD_ATTR_KEY$8,
33322
+ xmlName: XML_NODE_NAME$n,
33323
+ sdNodeOrKeyName: SD_ATTR_KEY$9,
33370
33324
  attributes: { "w:val": value ?? null }
33371
33325
  };
33372
33326
  };
33373
- const config$i = {
33374
- xmlName: XML_NODE_NAME$k,
33375
- sdNodeOrKeyName: SD_ATTR_KEY$8,
33327
+ const config$l = {
33328
+ xmlName: XML_NODE_NAME$n,
33329
+ sdNodeOrKeyName: SD_ATTR_KEY$9,
33376
33330
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
33377
- encode: encode$w,
33331
+ encode: encode$z,
33378
33332
  attributes: validXmlAttributes$d
33379
33333
  };
33380
- const translator$Y = NodeTranslator.from(config$i);
33381
- const encode$v = (attributes) => attributes?.["w:val"];
33382
- const decode$s = (attrs) => attrs?.fontSize;
33334
+ const translator$$ = NodeTranslator.from(config$l);
33335
+ const encode$y = (attributes) => attributes?.["w:val"];
33336
+ const decode$u = (attrs) => attrs?.fontSize;
33383
33337
  const attrConfig$b = Object.freeze({
33384
33338
  xmlName: "w:val",
33385
33339
  sdName: "fontSize",
33386
- encode: encode$v,
33387
- decode: decode$s
33340
+ encode: encode$y,
33341
+ decode: decode$u
33388
33342
  });
33389
33343
  const validXmlAttributes$c = [attrConfig$b];
33390
- const XML_NODE_NAME$j = "w:sz";
33391
- const SD_ATTR_KEY$7 = "fontSize";
33392
- const encode$u = (params2, encodedAttrs = {}) => {
33344
+ const XML_NODE_NAME$m = "w:sz";
33345
+ const SD_ATTR_KEY$8 = "fontSize";
33346
+ const encode$x = (params2, encodedAttrs = {}) => {
33393
33347
  const { nodes } = params2;
33394
33348
  const node = nodes?.[0];
33395
33349
  const value = encodedAttrs.fontSize ?? node?.attributes?.["w:val"];
33396
33350
  return {
33397
33351
  type: "attr",
33398
- xmlName: XML_NODE_NAME$j,
33399
- sdNodeOrKeyName: SD_ATTR_KEY$7,
33352
+ xmlName: XML_NODE_NAME$m,
33353
+ sdNodeOrKeyName: SD_ATTR_KEY$8,
33400
33354
  attributes: { "w:val": value ?? null }
33401
33355
  };
33402
33356
  };
33403
- const config$h = {
33404
- xmlName: XML_NODE_NAME$j,
33405
- sdNodeOrKeyName: SD_ATTR_KEY$7,
33357
+ const config$k = {
33358
+ xmlName: XML_NODE_NAME$m,
33359
+ sdNodeOrKeyName: SD_ATTR_KEY$8,
33406
33360
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
33407
- encode: encode$u,
33361
+ encode: encode$x,
33408
33362
  attributes: validXmlAttributes$c
33409
33363
  };
33410
- const translator$X = NodeTranslator.from(config$h);
33411
- const encode$t = (attributes) => attributes?.["w:val"];
33412
- const decode$r = (attrs) => attrs?.fontSizeCs;
33364
+ const translator$_ = NodeTranslator.from(config$k);
33365
+ const encode$w = (attributes) => attributes?.["w:val"];
33366
+ const decode$t = (attrs) => attrs?.fontSizeCs;
33413
33367
  const attrConfig$a = Object.freeze({
33414
33368
  xmlName: "w:val",
33415
33369
  sdName: "fontSizeCs",
33416
- encode: encode$t,
33417
- decode: decode$r
33370
+ encode: encode$w,
33371
+ decode: decode$t
33418
33372
  });
33419
33373
  const validXmlAttributes$b = [attrConfig$a];
33420
- const XML_NODE_NAME$i = "w:szCs";
33421
- const SD_ATTR_KEY$6 = "fontSizeCs";
33422
- const encode$s = (params2, encodedAttrs = {}) => {
33374
+ const XML_NODE_NAME$l = "w:szCs";
33375
+ const SD_ATTR_KEY$7 = "fontSizeCs";
33376
+ const encode$v = (params2, encodedAttrs = {}) => {
33423
33377
  const { nodes } = params2;
33424
33378
  const node = nodes?.[0];
33425
33379
  const value = encodedAttrs.fontSizeCs ?? node?.attributes?.["w:val"];
33426
33380
  return {
33427
33381
  type: "attr",
33428
- xmlName: XML_NODE_NAME$i,
33429
- sdNodeOrKeyName: SD_ATTR_KEY$6,
33382
+ xmlName: XML_NODE_NAME$l,
33383
+ sdNodeOrKeyName: SD_ATTR_KEY$7,
33430
33384
  attributes: { "w:val": value ?? null }
33431
33385
  };
33432
33386
  };
33433
- const config$g = {
33434
- xmlName: XML_NODE_NAME$i,
33435
- sdNodeOrKeyName: SD_ATTR_KEY$6,
33387
+ const config$j = {
33388
+ xmlName: XML_NODE_NAME$l,
33389
+ sdNodeOrKeyName: SD_ATTR_KEY$7,
33436
33390
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
33437
- encode: encode$s,
33391
+ encode: encode$v,
33438
33392
  attributes: validXmlAttributes$b
33439
33393
  };
33440
- const translator$W = NodeTranslator.from(config$g);
33394
+ const translator$Z = NodeTranslator.from(config$j);
33395
+ const generateV2HandlerEntity = (handlerName, translator2) => ({
33396
+ handlerName,
33397
+ handler: (params2) => {
33398
+ const { nodes } = params2;
33399
+ if (nodes.length === 0 || nodes[0].name !== translator2.xmlName) {
33400
+ return { nodes: [], consumed: 0 };
33401
+ }
33402
+ const result = translator2.encode(params2);
33403
+ if (!result) return { nodes: [], consumed: 0 };
33404
+ return {
33405
+ nodes: Array.isArray(result) ? result : [result],
33406
+ consumed: 1
33407
+ };
33408
+ }
33409
+ });
33410
+ function createSingleAttrPropertyHandler(xmlName, sdName = null, attrName = "w:val", transformEncode = null, transformDecode = null) {
33411
+ if (!sdName) sdName = xmlName.split(":")[1];
33412
+ if (!transformEncode) transformEncode = (v2) => v2;
33413
+ if (!transformDecode) transformDecode = (v2) => v2;
33414
+ return {
33415
+ xmlName,
33416
+ sdNodeOrKeyName: sdName,
33417
+ encode: ({ nodes }) => {
33418
+ return transformEncode(nodes[0].attributes[attrName]) ?? void 0;
33419
+ },
33420
+ decode: ({ node }) => {
33421
+ const value = node.attrs?.[sdName] != null ? transformDecode(node.attrs[sdName]) : void 0;
33422
+ return value != null ? { name: xmlName, attributes: { [attrName]: value } } : void 0;
33423
+ }
33424
+ };
33425
+ }
33426
+ function createMeasurementPropertyHandler(xmlName, sdName = null) {
33427
+ if (!sdName) sdName = xmlName.split(":")[1];
33428
+ return {
33429
+ xmlName,
33430
+ sdNodeOrKeyName: sdName,
33431
+ attributes: [
33432
+ createAttributeHandler("w:w", "value", parseInteger, integerToString),
33433
+ createAttributeHandler("w:type")
33434
+ ],
33435
+ encode: (_2, encodedAttrs) => {
33436
+ return encodedAttrs["value"] != null ? encodedAttrs : void 0;
33437
+ },
33438
+ decode: function({ node }) {
33439
+ const decodedAttrs = this.decodeAttributes({ node: { ...node, attrs: node.attrs[sdName] || {} } });
33440
+ return decodedAttrs["w:w"] != null ? { attributes: decodedAttrs } : void 0;
33441
+ }
33442
+ };
33443
+ }
33444
+ function createBorderPropertyHandler(xmlName, sdName = null) {
33445
+ if (!sdName) sdName = xmlName.split(":")[1];
33446
+ return {
33447
+ xmlName,
33448
+ sdNodeOrKeyName: sdName,
33449
+ attributes: [
33450
+ createAttributeHandler("w:val"),
33451
+ createAttributeHandler("w:color"),
33452
+ createAttributeHandler("w:themeColor"),
33453
+ createAttributeHandler("w:themeTint"),
33454
+ createAttributeHandler("w:themeShade"),
33455
+ createAttributeHandler("w:sz", "size", parseInteger, integerToString),
33456
+ createAttributeHandler("w:space", null, parseInteger, integerToString),
33457
+ createAttributeHandler("w:shadow", null, parseBoolean, booleanToString),
33458
+ createAttributeHandler("w:frame", null, parseBoolean, booleanToString)
33459
+ ],
33460
+ encode: (params2, encodedAttrs) => {
33461
+ return Object.keys(encodedAttrs).length > 0 ? encodedAttrs : void 0;
33462
+ },
33463
+ decode: function({ node }, context) {
33464
+ const decodedAttrs = this.decodeAttributes({ node: { ...node, attrs: node.attrs[sdName] || {} } });
33465
+ return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
33466
+ }
33467
+ };
33468
+ }
33469
+ const createAttributeHandler = (xmlName, sdName = null, transformEncode = null, transformDecode = null) => {
33470
+ if (!transformEncode) transformEncode = (v2) => v2;
33471
+ if (!transformDecode) transformDecode = (v2) => v2;
33472
+ if (!sdName) sdName = xmlName.split(":")[1];
33473
+ return {
33474
+ xmlName,
33475
+ sdName,
33476
+ encode: (attributes) => transformEncode(attributes[xmlName]),
33477
+ decode: (attributes) => transformDecode(attributes[sdName])
33478
+ };
33479
+ };
33480
+ function encodeProperties(node, translatorsByXmlName, asArray = false) {
33481
+ if (!node?.elements || node.elements.length === 0) {
33482
+ return asArray ? [] : {};
33483
+ }
33484
+ const attributes = asArray ? [] : {};
33485
+ node.elements.forEach((el) => {
33486
+ const translator2 = translatorsByXmlName[el.name];
33487
+ if (translator2) {
33488
+ const encodedAttr = translator2.encode({ nodes: [el] });
33489
+ if (encodedAttr != null) {
33490
+ if (asArray) {
33491
+ attributes.push({ [translator2.sdNodeOrKeyName]: encodedAttr });
33492
+ } else {
33493
+ attributes[translator2.sdNodeOrKeyName] = encodedAttr;
33494
+ }
33495
+ }
33496
+ }
33497
+ });
33498
+ return attributes;
33499
+ }
33500
+ function decodeProperties(translatorsBySdName, properties) {
33501
+ if (!properties || typeof properties !== "object") {
33502
+ return [];
33503
+ }
33504
+ const elements = [];
33505
+ Object.keys(properties).forEach((key2) => {
33506
+ const translator2 = translatorsBySdName[key2];
33507
+ if (translator2) {
33508
+ const result = translator2.decode({ node: { attrs: { [key2]: properties[key2] } } });
33509
+ if (result != null) {
33510
+ result.name = translator2.xmlName;
33511
+ elements.push(result);
33512
+ }
33513
+ }
33514
+ });
33515
+ return elements;
33516
+ }
33517
+ const parseBoolean = (value) => value != null ? ["1", "true"].includes(value) : void 0;
33518
+ const booleanToString = (value) => value != null ? value ? "1" : "0" : void 0;
33519
+ const parseInteger = (value) => {
33520
+ if (value == null) return void 0;
33521
+ const intValue = parseInt(value, 10);
33522
+ return isNaN(intValue) ? void 0 : intValue;
33523
+ };
33524
+ const integerToString = (value) => {
33525
+ const intValue = parseInteger(value);
33526
+ return intValue != void 0 ? String(intValue) : void 0;
33527
+ };
33528
+ const XML_NODE_NAME$k = "w:caps";
33529
+ const SD_ATTR_KEY$6 = "textTransform";
33530
+ const encode$u = (params2, encodedAttrs = {}) => {
33531
+ const { nodes } = params2;
33532
+ const node = nodes[0];
33533
+ if (!node) return void 0;
33534
+ let result;
33535
+ if (!["false", "0"].includes(encodedAttrs.val)) {
33536
+ result = "uppercase";
33537
+ } else {
33538
+ return void 0;
33539
+ }
33540
+ return {
33541
+ type: "attr",
33542
+ xmlName: XML_NODE_NAME$k,
33543
+ sdNodeOrKeyName: SD_ATTR_KEY$6,
33544
+ attributes: { [SD_ATTR_KEY$6]: result }
33545
+ };
33546
+ };
33547
+ const config$i = {
33548
+ xmlName: XML_NODE_NAME$k,
33549
+ sdNodeOrKeyName: SD_ATTR_KEY$6,
33550
+ type: NodeTranslator.translatorTypes.ATTRIBUTE,
33551
+ encode: encode$u,
33552
+ attributes: [createAttributeHandler("w:val")]
33553
+ };
33554
+ const translator$Y = NodeTranslator.from(config$i);
33441
33555
  const runPropertyTranslators = Object.freeze({
33442
- "w:b": translator$12,
33443
- "w:i": translator$11,
33444
- "w:u": translator$10,
33445
- "w:strike": translator$$,
33446
- "w:color": translator$_,
33447
- "w:highlight": translator$15,
33448
- "w:rFonts": translator$Z,
33449
- "w:rStyle": translator$Y,
33450
- "w:sz": translator$X,
33451
- "w:szCs": translator$W
33556
+ "w:b": translator$15,
33557
+ "w:i": translator$14,
33558
+ "w:u": translator$13,
33559
+ "w:strike": translator$12,
33560
+ "w:color": translator$11,
33561
+ "w:highlight": translator$18,
33562
+ "w:rFonts": translator$10,
33563
+ "w:rStyle": translator$$,
33564
+ "w:sz": translator$_,
33565
+ "w:szCs": translator$Z,
33566
+ "w:caps": translator$Y
33452
33567
  });
33453
33568
  const rawRunPropertyXmlNames = Object.freeze(["w:lang", "w:shd"]);
33454
33569
  const RAW_CHILD_NAME_SET = new Set(rawRunPropertyXmlNames);
@@ -33462,9 +33577,9 @@ Please report this to https://github.com/markedjs/marked.`, e) {
33462
33577
  attributes: { ...candidate.attributes || {} }
33463
33578
  };
33464
33579
  };
33465
- const XML_NODE_NAME$h = "w:rPr";
33580
+ const XML_NODE_NAME$j = "w:rPr";
33466
33581
  const SD_ATTR_KEY$5 = "runProperties";
33467
- const encode$r = (params2) => {
33582
+ const encode$t = (params2) => {
33468
33583
  const { nodes } = params2;
33469
33584
  const node = nodes?.[0] || {};
33470
33585
  const contents = Array.isArray(node.elements) ? node.elements : [];
@@ -33498,16 +33613,16 @@ Please report this to https://github.com/markedjs/marked.`, e) {
33498
33613
  attributes: runPropsArray
33499
33614
  };
33500
33615
  };
33501
- const config$f = {
33502
- xmlName: XML_NODE_NAME$h,
33616
+ const config$h = {
33617
+ xmlName: XML_NODE_NAME$j,
33503
33618
  sdNodeOrKeyName: SD_ATTR_KEY$5,
33504
33619
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
33505
- encode: encode$r
33620
+ encode: encode$t
33506
33621
  };
33507
- const translator$V = NodeTranslator.from(config$f);
33622
+ const translator$X = NodeTranslator.from(config$h);
33508
33623
  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;
33509
33624
  const containsEastAsianCharacters = (text) => EAST_ASIAN_CHARACTER_REGEX.test(text);
33510
- const collectRunProperties = (params2, rPrNode, translator2 = translator$V) => {
33625
+ const collectRunProperties = (params2, rPrNode, translator2 = translator$X) => {
33511
33626
  if (!rPrNode) return { entries: [], hadRPr: false, styleChangeMarks: [] };
33512
33627
  const result = translator2.encode({ ...params2, nodes: [rPrNode] }) || {};
33513
33628
  let entries = [];
@@ -33576,7 +33691,10 @@ Please report this to https://github.com/markedjs/marked.`, e) {
33576
33691
  };
33577
33692
  const deriveStyleMarks = ({ docx, paragraphStyleId, runStyleId }) => {
33578
33693
  const paragraphStyleMarks = collectStyleMarks(paragraphStyleId, docx);
33579
- const runStyleMarks = collectStyleMarks(runStyleId, docx);
33694
+ if (paragraphStyleId?.startsWith("TOC")) {
33695
+ return paragraphStyleMarks;
33696
+ }
33697
+ let runStyleMarks = collectStyleMarks(runStyleId, docx);
33580
33698
  const inlineMarks = mergeInlineMarkSets(paragraphStyleMarks.inlineMarks, runStyleMarks.inlineMarks);
33581
33699
  const textStyleAttrs = mergeTextStyleAttrs(paragraphStyleMarks.textStyleAttrs, runStyleMarks.textStyleAttrs);
33582
33700
  return { inlineMarks, textStyleAttrs };
@@ -33802,6 +33920,13 @@ Please report this to https://github.com/markedjs/marked.`, e) {
33802
33920
  }
33803
33921
  break;
33804
33922
  }
33923
+ case "w:caps": {
33924
+ if (attributes["textTransform"] != null) {
33925
+ hasTextStyle = true;
33926
+ textStyleAttrs.textTransform = attributes["textTransform"];
33927
+ }
33928
+ break;
33929
+ }
33805
33930
  case "w:rFonts": {
33806
33931
  const asciiFamily = attributes["w:ascii"] || attributes["w:hAnsi"] || (attributes["w:eastAsia"] ? void 0 : attributes["w:val"]);
33807
33932
  const eastAsiaFamily = attributes["w:eastAsia"];
@@ -33821,9 +33946,10 @@ Please report this to https://github.com/markedjs/marked.`, e) {
33821
33946
  case "w:sz":
33822
33947
  case "w:szCs": {
33823
33948
  const rawSize = Number(attributes["w:val"]);
33949
+ const attrName = entry.xmlName === "w:sz" ? "fontSize" : "fontSizeCs";
33824
33950
  if (Number.isFinite(rawSize) && rawSize > 0) {
33825
33951
  hasTextStyle = true;
33826
- textStyleAttrs.fontSize = `${rawSize / 2}pt`;
33952
+ textStyleAttrs[attrName] = `${rawSize / 2}pt`;
33827
33953
  }
33828
33954
  break;
33829
33955
  }
@@ -33969,46 +34095,166 @@ Please report this to https://github.com/markedjs/marked.`, e) {
33969
34095
  }
33970
34096
  return runs;
33971
34097
  };
33972
- const encode$q = (attributes) => {
34098
+ const XML_NODE_NAME$i = "w:hyperlink";
34099
+ const SD_NODE_NAME$c = "link";
34100
+ const _createAttributeHandler = (xmlName, sdName) => ({
34101
+ xmlName,
34102
+ sdName,
34103
+ encode: (attributes) => attributes[xmlName],
34104
+ decode: (attributes) => attributes[sdName]
34105
+ });
34106
+ const validXmlAttributes$a = [
34107
+ _createAttributeHandler("w:anchor", "anchor"),
34108
+ _createAttributeHandler("w:docLocation", "docLocation"),
34109
+ {
34110
+ xmlName: "w:history",
34111
+ sdName: "history",
34112
+ encode: (attributes) => attributes["w:history"] === "1" || attributes["w:history"] === "true",
34113
+ decode: (attributes) => attributes["history"] ? "1" : "0"
34114
+ },
34115
+ _createAttributeHandler("w:tooltip", "tooltip"),
34116
+ _createAttributeHandler("r:id", "rId"),
34117
+ _createAttributeHandler("w:tgtFrame", "target")
34118
+ ];
34119
+ const encode$s = (params2, encodedAttrs) => {
34120
+ const { nodes, docx, nodeListHandler } = params2;
34121
+ const node = nodes[0];
34122
+ let href = _resolveHref(docx, encodedAttrs);
34123
+ const linkMark = { type: "link", attrs: { ...encodedAttrs, href } };
34124
+ const referenceNodeTypes = ["sd:pageReference", "sd:autoPageNumber", "sd:totalPageNumber"];
34125
+ const contentNodes = node.elements.filter((el) => el.name === "w:r" || referenceNodeTypes.includes(el.name));
34126
+ contentNodes.forEach((contentNode) => {
34127
+ const existingMarks = Array.isArray(contentNode.marks) ? contentNode.marks : [];
34128
+ const marksWithoutLink = existingMarks.filter((mark) => mark?.type !== "link");
34129
+ contentNode.marks = [...marksWithoutLink, linkMark];
34130
+ });
34131
+ const updatedNode = nodeListHandler.handler({
34132
+ ...params2,
34133
+ nodes: contentNodes,
34134
+ path: [...params2.path || [], node]
34135
+ });
34136
+ return updatedNode;
34137
+ };
34138
+ const _resolveHref = (docx, encodedAttrs) => {
34139
+ const rels = docx["word/_rels/document.xml.rels"];
34140
+ const relationships = rels.elements.find((el) => el.name === "Relationships");
34141
+ const { elements } = relationships;
34142
+ const { rId, anchor } = encodedAttrs;
34143
+ let href;
34144
+ if (!rId && anchor) {
34145
+ href = `#${anchor}`;
34146
+ } else if (rId) {
34147
+ const rel = elements.find((el) => el.attributes["Id"] === rId) || {};
34148
+ const { attributes: relAttributes = {} } = rel;
34149
+ href = relAttributes["Target"];
34150
+ }
34151
+ return href;
34152
+ };
34153
+ function decode$s(params2) {
34154
+ const { hyperlinkGroup = [params2.node] } = params2.extraParams || {};
34155
+ const node = hyperlinkGroup[0];
34156
+ const linkMark = node.marks.find((m2) => m2.type === "link");
34157
+ const linkAttrs = this.decodeAttributes({ ...params2, node: linkMark });
34158
+ let { anchor, href: link } = linkMark.attrs;
34159
+ const isExternalLink = !anchor;
34160
+ if (isExternalLink) {
34161
+ linkAttrs["r:id"] = _addNewLinkRelationship(params2, link, linkAttrs["r:id"]);
34162
+ }
34163
+ let contentNodes = [];
34164
+ hyperlinkGroup.forEach((linkNode) => {
34165
+ if ("marks" in linkNode) {
34166
+ linkNode.marks = linkNode.marks.filter((m2) => m2.type !== "link");
34167
+ } else {
34168
+ linkNode.attrs.marksAsAttrs = linkNode.attrs.marksAsAttrs.filter((m2) => m2.type !== "link");
34169
+ }
34170
+ const outputNode = exportSchemaToJson({ ...params2, node: linkNode });
34171
+ if (outputNode) {
34172
+ if (outputNode instanceof Array) contentNodes.push(...outputNode);
34173
+ else contentNodes.push(outputNode);
34174
+ }
34175
+ });
34176
+ const newNode = {
34177
+ name: "w:hyperlink",
34178
+ type: "element",
34179
+ attributes: {
34180
+ ...linkAttrs
34181
+ },
34182
+ elements: contentNodes
34183
+ };
34184
+ return newNode;
34185
+ }
34186
+ function _addNewLinkRelationship(params2, link, rId) {
34187
+ if (!rId) rId = generateDocxRandomId();
34188
+ if (!params2.relationships || !Array.isArray(params2.relationships)) {
34189
+ params2.relationships = [];
34190
+ }
34191
+ const existingRel = params2.relationships.find(
34192
+ (rel) => rel.attributes && rel.attributes.Id === rId && rel.attributes.Target === link
34193
+ );
34194
+ if (existingRel) {
34195
+ return rId;
34196
+ }
34197
+ params2.relationships.push({
34198
+ type: "element",
34199
+ name: "Relationship",
34200
+ attributes: {
34201
+ Id: rId,
34202
+ Type: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",
34203
+ Target: link,
34204
+ TargetMode: "External"
34205
+ }
34206
+ });
34207
+ return rId;
34208
+ }
34209
+ const config$g = {
34210
+ xmlName: XML_NODE_NAME$i,
34211
+ sdNodeOrKeyName: SD_NODE_NAME$c,
34212
+ type: NodeTranslator.translatorTypes.NODE,
34213
+ encode: encode$s,
34214
+ decode: decode$s,
34215
+ attributes: validXmlAttributes$a
34216
+ };
34217
+ const translator$W = NodeTranslator.from(config$g);
34218
+ const encode$r = (attributes) => {
33973
34219
  return attributes["w:rsidR"];
33974
34220
  };
33975
- const decode$q = (attrs) => {
34221
+ const decode$r = (attrs) => {
33976
34222
  return attrs.rsidR;
33977
34223
  };
33978
34224
  const attrConfig$9 = Object.freeze({
33979
34225
  xmlName: "w:rsidR",
33980
34226
  sdName: "rsidR",
33981
- encode: encode$q,
33982
- decode: decode$q
34227
+ encode: encode$r,
34228
+ decode: decode$r
33983
34229
  });
33984
- const encode$p = (attributes) => {
34230
+ const encode$q = (attributes) => {
33985
34231
  return attributes["w:rsidRPr"];
33986
34232
  };
33987
- const decode$p = (attrs) => {
34233
+ const decode$q = (attrs) => {
33988
34234
  return attrs.rsidRPr;
33989
34235
  };
33990
34236
  const attrConfig$8 = Object.freeze({
33991
34237
  xmlName: "w:rsidRPr",
33992
34238
  sdName: "rsidRPr",
33993
- encode: encode$p,
33994
- decode: decode$p
34239
+ encode: encode$q,
34240
+ decode: decode$q
33995
34241
  });
33996
- const encode$o = (attributes) => {
34242
+ const encode$p = (attributes) => {
33997
34243
  return attributes["w:rsidDel"];
33998
34244
  };
33999
- const decode$o = (attrs) => {
34245
+ const decode$p = (attrs) => {
34000
34246
  return attrs.rsidDel;
34001
34247
  };
34002
34248
  const attrConfig$7 = Object.freeze({
34003
34249
  xmlName: "w:rsidDel",
34004
34250
  sdName: "rsidDel",
34005
- encode: encode$o,
34006
- decode: decode$o
34251
+ encode: encode$p,
34252
+ decode: decode$p
34007
34253
  });
34008
- const validXmlAttributes$a = [attrConfig$9, attrConfig$8, attrConfig$7];
34009
- const XML_NODE_NAME$g = "w:r";
34254
+ const validXmlAttributes$9 = [attrConfig$9, attrConfig$8, attrConfig$7];
34255
+ const XML_NODE_NAME$h = "w:r";
34010
34256
  const SD_KEY_NAME = "run";
34011
- const encode$n = (params2, encodedAttrs = {}) => {
34257
+ const encode$o = (params2, encodedAttrs = {}) => {
34012
34258
  const { nodes = [], nodeListHandler } = params2 || {};
34013
34259
  const runNode = nodes[0];
34014
34260
  if (!runNode) return void 0;
@@ -34056,9 +34302,11 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34056
34302
  }
34057
34303
  return runNodeResult;
34058
34304
  };
34059
- const decode$n = (params2, decodedAttrs = {}) => {
34305
+ const decode$o = (params2, decodedAttrs = {}) => {
34060
34306
  const { node } = params2 || {};
34061
34307
  if (!node) return void 0;
34308
+ const isLinkNode = node.marks?.some((m2) => m2.type === "link");
34309
+ if (isLinkNode) return translator$W.decode(params2);
34062
34310
  const { runNode: runNodeForExport, trackingMarksByType } = prepareRunTrackingContext(node);
34063
34311
  const runAttrs = runNodeForExport.attrs || {};
34064
34312
  const runProperties = Array.isArray(runAttrs.runProperties) ? runAttrs.runProperties : [];
@@ -34113,7 +34361,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34113
34361
  runs.push(trackedClone);
34114
34362
  return;
34115
34363
  }
34116
- const runWrapper = { name: XML_NODE_NAME$g, elements: [] };
34364
+ const runWrapper = { name: XML_NODE_NAME$h, elements: [] };
34117
34365
  applyBaseRunProps(runWrapper);
34118
34366
  if (!Array.isArray(runWrapper.elements)) runWrapper.elements = [];
34119
34367
  runWrapper.elements.push(cloneXmlNode(child));
@@ -34121,7 +34369,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34121
34369
  });
34122
34370
  const trackedRuns = ensureTrackedWrapper(runs, trackingMarksByType);
34123
34371
  if (!trackedRuns.length) {
34124
- const emptyRun = { name: XML_NODE_NAME$g, elements: [] };
34372
+ const emptyRun = { name: XML_NODE_NAME$h, elements: [] };
34125
34373
  applyBaseRunProps(emptyRun);
34126
34374
  trackedRuns.push(emptyRun);
34127
34375
  }
@@ -34135,148 +34383,15 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34135
34383
  }
34136
34384
  return trackedRuns;
34137
34385
  };
34138
- const config$e = {
34139
- xmlName: XML_NODE_NAME$g,
34386
+ const config$f = {
34387
+ xmlName: XML_NODE_NAME$h,
34140
34388
  sdNodeOrKeyName: SD_KEY_NAME,
34141
34389
  type: NodeTranslator.translatorTypes.NODE,
34142
- encode: encode$n,
34143
- decode: decode$n,
34144
- attributes: validXmlAttributes$a
34145
- };
34146
- const translator$U = NodeTranslator.from(config$e);
34147
- const generateV2HandlerEntity = (handlerName, translator2) => ({
34148
- handlerName,
34149
- handler: (params2) => {
34150
- const { nodes } = params2;
34151
- if (nodes.length === 0 || nodes[0].name !== translator2.xmlName) {
34152
- return { nodes: [], consumed: 0 };
34153
- }
34154
- const result = translator2.encode(params2);
34155
- if (!result) return { nodes: [], consumed: 0 };
34156
- return {
34157
- nodes: Array.isArray(result) ? result : [result],
34158
- consumed: 1
34159
- };
34160
- }
34161
- });
34162
- function createSingleAttrPropertyHandler(xmlName, sdName = null, attrName = "w:val", transformEncode = null, transformDecode = null) {
34163
- if (!sdName) sdName = xmlName.split(":")[1];
34164
- if (!transformEncode) transformEncode = (v2) => v2;
34165
- if (!transformDecode) transformDecode = (v2) => v2;
34166
- return {
34167
- xmlName,
34168
- sdNodeOrKeyName: sdName,
34169
- encode: ({ nodes }) => {
34170
- return transformEncode(nodes[0].attributes[attrName]) ?? void 0;
34171
- },
34172
- decode: ({ node }) => {
34173
- const value = node.attrs?.[sdName] != null ? transformDecode(node.attrs[sdName]) : void 0;
34174
- return value != null ? { name: xmlName, attributes: { [attrName]: value } } : void 0;
34175
- }
34176
- };
34177
- }
34178
- function createMeasurementPropertyHandler(xmlName, sdName = null) {
34179
- if (!sdName) sdName = xmlName.split(":")[1];
34180
- return {
34181
- xmlName,
34182
- sdNodeOrKeyName: sdName,
34183
- attributes: [
34184
- createAttributeHandler("w:w", "value", parseInteger, integerToString),
34185
- createAttributeHandler("w:type")
34186
- ],
34187
- encode: (_2, encodedAttrs) => {
34188
- return encodedAttrs["value"] != null ? encodedAttrs : void 0;
34189
- },
34190
- decode: function({ node }) {
34191
- const decodedAttrs = this.decodeAttributes({ node: { ...node, attrs: node.attrs[sdName] || {} } });
34192
- return decodedAttrs["w:w"] != null ? { attributes: decodedAttrs } : void 0;
34193
- }
34194
- };
34195
- }
34196
- function createBorderPropertyHandler(xmlName, sdName = null) {
34197
- if (!sdName) sdName = xmlName.split(":")[1];
34198
- return {
34199
- xmlName,
34200
- sdNodeOrKeyName: sdName,
34201
- attributes: [
34202
- createAttributeHandler("w:val"),
34203
- createAttributeHandler("w:color"),
34204
- createAttributeHandler("w:themeColor"),
34205
- createAttributeHandler("w:themeTint"),
34206
- createAttributeHandler("w:themeShade"),
34207
- createAttributeHandler("w:sz", "size", parseInteger, integerToString),
34208
- createAttributeHandler("w:space", null, parseInteger, integerToString),
34209
- createAttributeHandler("w:shadow", null, parseBoolean, booleanToString),
34210
- createAttributeHandler("w:frame", null, parseBoolean, booleanToString)
34211
- ],
34212
- encode: (params2, encodedAttrs) => {
34213
- return Object.keys(encodedAttrs).length > 0 ? encodedAttrs : void 0;
34214
- },
34215
- decode: function({ node }, context) {
34216
- const decodedAttrs = this.decodeAttributes({ node: { ...node, attrs: node.attrs[sdName] || {} } });
34217
- return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
34218
- }
34219
- };
34220
- }
34221
- const createAttributeHandler = (xmlName, sdName = null, transformEncode = null, transformDecode = null) => {
34222
- if (!transformEncode) transformEncode = (v2) => v2;
34223
- if (!transformDecode) transformDecode = (v2) => v2;
34224
- if (!sdName) sdName = xmlName.split(":")[1];
34225
- return {
34226
- xmlName,
34227
- sdName,
34228
- encode: (attributes) => transformEncode(attributes[xmlName]),
34229
- decode: (attributes) => transformDecode(attributes[sdName])
34230
- };
34231
- };
34232
- function encodeProperties(node, translatorsByXmlName, asArray = false) {
34233
- if (!node?.elements || node.elements.length === 0) {
34234
- return asArray ? [] : {};
34235
- }
34236
- const attributes = asArray ? [] : {};
34237
- node.elements.forEach((el) => {
34238
- const translator2 = translatorsByXmlName[el.name];
34239
- if (translator2) {
34240
- const encodedAttr = translator2.encode({ nodes: [el] });
34241
- if (encodedAttr != null) {
34242
- if (asArray) {
34243
- attributes.push({ [translator2.sdNodeOrKeyName]: encodedAttr });
34244
- } else {
34245
- attributes[translator2.sdNodeOrKeyName] = encodedAttr;
34246
- }
34247
- }
34248
- }
34249
- });
34250
- return attributes;
34251
- }
34252
- function decodeProperties(translatorsBySdName, properties) {
34253
- if (!properties || typeof properties !== "object") {
34254
- return [];
34255
- }
34256
- const elements = [];
34257
- Object.keys(properties).forEach((key2) => {
34258
- const translator2 = translatorsBySdName[key2];
34259
- if (translator2) {
34260
- const result = translator2.decode({ node: { attrs: { [key2]: properties[key2] } } });
34261
- if (result != null) {
34262
- result.name = translator2.xmlName;
34263
- elements.push(result);
34264
- }
34265
- }
34266
- });
34267
- return elements;
34268
- }
34269
- const parseBoolean = (value) => value != null ? ["1", "true"].includes(value) : void 0;
34270
- const booleanToString = (value) => value != null ? value ? "1" : "0" : void 0;
34271
- const parseInteger = (value) => {
34272
- if (value == null) return void 0;
34273
- const intValue = parseInt(value, 10);
34274
- return isNaN(intValue) ? void 0 : intValue;
34275
- };
34276
- const integerToString = (value) => {
34277
- const intValue = parseInteger(value);
34278
- return intValue != void 0 ? String(intValue) : void 0;
34390
+ encode: encode$o,
34391
+ decode: decode$o,
34392
+ attributes: validXmlAttributes$9
34279
34393
  };
34394
+ const translator$V = NodeTranslator.from(config$f);
34280
34395
  function preProcessVerticalMergeCells(table, { editorSchema }) {
34281
34396
  if (!table || !Array.isArray(table.content)) {
34282
34397
  return table;
@@ -34317,13 +34432,13 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34317
34432
  }
34318
34433
  return table;
34319
34434
  }
34320
- const translator$T = NodeTranslator.from({
34435
+ const translator$U = NodeTranslator.from({
34321
34436
  xmlName: "w:cantSplit",
34322
34437
  sdNodeOrKeyName: "cantSplit",
34323
34438
  encode: ({ nodes }) => ["1", "true"].includes(nodes[0].attributes?.["w:val"] ?? "1"),
34324
34439
  decode: ({ node }) => node.attrs?.cantSplit ? { attributes: {} } : void 0
34325
34440
  });
34326
- const translator$S = NodeTranslator.from({
34441
+ const translator$T = NodeTranslator.from({
34327
34442
  xmlName: "w:cnfStyle",
34328
34443
  sdNodeOrKeyName: "cnfStyle",
34329
34444
  attributes: [
@@ -34349,8 +34464,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34349
34464
  return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
34350
34465
  }
34351
34466
  });
34352
- const translator$R = NodeTranslator.from(createSingleAttrPropertyHandler("w:divId"));
34353
- const translator$Q = NodeTranslator.from(
34467
+ const translator$S = NodeTranslator.from(createSingleAttrPropertyHandler("w:divId"));
34468
+ const translator$R = NodeTranslator.from(
34354
34469
  createSingleAttrPropertyHandler(
34355
34470
  "w:gridAfter",
34356
34471
  null,
@@ -34359,7 +34474,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34359
34474
  (v2) => integerToString(v2)
34360
34475
  )
34361
34476
  );
34362
- const translator$P = NodeTranslator.from(
34477
+ const translator$Q = NodeTranslator.from(
34363
34478
  createSingleAttrPropertyHandler(
34364
34479
  "w:gridBefore",
34365
34480
  null,
@@ -34368,21 +34483,21 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34368
34483
  (v2) => integerToString(v2)
34369
34484
  )
34370
34485
  );
34371
- const translator$O = NodeTranslator.from({
34486
+ const translator$P = NodeTranslator.from({
34372
34487
  xmlName: "w:hidden",
34373
34488
  sdNodeOrKeyName: "hidden",
34374
34489
  encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
34375
34490
  decode: ({ node }) => node.attrs.hidden ? { attributes: {} } : void 0
34376
34491
  });
34377
- const translator$N = NodeTranslator.from(createSingleAttrPropertyHandler("w:jc", "justification"));
34378
- const translator$M = NodeTranslator.from(createMeasurementPropertyHandler("w:tblCellSpacing", "tableCellSpacing"));
34379
- const translator$L = NodeTranslator.from({
34492
+ const translator$O = NodeTranslator.from(createSingleAttrPropertyHandler("w:jc", "justification"));
34493
+ const translator$N = NodeTranslator.from(createMeasurementPropertyHandler("w:tblCellSpacing", "tableCellSpacing"));
34494
+ const translator$M = NodeTranslator.from({
34380
34495
  xmlName: "w:tblHeader",
34381
34496
  sdNodeOrKeyName: "repeatHeader",
34382
34497
  encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
34383
34498
  decode: ({ node }) => node.attrs.repeatHeader ? { attributes: {} } : void 0
34384
34499
  });
34385
- const translator$K = NodeTranslator.from({
34500
+ const translator$L = NodeTranslator.from({
34386
34501
  xmlName: "w:trHeight",
34387
34502
  sdNodeOrKeyName: "rowHeight",
34388
34503
  encode: ({ nodes }) => {
@@ -34409,11 +34524,11 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34409
34524
  return Object.keys(heightAttrs).length > 0 ? { attributes: heightAttrs } : void 0;
34410
34525
  }
34411
34526
  });
34412
- const translator$J = NodeTranslator.from(createMeasurementPropertyHandler("w:wAfter"));
34413
- const translator$I = NodeTranslator.from(createMeasurementPropertyHandler("w:wBefore"));
34414
- const XML_NODE_NAME$f = "w:trPr";
34527
+ const translator$K = NodeTranslator.from(createMeasurementPropertyHandler("w:wAfter"));
34528
+ const translator$J = NodeTranslator.from(createMeasurementPropertyHandler("w:wBefore"));
34529
+ const XML_NODE_NAME$g = "w:trPr";
34415
34530
  const SD_ATTR_KEY$4 = "tableRowProperties";
34416
- const encode$m = (params2) => {
34531
+ const encode$n = (params2) => {
34417
34532
  const { nodes } = params2;
34418
34533
  const node = nodes[0];
34419
34534
  let attributes = {
@@ -34427,12 +34542,12 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34427
34542
  };
34428
34543
  return {
34429
34544
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
34430
- xmlName: XML_NODE_NAME$f,
34545
+ xmlName: XML_NODE_NAME$g,
34431
34546
  sdNodeOrKeyName: SD_ATTR_KEY$4,
34432
34547
  attributes
34433
34548
  };
34434
34549
  };
34435
- const decode$m = (params2) => {
34550
+ const decode$n = (params2) => {
34436
34551
  const { tableRowProperties = {} } = params2.node.attrs || {};
34437
34552
  const elements = decodeProperties(propertyTranslatorsBySdName$2, tableRowProperties);
34438
34553
  const newNode = {
@@ -34444,6 +34559,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34444
34559
  return newNode;
34445
34560
  };
34446
34561
  const propertyTranslators$3 = [
34562
+ translator$U,
34447
34563
  translator$T,
34448
34564
  translator$S,
34449
34565
  translator$R,
@@ -34454,8 +34570,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34454
34570
  translator$M,
34455
34571
  translator$L,
34456
34572
  translator$K,
34457
- translator$J,
34458
- translator$I
34573
+ translator$J
34459
34574
  ];
34460
34575
  const propertyTranslatorsByXmlName$2 = {};
34461
34576
  propertyTranslators$3.forEach((translator2) => {
@@ -34465,25 +34580,25 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34465
34580
  propertyTranslators$3.forEach((translator2) => {
34466
34581
  propertyTranslatorsBySdName$2[translator2.sdNodeOrKeyName] = translator2;
34467
34582
  });
34468
- const config$d = {
34469
- xmlName: XML_NODE_NAME$f,
34583
+ const config$e = {
34584
+ xmlName: XML_NODE_NAME$g,
34470
34585
  sdNodeOrKeyName: SD_ATTR_KEY$4,
34471
34586
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
34472
- encode: encode$m,
34473
- decode: decode$m
34587
+ encode: encode$n,
34588
+ decode: decode$n
34474
34589
  };
34475
- const translator$H = NodeTranslator.from(config$d);
34476
- const XML_NODE_NAME$e = "w:tr";
34477
- const SD_NODE_NAME$a = "tableRow";
34478
- const validXmlAttributes$9 = ["w:rsidDel", "w:rsidR", "w:rsidRPr", "w:rsidTr", "w14:paraId", "w14:textId"].map(
34590
+ const translator$I = NodeTranslator.from(config$e);
34591
+ const XML_NODE_NAME$f = "w:tr";
34592
+ const SD_NODE_NAME$b = "tableRow";
34593
+ const validXmlAttributes$8 = ["w:rsidDel", "w:rsidR", "w:rsidRPr", "w:rsidTr", "w14:paraId", "w14:textId"].map(
34479
34594
  (xmlName) => createAttributeHandler(xmlName)
34480
34595
  );
34481
- const encode$l = (params2, encodedAttrs) => {
34596
+ const encode$m = (params2, encodedAttrs) => {
34482
34597
  const { row } = params2.extraParams;
34483
34598
  let tableRowProperties = {};
34484
34599
  const tPr = row.elements.find((el) => el.name === "w:trPr");
34485
34600
  if (tPr) {
34486
- ({ attributes: tableRowProperties } = translator$H.encode({
34601
+ ({ attributes: tableRowProperties } = translator$I.encode({
34487
34602
  ...params2,
34488
34603
  nodes: [tPr]
34489
34604
  }));
@@ -34496,7 +34611,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34496
34611
  let currentColumnIndex = 0;
34497
34612
  const content = cellNodes?.map((n) => {
34498
34613
  let columnWidth = gridColumnWidths?.[currentColumnIndex] || null;
34499
- const result = translator$8.encode({
34614
+ const result = translator$9.encode({
34500
34615
  ...params2,
34501
34616
  extraParams: {
34502
34617
  ...params2.extraParams,
@@ -34518,7 +34633,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34518
34633
  };
34519
34634
  return newNode;
34520
34635
  };
34521
- const decode$l = (params2, decodedAttrs) => {
34636
+ const decode$m = (params2, decodedAttrs) => {
34522
34637
  const { node } = params2;
34523
34638
  const elements = translateChildNodes(params2);
34524
34639
  if (node.attrs?.tableRowProperties) {
@@ -34530,7 +34645,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34530
34645
  }
34531
34646
  }
34532
34647
  tableRowProperties["cantSplit"] = node.attrs["cantSplit"];
34533
- const trPr = translator$H.decode({
34648
+ const trPr = translator$I.decode({
34534
34649
  ...params2,
34535
34650
  node: { ...node, attrs: { ...node.attrs, tableRowProperties } }
34536
34651
  });
@@ -34542,22 +34657,22 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34542
34657
  elements
34543
34658
  };
34544
34659
  };
34545
- const config$c = {
34546
- xmlName: XML_NODE_NAME$e,
34547
- sdNodeOrKeyName: SD_NODE_NAME$a,
34660
+ const config$d = {
34661
+ xmlName: XML_NODE_NAME$f,
34662
+ sdNodeOrKeyName: SD_NODE_NAME$b,
34548
34663
  type: NodeTranslator.translatorTypes.NODE,
34549
- encode: encode$l,
34550
- decode: decode$l,
34551
- attributes: validXmlAttributes$9
34664
+ encode: encode$m,
34665
+ decode: decode$m,
34666
+ attributes: validXmlAttributes$8
34552
34667
  };
34553
- const translator$G = NodeTranslator.from(config$c);
34554
- const translator$F = NodeTranslator.from({
34668
+ const translator$H = NodeTranslator.from(config$d);
34669
+ const translator$G = NodeTranslator.from({
34555
34670
  xmlName: "w:bidiVisual",
34556
34671
  sdNodeOrKeyName: "rightToLeft",
34557
34672
  encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
34558
34673
  decode: ({ node }) => node.attrs.rightToLeft ? { attributes: {} } : void 0
34559
34674
  });
34560
- const translator$E = NodeTranslator.from({
34675
+ const translator$F = NodeTranslator.from({
34561
34676
  xmlName: "w:shd",
34562
34677
  sdNodeOrKeyName: "shading",
34563
34678
  attributes: [
@@ -34579,11 +34694,11 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34579
34694
  return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
34580
34695
  }
34581
34696
  });
34582
- const translator$D = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblCaption", "caption"));
34583
- const translator$C = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblDescription", "description"));
34584
- const translator$B = NodeTranslator.from(createMeasurementPropertyHandler("w:tblInd", "tableIndent"));
34585
- const translator$A = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblLayout", "tableLayout", "w:type"));
34586
- const translator$z = NodeTranslator.from({
34697
+ const translator$E = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblCaption", "caption"));
34698
+ const translator$D = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblDescription", "description"));
34699
+ const translator$C = NodeTranslator.from(createMeasurementPropertyHandler("w:tblInd", "tableIndent"));
34700
+ const translator$B = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblLayout", "tableLayout", "w:type"));
34701
+ const translator$A = NodeTranslator.from({
34587
34702
  xmlName: "w:tblLook",
34588
34703
  sdNodeOrKeyName: "tblLook",
34589
34704
  attributes: ["w:firstColumn", "w:firstRow", "w:lastColumn", "w:lastRow", "w:noHBand", "w:noVBand"].map((attr) => createAttributeHandler(attr, null, parseBoolean, booleanToString)).concat([createAttributeHandler("w:val")]),
@@ -34595,16 +34710,16 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34595
34710
  return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
34596
34711
  }
34597
34712
  });
34598
- const translator$y = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblOverlap", "overlap"));
34599
- const translator$x = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblStyle", "tableStyleId"));
34600
- const translator$w = NodeTranslator.from(
34713
+ const translator$z = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblOverlap", "overlap"));
34714
+ const translator$y = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblStyle", "tableStyleId"));
34715
+ const translator$x = NodeTranslator.from(
34601
34716
  createSingleAttrPropertyHandler("w:tblStyleColBandSize", "tableStyleColBandSize")
34602
34717
  );
34603
- const translator$v = NodeTranslator.from(
34718
+ const translator$w = NodeTranslator.from(
34604
34719
  createSingleAttrPropertyHandler("w:tblStyleRowBandSize", "tableStyleRowBandSize")
34605
34720
  );
34606
- const translator$u = NodeTranslator.from(createMeasurementPropertyHandler("w:tblW", "tableWidth"));
34607
- const translator$t = NodeTranslator.from({
34721
+ const translator$v = NodeTranslator.from(createMeasurementPropertyHandler("w:tblW", "tableWidth"));
34722
+ const translator$u = NodeTranslator.from({
34608
34723
  xmlName: "w:tblpPr",
34609
34724
  sdNodeOrKeyName: "floatingTableProperties",
34610
34725
  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))),
@@ -34616,29 +34731,29 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34616
34731
  return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
34617
34732
  }
34618
34733
  });
34619
- const translator$s = NodeTranslator.from(createBorderPropertyHandler("w:bottom"));
34620
- const translator$r = NodeTranslator.from(createMeasurementPropertyHandler("w:bottom", "marginBottom"));
34621
- const translator$q = NodeTranslator.from(createBorderPropertyHandler("w:end"));
34622
- const translator$p = NodeTranslator.from(createMeasurementPropertyHandler("w:end", "marginEnd"));
34623
- const translator$o = NodeTranslator.from(createBorderPropertyHandler("w:insideH"));
34624
- const translator$n = NodeTranslator.from(createBorderPropertyHandler("w:insideV"));
34625
- const translator$m = NodeTranslator.from(createBorderPropertyHandler("w:left"));
34626
- const translator$l = NodeTranslator.from(createMeasurementPropertyHandler("w:left", "marginLeft"));
34627
- const translator$k = NodeTranslator.from(createBorderPropertyHandler("w:right"));
34628
- const translator$j = NodeTranslator.from(createMeasurementPropertyHandler("w:right", "marginRight"));
34629
- const translator$i = NodeTranslator.from(createBorderPropertyHandler("w:start"));
34630
- const translator$h = NodeTranslator.from(createMeasurementPropertyHandler("w:start", "marginStart"));
34631
- const translator$g = NodeTranslator.from(createBorderPropertyHandler("w:top"));
34632
- const translator$f = NodeTranslator.from(createMeasurementPropertyHandler("w:top", "marginTop"));
34633
- const XML_NODE_NAME$d = "w:tblBorders";
34734
+ const translator$t = NodeTranslator.from(createBorderPropertyHandler("w:bottom"));
34735
+ const translator$s = NodeTranslator.from(createMeasurementPropertyHandler("w:bottom", "marginBottom"));
34736
+ const translator$r = NodeTranslator.from(createBorderPropertyHandler("w:end"));
34737
+ const translator$q = NodeTranslator.from(createMeasurementPropertyHandler("w:end", "marginEnd"));
34738
+ const translator$p = NodeTranslator.from(createBorderPropertyHandler("w:insideH"));
34739
+ const translator$o = NodeTranslator.from(createBorderPropertyHandler("w:insideV"));
34740
+ const translator$n = NodeTranslator.from(createBorderPropertyHandler("w:left"));
34741
+ const translator$m = NodeTranslator.from(createMeasurementPropertyHandler("w:left", "marginLeft"));
34742
+ const translator$l = NodeTranslator.from(createBorderPropertyHandler("w:right"));
34743
+ const translator$k = NodeTranslator.from(createMeasurementPropertyHandler("w:right", "marginRight"));
34744
+ const translator$j = NodeTranslator.from(createBorderPropertyHandler("w:start"));
34745
+ const translator$i = NodeTranslator.from(createMeasurementPropertyHandler("w:start", "marginStart"));
34746
+ const translator$h = NodeTranslator.from(createBorderPropertyHandler("w:top"));
34747
+ const translator$g = NodeTranslator.from(createMeasurementPropertyHandler("w:top", "marginTop"));
34748
+ const XML_NODE_NAME$e = "w:tblBorders";
34634
34749
  const SD_ATTR_KEY$3 = "borders";
34635
- const encode$k = (params2) => {
34750
+ const encode$l = (params2) => {
34636
34751
  const { nodes } = params2;
34637
34752
  const node = nodes[0];
34638
34753
  const attributes = encodeProperties(node, tblBordersTranslatorsByXmlName);
34639
34754
  return Object.keys(attributes).length > 0 ? attributes : void 0;
34640
34755
  };
34641
- const decode$k = (params2) => {
34756
+ const decode$l = (params2) => {
34642
34757
  const { borders = {} } = params2.node.attrs || {};
34643
34758
  const elements = decodeProperties(tblBordersTranslatorsBySdName, borders);
34644
34759
  const newNode = {
@@ -34650,14 +34765,14 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34650
34765
  return newNode;
34651
34766
  };
34652
34767
  const propertyTranslators$2 = [
34653
- translator$s,
34654
- translator$q,
34768
+ translator$t,
34769
+ translator$r,
34770
+ translator$p,
34655
34771
  translator$o,
34656
34772
  translator$n,
34657
- translator$m,
34658
- translator$k,
34659
- translator$i,
34660
- translator$g
34773
+ translator$l,
34774
+ translator$j,
34775
+ translator$h
34661
34776
  ];
34662
34777
  const tblBordersTranslatorsByXmlName = {};
34663
34778
  const tblBordersTranslatorsBySdName = {};
@@ -34665,27 +34780,27 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34665
34780
  tblBordersTranslatorsByXmlName[translator2.xmlName] = translator2;
34666
34781
  tblBordersTranslatorsBySdName[translator2.sdNodeOrKeyName] = translator2;
34667
34782
  });
34668
- const translator$e = NodeTranslator.from({
34669
- xmlName: XML_NODE_NAME$d,
34783
+ const translator$f = NodeTranslator.from({
34784
+ xmlName: XML_NODE_NAME$e,
34670
34785
  sdNodeOrKeyName: SD_ATTR_KEY$3,
34671
34786
  type: NodeTranslator.translatorTypes.NODE,
34672
34787
  attributes: [],
34673
- encode: encode$k,
34674
- decode: decode$k
34788
+ encode: encode$l,
34789
+ decode: decode$l
34675
34790
  });
34676
- const XML_NODE_NAME$c = "w:tblCellMar";
34791
+ const XML_NODE_NAME$d = "w:tblCellMar";
34677
34792
  const SD_ATTR_KEY$2 = "cellMargins";
34678
- const encode$j = (params2) => {
34793
+ const encode$k = (params2) => {
34679
34794
  const { nodes } = params2;
34680
34795
  const node = nodes[0];
34681
34796
  const attributes = encodeProperties(node, propertyTranslatorsByXmlName$1);
34682
34797
  return Object.keys(attributes).length > 0 ? attributes : void 0;
34683
34798
  };
34684
- const decode$j = (params2) => {
34799
+ const decode$k = (params2) => {
34685
34800
  const { cellMargins = {} } = params2.node.attrs || {};
34686
34801
  const elements = decodeProperties(propertyTranslatorsBySdName$1, cellMargins);
34687
34802
  const newNode = {
34688
- name: XML_NODE_NAME$c,
34803
+ name: XML_NODE_NAME$d,
34689
34804
  type: "element",
34690
34805
  attributes: {},
34691
34806
  elements
@@ -34693,12 +34808,12 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34693
34808
  return newNode;
34694
34809
  };
34695
34810
  const propertyTranslators$1 = [
34696
- translator$r,
34697
- translator$p,
34698
- translator$l,
34699
- translator$j,
34700
- translator$h,
34701
- translator$f
34811
+ translator$s,
34812
+ translator$q,
34813
+ translator$m,
34814
+ translator$k,
34815
+ translator$i,
34816
+ translator$g
34702
34817
  ];
34703
34818
  const propertyTranslatorsByXmlName$1 = {};
34704
34819
  const propertyTranslatorsBySdName$1 = {};
@@ -34706,27 +34821,27 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34706
34821
  propertyTranslatorsByXmlName$1[translator2.xmlName] = translator2;
34707
34822
  propertyTranslatorsBySdName$1[translator2.sdNodeOrKeyName] = translator2;
34708
34823
  });
34709
- const translator$d = NodeTranslator.from({
34710
- xmlName: XML_NODE_NAME$c,
34824
+ const translator$e = NodeTranslator.from({
34825
+ xmlName: XML_NODE_NAME$d,
34711
34826
  sdNodeOrKeyName: SD_ATTR_KEY$2,
34712
34827
  type: NodeTranslator.translatorTypes.NODE,
34713
34828
  attributes: [],
34714
- encode: encode$j,
34715
- decode: decode$j
34829
+ encode: encode$k,
34830
+ decode: decode$k
34716
34831
  });
34717
- const XML_NODE_NAME$b = "w:tblPr";
34832
+ const XML_NODE_NAME$c = "w:tblPr";
34718
34833
  const SD_ATTR_KEY$1 = "tableProperties";
34719
- const encode$i = (params2) => {
34834
+ const encode$j = (params2) => {
34720
34835
  const { nodes } = params2;
34721
34836
  const node = nodes[0];
34722
34837
  const attributes = encodeProperties(node, propertyTranslatorsByXmlName);
34723
34838
  return {
34724
- xmlName: XML_NODE_NAME$b,
34839
+ xmlName: XML_NODE_NAME$c,
34725
34840
  sdNodeOrKeyName: SD_ATTR_KEY$1,
34726
34841
  attributes
34727
34842
  };
34728
34843
  };
34729
- const decode$i = (params2) => {
34844
+ const decode$j = (params2) => {
34730
34845
  const { tableProperties = {} } = params2.node.attrs || {};
34731
34846
  const elements = decodeProperties(propertyTranslatorsBySdName, tableProperties);
34732
34847
  const newNode = {
@@ -34738,11 +34853,12 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34738
34853
  return newNode;
34739
34854
  };
34740
34855
  const propertyTranslators = [
34856
+ translator$G,
34857
+ translator$O,
34741
34858
  translator$F,
34742
- translator$N,
34743
34859
  translator$E,
34860
+ translator$N,
34744
34861
  translator$D,
34745
- translator$M,
34746
34862
  translator$C,
34747
34863
  translator$B,
34748
34864
  translator$A,
@@ -34752,9 +34868,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34752
34868
  translator$w,
34753
34869
  translator$v,
34754
34870
  translator$u,
34755
- translator$t,
34756
- translator$e,
34757
- translator$d
34871
+ translator$f,
34872
+ translator$e
34758
34873
  ];
34759
34874
  const propertyTranslatorsByXmlName = {};
34760
34875
  const propertyTranslatorsBySdName = {};
@@ -34762,14 +34877,14 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34762
34877
  propertyTranslatorsByXmlName[translator2.xmlName] = translator2;
34763
34878
  propertyTranslatorsBySdName[translator2.sdNodeOrKeyName] = translator2;
34764
34879
  });
34765
- const config$b = {
34766
- xmlName: XML_NODE_NAME$b,
34880
+ const config$c = {
34881
+ xmlName: XML_NODE_NAME$c,
34767
34882
  sdNodeOrKeyName: SD_ATTR_KEY$1,
34768
- encode: encode$i,
34769
- decode: decode$i
34883
+ encode: encode$j,
34884
+ decode: decode$j
34770
34885
  };
34771
- const translator$c = NodeTranslator.from(config$b);
34772
- const translator$b = NodeTranslator.from(
34886
+ const translator$d = NodeTranslator.from(config$c);
34887
+ const translator$c = NodeTranslator.from(
34773
34888
  createSingleAttrPropertyHandler("w:gridCol", "col", "w:w", parseInteger, integerToString)
34774
34889
  );
34775
34890
  const DEFAULT_COLUMN_WIDTH_PX = 100;
@@ -34819,20 +34934,20 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34819
34934
  }
34820
34935
  return Math.max(fallbackWidthTwips, cellMinWidthTwips);
34821
34936
  };
34822
- const XML_NODE_NAME$a = "w:tblGrid";
34937
+ const XML_NODE_NAME$b = "w:tblGrid";
34823
34938
  const SD_ATTR_KEY = "grid";
34824
34939
  const cellMinWidth = pixelsToTwips(10);
34825
- const encode$h = (params2) => {
34940
+ const encode$i = (params2) => {
34826
34941
  const { nodes } = params2;
34827
34942
  const node = nodes[0];
34828
- const attributes = encodeProperties(node, { [translator$b.xmlName]: translator$b }, true);
34943
+ const attributes = encodeProperties(node, { [translator$c.xmlName]: translator$c }, true);
34829
34944
  return {
34830
- xmlName: XML_NODE_NAME$a,
34945
+ xmlName: XML_NODE_NAME$b,
34831
34946
  sdNodeOrKeyName: SD_ATTR_KEY,
34832
34947
  attributes
34833
34948
  };
34834
34949
  };
34835
- const decode$h = (params2) => {
34950
+ const decode$i = (params2) => {
34836
34951
  const { grid: rawGrid } = params2.node.attrs || {};
34837
34952
  const grid = Array.isArray(rawGrid) ? rawGrid : [];
34838
34953
  const { firstRow = {} } = params2.extraParams || {};
@@ -34851,10 +34966,10 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34851
34966
  numericWidth = fallbackColumnWidthTwips;
34852
34967
  }
34853
34968
  numericWidth = Math.max(numericWidth, cellMinWidth);
34854
- const decoded = translator$b.decode({
34969
+ const decoded = translator$c.decode({
34855
34970
  node: { type: (
34856
34971
  /** @type {string} */
34857
- translator$b.sdNodeOrKeyName
34972
+ translator$c.sdNodeOrKeyName
34858
34973
  ), attrs: { col: numericWidth } }
34859
34974
  });
34860
34975
  if (decoded) elements.push(decoded);
@@ -34889,19 +35004,19 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34889
35004
  columnIndex++;
34890
35005
  }
34891
35006
  const newNode = {
34892
- name: XML_NODE_NAME$a,
35007
+ name: XML_NODE_NAME$b,
34893
35008
  attributes: {},
34894
35009
  elements
34895
35010
  };
34896
35011
  return newNode;
34897
35012
  };
34898
- const config$a = {
34899
- xmlName: XML_NODE_NAME$a,
35013
+ const config$b = {
35014
+ xmlName: XML_NODE_NAME$b,
34900
35015
  sdNodeOrKeyName: SD_ATTR_KEY,
34901
- encode: encode$h,
34902
- decode: decode$h
35016
+ encode: encode$i,
35017
+ decode: decode$i
34903
35018
  };
34904
- const translator$a = NodeTranslator.from(config$a);
35019
+ const translator$b = NodeTranslator.from(config$b);
34905
35020
  const DEFAULT_PAGE_WIDTH_TWIPS = 12240;
34906
35021
  const DEFAULT_PAGE_MARGIN_TWIPS = 1440;
34907
35022
  const DEFAULT_CONTENT_WIDTH_TWIPS = DEFAULT_PAGE_WIDTH_TWIPS - 2 * DEFAULT_PAGE_MARGIN_TWIPS;
@@ -34964,19 +35079,19 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34964
35079
  columnWidths: Array(columnCount).fill(fallbackColumnWidthPx)
34965
35080
  };
34966
35081
  };
34967
- const XML_NODE_NAME$9 = "w:tbl";
34968
- const SD_NODE_NAME$9 = "table";
34969
- const encode$g = (params2, encodedAttrs) => {
35082
+ const XML_NODE_NAME$a = "w:tbl";
35083
+ const SD_NODE_NAME$a = "table";
35084
+ const encode$h = (params2, encodedAttrs) => {
34970
35085
  const { nodes } = params2;
34971
35086
  const node = nodes[0];
34972
35087
  const tblPr = node.elements.find((el) => el.name === "w:tblPr");
34973
35088
  if (tblPr) {
34974
- const encodedProperties = translator$c.encode({ ...params2, nodes: [tblPr] });
35089
+ const encodedProperties = translator$d.encode({ ...params2, nodes: [tblPr] });
34975
35090
  encodedAttrs["tableProperties"] = encodedProperties?.attributes || {};
34976
35091
  }
34977
35092
  const tblGrid = node.elements.find((el) => el.name === "w:tblGrid");
34978
35093
  if (tblGrid) {
34979
- encodedAttrs["grid"] = translator$a.encode({ ...params2, nodes: [tblGrid] }).attributes;
35094
+ encodedAttrs["grid"] = translator$b.encode({ ...params2, nodes: [tblGrid] }).attributes;
34980
35095
  }
34981
35096
  [
34982
35097
  "tableStyleId",
@@ -35043,7 +35158,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
35043
35158
  }
35044
35159
  const content = [];
35045
35160
  rows.forEach((row) => {
35046
- const result = translator$G.encode({
35161
+ const result = translator$H.encode({
35047
35162
  ...params2,
35048
35163
  nodes: [row],
35049
35164
  extraParams: {
@@ -35062,13 +35177,13 @@ Please report this to https://github.com/markedjs/marked.`, e) {
35062
35177
  attrs: encodedAttrs
35063
35178
  };
35064
35179
  };
35065
- const decode$g = (params2, decodedAttrs) => {
35180
+ const decode$h = (params2, decodedAttrs) => {
35066
35181
  params2.node = preProcessVerticalMergeCells(params2.node, params2);
35067
35182
  const { node } = params2;
35068
35183
  const elements = translateChildNodes(params2);
35069
35184
  const firstRow = node.content?.find((n) => n.type === "tableRow");
35070
35185
  const properties = node.attrs.grid;
35071
- const element = translator$a.decode({
35186
+ const element = translator$b.decode({
35072
35187
  ...params2,
35073
35188
  node: { ...node, attrs: { ...node.attrs, grid: properties } },
35074
35189
  extraParams: {
@@ -35078,7 +35193,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
35078
35193
  if (element) elements.unshift(element);
35079
35194
  if (node.attrs?.tableProperties) {
35080
35195
  const properties2 = { ...node.attrs.tableProperties };
35081
- const element2 = translator$c.decode({
35196
+ const element2 = translator$d.decode({
35082
35197
  ...params2,
35083
35198
  node: { ...node, attrs: { ...node.attrs, tableProperties: properties2 } }
35084
35199
  });
@@ -35144,7 +35259,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
35144
35259
  if (baseTblPr && baseTblPr.elements) {
35145
35260
  tblPr.elements.push(...baseTblPr.elements);
35146
35261
  }
35147
- const tableProperties = translator$c.encode({ ...params2, nodes: [tblPr] }).attributes;
35262
+ const tableProperties = translator$d.encode({ ...params2, nodes: [tblPr] }).attributes;
35148
35263
  const { borders, rowBorders } = _processTableBorders(tableProperties.borders || {});
35149
35264
  if (borders) stylesToReturn.borders = borders;
35150
35265
  if (rowBorders) stylesToReturn.rowBorders = rowBorders;
@@ -35161,16 +35276,16 @@ Please report this to https://github.com/markedjs/marked.`, e) {
35161
35276
  }
35162
35277
  return stylesToReturn;
35163
35278
  }
35164
- const config$9 = {
35165
- xmlName: XML_NODE_NAME$9,
35166
- sdNodeOrKeyName: SD_NODE_NAME$9,
35279
+ const config$a = {
35280
+ xmlName: XML_NODE_NAME$a,
35281
+ sdNodeOrKeyName: SD_NODE_NAME$a,
35167
35282
  type: NodeTranslator.translatorTypes.NODE,
35168
- encode: encode$g,
35169
- decode: decode$g,
35283
+ encode: encode$h,
35284
+ decode: decode$h,
35170
35285
  attributes: []
35171
35286
  };
35172
- const translator$9 = NodeTranslator.from(config$9);
35173
- const tableNodeHandlerEntity = generateV2HandlerEntity("tableNodeHandler", translator$9);
35287
+ const translator$a = NodeTranslator.from(config$a);
35288
+ const tableNodeHandlerEntity = generateV2HandlerEntity("tableNodeHandler", translator$a);
35174
35289
  function getReferencedTableStyles(tblStyleTag, docx) {
35175
35290
  if (!tblStyleTag) return null;
35176
35291
  const stylesToReturn = {};
@@ -35532,10 +35647,10 @@ Please report this to https://github.com/markedjs/marked.`, e) {
35532
35647
  if (left2 != null) elements.push({ name: "w:left", attributes: { "w:w": pixelsToTwips(left2) } });
35533
35648
  return elements;
35534
35649
  }
35535
- const XML_NODE_NAME$8 = "w:tc";
35536
- const SD_NODE_NAME$8 = "tableCell";
35537
- const validXmlAttributes$8 = [];
35538
- function encode$f(params2, encodedAttrs) {
35650
+ const XML_NODE_NAME$9 = "w:tc";
35651
+ const SD_NODE_NAME$9 = "tableCell";
35652
+ const validXmlAttributes$7 = [];
35653
+ function encode$g(params2, encodedAttrs) {
35539
35654
  const {
35540
35655
  node,
35541
35656
  table,
@@ -35562,162 +35677,22 @@ Please report this to https://github.com/markedjs/marked.`, e) {
35562
35677
  }
35563
35678
  return schemaNode;
35564
35679
  }
35565
- function decode$f(params2, decodedAttrs) {
35680
+ function decode$g(params2, decodedAttrs) {
35566
35681
  const translated = translateTableCell(params2);
35567
35682
  if (decodedAttrs && Object.keys(decodedAttrs).length) {
35568
35683
  translated.attributes = { ...translated.attributes || {}, ...decodedAttrs };
35569
35684
  }
35570
35685
  return translated;
35571
35686
  }
35572
- const config$8 = {
35573
- xmlName: XML_NODE_NAME$8,
35574
- sdNodeOrKeyName: SD_NODE_NAME$8,
35575
- type: NodeTranslator.translatorTypes.NODE,
35576
- encode: encode$f,
35577
- decode: decode$f,
35578
- attributes: validXmlAttributes$8
35579
- };
35580
- const translator$8 = NodeTranslator.from(config$8);
35581
- const XML_NODE_NAME$7 = "w:hyperlink";
35582
- const SD_NODE_NAME$7 = "link";
35583
- const _createAttributeHandler = (xmlName, sdName) => ({
35584
- xmlName,
35585
- sdName,
35586
- encode: (attributes) => attributes[xmlName],
35587
- decode: (attributes) => attributes[sdName]
35588
- });
35589
- const validXmlAttributes$7 = [
35590
- _createAttributeHandler("w:anchor", "anchor"),
35591
- _createAttributeHandler("w:docLocation", "docLocation"),
35592
- {
35593
- xmlName: "w:history",
35594
- sdName: "history",
35595
- encode: (attributes) => attributes["w:history"] === "1" || attributes["w:history"] === "true",
35596
- decode: (attributes) => attributes["history"] ? "1" : "0"
35597
- },
35598
- _createAttributeHandler("w:tooltip", "tooltip"),
35599
- _createAttributeHandler("r:id", "rId"),
35600
- _createAttributeHandler("w:tgtFrame", "target")
35601
- ];
35602
- const encode$e = (params2, encodedAttrs) => {
35603
- const { nodes, docx, nodeListHandler } = params2;
35604
- const node = nodes[0];
35605
- let href = _resolveHref(docx, encodedAttrs);
35606
- const linkMark = { attrs: { ...encodedAttrs, href } };
35607
- const runNodes = node.elements.filter((el) => el.name === "w:r");
35608
- runNodes.forEach((runNode) => {
35609
- const existingRunMarks = Array.isArray(runNode.marks) ? runNode.marks : [];
35610
- const runMarksWithoutLink = existingRunMarks.filter((mark) => mark?.type !== "link");
35611
- runNode.marks = runMarksWithoutLink;
35612
- });
35613
- const updatedNode = nodeListHandler.handler({
35614
- ...params2,
35615
- nodes: runNodes,
35616
- path: [...params2.path || [], node]
35617
- });
35618
- const cloneMark2 = (mark) => {
35619
- if (!mark || typeof mark !== "object") return mark;
35620
- if (!mark.attrs) return { ...mark };
35621
- return { ...mark, attrs: { ...mark.attrs } };
35622
- };
35623
- const ensureLinkMark = (child) => {
35624
- if (!child || typeof child !== "object") return child;
35625
- if (Array.isArray(child.content)) {
35626
- const updatedContent = child.content.map((item) => ensureLinkMark(item));
35627
- if (updatedContent !== child.content) {
35628
- child = { ...child, content: updatedContent };
35629
- }
35630
- }
35631
- if (child.type === "run") {
35632
- const existingMarks2 = Array.isArray(child.marks) ? child.marks : [];
35633
- const filteredMarks = existingMarks2.filter((mark) => mark?.type !== "link").map((mark) => cloneMark2(mark));
35634
- if (filteredMarks.length !== existingMarks2.length) {
35635
- if (filteredMarks.length) child = { ...child, marks: filteredMarks };
35636
- else {
35637
- const { marks: _removedMarks, ...rest } = child;
35638
- child = rest;
35639
- }
35640
- }
35641
- return child;
35642
- }
35643
- if (child.type !== "text") return child;
35644
- const existingMarks = Array.isArray(child.marks) ? child.marks.map((mark) => cloneMark2(mark)) : [];
35645
- const hasLink = existingMarks.some((mark) => mark?.type === "link");
35646
- if (hasLink) return child;
35647
- const linkClone = { type: "link", attrs: { ...linkMark.attrs } };
35648
- return { ...child, marks: [...existingMarks, linkClone] };
35649
- };
35650
- if (!Array.isArray(updatedNode)) return updatedNode;
35651
- return updatedNode.map((child) => ensureLinkMark(child));
35652
- };
35653
- const _resolveHref = (docx, encodedAttrs) => {
35654
- const rels = docx["word/_rels/document.xml.rels"];
35655
- const relationships = rels.elements.find((el) => el.name === "Relationships");
35656
- const { elements } = relationships;
35657
- const { rId, anchor } = encodedAttrs;
35658
- let href;
35659
- if (!rId && anchor) {
35660
- href = `#${anchor}`;
35661
- } else if (rId) {
35662
- const rel = elements.find((el) => el.attributes["Id"] === rId) || {};
35663
- const { attributes: relAttributes = {} } = rel;
35664
- href = relAttributes["Target"];
35665
- }
35666
- return href;
35667
- };
35668
- function decode$e(params2) {
35669
- const { node } = params2;
35670
- const linkMark = node.marks.find((m2) => m2.type === "link");
35671
- const linkAttrs = this.decodeAttributes({ ...params2, node: linkMark });
35672
- let { anchor, href: link } = linkMark.attrs;
35673
- const isExternalLink = !anchor;
35674
- if (isExternalLink) {
35675
- linkAttrs["r:id"] = _addNewLinkRelationship(params2, link, linkAttrs["r:id"]);
35676
- }
35677
- node.marks = node.marks.filter((m2) => m2.type !== "link");
35678
- const outputNode = exportSchemaToJson({ ...params2, node });
35679
- const newNode = {
35680
- name: "w:hyperlink",
35681
- type: "element",
35682
- attributes: {
35683
- ...linkAttrs
35684
- },
35685
- elements: [outputNode]
35686
- };
35687
- return newNode;
35688
- }
35689
- function _addNewLinkRelationship(params2, link, rId) {
35690
- if (!rId) rId = generateDocxRandomId();
35691
- if (!params2.relationships || !Array.isArray(params2.relationships)) {
35692
- params2.relationships = [];
35693
- }
35694
- const existingRel = params2.relationships.find(
35695
- (rel) => rel.attributes && rel.attributes.Id === rId && rel.attributes.Target === link
35696
- );
35697
- if (existingRel) {
35698
- return rId;
35699
- }
35700
- params2.relationships.push({
35701
- type: "element",
35702
- name: "Relationship",
35703
- attributes: {
35704
- Id: rId,
35705
- Type: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",
35706
- Target: link,
35707
- TargetMode: "External"
35708
- }
35709
- });
35710
- return rId;
35711
- }
35712
- const config$7 = {
35713
- xmlName: XML_NODE_NAME$7,
35714
- sdNodeOrKeyName: SD_NODE_NAME$7,
35687
+ const config$9 = {
35688
+ xmlName: XML_NODE_NAME$9,
35689
+ sdNodeOrKeyName: SD_NODE_NAME$9,
35715
35690
  type: NodeTranslator.translatorTypes.NODE,
35716
- encode: encode$e,
35717
- decode: decode$e,
35691
+ encode: encode$g,
35692
+ decode: decode$g,
35718
35693
  attributes: validXmlAttributes$7
35719
35694
  };
35720
- const translator$7 = NodeTranslator.from(config$7);
35695
+ const translator$9 = NodeTranslator.from(config$9);
35721
35696
  function parseTagValueJSON(json) {
35722
35697
  if (typeof json !== "string") {
35723
35698
  return {};
@@ -35853,12 +35828,32 @@ Please report this to https://github.com/markedjs/marked.`, e) {
35853
35828
  }
35854
35829
  const content = node?.elements.find((el) => el.name === "w:sdtContent");
35855
35830
  const handler2 = validGalleryTypeMap[docPartGalleryType];
35856
- const result = handler2({ ...params2, nodes: [content] });
35831
+ const result = handler2({
35832
+ ...params2,
35833
+ nodes: [content],
35834
+ extraParams: { ...params2.extraParams || {}, sdtPr }
35835
+ });
35857
35836
  return result;
35858
35837
  }
35859
35838
  const tableOfContentsHandler = (params2) => {
35860
35839
  const node = params2.nodes[0];
35861
- return params2.nodeListHandler.handler({ ...params2, nodes: node.elements });
35840
+ const translatedContent = params2.nodeListHandler.handler({
35841
+ ...params2,
35842
+ nodes: node.elements,
35843
+ path: [...params2.path || [], node]
35844
+ });
35845
+ const sdtPr = params2.extraParams.sdtPr;
35846
+ const id = sdtPr.elements?.find((el) => el.name === "w:id")?.attributes["w:val"] || "";
35847
+ const result = {
35848
+ type: "documentPartObject",
35849
+ content: translatedContent,
35850
+ attrs: {
35851
+ id,
35852
+ docPartGallery: "Table of Contents",
35853
+ docPartUnique: true
35854
+ }
35855
+ };
35856
+ return result;
35862
35857
  };
35863
35858
  const validGalleryTypeMap = {
35864
35859
  "Table of Contents": tableOfContentsHandler
@@ -36516,32 +36511,32 @@ Please report this to https://github.com/markedjs/marked.`, e) {
36516
36511
  elements: [...anchorElements, ...elementsWithWrap]
36517
36512
  };
36518
36513
  }
36519
- const XML_NODE_NAME$6 = "wp:anchor";
36520
- const SD_NODE_NAME$6 = ["image"];
36514
+ const XML_NODE_NAME$8 = "wp:anchor";
36515
+ const SD_NODE_NAME$8 = ["image"];
36521
36516
  const validXmlAttributes$6 = ["distT", "distB", "distL", "distR"].map((xmlName) => createAttributeHandler(xmlName));
36522
- function encode$d(params2) {
36517
+ function encode$f(params2) {
36523
36518
  const { node } = params2.extraParams;
36524
36519
  if (!node || !node.type) {
36525
36520
  return null;
36526
36521
  }
36527
36522
  return handleAnchorNode(params2);
36528
36523
  }
36529
- function decode$d(params2) {
36524
+ function decode$f(params2) {
36530
36525
  const { node } = params2;
36531
36526
  if (!node || !node.type) {
36532
36527
  return null;
36533
36528
  }
36534
36529
  return translateAnchorNode(params2);
36535
36530
  }
36536
- const config$6 = {
36537
- xmlName: XML_NODE_NAME$6,
36538
- sdNodeOrKeyName: SD_NODE_NAME$6,
36531
+ const config$8 = {
36532
+ xmlName: XML_NODE_NAME$8,
36533
+ sdNodeOrKeyName: SD_NODE_NAME$8,
36539
36534
  type: NodeTranslator.translatorTypes.NODE,
36540
- encode: encode$d,
36541
- decode: decode$d,
36535
+ encode: encode$f,
36536
+ decode: decode$f,
36542
36537
  attributes: validXmlAttributes$6
36543
36538
  };
36544
- const translator$6 = NodeTranslator.from(config$6);
36539
+ const translator$8 = NodeTranslator.from(config$8);
36545
36540
  function handleInlineNode(params2) {
36546
36541
  const { node } = params2.extraParams;
36547
36542
  if (node.name !== "wp:inline") {
@@ -36557,41 +36552,41 @@ Please report this to https://github.com/markedjs/marked.`, e) {
36557
36552
  elements: nodeElements.elements
36558
36553
  };
36559
36554
  }
36560
- const XML_NODE_NAME$5 = "wp:inline";
36561
- const SD_NODE_NAME$5 = ["image"];
36555
+ const XML_NODE_NAME$7 = "wp:inline";
36556
+ const SD_NODE_NAME$7 = ["image"];
36562
36557
  const validXmlAttributes$5 = ["distT", "distB", "distL", "distR"].map((xmlName) => createAttributeHandler(xmlName));
36563
- function encode$c(params2) {
36558
+ function encode$e(params2) {
36564
36559
  const { node } = params2.extraParams;
36565
36560
  if (!node || !node.type) {
36566
36561
  return null;
36567
36562
  }
36568
36563
  return handleInlineNode(params2);
36569
36564
  }
36570
- function decode$c(params2) {
36565
+ function decode$e(params2) {
36571
36566
  const { node } = params2;
36572
36567
  if (!node || !node.type) {
36573
36568
  return null;
36574
36569
  }
36575
36570
  return translateInlineNode(params2);
36576
36571
  }
36577
- const config$5 = {
36578
- xmlName: XML_NODE_NAME$5,
36579
- sdNodeOrKeyName: SD_NODE_NAME$5,
36572
+ const config$7 = {
36573
+ xmlName: XML_NODE_NAME$7,
36574
+ sdNodeOrKeyName: SD_NODE_NAME$7,
36580
36575
  type: NodeTranslator.translatorTypes.NODE,
36581
- encode: encode$c,
36582
- decode: decode$c,
36576
+ encode: encode$e,
36577
+ decode: decode$e,
36583
36578
  attributes: validXmlAttributes$5
36584
36579
  };
36585
- const translator$5 = NodeTranslator.from(config$5);
36586
- const XML_NODE_NAME$4 = "w:drawing";
36587
- const SD_NODE_NAME$4 = [];
36580
+ const translator$7 = NodeTranslator.from(config$7);
36581
+ const XML_NODE_NAME$6 = "w:drawing";
36582
+ const SD_NODE_NAME$6 = [];
36588
36583
  const validXmlAttributes$4 = [];
36589
- function encode$b(params2) {
36584
+ function encode$d(params2) {
36590
36585
  const nodes = params2.nodes;
36591
36586
  const node = nodes[0];
36592
36587
  const translatorByChildName = {
36593
- "wp:anchor": translator$6,
36594
- "wp:inline": translator$5
36588
+ "wp:anchor": translator$8,
36589
+ "wp:inline": translator$7
36595
36590
  };
36596
36591
  return node.elements.reduce((acc, child) => {
36597
36592
  if (acc) return acc;
@@ -36600,12 +36595,12 @@ Please report this to https://github.com/markedjs/marked.`, e) {
36600
36595
  return translator2.encode({ ...params2, extraParams: { node: child } }) || acc;
36601
36596
  }, null);
36602
36597
  }
36603
- function decode$b(params2) {
36598
+ function decode$d(params2) {
36604
36599
  const { node } = params2;
36605
36600
  if (!node || !node.type) {
36606
36601
  return null;
36607
36602
  }
36608
- const childTranslator = node.attrs.isAnchor ? translator$6 : translator$5;
36603
+ const childTranslator = node.attrs.isAnchor ? translator$8 : translator$7;
36609
36604
  const resultNode = childTranslator.decode(params2);
36610
36605
  return wrapTextInRun(
36611
36606
  {
@@ -36615,15 +36610,15 @@ Please report this to https://github.com/markedjs/marked.`, e) {
36615
36610
  []
36616
36611
  );
36617
36612
  }
36618
- const config$4 = {
36619
- xmlName: XML_NODE_NAME$4,
36620
- sdNodeOrKeyName: SD_NODE_NAME$4,
36613
+ const config$6 = {
36614
+ xmlName: XML_NODE_NAME$6,
36615
+ sdNodeOrKeyName: SD_NODE_NAME$6,
36621
36616
  type: NodeTranslator.translatorTypes.NODE,
36622
- encode: encode$b,
36623
- decode: decode$b,
36617
+ encode: encode$d,
36618
+ decode: decode$d,
36624
36619
  attributes: validXmlAttributes$4
36625
36620
  };
36626
- const translator$4 = NodeTranslator.from(config$4);
36621
+ const translator$6 = NodeTranslator.from(config$6);
36627
36622
  class CommandService {
36628
36623
  /**
36629
36624
  * @param {import('./commands/types/index.js').CommandServiceOptions} props
@@ -37961,7 +37956,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
37961
37956
  return getTextNodeForExport(attrs.displayLabel, [...marks, ...marksFromAttrs], params2);
37962
37957
  }
37963
37958
  function prepareImageAnnotation(params2, imageSize) {
37964
- return translator$4.decode({
37959
+ return translator$6.decode({
37965
37960
  ...params2,
37966
37961
  imageSize
37967
37962
  });
@@ -38181,6 +38176,49 @@ Please report this to https://github.com/markedjs/marked.`, e) {
38181
38176
  ]
38182
38177
  };
38183
38178
  };
38179
+ function translateDocumentPartObj(params2) {
38180
+ const { node } = params2;
38181
+ const { attrs = {} } = node;
38182
+ const childContent = translateChildNodes({ ...params2, nodes: node.content });
38183
+ const nodeElements = [
38184
+ {
38185
+ name: "w:sdtPr",
38186
+ elements: [
38187
+ {
38188
+ name: "w:id",
38189
+ attributes: {
38190
+ "w:val": attrs.id
38191
+ }
38192
+ },
38193
+ {
38194
+ name: "w:docPartObj",
38195
+ elements: [
38196
+ {
38197
+ name: "w:docPartGallery",
38198
+ attributes: {
38199
+ "w:val": attrs.docPartGallery
38200
+ }
38201
+ },
38202
+ ...attrs.docPartUnique ? [
38203
+ {
38204
+ name: "w:docPartUnique"
38205
+ }
38206
+ ] : []
38207
+ ]
38208
+ }
38209
+ ]
38210
+ },
38211
+ {
38212
+ name: "w:sdtContent",
38213
+ elements: childContent
38214
+ }
38215
+ ];
38216
+ const result = {
38217
+ name: "w:sdt",
38218
+ elements: nodeElements
38219
+ };
38220
+ return result;
38221
+ }
38184
38222
  function translateStructuredContent(params2) {
38185
38223
  const { node } = params2;
38186
38224
  const childContent = translateChildNodes({ ...params2, nodes: node.content });
@@ -38232,10 +38270,10 @@ Please report this to https://github.com/markedjs/marked.`, e) {
38232
38270
  };
38233
38271
  return result;
38234
38272
  }
38235
- const XML_NODE_NAME$3 = "w:sdt";
38236
- const SD_NODE_NAME$3 = ["fieldAnnotation", "structuredContent", "structuredContentBlock", "documentSection"];
38273
+ const XML_NODE_NAME$5 = "w:sdt";
38274
+ const SD_NODE_NAME$5 = ["fieldAnnotation", "structuredContent", "structuredContentBlock", "documentSection"];
38237
38275
  const validXmlAttributes$3 = [];
38238
- function encode$a(params2) {
38276
+ function encode$c(params2) {
38239
38277
  const nodes = params2.nodes;
38240
38278
  const node = nodes[0];
38241
38279
  const { type: sdtType, handler: handler2 } = sdtNodeTypeStrategy(node);
@@ -38245,7 +38283,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
38245
38283
  const result = handler2(params2);
38246
38284
  return result;
38247
38285
  }
38248
- function decode$a(params2) {
38286
+ function decode$c(params2) {
38249
38287
  const { node } = params2;
38250
38288
  if (!node || !node.type) {
38251
38289
  return null;
@@ -38255,91 +38293,93 @@ Please report this to https://github.com/markedjs/marked.`, e) {
38255
38293
  structuredContent: () => translateStructuredContent(params2),
38256
38294
  structuredContentBlock: () => translateStructuredContent(params2),
38257
38295
  documentSection: () => translateDocumentSection(params2),
38296
+ documentPartObject: () => translateDocumentPartObj(params2),
38297
+ // Handled in doc-part-obj translator
38258
38298
  default: () => null
38259
38299
  };
38260
38300
  const decoder = types2[node.type] ?? types2.default;
38261
38301
  const result = decoder();
38262
38302
  return result;
38263
38303
  }
38264
- const config$3 = {
38265
- xmlName: XML_NODE_NAME$3,
38266
- sdNodeOrKeyName: SD_NODE_NAME$3,
38304
+ const config$5 = {
38305
+ xmlName: XML_NODE_NAME$5,
38306
+ sdNodeOrKeyName: SD_NODE_NAME$5,
38267
38307
  type: NodeTranslator.translatorTypes.NODE,
38268
- encode: encode$a,
38269
- decode: decode$a,
38308
+ encode: encode$c,
38309
+ decode: decode$c,
38270
38310
  attributes: validXmlAttributes$3
38271
38311
  };
38272
- const translator$3 = NodeTranslator.from(config$3);
38273
- const encode$9 = (attributes) => {
38312
+ const translator$5 = NodeTranslator.from(config$5);
38313
+ const encode$b = (attributes) => {
38274
38314
  return attributes["w:id"];
38275
38315
  };
38276
- const decode$9 = (attrs) => {
38316
+ const decode$b = (attrs) => {
38277
38317
  return attrs.id;
38278
38318
  };
38279
38319
  const attrConfig$6 = Object.freeze({
38280
38320
  xmlName: "w:id",
38281
38321
  sdName: "id",
38282
- encode: encode$9,
38283
- decode: decode$9
38322
+ encode: encode$b,
38323
+ decode: decode$b
38284
38324
  });
38285
- const encode$8 = (attributes) => {
38325
+ const encode$a = (attributes) => {
38286
38326
  return attributes["w:name"];
38287
38327
  };
38288
- const decode$8 = (attrs) => {
38328
+ const decode$a = (attrs) => {
38289
38329
  return attrs.name;
38290
38330
  };
38291
38331
  const attrConfig$5 = Object.freeze({
38292
38332
  xmlName: "w:name",
38293
38333
  sdName: "name",
38294
- encode: encode$8,
38295
- decode: decode$8
38334
+ encode: encode$a,
38335
+ decode: decode$a
38296
38336
  });
38297
- const encode$7 = (attributes) => {
38337
+ const encode$9 = (attributes) => {
38298
38338
  return attributes["w:colFirst"];
38299
38339
  };
38300
- const decode$7 = (attrs) => {
38340
+ const decode$9 = (attrs) => {
38301
38341
  return attrs.colFirst;
38302
38342
  };
38303
38343
  const attrConfig$4 = Object.freeze({
38304
38344
  xmlName: "w:colFirst",
38305
38345
  sdName: "colFirst",
38306
- encode: encode$7,
38307
- decode: decode$7
38346
+ encode: encode$9,
38347
+ decode: decode$9
38308
38348
  });
38309
- const encode$6 = (attributes) => {
38349
+ const encode$8 = (attributes) => {
38310
38350
  return attributes["w:colLast"];
38311
38351
  };
38312
- const decode$6 = (attrs) => {
38352
+ const decode$8 = (attrs) => {
38313
38353
  return attrs.colLast;
38314
38354
  };
38315
38355
  const attrConfig$3 = Object.freeze({
38316
38356
  xmlName: "w:colLast",
38317
38357
  sdName: "colLast",
38318
- encode: encode$6,
38319
- decode: decode$6
38358
+ encode: encode$8,
38359
+ decode: decode$8
38320
38360
  });
38321
- const encode$5 = (attributes) => {
38361
+ const encode$7 = (attributes) => {
38322
38362
  return attributes["w:displacedByCustomXml"];
38323
38363
  };
38324
- const decode$5 = (attrs) => {
38364
+ const decode$7 = (attrs) => {
38325
38365
  return attrs.displacedByCustomXml;
38326
38366
  };
38327
38367
  const attrConfig$2 = Object.freeze({
38328
38368
  xmlName: "w:displacedByCustomXml",
38329
38369
  sdName: "displacedByCustomXml",
38330
- encode: encode$5,
38331
- decode: decode$5
38370
+ encode: encode$7,
38371
+ decode: decode$7
38332
38372
  });
38333
38373
  const validXmlAttributes$2 = [attrConfig$6, attrConfig$5, attrConfig$4, attrConfig$3, attrConfig$2];
38334
- const XML_NODE_NAME$2 = "w:bookmarkStart";
38335
- const SD_NODE_NAME$2 = "bookmarkStart";
38336
- const encode$4 = (params2, encodedAttrs = {}) => {
38374
+ const XML_NODE_NAME$4 = "w:bookmarkStart";
38375
+ const SD_NODE_NAME$4 = "bookmarkStart";
38376
+ const encode$6 = (params2, encodedAttrs = {}) => {
38337
38377
  return {
38338
38378
  type: "bookmarkStart",
38339
38379
  attrs: encodedAttrs
38340
38380
  };
38341
38381
  };
38342
- const decode$4 = (params2, decodedAttrs = {}) => {
38382
+ const decode$6 = (params2, decodedAttrs = {}) => {
38343
38383
  const result = {
38344
38384
  name: "w:bookmarkStart",
38345
38385
  elements: []
@@ -38349,49 +38389,49 @@ Please report this to https://github.com/markedjs/marked.`, e) {
38349
38389
  }
38350
38390
  return result;
38351
38391
  };
38352
- const config$2 = {
38353
- xmlName: XML_NODE_NAME$2,
38354
- sdNodeOrKeyName: SD_NODE_NAME$2,
38392
+ const config$4 = {
38393
+ xmlName: XML_NODE_NAME$4,
38394
+ sdNodeOrKeyName: SD_NODE_NAME$4,
38355
38395
  type: NodeTranslator.translatorTypes.NODE,
38356
- encode: encode$4,
38357
- decode: decode$4,
38396
+ encode: encode$6,
38397
+ decode: decode$6,
38358
38398
  attributes: validXmlAttributes$2
38359
38399
  };
38360
- const translator$2 = NodeTranslator.from(config$2);
38361
- const encode$3 = (attributes) => {
38400
+ const translator$4 = NodeTranslator.from(config$4);
38401
+ const encode$5 = (attributes) => {
38362
38402
  return attributes["w:id"];
38363
38403
  };
38364
- const decode$3 = (attrs) => {
38404
+ const decode$5 = (attrs) => {
38365
38405
  return attrs.id;
38366
38406
  };
38367
38407
  const attrConfig$1 = Object.freeze({
38368
38408
  xmlName: "w:id",
38369
38409
  sdName: "id",
38370
- encode: encode$3,
38371
- decode: decode$3
38410
+ encode: encode$5,
38411
+ decode: decode$5
38372
38412
  });
38373
- const encode$2 = (attributes) => {
38413
+ const encode$4 = (attributes) => {
38374
38414
  return attributes["w:displacedByCustomXml"];
38375
38415
  };
38376
- const decode$2 = (attrs) => {
38416
+ const decode$4 = (attrs) => {
38377
38417
  return attrs.displacedByCustomXml;
38378
38418
  };
38379
38419
  const attrConfig = Object.freeze({
38380
38420
  xmlName: "w:displacedByCustomXml",
38381
38421
  sdName: "displacedByCustomXml",
38382
- encode: encode$2,
38383
- decode: decode$2
38422
+ encode: encode$4,
38423
+ decode: decode$4
38384
38424
  });
38385
38425
  const validXmlAttributes$1 = [attrConfig$1, attrConfig];
38386
- const XML_NODE_NAME$1 = "w:bookmarkEnd";
38387
- const SD_NODE_NAME$1 = "bookmarkEnd";
38388
- const encode$1 = (params2, encodedAttrs = {}) => {
38426
+ const XML_NODE_NAME$3 = "w:bookmarkEnd";
38427
+ const SD_NODE_NAME$3 = "bookmarkEnd";
38428
+ const encode$3 = (params2, encodedAttrs = {}) => {
38389
38429
  return {
38390
38430
  type: "bookmarkEnd",
38391
38431
  attrs: encodedAttrs
38392
38432
  };
38393
38433
  };
38394
- const decode$1 = (params2, decodedAttrs = {}) => {
38434
+ const decode$3 = (params2, decodedAttrs = {}) => {
38395
38435
  const result = {
38396
38436
  name: "w:bookmarkEnd",
38397
38437
  elements: []
@@ -38401,19 +38441,19 @@ Please report this to https://github.com/markedjs/marked.`, e) {
38401
38441
  }
38402
38442
  return result;
38403
38443
  };
38404
- const config$1 = {
38405
- xmlName: XML_NODE_NAME$1,
38406
- sdNodeOrKeyName: SD_NODE_NAME$1,
38444
+ const config$3 = {
38445
+ xmlName: XML_NODE_NAME$3,
38446
+ sdNodeOrKeyName: SD_NODE_NAME$3,
38407
38447
  type: NodeTranslator.translatorTypes.NODE,
38408
- encode: encode$1,
38409
- decode: decode$1,
38448
+ encode: encode$3,
38449
+ decode: decode$3,
38410
38450
  attributes: validXmlAttributes$1
38411
38451
  };
38412
- const translator$1 = NodeTranslator.from(config$1);
38413
- const XML_NODE_NAME = "mc:AlternateContent";
38414
- const SD_NODE_NAME = [];
38452
+ const translator$3 = NodeTranslator.from(config$3);
38453
+ const XML_NODE_NAME$2 = "mc:AlternateContent";
38454
+ const SD_NODE_NAME$2 = [];
38415
38455
  const validXmlAttributes = [];
38416
- function encode$19(params2) {
38456
+ function encode$2(params2) {
38417
38457
  const { nodeListHandler } = params2;
38418
38458
  const { node } = params2.extraParams;
38419
38459
  if (!node || !node.type) {
@@ -38433,7 +38473,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
38433
38473
  path: [...params2.path || [], wpsNode]
38434
38474
  });
38435
38475
  }
38436
- function decode(params2) {
38476
+ function decode$2(params2) {
38437
38477
  const { node } = params2;
38438
38478
  const { drawingContent } = node.attrs;
38439
38479
  const drawing = {
@@ -38450,13 +38490,186 @@ Please report this to https://github.com/markedjs/marked.`, e) {
38450
38490
  elements: [choice]
38451
38491
  };
38452
38492
  }
38493
+ const config$2 = {
38494
+ xmlName: XML_NODE_NAME$2,
38495
+ sdNodeOrKeyName: SD_NODE_NAME$2,
38496
+ type: NodeTranslator.translatorTypes.NODE,
38497
+ encode: encode$2,
38498
+ decode: decode$2,
38499
+ attributes: validXmlAttributes
38500
+ };
38501
+ const translator$2 = NodeTranslator.from(config$2);
38502
+ const XML_NODE_NAME$1 = "sd:pageReference";
38503
+ const SD_NODE_NAME$1 = "pageReference";
38504
+ const encode$1 = (params2, _2) => {
38505
+ const { nodes = [], nodeListHandler } = params2 || {};
38506
+ const node = nodes[0];
38507
+ const processedText = nodeListHandler.handler({
38508
+ ...params2,
38509
+ nodes: node.elements
38510
+ });
38511
+ const processedNode = {
38512
+ type: "pageReference",
38513
+ attrs: {
38514
+ instruction: node.attributes?.instruction || "",
38515
+ marksAsAttrs: node.marks || []
38516
+ },
38517
+ content: processedText
38518
+ };
38519
+ return processedNode;
38520
+ };
38521
+ const decode$1 = (params2, _2) => {
38522
+ const { node } = params2;
38523
+ const outputMarks = processOutputMarks(node.attrs?.marksAsAttrs || []);
38524
+ const contentNodes = (node.content ?? []).flatMap((n) => exportSchemaToJson({ ...params2, node: n }));
38525
+ const translated = [
38526
+ {
38527
+ name: "w:r",
38528
+ elements: [
38529
+ {
38530
+ name: "w:rPr",
38531
+ elements: outputMarks
38532
+ },
38533
+ {
38534
+ name: "w:fldChar",
38535
+ attributes: {
38536
+ "w:fldCharType": "begin"
38537
+ }
38538
+ }
38539
+ ]
38540
+ },
38541
+ {
38542
+ name: "w:r",
38543
+ elements: [
38544
+ {
38545
+ name: "w:rPr",
38546
+ elements: outputMarks
38547
+ },
38548
+ {
38549
+ name: "w:instrText",
38550
+ attributes: { "xml:space": "preserve" },
38551
+ elements: [
38552
+ {
38553
+ type: "text",
38554
+ text: `${node.attrs.instruction}`
38555
+ }
38556
+ ]
38557
+ }
38558
+ ]
38559
+ },
38560
+ {
38561
+ name: "w:r",
38562
+ elements: [
38563
+ {
38564
+ name: "w:rPr",
38565
+ elements: outputMarks
38566
+ },
38567
+ {
38568
+ name: "w:fldChar",
38569
+ attributes: {
38570
+ "w:fldCharType": "separate"
38571
+ }
38572
+ }
38573
+ ]
38574
+ },
38575
+ ...contentNodes,
38576
+ {
38577
+ name: "w:r",
38578
+ elements: [
38579
+ {
38580
+ name: "w:rPr",
38581
+ elements: outputMarks
38582
+ },
38583
+ {
38584
+ name: "w:fldChar",
38585
+ attributes: {
38586
+ "w:fldCharType": "end"
38587
+ }
38588
+ }
38589
+ ]
38590
+ }
38591
+ ];
38592
+ return translated;
38593
+ };
38594
+ const config$1 = {
38595
+ xmlName: XML_NODE_NAME$1,
38596
+ sdNodeOrKeyName: SD_NODE_NAME$1,
38597
+ type: NodeTranslator.translatorTypes.NODE,
38598
+ encode: encode$1,
38599
+ decode: decode$1
38600
+ };
38601
+ const translator$1 = NodeTranslator.from(config$1);
38602
+ const XML_NODE_NAME = "sd:tableOfContents";
38603
+ const SD_NODE_NAME = "tableOfContents";
38604
+ const encode$1c = (params2, _2) => {
38605
+ const { nodes = [], nodeListHandler } = params2 || {};
38606
+ const node = nodes[0];
38607
+ const processedContent = nodeListHandler.handler({
38608
+ ...params2,
38609
+ nodes: node.elements || []
38610
+ });
38611
+ const processedNode = {
38612
+ type: "tableOfContents",
38613
+ attrs: {
38614
+ instruction: node.attributes?.instruction || ""
38615
+ },
38616
+ content: processedContent
38617
+ };
38618
+ return processedNode;
38619
+ };
38620
+ const decode = (params2, _2) => {
38621
+ const { node } = params2;
38622
+ const contentNodes = node.content.map((n) => exportSchemaToJson({ ...params2, node: n }));
38623
+ const tocBeginElements = [
38624
+ {
38625
+ name: "w:r",
38626
+ elements: [{ name: "w:fldChar", attributes: { "w:fldCharType": "begin" }, elements: [] }]
38627
+ },
38628
+ {
38629
+ name: "w:r",
38630
+ elements: [
38631
+ {
38632
+ name: "w:instrText",
38633
+ attributes: { "xml:space": "preserve" },
38634
+ elements: [{ text: node.attrs?.instruction || "", type: "text", name: "#text", elements: [] }]
38635
+ }
38636
+ ]
38637
+ },
38638
+ { name: "w:r", elements: [{ name: "w:fldChar", attributes: { "w:fldCharType": "separate" }, elements: [] }] }
38639
+ ];
38640
+ if (contentNodes.length > 0) {
38641
+ const firstParagraph = contentNodes[0];
38642
+ let insertIndex = 0;
38643
+ if (firstParagraph.elements) {
38644
+ const pPrIndex = firstParagraph.elements.findIndex((el) => el.name === "w:pPr");
38645
+ insertIndex = pPrIndex >= 0 ? pPrIndex + 1 : 0;
38646
+ } else {
38647
+ firstParagraph.elements = [];
38648
+ }
38649
+ firstParagraph.elements.splice(insertIndex, 0, ...tocBeginElements);
38650
+ } else {
38651
+ contentNodes.push({
38652
+ name: "w:p",
38653
+ elements: tocBeginElements
38654
+ });
38655
+ }
38656
+ const tocEndElements = [
38657
+ { name: "w:r", elements: [{ name: "w:fldChar", attributes: { "w:fldCharType": "end" }, elements: [] }] }
38658
+ ];
38659
+ const lastParagraph = contentNodes[contentNodes.length - 1];
38660
+ if (lastParagraph.elements) {
38661
+ lastParagraph.elements.push(...tocEndElements);
38662
+ } else {
38663
+ lastParagraph.elements = [...tocEndElements];
38664
+ }
38665
+ return contentNodes;
38666
+ };
38453
38667
  const config = {
38454
38668
  xmlName: XML_NODE_NAME,
38455
38669
  sdNodeOrKeyName: SD_NODE_NAME,
38456
38670
  type: NodeTranslator.translatorTypes.NODE,
38457
- encode: encode$19,
38458
- decode,
38459
- attributes: validXmlAttributes
38671
+ encode: encode$1c,
38672
+ decode
38460
38673
  };
38461
38674
  const translator = NodeTranslator.from(config);
38462
38675
  const DEFAULT_SECTION_PROPS_TWIPS = Object.freeze({
@@ -38530,32 +38743,35 @@ Please report this to https://github.com/markedjs/marked.`, e) {
38530
38743
  doc: translateDocumentNode,
38531
38744
  body: translateBodyNode,
38532
38745
  heading: translateHeadingNode,
38533
- paragraph: translator$13,
38534
- run: translator$U,
38746
+ paragraph: translator$16,
38747
+ run: translator$V,
38535
38748
  text: translateTextNode,
38536
38749
  bulletList: translateList,
38537
38750
  orderedList: translateList,
38538
- lineBreak: translator$16,
38539
- table: translator$9,
38540
- tableRow: translator$G,
38541
- tableCell: translator$8,
38542
- bookmarkStart: translator$2,
38543
- bookmarkEnd: translator$1,
38544
- fieldAnnotation: translator$3,
38545
- tab: translator$14,
38546
- image: translator$4,
38547
- hardBreak: translator$16,
38751
+ lineBreak: translator$19,
38752
+ table: translator$a,
38753
+ tableRow: translator$H,
38754
+ tableCell: translator$9,
38755
+ bookmarkStart: translator$4,
38756
+ bookmarkEnd: translator$3,
38757
+ fieldAnnotation: translator$5,
38758
+ tab: translator$17,
38759
+ image: translator$6,
38760
+ hardBreak: translator$19,
38548
38761
  commentRangeStart: () => translateCommentNode(params2, "Start"),
38549
38762
  commentRangeEnd: () => translateCommentNode(params2, "End"),
38550
38763
  commentReference: () => null,
38551
38764
  shapeContainer: translateShapeContainer,
38552
38765
  shapeTextbox: translateShapeTextbox,
38553
38766
  contentBlock: translateContentBlock,
38554
- structuredContent: translator$3,
38555
- structuredContentBlock: translator$3,
38556
- documentSection: translator$3,
38767
+ structuredContent: translator$5,
38768
+ structuredContentBlock: translator$5,
38769
+ documentPartObject: translator$5,
38770
+ documentSection: translator$5,
38557
38771
  "page-number": translatePageNumberNode,
38558
- "total-page-number": translateTotalPageNumberNode
38772
+ "total-page-number": translateTotalPageNumberNode,
38773
+ pageReference: translator$1,
38774
+ tableOfContents: translator
38559
38775
  };
38560
38776
  let handler2 = router[type2];
38561
38777
  if (handler2 && "decode" in handler2 && typeof handler2.decode === "function") {
@@ -38893,8 +39109,6 @@ Please report this to https://github.com/markedjs/marked.`, e) {
38893
39109
  const trackedMarks = [TrackInsertMarkName, TrackDeleteMarkName];
38894
39110
  const isTrackedNode = node.marks?.some((m2) => trackedMarks.includes(m2.type));
38895
39111
  if (isTrackedNode) return translateTrackedNode(params2);
38896
- const isLinkNode = node.marks?.some((m2) => m2.type === "link");
38897
- if (isLinkNode) return translator$7.decode(params2);
38898
39112
  const { text, marks = [] } = node;
38899
39113
  return getTextNodeForExport(text, marks, params2);
38900
39114
  }
@@ -39200,7 +39414,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
39200
39414
  markElement.type = "element";
39201
39415
  break;
39202
39416
  case "underline": {
39203
- const translated = translator$10.decode({
39417
+ const translated = translator$13.decode({
39204
39418
  node: {
39205
39419
  attrs: {
39206
39420
  underlineType: attrs.underlineType ?? attrs.underline ?? null,
@@ -39264,7 +39478,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
39264
39478
  break;
39265
39479
  case "highlight": {
39266
39480
  const highlightValue = attrs.color ?? attrs.highlight ?? null;
39267
- const translated = translator$15.decode({ node: { attrs: { highlight: highlightValue } } });
39481
+ const translated = translator$18.decode({ node: { attrs: { highlight: highlightValue } } });
39268
39482
  return translated || {};
39269
39483
  }
39270
39484
  }
@@ -39292,7 +39506,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
39292
39506
  const pict = {
39293
39507
  name: "w:pict",
39294
39508
  attributes: {
39295
- "w14:anchorId": Math.floor(Math.random() * 4294967295).toString()
39509
+ "w14:anchorId": generateRandomSigned32BitIntStrId()
39296
39510
  },
39297
39511
  elements: [shape]
39298
39512
  };
@@ -39324,7 +39538,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
39324
39538
  if (vmlAttributes || horizontalRule) {
39325
39539
  return translateVRectContentBlock(params2);
39326
39540
  }
39327
- const alternateContent = translator.decode(params2);
39541
+ const alternateContent = translator$2.decode(params2);
39328
39542
  return wrapTextInRun(alternateContent);
39329
39543
  }
39330
39544
  function translateVRectContentBlock(params2) {
@@ -39359,7 +39573,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
39359
39573
  const pict = {
39360
39574
  name: "w:pict",
39361
39575
  attributes: {
39362
- "w14:anchorId": Math.floor(Math.random() * 4294967295).toString()
39576
+ "w14:anchorId": generateRandomSigned32BitIntStrId()
39363
39577
  },
39364
39578
  elements: [rect]
39365
39579
  };
@@ -39469,6 +39683,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
39469
39683
  },
39470
39684
  {
39471
39685
  name: "w:instrText",
39686
+ attributes: { "xml:space": "preserve" },
39472
39687
  elements: [
39473
39688
  {
39474
39689
  type: "text",
@@ -39528,7 +39743,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
39528
39743
  if (mainNode.name === "w:drawing") node = mainNode;
39529
39744
  else node = mainNode.elements.find((el) => el.name === "w:drawing");
39530
39745
  if (!node) return { nodes: [], consumed: 0 };
39531
- const schemaNode = translator$4.encode(params2);
39746
+ const schemaNode = translator$6.encode(params2);
39532
39747
  const newNodes = schemaNode ? [schemaNode] : [];
39533
39748
  return { nodes: newNodes, consumed: 1 };
39534
39749
  };
@@ -39630,8 +39845,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
39630
39845
  handlerName: "trackChangeNodeHandler",
39631
39846
  handler: handleTrackChangeNode
39632
39847
  };
39633
- const hyperlinkNodeHandlerEntity = generateV2HandlerEntity("hyperlinkNodeHandler", translator$7);
39634
- const runNodeHandlerEntity = generateV2HandlerEntity("runNodeHandler", translator$U);
39848
+ const hyperlinkNodeHandlerEntity = generateV2HandlerEntity("hyperlinkNodeHandler", translator$W);
39849
+ const runNodeHandlerEntity = generateV2HandlerEntity("runNodeHandler", translator$V);
39635
39850
  const handleTextNode = (params2) => {
39636
39851
  const { nodes, insideTrackChange } = params2;
39637
39852
  if (nodes.length === 0 || !(nodes[0].name === "w:t" || insideTrackChange && nodes[0].name === "w:delText")) {
@@ -39672,7 +39887,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
39672
39887
  if (nodes.length === 0 || nodes[0].name !== "w:p") {
39673
39888
  return { nodes: [], consumed: 0 };
39674
39889
  }
39675
- const schemaNode = translator$13.encode(params2);
39890
+ const schemaNode = translator$16.encode(params2);
39676
39891
  const newNodes = schemaNode ? [schemaNode] : [];
39677
39892
  return { nodes: newNodes, consumed: 1 };
39678
39893
  };
@@ -39685,7 +39900,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
39685
39900
  if (nodes.length === 0 || nodes[0].name !== "w:sdt") {
39686
39901
  return { nodes: [], consumed: 0 };
39687
39902
  }
39688
- const result = translator$3.encode(params2);
39903
+ const result = translator$5.encode(params2);
39689
39904
  if (!result) {
39690
39905
  return { nodes: [], consumed: 0 };
39691
39906
  }
@@ -39775,7 +39990,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
39775
39990
  if (nodes.length === 0 || nodes[0].name !== "w:br") {
39776
39991
  return { nodes: [], consumed: 0 };
39777
39992
  }
39778
- const result = translator$16.encode(params2);
39993
+ const result = translator$19.encode(params2);
39779
39994
  if (!result) return { nodes: [], consumed: 0 };
39780
39995
  return {
39781
39996
  nodes: [result],
@@ -39847,7 +40062,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
39847
40062
  if (isCustomMarkBookmark(nodes[0], params2.editor)) {
39848
40063
  return handleBookmarkNode(params2);
39849
40064
  }
39850
- const node = translator$2.encode(params2);
40065
+ const node = translator$4.encode(params2);
39851
40066
  if (!node) return { nodes: [], consumed: 0 };
39852
40067
  return { nodes: [node], consumed: 1 };
39853
40068
  };
@@ -39879,7 +40094,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
39879
40094
  if (!nodes.length || nodes[0].name !== "w:bookmarkEnd") {
39880
40095
  return { nodes: [], consumed: 0 };
39881
40096
  }
39882
- const node = translator$1.encode(params2);
40097
+ const node = translator$3.encode(params2);
39883
40098
  if (!node) return { nodes: [], consumed: 0 };
39884
40099
  return { nodes: [node], consumed: 1 };
39885
40100
  };
@@ -40012,6 +40227,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
40012
40227
  handlerName: "autoTotalPageCountEntity",
40013
40228
  handler: handleAutoTotalPageNumber
40014
40229
  };
40230
+ const pageReferenceEntity = generateV2HandlerEntity("pageReferenceNodeHandler", translator$1);
40015
40231
  const handlePictNode = (params2) => {
40016
40232
  const { nodes } = params2;
40017
40233
  if (!nodes.length || nodes[0].name !== "w:p") {
@@ -40483,6 +40699,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
40483
40699
  const spacing = pPr?.elements?.find((el) => el.name === "w:spacing");
40484
40700
  const justify = pPr?.elements?.find((el) => el.name === "w:jc");
40485
40701
  const indent = pPr?.elements?.find((el) => el.name === "w:ind");
40702
+ const tabs = pPr?.elements?.find((el) => el.name === "w:tabs");
40486
40703
  let lineSpaceBefore, lineSpaceAfter, line;
40487
40704
  if (spacing) {
40488
40705
  lineSpaceBefore = twipsToPixels(spacing?.attributes["w:before"]);
@@ -40496,6 +40713,22 @@ Please report this to https://github.com/markedjs/marked.`, e) {
40496
40713
  rightIndent = twipsToPixels(indent?.attributes["w:right"]);
40497
40714
  firstLine = twipsToPixels(indent?.attributes["w:firstLine"]);
40498
40715
  }
40716
+ let tabStops = [];
40717
+ if (tabs) {
40718
+ tabStops = (tabs.elements || []).filter((el) => el.name === "w:tab").map((tab) => {
40719
+ let val = tab.attributes["w:val"];
40720
+ if (val == "left") {
40721
+ val = "start";
40722
+ } else if (val == "right") {
40723
+ val = "end";
40724
+ }
40725
+ return {
40726
+ val,
40727
+ pos: twipsToPixels(tab.attributes["w:pos"]),
40728
+ leader: tab.attributes["w:leader"]
40729
+ };
40730
+ });
40731
+ }
40499
40732
  const keepNext = pPr?.elements?.find((el) => el.name === "w:keepNext");
40500
40733
  const keepLines = pPr?.elements?.find((el) => el.name === "w:keepLines");
40501
40734
  const outlineLevel = pPr?.elements?.find((el) => el.name === "w:outlineLvl");
@@ -40528,7 +40761,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
40528
40761
  const parsedStyles = {
40529
40762
  spacing: { lineSpaceAfter, lineSpaceBefore, line },
40530
40763
  textAlign,
40531
- indent: { leftIndent, rightIndent, firstLine }
40764
+ indent: { leftIndent, rightIndent, firstLine },
40765
+ tabStops: tabStops.length > 0 ? tabStops : null
40532
40766
  };
40533
40767
  parsedMarks.forEach((mark) => {
40534
40768
  const { type: type2, attrs } = mark;
@@ -40552,13 +40786,213 @@ Please report this to https://github.com/markedjs/marked.`, e) {
40552
40786
  if (!nodes.length || nodes[0].name !== "w:tab") {
40553
40787
  return { nodes: [], consumed: 0 };
40554
40788
  }
40555
- const node = translator$14.encode(params2);
40789
+ const node = translator$17.encode(params2);
40556
40790
  return { nodes: [node], consumed: 1 };
40557
40791
  };
40558
40792
  const tabNodeEntityHandler = {
40559
40793
  handlerName: "w:tabTranslator",
40560
40794
  handler: handleTabNode
40561
40795
  };
40796
+ const tableOfContentsHandlerEntity = generateV2HandlerEntity("tableOfContentsHandler", translator);
40797
+ function preProcessPageInstruction(nodesToCombine, _2, __) {
40798
+ const pageNumNode = {
40799
+ name: "sd:autoPageNumber",
40800
+ type: "element"
40801
+ };
40802
+ nodesToCombine.forEach((n) => {
40803
+ const rPrNode = n.elements.find((el) => el.name === "w:rPr");
40804
+ if (rPrNode) pageNumNode.elements = [rPrNode];
40805
+ });
40806
+ return [pageNumNode];
40807
+ }
40808
+ function preProcessNumPagesInstruction(nodesToCombine, _2, __) {
40809
+ const totalPageNumNode = {
40810
+ name: "sd:totalPageNumber",
40811
+ type: "element"
40812
+ };
40813
+ nodesToCombine.forEach((n) => {
40814
+ const rPrNode = n.elements?.find((el) => el.name === "w:rPr");
40815
+ if (rPrNode) totalPageNumNode.elements = [rPrNode];
40816
+ });
40817
+ return [totalPageNumNode];
40818
+ }
40819
+ function preProcessPageRefInstruction(nodesToCombine, instrText, _2) {
40820
+ const pageRefNode = {
40821
+ name: "sd:pageReference",
40822
+ type: "element",
40823
+ attributes: {
40824
+ instruction: instrText
40825
+ },
40826
+ elements: nodesToCombine
40827
+ };
40828
+ return [pageRefNode];
40829
+ }
40830
+ function preProcessHyperlinkInstruction(nodesToCombine, instruction, docx) {
40831
+ const urlMatch = instruction.match(/HYPERLINK\s+"([^"]+)"/);
40832
+ let linkAttributes;
40833
+ if (urlMatch && urlMatch.length >= 2) {
40834
+ const url = urlMatch[1];
40835
+ const rels = docx["word/_rels/document.xml.rels"];
40836
+ const relationships = rels?.elements.find((el) => el.name === "Relationships");
40837
+ if (relationships) {
40838
+ const rId = generateDocxRandomId();
40839
+ relationships.elements.push({
40840
+ type: "element",
40841
+ name: "Relationship",
40842
+ attributes: {
40843
+ Id: rId,
40844
+ Type: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",
40845
+ Target: url,
40846
+ TargetMode: "External"
40847
+ }
40848
+ });
40849
+ linkAttributes = { "r:id": rId };
40850
+ } else {
40851
+ linkAttributes = { "w:anchor": url };
40852
+ }
40853
+ } else {
40854
+ const availableSwitches = {
40855
+ "w:anchor": `l "(?<value>[^"]+)"`,
40856
+ new_window: `
40857
+ `,
40858
+ "w:tgtFrame": ` "(?<value>[^"]+)"`,
40859
+ "w:tooltip": `o "(?<value>[^"]+)"`
40860
+ };
40861
+ const parsedSwitches = {};
40862
+ for (const [key2, regex] of Object.entries(availableSwitches)) {
40863
+ const match = instruction.match(new RegExp(regex));
40864
+ if (match) {
40865
+ parsedSwitches[key2] = match.groups?.value || true;
40866
+ }
40867
+ }
40868
+ if (parsedSwitches.new_window) {
40869
+ parsedSwitches["w:tgtFrame"] = "_blank";
40870
+ delete parsedSwitches.new_window;
40871
+ }
40872
+ linkAttributes = { ...parsedSwitches };
40873
+ }
40874
+ return [
40875
+ {
40876
+ name: "w:hyperlink",
40877
+ type: "element",
40878
+ attributes: linkAttributes,
40879
+ elements: nodesToCombine
40880
+ }
40881
+ ];
40882
+ }
40883
+ function preProcessTocInstruction(nodesToCombine, instrText) {
40884
+ return [
40885
+ {
40886
+ name: "sd:tableOfContents",
40887
+ type: "element",
40888
+ attributes: {
40889
+ instruction: instrText
40890
+ },
40891
+ elements: nodesToCombine
40892
+ }
40893
+ ];
40894
+ }
40895
+ const getInstructionPreProcessor = (instruction) => {
40896
+ const instructionType = instruction.split(" ")[0];
40897
+ switch (instructionType) {
40898
+ case "PAGE":
40899
+ return preProcessPageInstruction;
40900
+ case "NUMPAGES":
40901
+ return preProcessNumPagesInstruction;
40902
+ case "PAGEREF":
40903
+ return preProcessPageRefInstruction;
40904
+ case "HYPERLINK":
40905
+ return preProcessHyperlinkInstruction;
40906
+ case "TOC":
40907
+ return preProcessTocInstruction;
40908
+ default:
40909
+ return null;
40910
+ }
40911
+ };
40912
+ const preProcessNodesForFldChar = (nodes = [], docx) => {
40913
+ const processedNodes = [];
40914
+ let collectedNodesStack = [];
40915
+ let currentFieldStack = [];
40916
+ let unpairedEnd = null;
40917
+ let collecting = false;
40918
+ const finalizeField = () => {
40919
+ if (collecting) {
40920
+ const collectedNodes = collectedNodesStack.pop().filter((n) => n !== null);
40921
+ const currentField = currentFieldStack.pop();
40922
+ const combined = _processCombinedNodesForFldChar(collectedNodes, currentField.instrText.trim(), docx);
40923
+ if (collectedNodesStack.length === 0) {
40924
+ processedNodes.push(...combined);
40925
+ } else {
40926
+ collectedNodesStack[collectedNodesStack.length - 1].push(...combined);
40927
+ }
40928
+ } else {
40929
+ unpairedEnd = true;
40930
+ }
40931
+ };
40932
+ for (const node of nodes) {
40933
+ const fldCharEl = node.elements?.find((el) => el.name === "w:fldChar");
40934
+ const fldType = fldCharEl?.attributes?.["w:fldCharType"];
40935
+ const instrTextEl = node.elements?.find((el) => el.name === "w:instrText");
40936
+ collecting = collectedNodesStack.length > 0;
40937
+ if (fldType === "begin") {
40938
+ collectedNodesStack.push([null]);
40939
+ currentFieldStack.push({ instrText: "" });
40940
+ continue;
40941
+ }
40942
+ if (instrTextEl && collecting && currentFieldStack.length > 0) {
40943
+ currentFieldStack[currentFieldStack.length - 1].instrText += (instrTextEl.elements?.[0]?.text || "") + " ";
40944
+ continue;
40945
+ }
40946
+ if (fldType === "end") {
40947
+ finalizeField();
40948
+ continue;
40949
+ } else if (fldType === "separate") {
40950
+ continue;
40951
+ }
40952
+ if (Array.isArray(node.elements)) {
40953
+ const childResult = preProcessNodesForFldChar(node.elements, docx);
40954
+ node.elements = childResult.processedNodes;
40955
+ if (childResult.unpairedBegin) {
40956
+ childResult.unpairedBegin.forEach((pendingField) => {
40957
+ currentFieldStack.push(pendingField.fieldInfo);
40958
+ collectedNodesStack.push([node]);
40959
+ });
40960
+ } else if (childResult.unpairedEnd) {
40961
+ collectedNodesStack[collectedNodesStack.length - 1].push(node);
40962
+ finalizeField();
40963
+ } else if (collecting) {
40964
+ collectedNodesStack[collectedNodesStack.length - 1].push(node);
40965
+ } else {
40966
+ processedNodes.push(node);
40967
+ }
40968
+ } else if (collecting) {
40969
+ collectedNodesStack[collectedNodesStack.length - 1].push(node);
40970
+ } else {
40971
+ processedNodes.push(node);
40972
+ }
40973
+ }
40974
+ let unpairedBegin = null;
40975
+ if (collectedNodesStack.length > 0) {
40976
+ unpairedBegin = [];
40977
+ for (let i2 = 0; i2 < collectedNodesStack.length; i2++) {
40978
+ processedNodes.push(...collectedNodesStack[i2].filter((n) => n !== null));
40979
+ unpairedBegin.push({
40980
+ nodes: collectedNodesStack[i2],
40981
+ fieldInfo: currentFieldStack[i2]
40982
+ });
40983
+ }
40984
+ }
40985
+ return { processedNodes, unpairedBegin, unpairedEnd };
40986
+ };
40987
+ const _processCombinedNodesForFldChar = (nodesToCombine = [], instrText, docx) => {
40988
+ const instructionType = instrText.trim().split(" ")[0];
40989
+ const instructionPreProcessor = getInstructionPreProcessor(instructionType);
40990
+ if (instructionPreProcessor) {
40991
+ return instructionPreProcessor(nodesToCombine, instrText, docx);
40992
+ } else {
40993
+ return nodesToCombine;
40994
+ }
40995
+ };
40562
40996
  const createDocumentJson = (docx, converter, editor) => {
40563
40997
  const json = carbonCopy(getInitialJSON(docx));
40564
40998
  if (!json) return null;
@@ -40588,6 +41022,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
40588
41022
  if (bodyNode) {
40589
41023
  ensureSectionProperties(bodyNode);
40590
41024
  const node = bodyNode;
41025
+ const { processedNodes } = preProcessNodesForFldChar(node.elements ?? [], docx);
41026
+ node.elements = processedNodes;
40591
41027
  const contentElements = node.elements?.filter((n) => n.name !== "w:sectPr") ?? [];
40592
41028
  const content = pruneIgnoredNodes(contentElements);
40593
41029
  const comments = importCommentData({ docx, converter, editor });
@@ -40643,8 +41079,10 @@ Please report this to https://github.com/markedjs/marked.`, e) {
40643
41079
  trackChangeNodeHandlerEntity,
40644
41080
  tableNodeHandlerEntity,
40645
41081
  tabNodeEntityHandler,
41082
+ tableOfContentsHandlerEntity,
40646
41083
  autoPageHandlerEntity,
40647
41084
  autoTotalPageCountEntity,
41085
+ pageReferenceEntity,
40648
41086
  standardNodeHandlerEntity
40649
41087
  ];
40650
41088
  const handler2 = createNodeListHandler(entities);
@@ -40832,7 +41270,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
40832
41270
  gutter: "0"
40833
41271
  })
40834
41272
  });
40835
- function ensureSectionProperties(bodyNode, converter) {
41273
+ function ensureSectionProperties(bodyNode) {
40836
41274
  if (!bodyNode.elements) bodyNode.elements = [];
40837
41275
  let sectPr = bodyNode.elements.find((el) => el.name === "w:sectPr");
40838
41276
  if (!sectPr) {
@@ -56406,7 +56844,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
56406
56844
  if (emitParams) editor.emit("commentsUpdate", emitParams);
56407
56845
  return newTrackedChanges;
56408
56846
  };
56409
- const getTrackedChangeText = ({ state: state2, nodes, mark, marks, trackedChangeType, isDeletionInsertion }) => {
56847
+ const getTrackedChangeText = ({ nodes, mark, trackedChangeType, isDeletionInsertion }) => {
56410
56848
  let trackedChangeText = "";
56411
56849
  let deletionText = "";
56412
56850
  if (trackedChangeType === TrackInsertMarkName) {
@@ -56448,10 +56886,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
56448
56886
  if (hasMatchingId) nodesWithMark.push(node2);
56449
56887
  });
56450
56888
  const { deletionText, trackedChangeText } = getTrackedChangeText({
56451
- state: newEditorState,
56452
56889
  nodes: nodesWithMark.length ? nodesWithMark : [node],
56453
56890
  mark: trackedMark,
56454
- marks,
56455
56891
  trackedChangeType,
56456
56892
  isDeletionInsertion
56457
56893
  });
@@ -61549,7 +61985,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
61549
61985
  }
61550
61986
  const attrs = {
61551
61987
  ...options.attrs,
61552
- id: options.attrs?.id || randomId(),
61988
+ id: options.attrs?.id || generateRandomSigned32BitIntStrId(),
61553
61989
  tag: "inline_text_sdt",
61554
61990
  alias: options.attrs?.alias || "Structured content"
61555
61991
  };
@@ -61590,7 +62026,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
61590
62026
  }
61591
62027
  const attrs = {
61592
62028
  ...options.attrs,
61593
- id: options.attrs?.id || randomId(),
62029
+ id: options.attrs?.id || generateRandomSigned32BitIntStrId(),
61594
62030
  tag: "block_table_sdt",
61595
62031
  alias: options.attrs?.alias || "Structured content"
61596
62032
  };
@@ -61697,7 +62133,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
61697
62133
  * Removes a structured content at cursor, preserving its content.
61698
62134
  * @category Command
61699
62135
  */
61700
- deleteStructuredContentAtSelection: () => ({ editor, dispatch, state: state2, tr }) => {
62136
+ deleteStructuredContentAtSelection: () => ({ dispatch, state: state2, tr }) => {
61701
62137
  const predicate = (node) => STRUCTURED_CONTENT_NAMES.includes(node.type.name);
61702
62138
  const structuredContent = findParentNode(predicate)(state2.selection);
61703
62139
  if (!structuredContent) {
@@ -61720,9 +62156,6 @@ Please report this to https://github.com/markedjs/marked.`, e) {
61720
62156
  };
61721
62157
  }
61722
62158
  });
61723
- const randomId = () => {
61724
- return Math.floor(Math.random() * 4294967295).toString();
61725
- };
61726
62159
  class DocumentSectionView {
61727
62160
  constructor(node, getPos, decorations, editor) {
61728
62161
  __privateAdd$1(this, _DocumentSectionView_instances);
@@ -62104,6 +62537,48 @@ Please report this to https://github.com/markedjs/marked.`, e) {
62104
62537
  };
62105
62538
  }
62106
62539
  });
62540
+ const DocumentPartObject = Node$1.create({
62541
+ name: "documentPartObject",
62542
+ group: "block",
62543
+ content: "block*",
62544
+ isolating: true,
62545
+ addOptions() {
62546
+ return {
62547
+ htmlAttributes: {
62548
+ class: "sd-document-part-object-block",
62549
+ "aria-label": "Structured document part block"
62550
+ }
62551
+ };
62552
+ },
62553
+ parseDOM() {
62554
+ return [
62555
+ {
62556
+ tag: "div.sd-document-part-object-block",
62557
+ priority: 60
62558
+ }
62559
+ ];
62560
+ },
62561
+ renderDOM({ htmlAttributes }) {
62562
+ return ["div", Attribute.mergeAttributes(this.options.htmlAttributes, htmlAttributes), 0];
62563
+ },
62564
+ addAttributes() {
62565
+ return {
62566
+ sdBlockId: {
62567
+ default: null,
62568
+ keepOnSplit: false,
62569
+ parseDOM: (elem) => elem.getAttribute("data-sd-block-id"),
62570
+ renderDOM: (attrs) => {
62571
+ return attrs.sdBlockId ? { "data-sd-block-id": attrs.sdBlockId } : {};
62572
+ }
62573
+ },
62574
+ id: {},
62575
+ docPartGallery: {},
62576
+ docPartUnique: {
62577
+ default: true
62578
+ }
62579
+ };
62580
+ }
62581
+ });
62107
62582
  const Document = Node$1.create({
62108
62583
  name: "doc",
62109
62584
  topNode: true,
@@ -63240,7 +63715,12 @@ Please report this to https://github.com/markedjs/marked.`, e) {
63240
63715
  return { ...base2, ...linkedStyle.definition?.styles || {} };
63241
63716
  };
63242
63717
  const pMap = buildStyleMap(paragraphStyleId);
63243
- const tMap = buildStyleMap(inlineTextStyleId);
63718
+ let tMap;
63719
+ if (paragraphStyleId?.startsWith("TOC")) {
63720
+ tMap = {};
63721
+ } else {
63722
+ tMap = buildStyleMap(inlineTextStyleId);
63723
+ }
63244
63724
  const rMap = buildStyleMap(runStyleId);
63245
63725
  const finalStyles = { ...pMap, ...tMap, ...rMap };
63246
63726
  if (Object.keys(finalStyles).length === 0) return;
@@ -64537,7 +65017,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
64537
65017
  });
64538
65018
  const defaultTabDistance = 48;
64539
65019
  const defaultLineLength = 816;
64540
- const getTabDecorations = (doc2, view, from2 = 0, to = null) => {
65020
+ const getTabDecorations = (doc2, view, helpers2, from2 = 0, to = null) => {
64541
65021
  const decorations = [];
64542
65022
  const paragraphCache = /* @__PURE__ */ new Map();
64543
65023
  const end2 = to ?? doc2.content.size;
@@ -64545,7 +65025,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
64545
65025
  if (node.type.name !== "tab") return;
64546
65026
  let extraStyles = "";
64547
65027
  const $pos = doc2.resolve(pos);
64548
- const paragraphContext = getParagraphContext($pos, paragraphCache);
65028
+ const paragraphContext = getParagraphContext($pos, paragraphCache, helpers2);
64549
65029
  if (!paragraphContext) return;
64550
65030
  try {
64551
65031
  const { tabStops, flattened, startPos } = paragraphContext;
@@ -64600,18 +65080,27 @@ Please report this to https://github.com/markedjs/marked.`, e) {
64600
65080
  });
64601
65081
  return decorations;
64602
65082
  };
64603
- function getParagraphContext($pos, cache2) {
65083
+ function getParagraphContext($pos, cache2, helpers2) {
64604
65084
  for (let depth = $pos.depth; depth >= 0; depth--) {
64605
65085
  const node = $pos.node(depth);
64606
65086
  if (node?.type?.name === "paragraph") {
64607
65087
  const startPos = $pos.start(depth);
64608
65088
  if (!cache2.has(startPos)) {
65089
+ let tabStops = [];
65090
+ if (Array.isArray(node.attrs?.tabStops)) {
65091
+ tabStops = node.attrs.tabStops;
65092
+ } else {
65093
+ const style2 = helpers2.linkedStyles.getStyleById(node.attrs?.styleId);
65094
+ if (Array.isArray(style2?.definition?.styles?.tabStops)) {
65095
+ tabStops = style2.definition.styles.tabStops;
65096
+ }
65097
+ }
64609
65098
  cache2.set(startPos, {
64610
65099
  paragraph: node,
64611
65100
  paragraphDepth: depth,
64612
65101
  startPos,
64613
65102
  indent: node.attrs?.indent || {},
64614
- tabStops: Array.isArray(node.attrs?.tabStops) ? node.attrs.tabStops : [],
65103
+ tabStops,
64615
65104
  flattened: flattenParagraph(node, startPos),
64616
65105
  accumulatedTabWidth: 0
64617
65106
  });
@@ -64777,7 +65266,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
64777
65266
  };
64778
65267
  },
64779
65268
  addPmPlugins() {
64780
- const { view } = this.editor;
65269
+ const { view, helpers: helpers2 } = this.editor;
64781
65270
  const tabPlugin = new Plugin({
64782
65271
  name: "tabPlugin",
64783
65272
  key: new PluginKey("tabPlugin"),
@@ -64787,7 +65276,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
64787
65276
  },
64788
65277
  apply(tr, { decorations }, _oldState, newState) {
64789
65278
  if (!decorations) {
64790
- decorations = DecorationSet.create(newState.doc, getTabDecorations(newState.doc, view));
65279
+ decorations = DecorationSet.create(newState.doc, getTabDecorations(newState.doc, view, helpers2));
64791
65280
  }
64792
65281
  if (!tr.docChanged) {
64793
65282
  return { decorations };
@@ -64827,7 +65316,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
64827
65316
  rangesToRecalculate.forEach(([start2, end2]) => {
64828
65317
  const oldDecorations = decorations.find(start2, end2);
64829
65318
  decorations = decorations.remove(oldDecorations);
64830
- const newDecorations = getTabDecorations(newState.doc, view, start2, end2);
65319
+ const newDecorations = getTabDecorations(newState.doc, view, helpers2, start2, end2);
64831
65320
  decorations = decorations.add(newState.doc, newDecorations);
64832
65321
  });
64833
65322
  return { decorations };
@@ -71108,6 +71597,43 @@ Please report this to https://github.com/markedjs/marked.`, e) {
71108
71597
  });
71109
71598
  return styles;
71110
71599
  };
71600
+ const PageReference = Node$1.create({
71601
+ name: "pageReference",
71602
+ group: "inline",
71603
+ inline: true,
71604
+ atom: true,
71605
+ draggable: false,
71606
+ selectable: false,
71607
+ content: "inline*",
71608
+ addOptions() {
71609
+ return {
71610
+ htmlAttributes: {
71611
+ contenteditable: false,
71612
+ "data-id": "auto-page-reference",
71613
+ "aria-label": "Page reference node",
71614
+ class: "sd-editor-page-reference"
71615
+ }
71616
+ };
71617
+ },
71618
+ addAttributes() {
71619
+ return {
71620
+ marksAsAttrs: {
71621
+ default: null,
71622
+ rendered: false
71623
+ },
71624
+ instruction: {
71625
+ default: "",
71626
+ rendered: false
71627
+ }
71628
+ };
71629
+ },
71630
+ parseDOM() {
71631
+ return [{ tag: 'span[data-id="auto-page-reference"]' }];
71632
+ },
71633
+ renderDOM({ htmlAttributes }) {
71634
+ return ["span", Attribute.mergeAttributes(this.options.htmlAttributes, htmlAttributes), 0];
71635
+ }
71636
+ });
71111
71637
  const ShapeContainer = Node$1.create({
71112
71638
  name: "shapeContainer",
71113
71639
  group: "block",
@@ -71521,6 +72047,51 @@ Please report this to https://github.com/markedjs/marked.`, e) {
71521
72047
  });
71522
72048
  });
71523
72049
  };
72050
+ const TableOfContents = Node$1.create({
72051
+ name: "tableOfContents",
72052
+ group: "block",
72053
+ content: "paragraph+",
72054
+ inline: false,
72055
+ addOptions() {
72056
+ return {
72057
+ htmlAttributes: {
72058
+ "data-id": "table-of-contents",
72059
+ "aria-label": "Table of Contents"
72060
+ }
72061
+ };
72062
+ },
72063
+ parseDOM() {
72064
+ return [
72065
+ {
72066
+ tag: 'div[data-id="table-of-contents"]'
72067
+ }
72068
+ ];
72069
+ },
72070
+ renderDOM({ htmlAttributes }) {
72071
+ return ["div", Attribute.mergeAttributes(this.options.htmlAttributes, htmlAttributes), 0];
72072
+ },
72073
+ addAttributes() {
72074
+ return {
72075
+ instruction: {
72076
+ default: null,
72077
+ rendered: false
72078
+ },
72079
+ /**
72080
+ * @private
72081
+ * @category Attribute
72082
+ * @param {string} [sdBlockId] - Internal block tracking ID (not user-configurable)
72083
+ */
72084
+ sdBlockId: {
72085
+ default: null,
72086
+ keepOnSplit: false,
72087
+ parseDOM: (elem) => elem.getAttribute("data-sd-block-id"),
72088
+ renderDOM: (attrs) => {
72089
+ return attrs.sdBlockId ? { "data-sd-block-id": attrs.sdBlockId } : {};
72090
+ }
72091
+ }
72092
+ };
72093
+ }
72094
+ });
71524
72095
  const TextStyle = Mark.create({
71525
72096
  name: "textStyle",
71526
72097
  addOptions() {
@@ -78127,6 +78698,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
78127
78698
  SlashMenu,
78128
78699
  Strike,
78129
78700
  TabNode,
78701
+ TableOfContents,
78130
78702
  Text,
78131
78703
  TextAlign,
78132
78704
  TextIndent,
@@ -78161,6 +78733,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
78161
78733
  AiLoaderNode,
78162
78734
  PageNumber,
78163
78735
  TotalPageCount,
78736
+ PageReference,
78164
78737
  ShapeContainer,
78165
78738
  ShapeTextbox,
78166
78739
  ContentBlock,
@@ -78169,6 +78742,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
78169
78742
  StructuredContentBlock,
78170
78743
  StructuredContentCommands,
78171
78744
  DocumentSection,
78745
+ DocumentPartObject,
78172
78746
  NodeResizer,
78173
78747
  CustomSelection,
78174
78748
  TextTransform
@@ -93705,71 +94279,73 @@ ${style2}
93705
94279
  };
93706
94280
  const SuperInput = /* @__PURE__ */ _export_sfc$1(_sfc_main$i, [["__scopeId", "data-v-4d5cff52"]]);
93707
94281
  const additionalHandlers = Object.freeze({
93708
- "mc:AlternateContent": translator,
93709
- "w:b": translator$12,
93710
- "w:bidiVisual": translator$F,
93711
- "w:bookmarkEnd": translator$1,
93712
- "w:bookmarkStart": translator$2,
93713
- "w:bottom": translator$s,
93714
- "w:br": translator$16,
93715
- "w:cantSplit": translator$T,
93716
- "w:cnfStyle": translator$S,
93717
- "w:color": translator$_,
93718
- "w:divId": translator$R,
93719
- "w:drawing": translator$4,
93720
- "w:end": translator$q,
93721
- "w:gridAfter": translator$Q,
93722
- "w:gridBefore": translator$P,
93723
- "w:gridCol": translator$b,
93724
- "w:hidden": translator$O,
93725
- "w:highlight": translator$15,
93726
- "w:hyperlink": translator$7,
93727
- "w:i": translator$11,
93728
- "w:insideH": translator$o,
93729
- "w:insideV": translator$n,
93730
- "w:jc": translator$N,
93731
- "w:left": translator$m,
93732
- "w:p": translator$13,
93733
- "w:r": translator$U,
93734
- "w:rFonts": translator$Z,
93735
- "w:rPr": translator$V,
93736
- "w:rStyle": translator$Y,
93737
- "w:right": translator$k,
93738
- "w:sdt": translator$3,
93739
- "w:shd": translator$E,
93740
- "w:start": translator$i,
93741
- "w:strike": translator$$,
93742
- "w:sz": translator$X,
93743
- "w:szCs": translator$W,
93744
- "w:tab": translator$14,
93745
- "w:tbl": translator$9,
93746
- "w:tblBorders": translator$e,
93747
- "w:tblCaption": translator$D,
93748
- "w:tblCellMar": translator$d,
93749
- "w:tblCellSpacing": translator$M,
93750
- "w:tblDescription": translator$C,
93751
- "w:tblGrid": translator$a,
93752
- "w:tblHeader": translator$L,
93753
- "w:tblInd": translator$B,
93754
- "w:tblLayout": translator$A,
93755
- "w:tblLook": translator$z,
93756
- "w:tblOverlap": translator$y,
93757
- "w:tblPr": translator$c,
93758
- "w:tblStyle": translator$x,
93759
- "w:tblStyleColBandSize": translator$w,
93760
- "w:tblStyleRowBandSize": translator$v,
93761
- "w:tblW": translator$u,
93762
- "w:tblpPr": translator$t,
93763
- "w:tc": translator$8,
93764
- "w:top": translator$g,
93765
- "w:tr": translator$G,
93766
- "w:trHeight": translator$K,
93767
- "w:trPr": translator$H,
93768
- "w:u": translator$10,
93769
- "w:wAfter": translator$J,
93770
- "w:wBefore": translator$I,
93771
- "wp:anchor": translator$6,
93772
- "wp:inline": translator$5
94282
+ "mc:AlternateContent": translator$2,
94283
+ "sd:pageReference": translator$1,
94284
+ "sd:tableOfContents": translator,
94285
+ "w:b": translator$15,
94286
+ "w:bidiVisual": translator$G,
94287
+ "w:bookmarkEnd": translator$3,
94288
+ "w:bookmarkStart": translator$4,
94289
+ "w:bottom": translator$t,
94290
+ "w:br": translator$19,
94291
+ "w:cantSplit": translator$U,
94292
+ "w:cnfStyle": translator$T,
94293
+ "w:color": translator$11,
94294
+ "w:divId": translator$S,
94295
+ "w:drawing": translator$6,
94296
+ "w:end": translator$r,
94297
+ "w:gridAfter": translator$R,
94298
+ "w:gridBefore": translator$Q,
94299
+ "w:gridCol": translator$c,
94300
+ "w:hidden": translator$P,
94301
+ "w:highlight": translator$18,
94302
+ "w:hyperlink": translator$W,
94303
+ "w:i": translator$14,
94304
+ "w:insideH": translator$p,
94305
+ "w:insideV": translator$o,
94306
+ "w:jc": translator$O,
94307
+ "w:left": translator$n,
94308
+ "w:p": translator$16,
94309
+ "w:r": translator$V,
94310
+ "w:rFonts": translator$10,
94311
+ "w:rPr": translator$X,
94312
+ "w:rStyle": translator$$,
94313
+ "w:right": translator$l,
94314
+ "w:sdt": translator$5,
94315
+ "w:shd": translator$F,
94316
+ "w:start": translator$j,
94317
+ "w:strike": translator$12,
94318
+ "w:sz": translator$_,
94319
+ "w:szCs": translator$Z,
94320
+ "w:tab": translator$17,
94321
+ "w:tbl": translator$a,
94322
+ "w:tblBorders": translator$f,
94323
+ "w:tblCaption": translator$E,
94324
+ "w:tblCellMar": translator$e,
94325
+ "w:tblCellSpacing": translator$N,
94326
+ "w:tblDescription": translator$D,
94327
+ "w:tblGrid": translator$b,
94328
+ "w:tblHeader": translator$M,
94329
+ "w:tblInd": translator$C,
94330
+ "w:tblLayout": translator$B,
94331
+ "w:tblLook": translator$A,
94332
+ "w:tblOverlap": translator$z,
94333
+ "w:tblPr": translator$d,
94334
+ "w:tblStyle": translator$y,
94335
+ "w:tblStyleColBandSize": translator$x,
94336
+ "w:tblStyleRowBandSize": translator$w,
94337
+ "w:tblW": translator$v,
94338
+ "w:tblpPr": translator$u,
94339
+ "w:tc": translator$9,
94340
+ "w:top": translator$h,
94341
+ "w:tr": translator$H,
94342
+ "w:trHeight": translator$L,
94343
+ "w:trPr": translator$I,
94344
+ "w:u": translator$13,
94345
+ "w:wAfter": translator$K,
94346
+ "w:wBefore": translator$J,
94347
+ "wp:anchor": translator$8,
94348
+ "wp:inline": translator$7
93773
94349
  });
93774
94350
  const baseHandlers = {
93775
94351
  ...runPropertyTranslators,