@harbour-enterprises/superdoc 0.21.0 → 0.21.1

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 (49) hide show
  1. package/dist/chunks/{PdfViewer-OZDJ7gwT.cjs → PdfViewer-B507M2sz.cjs} +1 -1
  2. package/dist/chunks/{PdfViewer-D3zo7tPo.es.js → PdfViewer-DCKxnML6.es.js} +1 -1
  3. package/dist/chunks/{index-MzW5BVNd.es.js → index-DWR8syta.es.js} +42 -21
  4. package/dist/chunks/{index-CfYf4T_z.cjs → index-djqw1MEc.cjs} +42 -21
  5. package/dist/chunks/{super-editor.es-Bntob7Wd.es.js → super-editor.es-D__G4K0i.es.js} +1595 -866
  6. package/dist/chunks/{super-editor.es-U-GVCd_F.cjs → super-editor.es-HekVJogH.cjs} +1595 -866
  7. package/dist/core/SuperDoc.d.ts +5 -0
  8. package/dist/core/SuperDoc.d.ts.map +1 -1
  9. package/dist/core/types/index.d.ts +12 -4
  10. package/dist/core/types/index.d.ts.map +1 -1
  11. package/dist/style.css +32 -27
  12. package/dist/super-editor/ai-writer.es.js +2 -2
  13. package/dist/super-editor/chunks/{converter-3xnF_NHq.js → converter-B_pO-5Ls.js} +1064 -710
  14. package/dist/super-editor/chunks/{docx-zipper-CZdELYi-.js → docx-zipper-WaO3WaIz.js} +73 -12
  15. package/dist/super-editor/chunks/{editor-BqYH4kDD.js → editor-DInvq7gF.js} +80 -26
  16. package/dist/super-editor/chunks/{toolbar-TkaE2kKM.js → toolbar-C15EomPB.js} +2 -2
  17. package/dist/super-editor/converter.es.js +1 -1
  18. package/dist/super-editor/docx-zipper.es.js +2 -2
  19. package/dist/super-editor/editor.es.js +3 -3
  20. package/dist/super-editor/file-zipper.es.js +1 -1
  21. package/dist/super-editor/src/components/slash-menu/menuItems.d.ts +5 -1
  22. package/dist/super-editor/src/components/slash-menu/tests/testHelpers.d.ts +466 -0
  23. package/dist/super-editor/src/components/slash-menu/utils.d.ts +9 -2
  24. package/dist/super-editor/src/core/DocxZipper.d.ts +1 -1
  25. package/dist/super-editor/src/core/commands/__tests__/schemaWithLists.d.ts +2 -0
  26. package/dist/super-editor/src/core/commands/__tests__/testHelpers.d.ts +4 -0
  27. package/dist/super-editor/src/core/commands/__tests__/testSchema.d.ts +2 -0
  28. package/dist/super-editor/src/core/commands/tests/commandTestUtils.d.ts +7 -0
  29. package/dist/super-editor/src/core/commands/tests/test-schema.d.ts +2 -0
  30. package/dist/super-editor/src/core/super-converter/SuperConverter.d.ts +1 -13
  31. package/dist/super-editor/src/core/super-converter/exporter.d.ts +1 -0
  32. package/dist/super-editor/src/core/super-converter/helpers/tableFallbackHelpers.d.ts +24 -0
  33. package/dist/super-editor/src/core/super-converter/v3/handlers/mc/altermateContent/alternate-content-translator.d.ts +6 -0
  34. package/dist/super-editor/src/core/super-converter/v3/handlers/mc/altermateContent/index.d.ts +1 -0
  35. package/dist/super-editor/src/extensions/custom-selection/custom-selection.d.ts +5 -0
  36. package/dist/super-editor/src/tests/helpers/helpers.d.ts +1 -0
  37. package/dist/super-editor/src/utils/contextmenu-helpers.d.ts +24 -0
  38. package/dist/super-editor/style.css +5 -0
  39. package/dist/super-editor/super-editor.es.js +454 -154
  40. package/dist/super-editor/toolbar.es.js +2 -2
  41. package/dist/super-editor.cjs +1 -1
  42. package/dist/super-editor.es.js +1 -1
  43. package/dist/superdoc.cjs +2 -2
  44. package/dist/superdoc.es.js +2 -2
  45. package/dist/superdoc.umd.js +1635 -885
  46. package/dist/superdoc.umd.js.map +1 -1
  47. package/package.json +2 -5
  48. package/dist/super-editor/src/extensions/run-item/index.d.ts +0 -1
  49. package/dist/super-editor/src/extensions/run-item/run-item.d.ts +0 -26
@@ -32058,37 +32058,37 @@ Please report this to https://github.com/markedjs/marked.`, e) {
32058
32058
  };
32059
32059
  __publicField$2(_NodeTranslator, "translatorTypes", TranslatorTypes);
32060
32060
  let NodeTranslator = _NodeTranslator;
32061
- const encode$17 = (attributes) => {
32061
+ const encode$18 = (attributes) => {
32062
32062
  return attributes["w:type"];
32063
32063
  };
32064
- const decode$_ = (attrs) => {
32064
+ const decode$$ = (attrs) => {
32065
32065
  const { lineBreakType } = attrs;
32066
32066
  return lineBreakType;
32067
32067
  };
32068
32068
  const attrConfig$F = Object.freeze({
32069
32069
  xmlName: "w:type",
32070
32070
  sdName: "lineBreakType",
32071
- encode: encode$17,
32072
- decode: decode$_
32071
+ encode: encode$18,
32072
+ decode: decode$$
32073
32073
  });
32074
- const encode$16 = (attributes) => {
32074
+ const encode$17 = (attributes) => {
32075
32075
  const xmlAttrValue = attributes["w:clear"];
32076
32076
  return xmlAttrValue;
32077
32077
  };
32078
- const decode$Z = (attrs) => {
32078
+ const decode$_ = (attrs) => {
32079
32079
  const { clear } = attrs;
32080
32080
  return clear;
32081
32081
  };
32082
32082
  const attrConfig$E = Object.freeze({
32083
32083
  xmlName: "w:clear",
32084
32084
  sdName: "clear",
32085
- encode: encode$16,
32086
- decode: decode$Z
32085
+ encode: encode$17,
32086
+ decode: decode$_
32087
32087
  });
32088
- const validXmlAttributes$l = [attrConfig$F, attrConfig$E];
32089
- const XML_NODE_NAME$t = "w:br";
32090
- const SD_NODE_NAME$c = "lineBreak";
32091
- const encode$15 = (_2, encodedAttrs) => {
32088
+ 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) => {
32092
32092
  const isPageBreak = encodedAttrs?.lineBreakType === "page";
32093
32093
  const translated = {
32094
32094
  type: isPageBreak ? "hardBreak" : "lineBreak"
@@ -32098,7 +32098,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
32098
32098
  }
32099
32099
  return translated;
32100
32100
  };
32101
- const decode$Y = (params2, decodedAttrs) => {
32101
+ const decode$Z = (params2, decodedAttrs) => {
32102
32102
  const { node } = params2;
32103
32103
  if (!node) return;
32104
32104
  const wBreak = { name: "w:br" };
@@ -32115,39 +32115,39 @@ Please report this to https://github.com/markedjs/marked.`, e) {
32115
32115
  };
32116
32116
  return translated;
32117
32117
  };
32118
- const config$r = {
32119
- xmlName: XML_NODE_NAME$t,
32120
- sdNodeOrKeyName: SD_NODE_NAME$c,
32118
+ const config$s = {
32119
+ xmlName: XML_NODE_NAME$u,
32120
+ sdNodeOrKeyName: SD_NODE_NAME$d,
32121
32121
  type: NodeTranslator.translatorTypes.NODE,
32122
- encode: encode$15,
32123
- decode: decode$Y,
32124
- attributes: validXmlAttributes$l
32122
+ encode: encode$16,
32123
+ decode: decode$Z,
32124
+ attributes: validXmlAttributes$m
32125
32125
  };
32126
- const translator$15 = NodeTranslator.from(config$r);
32127
- const encode$14 = (attributes) => attributes?.["w:val"];
32128
- const decode$X = (attrs) => attrs?.highlight;
32126
+ const translator$16 = NodeTranslator.from(config$s);
32127
+ const encode$15 = (attributes) => attributes?.["w:val"];
32128
+ const decode$Y = (attrs) => attrs?.highlight;
32129
32129
  const attrConfig$D = Object.freeze({
32130
32130
  xmlName: "w:val",
32131
32131
  sdName: "highlight",
32132
- encode: encode$14,
32133
- decode: decode$X
32132
+ encode: encode$15,
32133
+ decode: decode$Y
32134
32134
  });
32135
- const validXmlAttributes$k = [attrConfig$D];
32136
- const XML_NODE_NAME$s = "w:highlight";
32135
+ const validXmlAttributes$l = [attrConfig$D];
32136
+ const XML_NODE_NAME$t = "w:highlight";
32137
32137
  const SD_ATTR_KEY$f = "highlight";
32138
32138
  const DISABLED_TOKENS = /* @__PURE__ */ new Set(["transparent", "none", "inherit"]);
32139
- const encode$13 = (params2, encodedAttrs = {}) => {
32139
+ const encode$14 = (params2, encodedAttrs = {}) => {
32140
32140
  const { nodes } = params2;
32141
32141
  const node = nodes?.[0];
32142
32142
  const value = encodedAttrs.highlight ?? node?.attributes?.["w:val"];
32143
32143
  return {
32144
32144
  type: "attr",
32145
- xmlName: XML_NODE_NAME$s,
32145
+ xmlName: XML_NODE_NAME$t,
32146
32146
  sdNodeOrKeyName: SD_ATTR_KEY$f,
32147
32147
  attributes: { "w:val": value ?? null }
32148
32148
  };
32149
32149
  };
32150
- const decode$W = (params2) => {
32150
+ const decode$X = (params2) => {
32151
32151
  const attrs = params2?.node?.attrs || {};
32152
32152
  const highlightValue = attrs.highlight ?? attrs.color ?? null;
32153
32153
  if (!highlightValue) return void 0;
@@ -32155,14 +32155,14 @@ Please report this to https://github.com/markedjs/marked.`, e) {
32155
32155
  if (!normalizedValue) return void 0;
32156
32156
  if (DISABLED_TOKENS.has(normalizedValue)) {
32157
32157
  return {
32158
- name: XML_NODE_NAME$s,
32158
+ name: XML_NODE_NAME$t,
32159
32159
  attributes: { "w:val": "none" }
32160
32160
  };
32161
32161
  }
32162
32162
  const keyword = getDocxHighlightKeywordFromHex(highlightValue);
32163
32163
  if (keyword) {
32164
32164
  return {
32165
- name: XML_NODE_NAME$s,
32165
+ name: XML_NODE_NAME$t,
32166
32166
  attributes: { "w:val": keyword }
32167
32167
  };
32168
32168
  }
@@ -32177,63 +32177,63 @@ Please report this to https://github.com/markedjs/marked.`, e) {
32177
32177
  }
32178
32178
  };
32179
32179
  };
32180
- const config$q = {
32181
- xmlName: XML_NODE_NAME$s,
32180
+ const config$r = {
32181
+ xmlName: XML_NODE_NAME$t,
32182
32182
  sdNodeOrKeyName: SD_ATTR_KEY$f,
32183
32183
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
32184
- encode: encode$13,
32185
- decode: decode$W,
32186
- attributes: validXmlAttributes$k
32184
+ encode: encode$14,
32185
+ decode: decode$X,
32186
+ attributes: validXmlAttributes$l
32187
32187
  };
32188
- const translator$14 = NodeTranslator.from(config$q);
32189
- const encode$12 = (attributes) => {
32188
+ const translator$15 = NodeTranslator.from(config$r);
32189
+ const encode$13 = (attributes) => {
32190
32190
  return attributes["w:val"];
32191
32191
  };
32192
- const decode$V = (attrs) => {
32192
+ const decode$W = (attrs) => {
32193
32193
  const { tabSize } = attrs || {};
32194
32194
  return tabSize;
32195
32195
  };
32196
32196
  const attrConfig$C = Object.freeze({
32197
32197
  xmlName: "w:val",
32198
32198
  sdName: "tabSize",
32199
- encode: encode$12,
32200
- decode: decode$V
32199
+ encode: encode$13,
32200
+ decode: decode$W
32201
32201
  });
32202
- const encode$11 = (attributes) => {
32202
+ const encode$12 = (attributes) => {
32203
32203
  return attributes["w:leader"];
32204
32204
  };
32205
- const decode$U = (attrs) => {
32205
+ const decode$V = (attrs) => {
32206
32206
  const { leader } = attrs || {};
32207
32207
  return leader;
32208
32208
  };
32209
32209
  const attrConfig$B = Object.freeze({
32210
32210
  xmlName: "w:leader",
32211
32211
  sdName: "leader",
32212
- encode: encode$11,
32213
- decode: decode$U
32212
+ encode: encode$12,
32213
+ decode: decode$V
32214
32214
  });
32215
- const encode$10 = (attributes) => {
32215
+ const encode$11 = (attributes) => {
32216
32216
  return attributes["w:pos"];
32217
32217
  };
32218
- const decode$T = (attrs) => {
32218
+ const decode$U = (attrs) => {
32219
32219
  const { pos } = attrs || {};
32220
32220
  return pos;
32221
32221
  };
32222
32222
  const attrConfig$A = Object.freeze({
32223
32223
  xmlName: "w:pos",
32224
32224
  sdName: "pos",
32225
- encode: encode$10,
32226
- decode: decode$T
32225
+ encode: encode$11,
32226
+ decode: decode$U
32227
32227
  });
32228
- const validXmlAttributes$j = [attrConfig$C, attrConfig$A, attrConfig$B];
32229
- const XML_NODE_NAME$r = "w:tab";
32230
- const SD_NODE_NAME$b = "tab";
32231
- const encode$$ = (_2, encodedAttrs = {}) => {
32228
+ 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 = {}) => {
32232
32232
  const translated = { type: "tab" };
32233
32233
  if (encodedAttrs) translated.attrs = { ...encodedAttrs };
32234
32234
  return translated;
32235
32235
  };
32236
- const decode$S = (params2, decodedAttrs = {}) => {
32236
+ const decode$T = (params2, decodedAttrs = {}) => {
32237
32237
  const { node } = params2 || {};
32238
32238
  if (!node) return;
32239
32239
  const wTab = { name: "w:tab" };
@@ -32249,15 +32249,15 @@ Please report this to https://github.com/markedjs/marked.`, e) {
32249
32249
  }
32250
32250
  return translated;
32251
32251
  };
32252
- const config$p = {
32253
- xmlName: XML_NODE_NAME$r,
32254
- sdNodeOrKeyName: SD_NODE_NAME$b,
32252
+ const config$q = {
32253
+ xmlName: XML_NODE_NAME$s,
32254
+ sdNodeOrKeyName: SD_NODE_NAME$c,
32255
32255
  type: NodeTranslator.translatorTypes.NODE,
32256
- encode: encode$$,
32257
- decode: decode$S,
32258
- attributes: validXmlAttributes$j
32256
+ encode: encode$10,
32257
+ decode: decode$T,
32258
+ attributes: validXmlAttributes$k
32259
32259
  };
32260
- const translator$13 = NodeTranslator.from(config$p);
32260
+ const translator$14 = NodeTranslator.from(config$q);
32261
32261
  const mergeTextNodes = (nodes) => {
32262
32262
  if (!nodes || !Array.isArray(nodes)) {
32263
32263
  return nodes;
@@ -32581,17 +32581,16 @@ Please report this to https://github.com/markedjs/marked.`, e) {
32581
32581
  };
32582
32582
  const getDefaultParagraphStyle = (docx, styleId = "") => {
32583
32583
  const styles = docx["word/styles.xml"];
32584
- if (!styles) {
32584
+ const rootElements = styles?.elements?.[0]?.elements;
32585
+ if (!rootElements?.length) {
32585
32586
  return {};
32586
32587
  }
32587
- const defaults = styles.elements[0].elements?.find((el) => el.name === "w:docDefaults");
32588
- const pDefault = defaults.elements.find((el) => el.name === "w:pPrDefault");
32588
+ const defaults = rootElements.find((el) => el.name === "w:docDefaults");
32589
+ const pDefault = defaults?.elements?.find((el) => el.name === "w:pPrDefault") || {};
32589
32590
  const pPrDefault = pDefault?.elements?.find((el) => el.name === "w:pPr");
32590
32591
  const pPrDefaultSpacingTag = pPrDefault?.elements?.find((el) => el.name === "w:spacing") || {};
32591
32592
  const pPrDefaultIndentTag = pPrDefault?.elements?.find((el) => el.name === "w:ind") || {};
32592
- const stylesNormal = styles.elements[0].elements?.find(
32593
- (el) => el.name === "w:style" && el.attributes["w:styleId"] === "Normal"
32594
- );
32593
+ const stylesNormal = rootElements.find((el) => el.name === "w:style" && el.attributes["w:styleId"] === "Normal");
32595
32594
  const pPrNormal = stylesNormal?.elements?.find((el) => el.name === "w:pPr");
32596
32595
  const pPrNormalSpacingTag = pPrNormal?.elements?.find((el) => el.name === "w:spacing") || {};
32597
32596
  const pPrNormalIndentTag = pPrNormal?.elements?.find((el) => el.name === "w:ind") || {};
@@ -32600,9 +32599,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
32600
32599
  let pPrStyleIdIndentTag = {};
32601
32600
  let pPrStyleJc = {};
32602
32601
  if (styleId) {
32603
- const stylesById = styles.elements[0].elements?.find(
32604
- (el) => el.name === "w:style" && el.attributes["w:styleId"] === styleId
32605
- );
32602
+ const stylesById = rootElements.find((el) => el.name === "w:style" && el.attributes["w:styleId"] === styleId);
32606
32603
  const pPrById = stylesById?.elements?.find((el) => el.name === "w:pPr");
32607
32604
  pPrStyleIdSpacingTag = pPrById?.elements?.find((el) => el.name === "w:spacing") || {};
32608
32605
  pPrStyleIdIndentTag = pPrById?.elements?.find((el) => el.name === "w:ind") || {};
@@ -32872,91 +32869,91 @@ Please report this to https://github.com/markedjs/marked.`, e) {
32872
32869
  }
32873
32870
  return schemaNode;
32874
32871
  };
32875
- const encode$_ = (attributes) => {
32872
+ const encode$$ = (attributes) => {
32876
32873
  return attributes["w:rsidDel"];
32877
32874
  };
32878
- const decode$R = (attrs) => {
32875
+ const decode$S = (attrs) => {
32879
32876
  return attrs.rsidDel;
32880
32877
  };
32881
32878
  const attrConfig$z = Object.freeze({
32882
32879
  xmlName: "w:rsidDel",
32883
32880
  sdName: "rsidDel",
32884
- encode: encode$_,
32885
- decode: decode$R
32881
+ encode: encode$$,
32882
+ decode: decode$S
32886
32883
  });
32887
- const encode$Z = (attributes) => {
32884
+ const encode$_ = (attributes) => {
32888
32885
  return attributes["w:rsidP"];
32889
32886
  };
32890
- const decode$Q = (attrs) => {
32887
+ const decode$R = (attrs) => {
32891
32888
  return attrs.rsidP;
32892
32889
  };
32893
32890
  const attrConfig$y = Object.freeze({
32894
32891
  xmlName: "w:rsidP",
32895
32892
  sdName: "rsidP",
32896
- encode: encode$Z,
32897
- decode: decode$Q
32893
+ encode: encode$_,
32894
+ decode: decode$R
32898
32895
  });
32899
- const encode$Y = (attributes) => {
32896
+ const encode$Z = (attributes) => {
32900
32897
  return attributes["w:rsidR"];
32901
32898
  };
32902
- const decode$P = (attrs) => {
32899
+ const decode$Q = (attrs) => {
32903
32900
  return attrs.rsidR;
32904
32901
  };
32905
32902
  const attrConfig$x = Object.freeze({
32906
32903
  xmlName: "w:rsidR",
32907
32904
  sdName: "rsidR",
32908
- encode: encode$Y,
32909
- decode: decode$P
32905
+ encode: encode$Z,
32906
+ decode: decode$Q
32910
32907
  });
32911
- const encode$X = (attributes) => {
32908
+ const encode$Y = (attributes) => {
32912
32909
  return attributes["w:rsidRPr"];
32913
32910
  };
32914
- const decode$O = (attrs) => {
32911
+ const decode$P = (attrs) => {
32915
32912
  return attrs.rsidRPr;
32916
32913
  };
32917
32914
  const attrConfig$w = Object.freeze({
32918
32915
  xmlName: "w:rsidRPr",
32919
32916
  sdName: "rsidRPr",
32920
- encode: encode$X,
32921
- decode: decode$O
32917
+ encode: encode$Y,
32918
+ decode: decode$P
32922
32919
  });
32923
- const encode$W = (attributes) => {
32920
+ const encode$X = (attributes) => {
32924
32921
  return attributes["w:rsidRDefault"];
32925
32922
  };
32926
- const decode$N = (attrs) => {
32923
+ const decode$O = (attrs) => {
32927
32924
  return attrs.rsidRDefault;
32928
32925
  };
32929
32926
  const attrConfig$v = Object.freeze({
32930
32927
  xmlName: "w:rsidRDefault",
32931
32928
  sdName: "rsidRDefault",
32932
- encode: encode$W,
32933
- decode: decode$N
32929
+ encode: encode$X,
32930
+ decode: decode$O
32934
32931
  });
32935
- const encode$V = (attributes) => {
32932
+ const encode$W = (attributes) => {
32936
32933
  return attributes["w14:paraId"];
32937
32934
  };
32938
- const decode$M = (attrs) => {
32935
+ const decode$N = (attrs) => {
32939
32936
  return attrs.paraId;
32940
32937
  };
32941
32938
  const attrConfig$u = Object.freeze({
32942
32939
  xmlName: "w14:paraId",
32943
32940
  sdName: "paraId",
32944
- encode: encode$V,
32945
- decode: decode$M
32941
+ encode: encode$W,
32942
+ decode: decode$N
32946
32943
  });
32947
- const encode$U = (attributes) => {
32944
+ const encode$V = (attributes) => {
32948
32945
  return attributes["w14:textId"];
32949
32946
  };
32950
- const decode$L = (attrs) => {
32947
+ const decode$M = (attrs) => {
32951
32948
  return attrs.textId;
32952
32949
  };
32953
32950
  const attrConfig$t = Object.freeze({
32954
32951
  xmlName: "w14:textId",
32955
32952
  sdName: "textId",
32956
- encode: encode$U,
32957
- decode: decode$L
32953
+ encode: encode$V,
32954
+ decode: decode$M
32958
32955
  });
32959
- const validXmlAttributes$i = [
32956
+ const validXmlAttributes$j = [
32960
32957
  attrConfig$u,
32961
32958
  attrConfig$t,
32962
32959
  attrConfig$x,
@@ -32965,9 +32962,9 @@ Please report this to https://github.com/markedjs/marked.`, e) {
32965
32962
  attrConfig$w,
32966
32963
  attrConfig$z
32967
32964
  ];
32968
- const XML_NODE_NAME$q = "w:p";
32969
- const SD_NODE_NAME$a = "paragraph";
32970
- const encode$T = (params2, encodedAttrs = {}) => {
32965
+ const XML_NODE_NAME$r = "w:p";
32966
+ const SD_NODE_NAME$b = "paragraph";
32967
+ const encode$U = (params2, encodedAttrs = {}) => {
32971
32968
  const node = handleParagraphNode$1(params2);
32972
32969
  if (!node) return void 0;
32973
32970
  if (encodedAttrs && Object.keys(encodedAttrs).length) {
@@ -32975,7 +32972,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
32975
32972
  }
32976
32973
  return node;
32977
32974
  };
32978
- const decode$K = (params2, decodedAttrs = {}) => {
32975
+ const decode$L = (params2, decodedAttrs = {}) => {
32979
32976
  const translated = translateParagraphNode(params2);
32980
32977
  if (!translated) return void 0;
32981
32978
  if (decodedAttrs && Object.keys(decodedAttrs).length) {
@@ -32983,16 +32980,16 @@ Please report this to https://github.com/markedjs/marked.`, e) {
32983
32980
  }
32984
32981
  return translated;
32985
32982
  };
32986
- const config$o = {
32987
- xmlName: XML_NODE_NAME$q,
32988
- sdNodeOrKeyName: SD_NODE_NAME$a,
32983
+ const config$p = {
32984
+ xmlName: XML_NODE_NAME$r,
32985
+ sdNodeOrKeyName: SD_NODE_NAME$b,
32989
32986
  type: NodeTranslator.translatorTypes.NODE,
32990
- encode: encode$T,
32991
- decode: decode$K,
32992
- attributes: validXmlAttributes$i
32987
+ encode: encode$U,
32988
+ decode: decode$L,
32989
+ attributes: validXmlAttributes$j
32993
32990
  };
32994
- const translator$12 = NodeTranslator.from(config$o);
32995
- const encode$S = (attributes) => {
32991
+ const translator$13 = NodeTranslator.from(config$p);
32992
+ const encode$T = (attributes) => {
32996
32993
  const raw = attributes?.["w:val"];
32997
32994
  if (raw === void 0 || raw === null) return void 0;
32998
32995
  if (typeof raw === "boolean") return raw;
@@ -33002,20 +32999,20 @@ Please report this to https://github.com/markedjs/marked.`, e) {
33002
32999
  if (val === "1" || val === "true" || val === "on") return true;
33003
33000
  return void 0;
33004
33001
  };
33005
- const decode$J = (runProps) => {
33002
+ const decode$K = (runProps) => {
33006
33003
  if (runProps?.bold === false) return "0";
33007
33004
  return void 0;
33008
33005
  };
33009
33006
  const attrConfig$s = Object.freeze({
33010
33007
  xmlName: "w:val",
33011
33008
  sdName: "bold",
33012
- encode: encode$S,
33013
- decode: decode$J
33009
+ encode: encode$T,
33010
+ decode: decode$K
33014
33011
  });
33015
- const validXmlAttributes$h = [attrConfig$s];
33016
- const XML_NODE_NAME$p = "w:b";
33012
+ const validXmlAttributes$i = [attrConfig$s];
33013
+ const XML_NODE_NAME$q = "w:b";
33017
33014
  const SD_ATTR_KEY$e = "bold";
33018
- const encode$R = (params2, encodedAttrs = {}) => {
33015
+ const encode$S = (params2, encodedAttrs = {}) => {
33019
33016
  const { nodes } = params2;
33020
33017
  const node = nodes[0];
33021
33018
  if (!node) return void 0;
@@ -33027,85 +33024,85 @@ Please report this to https://github.com/markedjs/marked.`, e) {
33027
33024
  else attributes = node.attributes || {};
33028
33025
  return {
33029
33026
  type: "attr",
33030
- xmlName: XML_NODE_NAME$p,
33027
+ xmlName: XML_NODE_NAME$q,
33031
33028
  sdNodeOrKeyName: SD_ATTR_KEY$e,
33032
33029
  attributes
33033
33030
  };
33034
33031
  };
33035
- const config$n = {
33036
- xmlName: XML_NODE_NAME$p,
33032
+ const config$o = {
33033
+ xmlName: XML_NODE_NAME$q,
33037
33034
  sdNodeOrKeyName: SD_ATTR_KEY$e,
33038
33035
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
33039
- encode: encode$R,
33040
- attributes: validXmlAttributes$h
33036
+ encode: encode$S,
33037
+ attributes: validXmlAttributes$i
33041
33038
  };
33042
- const translator$11 = NodeTranslator.from(config$n);
33043
- const XML_NODE_NAME$o = "w:i";
33039
+ const translator$12 = NodeTranslator.from(config$o);
33040
+ const XML_NODE_NAME$p = "w:i";
33044
33041
  const SD_ATTR_KEY$d = "italic";
33045
- const encode$Q = (params2) => {
33042
+ const encode$R = (params2) => {
33046
33043
  const { nodes } = params2;
33047
33044
  const node = nodes?.[0];
33048
33045
  if (!node) return void 0;
33049
33046
  return {
33050
33047
  type: "attr",
33051
- xmlName: XML_NODE_NAME$o,
33048
+ xmlName: XML_NODE_NAME$p,
33052
33049
  sdNodeOrKeyName: SD_ATTR_KEY$d,
33053
33050
  attributes: {
33054
33051
  "w:val": node.attributes?.["w:val"] ?? null
33055
33052
  }
33056
33053
  };
33057
33054
  };
33058
- const config$m = {
33059
- xmlName: XML_NODE_NAME$o,
33055
+ const config$n = {
33056
+ xmlName: XML_NODE_NAME$p,
33060
33057
  sdNodeOrKeyName: SD_ATTR_KEY$d,
33061
33058
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
33062
- encode: encode$Q
33059
+ encode: encode$R
33063
33060
  };
33064
- const translator$10 = NodeTranslator.from(config$m);
33065
- const encode$P = (attributes) => attributes?.["w:val"];
33066
- const decode$I = (attrs) => attrs?.underline;
33061
+ const translator$11 = NodeTranslator.from(config$n);
33062
+ const encode$Q = (attributes) => attributes?.["w:val"];
33063
+ const decode$J = (attrs) => attrs?.underline;
33067
33064
  const attrConfig$r = Object.freeze({
33068
33065
  xmlName: "w:val",
33069
33066
  sdName: "underline",
33070
- encode: encode$P,
33071
- decode: decode$I
33067
+ encode: encode$Q,
33068
+ decode: decode$J
33072
33069
  });
33073
- const encode$O = (attributes) => attributes?.["w:color"];
33074
- const decode$H = (attrs) => attrs?.color;
33070
+ const encode$P = (attributes) => attributes?.["w:color"];
33071
+ const decode$I = (attrs) => attrs?.color;
33075
33072
  const attrConfig$q = Object.freeze({
33076
33073
  xmlName: "w:color",
33077
33074
  sdName: "color",
33078
- encode: encode$O,
33079
- decode: decode$H
33075
+ encode: encode$P,
33076
+ decode: decode$I
33080
33077
  });
33081
- const encode$N = (attributes) => attributes?.["w:themeColor"];
33082
- const decode$G = (attrs) => attrs?.themeColor;
33078
+ const encode$O = (attributes) => attributes?.["w:themeColor"];
33079
+ const decode$H = (attrs) => attrs?.themeColor;
33083
33080
  const attrConfig$p = Object.freeze({
33084
33081
  xmlName: "w:themeColor",
33085
33082
  sdName: "themeColor",
33086
- encode: encode$N,
33087
- decode: decode$G
33083
+ encode: encode$O,
33084
+ decode: decode$H
33088
33085
  });
33089
- const encode$M = (attributes) => attributes?.["w:themeTint"];
33090
- const decode$F = (attrs) => attrs?.themeTint;
33086
+ const encode$N = (attributes) => attributes?.["w:themeTint"];
33087
+ const decode$G = (attrs) => attrs?.themeTint;
33091
33088
  const attrConfig$o = Object.freeze({
33092
33089
  xmlName: "w:themeTint",
33093
33090
  sdName: "themeTint",
33094
- encode: encode$M,
33095
- decode: decode$F
33091
+ encode: encode$N,
33092
+ decode: decode$G
33096
33093
  });
33097
- const encode$L = (attributes) => attributes?.["w:themeShade"];
33098
- const decode$E = (attrs) => attrs?.themeShade;
33094
+ const encode$M = (attributes) => attributes?.["w:themeShade"];
33095
+ const decode$F = (attrs) => attrs?.themeShade;
33099
33096
  const attrConfig$n = Object.freeze({
33100
33097
  xmlName: "w:themeShade",
33101
33098
  sdName: "themeShade",
33102
- encode: encode$L,
33103
- decode: decode$E
33099
+ encode: encode$M,
33100
+ decode: decode$F
33104
33101
  });
33105
- const validXmlAttributes$g = [attrConfig$r, attrConfig$q, attrConfig$p, attrConfig$o, attrConfig$n];
33106
- const XML_NODE_NAME$n = "w:u";
33102
+ const validXmlAttributes$h = [attrConfig$r, attrConfig$q, attrConfig$p, attrConfig$o, attrConfig$n];
33103
+ const XML_NODE_NAME$o = "w:u";
33107
33104
  const SD_ATTR_KEY$c = "underline";
33108
- const encode$K = (params2, encodedAttrs = {}) => {
33105
+ const encode$L = (params2, encodedAttrs = {}) => {
33109
33106
  const { nodes } = params2;
33110
33107
  const node = nodes?.[0];
33111
33108
  const sourceAttrs = node?.attributes || {};
@@ -33121,12 +33118,12 @@ Please report this to https://github.com/markedjs/marked.`, e) {
33121
33118
  if (themeShade !== void 0 && themeShade !== null) attributes["w:themeShade"] = themeShade;
33122
33119
  return {
33123
33120
  type: "attr",
33124
- xmlName: XML_NODE_NAME$n,
33121
+ xmlName: XML_NODE_NAME$o,
33125
33122
  sdNodeOrKeyName: SD_ATTR_KEY$c,
33126
33123
  attributes
33127
33124
  };
33128
33125
  };
33129
- const decode$D = (params2) => {
33126
+ const decode$E = (params2) => {
33130
33127
  const attrs = params2?.node?.attrs || {};
33131
33128
  const underlineType = attrs.underlineType ?? attrs.underline ?? null;
33132
33129
  const color = attrs.underlineColor ?? attrs.color ?? null;
@@ -33144,20 +33141,20 @@ Please report this to https://github.com/markedjs/marked.`, e) {
33144
33141
  if (themeTint) attributes["w:themeTint"] = themeTint;
33145
33142
  if (themeShade) attributes["w:themeShade"] = themeShade;
33146
33143
  return {
33147
- name: XML_NODE_NAME$n,
33144
+ name: XML_NODE_NAME$o,
33148
33145
  attributes
33149
33146
  };
33150
33147
  };
33151
- const config$l = {
33152
- xmlName: XML_NODE_NAME$n,
33148
+ const config$m = {
33149
+ xmlName: XML_NODE_NAME$o,
33153
33150
  sdNodeOrKeyName: SD_ATTR_KEY$c,
33154
33151
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
33155
- encode: encode$K,
33156
- decode: decode$D,
33157
- attributes: validXmlAttributes$g
33152
+ encode: encode$L,
33153
+ decode: decode$E,
33154
+ attributes: validXmlAttributes$h
33158
33155
  };
33159
- const translator$$ = NodeTranslator.from(config$l);
33160
- const encode$J = (attributes) => {
33156
+ const translator$10 = NodeTranslator.from(config$m);
33157
+ const encode$K = (attributes) => {
33161
33158
  const raw = attributes?.["w:val"];
33162
33159
  if (raw === void 0 || raw === null) return void 0;
33163
33160
  if (typeof raw === "boolean") return raw;
@@ -33167,20 +33164,20 @@ Please report this to https://github.com/markedjs/marked.`, e) {
33167
33164
  if (val === "1" || val === "true" || val === "on") return true;
33168
33165
  return void 0;
33169
33166
  };
33170
- const decode$C = (attrs) => {
33167
+ const decode$D = (attrs) => {
33171
33168
  if (attrs?.strike === false) return "0";
33172
33169
  return void 0;
33173
33170
  };
33174
33171
  const attrConfig$m = Object.freeze({
33175
33172
  xmlName: "w:val",
33176
33173
  sdName: "strike",
33177
- encode: encode$J,
33178
- decode: decode$C
33174
+ encode: encode$K,
33175
+ decode: decode$D
33179
33176
  });
33180
- const validXmlAttributes$f = [attrConfig$m];
33181
- const XML_NODE_NAME$m = "w:strike";
33177
+ const validXmlAttributes$g = [attrConfig$m];
33178
+ const XML_NODE_NAME$n = "w:strike";
33182
33179
  const SD_ATTR_KEY$b = "strike";
33183
- const encode$I = (params2, encodedAttrs = {}) => {
33180
+ const encode$J = (params2, encodedAttrs = {}) => {
33184
33181
  const { nodes } = params2;
33185
33182
  const node = nodes?.[0];
33186
33183
  if (!node) return void 0;
@@ -33193,55 +33190,55 @@ Please report this to https://github.com/markedjs/marked.`, e) {
33193
33190
  else if (val === true && attributes["w:val"] === void 0) delete attributes["w:val"];
33194
33191
  return {
33195
33192
  type: "attr",
33196
- xmlName: XML_NODE_NAME$m,
33193
+ xmlName: XML_NODE_NAME$n,
33197
33194
  sdNodeOrKeyName: SD_ATTR_KEY$b,
33198
33195
  attributes
33199
33196
  };
33200
33197
  };
33201
- const config$k = {
33202
- xmlName: XML_NODE_NAME$m,
33198
+ const config$l = {
33199
+ xmlName: XML_NODE_NAME$n,
33203
33200
  sdNodeOrKeyName: SD_ATTR_KEY$b,
33204
33201
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
33205
- encode: encode$I,
33206
- attributes: validXmlAttributes$f
33202
+ encode: encode$J,
33203
+ attributes: validXmlAttributes$g
33207
33204
  };
33208
- const translator$_ = NodeTranslator.from(config$k);
33209
- const encode$H = (attributes) => attributes?.["w:val"];
33210
- const decode$B = (attrs) => attrs?.color;
33205
+ const translator$$ = NodeTranslator.from(config$l);
33206
+ const encode$I = (attributes) => attributes?.["w:val"];
33207
+ const decode$C = (attrs) => attrs?.color;
33211
33208
  const attrConfig$l = Object.freeze({
33212
33209
  xmlName: "w:val",
33213
33210
  sdName: "color",
33214
- encode: encode$H,
33215
- decode: decode$B
33211
+ encode: encode$I,
33212
+ decode: decode$C
33216
33213
  });
33217
- const encode$G = (attributes) => attributes?.["w:themeColor"];
33218
- const decode$A = (attrs) => attrs?.themeColor;
33214
+ const encode$H = (attributes) => attributes?.["w:themeColor"];
33215
+ const decode$B = (attrs) => attrs?.themeColor;
33219
33216
  const attrConfig$k = Object.freeze({
33220
33217
  xmlName: "w:themeColor",
33221
33218
  sdName: "themeColor",
33222
- encode: encode$G,
33223
- decode: decode$A
33219
+ encode: encode$H,
33220
+ decode: decode$B
33224
33221
  });
33225
- const encode$F = (attributes) => attributes?.["w:themeTint"];
33226
- const decode$z = (attrs) => attrs?.themeTint;
33222
+ const encode$G = (attributes) => attributes?.["w:themeTint"];
33223
+ const decode$A = (attrs) => attrs?.themeTint;
33227
33224
  const attrConfig$j = Object.freeze({
33228
33225
  xmlName: "w:themeTint",
33229
33226
  sdName: "themeTint",
33230
- encode: encode$F,
33231
- decode: decode$z
33227
+ encode: encode$G,
33228
+ decode: decode$A
33232
33229
  });
33233
- const encode$E = (attributes) => attributes?.["w:themeShade"];
33234
- const decode$y = (attrs) => attrs?.themeShade;
33230
+ const encode$F = (attributes) => attributes?.["w:themeShade"];
33231
+ const decode$z = (attrs) => attrs?.themeShade;
33235
33232
  const attrConfig$i = Object.freeze({
33236
33233
  xmlName: "w:themeShade",
33237
33234
  sdName: "themeShade",
33238
- encode: encode$E,
33239
- decode: decode$y
33235
+ encode: encode$F,
33236
+ decode: decode$z
33240
33237
  });
33241
- const validXmlAttributes$e = [attrConfig$l, attrConfig$k, attrConfig$j, attrConfig$i];
33242
- const XML_NODE_NAME$l = "w:color";
33238
+ const validXmlAttributes$f = [attrConfig$l, attrConfig$k, attrConfig$j, attrConfig$i];
33239
+ const XML_NODE_NAME$m = "w:color";
33243
33240
  const SD_ATTR_KEY$a = "color";
33244
- const encode$D = (params2, encodedAttrs = {}) => {
33241
+ const encode$E = (params2, encodedAttrs = {}) => {
33245
33242
  const { nodes } = params2;
33246
33243
  const node = nodes?.[0];
33247
33244
  const sourceAttrs = node?.attributes || {};
@@ -33256,63 +33253,63 @@ Please report this to https://github.com/markedjs/marked.`, e) {
33256
33253
  if (themeShade !== void 0 && themeShade !== null) attributes["w:themeShade"] = themeShade;
33257
33254
  return {
33258
33255
  type: "attr",
33259
- xmlName: XML_NODE_NAME$l,
33256
+ xmlName: XML_NODE_NAME$m,
33260
33257
  sdNodeOrKeyName: SD_ATTR_KEY$a,
33261
33258
  attributes
33262
33259
  };
33263
33260
  };
33264
- const config$j = {
33265
- xmlName: XML_NODE_NAME$l,
33261
+ const config$k = {
33262
+ xmlName: XML_NODE_NAME$m,
33266
33263
  sdNodeOrKeyName: SD_ATTR_KEY$a,
33267
33264
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
33268
- encode: encode$D,
33269
- attributes: validXmlAttributes$e
33265
+ encode: encode$E,
33266
+ attributes: validXmlAttributes$f
33270
33267
  };
33271
- const translator$Z = NodeTranslator.from(config$j);
33272
- const encode$C = (attributes) => attributes?.["w:eastAsia"];
33273
- const decode$x = (attrs) => attrs?.eastAsia;
33268
+ const translator$_ = NodeTranslator.from(config$k);
33269
+ const encode$D = (attributes) => attributes?.["w:eastAsia"];
33270
+ const decode$y = (attrs) => attrs?.eastAsia;
33274
33271
  const attrConfig$h = Object.freeze({
33275
33272
  xmlName: "w:eastAsia",
33276
33273
  sdName: "eastAsia",
33277
- encode: encode$C,
33278
- decode: decode$x
33274
+ encode: encode$D,
33275
+ decode: decode$y
33279
33276
  });
33280
- const encode$B = (attributes) => attributes?.["w:ascii"];
33281
- const decode$w = (attrs) => attrs?.ascii;
33277
+ const encode$C = (attributes) => attributes?.["w:ascii"];
33278
+ const decode$x = (attrs) => attrs?.ascii;
33282
33279
  const attrConfig$g = Object.freeze({
33283
33280
  xmlName: "w:ascii",
33284
33281
  sdName: "ascii",
33285
- encode: encode$B,
33286
- decode: decode$w
33282
+ encode: encode$C,
33283
+ decode: decode$x
33287
33284
  });
33288
- const encode$A = (attributes) => attributes?.["w:hAnsi"];
33289
- const decode$v = (attrs) => attrs?.hAnsi;
33285
+ const encode$B = (attributes) => attributes?.["w:hAnsi"];
33286
+ const decode$w = (attrs) => attrs?.hAnsi;
33290
33287
  const attrConfig$f = Object.freeze({
33291
33288
  xmlName: "w:hAnsi",
33292
33289
  sdName: "hAnsi",
33293
- encode: encode$A,
33294
- decode: decode$v
33290
+ encode: encode$B,
33291
+ decode: decode$w
33295
33292
  });
33296
- const encode$z = (attributes) => attributes?.["w:cs"];
33297
- const decode$u = (attrs) => attrs?.cs;
33293
+ const encode$A = (attributes) => attributes?.["w:cs"];
33294
+ const decode$v = (attrs) => attrs?.cs;
33298
33295
  const attrConfig$e = Object.freeze({
33299
33296
  xmlName: "w:cs",
33300
33297
  sdName: "cs",
33301
- encode: encode$z,
33302
- decode: decode$u
33298
+ encode: encode$A,
33299
+ decode: decode$v
33303
33300
  });
33304
- const encode$y = (attributes) => attributes?.["w:val"];
33305
- const decode$t = (attrs) => attrs?.value;
33301
+ const encode$z = (attributes) => attributes?.["w:val"];
33302
+ const decode$u = (attrs) => attrs?.value;
33306
33303
  const attrConfig$d = Object.freeze({
33307
33304
  xmlName: "w:val",
33308
33305
  sdName: "value",
33309
- encode: encode$y,
33310
- decode: decode$t
33306
+ encode: encode$z,
33307
+ decode: decode$u
33311
33308
  });
33312
- const validXmlAttributes$d = [attrConfig$h, attrConfig$g, attrConfig$f, attrConfig$e, attrConfig$d];
33313
- const XML_NODE_NAME$k = "w:rFonts";
33309
+ const validXmlAttributes$e = [attrConfig$h, attrConfig$g, attrConfig$f, attrConfig$e, attrConfig$d];
33310
+ const XML_NODE_NAME$l = "w:rFonts";
33314
33311
  const SD_ATTR_KEY$9 = "fontFamily";
33315
- const encode$x = (params2, encodedAttrs = {}) => {
33312
+ const encode$y = (params2, encodedAttrs = {}) => {
33316
33313
  const { nodes } = params2;
33317
33314
  const node = nodes?.[0];
33318
33315
  const sourceAttrs = node?.attributes || {};
@@ -33338,120 +33335,120 @@ Please report this to https://github.com/markedjs/marked.`, e) {
33338
33335
  if (attributes["w:val"] === void 0) delete attributes["w:val"];
33339
33336
  return {
33340
33337
  type: "attr",
33341
- xmlName: XML_NODE_NAME$k,
33338
+ xmlName: XML_NODE_NAME$l,
33342
33339
  sdNodeOrKeyName: SD_ATTR_KEY$9,
33343
33340
  attributes
33344
33341
  };
33345
33342
  };
33346
- const config$i = {
33347
- xmlName: XML_NODE_NAME$k,
33343
+ const config$j = {
33344
+ xmlName: XML_NODE_NAME$l,
33348
33345
  sdNodeOrKeyName: SD_ATTR_KEY$9,
33349
33346
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
33350
- encode: encode$x,
33351
- attributes: validXmlAttributes$d
33347
+ encode: encode$y,
33348
+ attributes: validXmlAttributes$e
33352
33349
  };
33353
- const translator$Y = NodeTranslator.from(config$i);
33354
- const encode$w = (attributes) => attributes?.["w:val"];
33355
- const decode$s = (attrs) => attrs?.styleId;
33350
+ const translator$Z = NodeTranslator.from(config$j);
33351
+ const encode$x = (attributes) => attributes?.["w:val"];
33352
+ const decode$t = (attrs) => attrs?.styleId;
33356
33353
  const attrConfig$c = Object.freeze({
33357
33354
  xmlName: "w:val",
33358
33355
  sdName: "styleId",
33359
- encode: encode$w,
33360
- decode: decode$s
33356
+ encode: encode$x,
33357
+ decode: decode$t
33361
33358
  });
33362
- const validXmlAttributes$c = [attrConfig$c];
33363
- const XML_NODE_NAME$j = "w:rStyle";
33359
+ const validXmlAttributes$d = [attrConfig$c];
33360
+ const XML_NODE_NAME$k = "w:rStyle";
33364
33361
  const SD_ATTR_KEY$8 = "styleId";
33365
- const encode$v = (params2, encodedAttrs = {}) => {
33362
+ const encode$w = (params2, encodedAttrs = {}) => {
33366
33363
  const { nodes } = params2;
33367
33364
  const node = nodes?.[0];
33368
33365
  const value = encodedAttrs.styleId ?? node?.attributes?.["w:val"];
33369
33366
  return {
33370
33367
  type: "attr",
33371
- xmlName: XML_NODE_NAME$j,
33368
+ xmlName: XML_NODE_NAME$k,
33372
33369
  sdNodeOrKeyName: SD_ATTR_KEY$8,
33373
33370
  attributes: { "w:val": value ?? null }
33374
33371
  };
33375
33372
  };
33376
- const config$h = {
33377
- xmlName: XML_NODE_NAME$j,
33373
+ const config$i = {
33374
+ xmlName: XML_NODE_NAME$k,
33378
33375
  sdNodeOrKeyName: SD_ATTR_KEY$8,
33379
33376
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
33380
- encode: encode$v,
33381
- attributes: validXmlAttributes$c
33377
+ encode: encode$w,
33378
+ attributes: validXmlAttributes$d
33382
33379
  };
33383
- const translator$X = NodeTranslator.from(config$h);
33384
- const encode$u = (attributes) => attributes?.["w:val"];
33385
- const decode$r = (attrs) => attrs?.fontSize;
33380
+ const translator$Y = NodeTranslator.from(config$i);
33381
+ const encode$v = (attributes) => attributes?.["w:val"];
33382
+ const decode$s = (attrs) => attrs?.fontSize;
33386
33383
  const attrConfig$b = Object.freeze({
33387
33384
  xmlName: "w:val",
33388
33385
  sdName: "fontSize",
33389
- encode: encode$u,
33390
- decode: decode$r
33386
+ encode: encode$v,
33387
+ decode: decode$s
33391
33388
  });
33392
- const validXmlAttributes$b = [attrConfig$b];
33393
- const XML_NODE_NAME$i = "w:sz";
33389
+ const validXmlAttributes$c = [attrConfig$b];
33390
+ const XML_NODE_NAME$j = "w:sz";
33394
33391
  const SD_ATTR_KEY$7 = "fontSize";
33395
- const encode$t = (params2, encodedAttrs = {}) => {
33392
+ const encode$u = (params2, encodedAttrs = {}) => {
33396
33393
  const { nodes } = params2;
33397
33394
  const node = nodes?.[0];
33398
33395
  const value = encodedAttrs.fontSize ?? node?.attributes?.["w:val"];
33399
33396
  return {
33400
33397
  type: "attr",
33401
- xmlName: XML_NODE_NAME$i,
33398
+ xmlName: XML_NODE_NAME$j,
33402
33399
  sdNodeOrKeyName: SD_ATTR_KEY$7,
33403
33400
  attributes: { "w:val": value ?? null }
33404
33401
  };
33405
33402
  };
33406
- const config$g = {
33407
- xmlName: XML_NODE_NAME$i,
33403
+ const config$h = {
33404
+ xmlName: XML_NODE_NAME$j,
33408
33405
  sdNodeOrKeyName: SD_ATTR_KEY$7,
33409
33406
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
33410
- encode: encode$t,
33411
- attributes: validXmlAttributes$b
33407
+ encode: encode$u,
33408
+ attributes: validXmlAttributes$c
33412
33409
  };
33413
- const translator$W = NodeTranslator.from(config$g);
33414
- const encode$s = (attributes) => attributes?.["w:val"];
33415
- const decode$q = (attrs) => attrs?.fontSizeCs;
33410
+ const translator$X = NodeTranslator.from(config$h);
33411
+ const encode$t = (attributes) => attributes?.["w:val"];
33412
+ const decode$r = (attrs) => attrs?.fontSizeCs;
33416
33413
  const attrConfig$a = Object.freeze({
33417
33414
  xmlName: "w:val",
33418
33415
  sdName: "fontSizeCs",
33419
- encode: encode$s,
33420
- decode: decode$q
33416
+ encode: encode$t,
33417
+ decode: decode$r
33421
33418
  });
33422
- const validXmlAttributes$a = [attrConfig$a];
33423
- const XML_NODE_NAME$h = "w:szCs";
33419
+ const validXmlAttributes$b = [attrConfig$a];
33420
+ const XML_NODE_NAME$i = "w:szCs";
33424
33421
  const SD_ATTR_KEY$6 = "fontSizeCs";
33425
- const encode$r = (params2, encodedAttrs = {}) => {
33422
+ const encode$s = (params2, encodedAttrs = {}) => {
33426
33423
  const { nodes } = params2;
33427
33424
  const node = nodes?.[0];
33428
33425
  const value = encodedAttrs.fontSizeCs ?? node?.attributes?.["w:val"];
33429
33426
  return {
33430
33427
  type: "attr",
33431
- xmlName: XML_NODE_NAME$h,
33428
+ xmlName: XML_NODE_NAME$i,
33432
33429
  sdNodeOrKeyName: SD_ATTR_KEY$6,
33433
33430
  attributes: { "w:val": value ?? null }
33434
33431
  };
33435
33432
  };
33436
- const config$f = {
33437
- xmlName: XML_NODE_NAME$h,
33433
+ const config$g = {
33434
+ xmlName: XML_NODE_NAME$i,
33438
33435
  sdNodeOrKeyName: SD_ATTR_KEY$6,
33439
33436
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
33440
- encode: encode$r,
33441
- attributes: validXmlAttributes$a
33437
+ encode: encode$s,
33438
+ attributes: validXmlAttributes$b
33442
33439
  };
33443
- const translator$V = NodeTranslator.from(config$f);
33440
+ const translator$W = NodeTranslator.from(config$g);
33444
33441
  const runPropertyTranslators = Object.freeze({
33445
- "w:b": translator$11,
33446
- "w:i": translator$10,
33447
- "w:u": translator$$,
33448
- "w:strike": translator$_,
33449
- "w:color": translator$Z,
33450
- "w:highlight": translator$14,
33451
- "w:rFonts": translator$Y,
33452
- "w:rStyle": translator$X,
33453
- "w:sz": translator$W,
33454
- "w:szCs": translator$V
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
33455
33452
  });
33456
33453
  const rawRunPropertyXmlNames = Object.freeze(["w:lang", "w:shd"]);
33457
33454
  const RAW_CHILD_NAME_SET = new Set(rawRunPropertyXmlNames);
@@ -33465,9 +33462,9 @@ Please report this to https://github.com/markedjs/marked.`, e) {
33465
33462
  attributes: { ...candidate.attributes || {} }
33466
33463
  };
33467
33464
  };
33468
- const XML_NODE_NAME$g = "w:rPr";
33465
+ const XML_NODE_NAME$h = "w:rPr";
33469
33466
  const SD_ATTR_KEY$5 = "runProperties";
33470
- const encode$q = (params2) => {
33467
+ const encode$r = (params2) => {
33471
33468
  const { nodes } = params2;
33472
33469
  const node = nodes?.[0] || {};
33473
33470
  const contents = Array.isArray(node.elements) ? node.elements : [];
@@ -33501,16 +33498,16 @@ Please report this to https://github.com/markedjs/marked.`, e) {
33501
33498
  attributes: runPropsArray
33502
33499
  };
33503
33500
  };
33504
- const config$e = {
33505
- xmlName: XML_NODE_NAME$g,
33501
+ const config$f = {
33502
+ xmlName: XML_NODE_NAME$h,
33506
33503
  sdNodeOrKeyName: SD_ATTR_KEY$5,
33507
33504
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
33508
- encode: encode$q
33505
+ encode: encode$r
33509
33506
  };
33510
- const translator$U = NodeTranslator.from(config$e);
33507
+ const translator$V = NodeTranslator.from(config$f);
33511
33508
  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;
33512
33509
  const containsEastAsianCharacters = (text) => EAST_ASIAN_CHARACTER_REGEX.test(text);
33513
- const collectRunProperties = (params2, rPrNode, translator2 = translator$U) => {
33510
+ const collectRunProperties = (params2, rPrNode, translator2 = translator$V) => {
33514
33511
  if (!rPrNode) return { entries: [], hadRPr: false, styleChangeMarks: [] };
33515
33512
  const result = translator2.encode({ ...params2, nodes: [rPrNode] }) || {};
33516
33513
  let entries = [];
@@ -33972,46 +33969,46 @@ Please report this to https://github.com/markedjs/marked.`, e) {
33972
33969
  }
33973
33970
  return runs;
33974
33971
  };
33975
- const encode$p = (attributes) => {
33972
+ const encode$q = (attributes) => {
33976
33973
  return attributes["w:rsidR"];
33977
33974
  };
33978
- const decode$p = (attrs) => {
33975
+ const decode$q = (attrs) => {
33979
33976
  return attrs.rsidR;
33980
33977
  };
33981
33978
  const attrConfig$9 = Object.freeze({
33982
33979
  xmlName: "w:rsidR",
33983
33980
  sdName: "rsidR",
33984
- encode: encode$p,
33985
- decode: decode$p
33981
+ encode: encode$q,
33982
+ decode: decode$q
33986
33983
  });
33987
- const encode$o = (attributes) => {
33984
+ const encode$p = (attributes) => {
33988
33985
  return attributes["w:rsidRPr"];
33989
33986
  };
33990
- const decode$o = (attrs) => {
33987
+ const decode$p = (attrs) => {
33991
33988
  return attrs.rsidRPr;
33992
33989
  };
33993
33990
  const attrConfig$8 = Object.freeze({
33994
33991
  xmlName: "w:rsidRPr",
33995
33992
  sdName: "rsidRPr",
33996
- encode: encode$o,
33997
- decode: decode$o
33993
+ encode: encode$p,
33994
+ decode: decode$p
33998
33995
  });
33999
- const encode$n = (attributes) => {
33996
+ const encode$o = (attributes) => {
34000
33997
  return attributes["w:rsidDel"];
34001
33998
  };
34002
- const decode$n = (attrs) => {
33999
+ const decode$o = (attrs) => {
34003
34000
  return attrs.rsidDel;
34004
34001
  };
34005
34002
  const attrConfig$7 = Object.freeze({
34006
34003
  xmlName: "w:rsidDel",
34007
34004
  sdName: "rsidDel",
34008
- encode: encode$n,
34009
- decode: decode$n
34005
+ encode: encode$o,
34006
+ decode: decode$o
34010
34007
  });
34011
- const validXmlAttributes$9 = [attrConfig$9, attrConfig$8, attrConfig$7];
34012
- const XML_NODE_NAME$f = "w:r";
34008
+ const validXmlAttributes$a = [attrConfig$9, attrConfig$8, attrConfig$7];
34009
+ const XML_NODE_NAME$g = "w:r";
34013
34010
  const SD_KEY_NAME = "run";
34014
- const encode$m = (params2, encodedAttrs = {}) => {
34011
+ const encode$n = (params2, encodedAttrs = {}) => {
34015
34012
  const { nodes = [], nodeListHandler } = params2 || {};
34016
34013
  const runNode = nodes[0];
34017
34014
  if (!runNode) return void 0;
@@ -34059,7 +34056,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34059
34056
  }
34060
34057
  return runNodeResult;
34061
34058
  };
34062
- const decode$m = (params2, decodedAttrs = {}) => {
34059
+ const decode$n = (params2, decodedAttrs = {}) => {
34063
34060
  const { node } = params2 || {};
34064
34061
  if (!node) return void 0;
34065
34062
  const { runNode: runNodeForExport, trackingMarksByType } = prepareRunTrackingContext(node);
@@ -34116,7 +34113,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34116
34113
  runs.push(trackedClone);
34117
34114
  return;
34118
34115
  }
34119
- const runWrapper = { name: XML_NODE_NAME$f, elements: [] };
34116
+ const runWrapper = { name: XML_NODE_NAME$g, elements: [] };
34120
34117
  applyBaseRunProps(runWrapper);
34121
34118
  if (!Array.isArray(runWrapper.elements)) runWrapper.elements = [];
34122
34119
  runWrapper.elements.push(cloneXmlNode(child));
@@ -34124,7 +34121,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34124
34121
  });
34125
34122
  const trackedRuns = ensureTrackedWrapper(runs, trackingMarksByType);
34126
34123
  if (!trackedRuns.length) {
34127
- const emptyRun = { name: XML_NODE_NAME$f, elements: [] };
34124
+ const emptyRun = { name: XML_NODE_NAME$g, elements: [] };
34128
34125
  applyBaseRunProps(emptyRun);
34129
34126
  trackedRuns.push(emptyRun);
34130
34127
  }
@@ -34138,15 +34135,15 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34138
34135
  }
34139
34136
  return trackedRuns;
34140
34137
  };
34141
- const config$d = {
34142
- xmlName: XML_NODE_NAME$f,
34138
+ const config$e = {
34139
+ xmlName: XML_NODE_NAME$g,
34143
34140
  sdNodeOrKeyName: SD_KEY_NAME,
34144
34141
  type: NodeTranslator.translatorTypes.NODE,
34145
- encode: encode$m,
34146
- decode: decode$m,
34147
- attributes: validXmlAttributes$9
34142
+ encode: encode$n,
34143
+ decode: decode$n,
34144
+ attributes: validXmlAttributes$a
34148
34145
  };
34149
- const translator$T = NodeTranslator.from(config$d);
34146
+ const translator$U = NodeTranslator.from(config$e);
34150
34147
  const generateV2HandlerEntity = (handlerName, translator2) => ({
34151
34148
  handlerName,
34152
34149
  handler: (params2) => {
@@ -34320,13 +34317,13 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34320
34317
  }
34321
34318
  return table;
34322
34319
  }
34323
- const translator$S = NodeTranslator.from({
34320
+ const translator$T = NodeTranslator.from({
34324
34321
  xmlName: "w:cantSplit",
34325
34322
  sdNodeOrKeyName: "cantSplit",
34326
34323
  encode: ({ nodes }) => ["1", "true"].includes(nodes[0].attributes?.["w:val"] ?? "1"),
34327
34324
  decode: ({ node }) => node.attrs?.cantSplit ? { attributes: {} } : void 0
34328
34325
  });
34329
- const translator$R = NodeTranslator.from({
34326
+ const translator$S = NodeTranslator.from({
34330
34327
  xmlName: "w:cnfStyle",
34331
34328
  sdNodeOrKeyName: "cnfStyle",
34332
34329
  attributes: [
@@ -34352,8 +34349,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34352
34349
  return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
34353
34350
  }
34354
34351
  });
34355
- const translator$Q = NodeTranslator.from(createSingleAttrPropertyHandler("w:divId"));
34356
- const translator$P = NodeTranslator.from(
34352
+ const translator$R = NodeTranslator.from(createSingleAttrPropertyHandler("w:divId"));
34353
+ const translator$Q = NodeTranslator.from(
34357
34354
  createSingleAttrPropertyHandler(
34358
34355
  "w:gridAfter",
34359
34356
  null,
@@ -34362,7 +34359,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34362
34359
  (v2) => integerToString(v2)
34363
34360
  )
34364
34361
  );
34365
- const translator$O = NodeTranslator.from(
34362
+ const translator$P = NodeTranslator.from(
34366
34363
  createSingleAttrPropertyHandler(
34367
34364
  "w:gridBefore",
34368
34365
  null,
@@ -34371,21 +34368,21 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34371
34368
  (v2) => integerToString(v2)
34372
34369
  )
34373
34370
  );
34374
- const translator$N = NodeTranslator.from({
34371
+ const translator$O = NodeTranslator.from({
34375
34372
  xmlName: "w:hidden",
34376
34373
  sdNodeOrKeyName: "hidden",
34377
34374
  encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
34378
34375
  decode: ({ node }) => node.attrs.hidden ? { attributes: {} } : void 0
34379
34376
  });
34380
- const translator$M = NodeTranslator.from(createSingleAttrPropertyHandler("w:jc", "justification"));
34381
- const translator$L = NodeTranslator.from(createMeasurementPropertyHandler("w:tblCellSpacing", "tableCellSpacing"));
34382
- const translator$K = NodeTranslator.from({
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({
34383
34380
  xmlName: "w:tblHeader",
34384
34381
  sdNodeOrKeyName: "repeatHeader",
34385
34382
  encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
34386
34383
  decode: ({ node }) => node.attrs.repeatHeader ? { attributes: {} } : void 0
34387
34384
  });
34388
- const translator$J = NodeTranslator.from({
34385
+ const translator$K = NodeTranslator.from({
34389
34386
  xmlName: "w:trHeight",
34390
34387
  sdNodeOrKeyName: "rowHeight",
34391
34388
  encode: ({ nodes }) => {
@@ -34412,11 +34409,11 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34412
34409
  return Object.keys(heightAttrs).length > 0 ? { attributes: heightAttrs } : void 0;
34413
34410
  }
34414
34411
  });
34415
- const translator$I = NodeTranslator.from(createMeasurementPropertyHandler("w:wAfter"));
34416
- const translator$H = NodeTranslator.from(createMeasurementPropertyHandler("w:wBefore"));
34417
- const XML_NODE_NAME$e = "w:trPr";
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";
34418
34415
  const SD_ATTR_KEY$4 = "tableRowProperties";
34419
- const encode$l = (params2) => {
34416
+ const encode$m = (params2) => {
34420
34417
  const { nodes } = params2;
34421
34418
  const node = nodes[0];
34422
34419
  let attributes = {
@@ -34430,12 +34427,12 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34430
34427
  };
34431
34428
  return {
34432
34429
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
34433
- xmlName: XML_NODE_NAME$e,
34430
+ xmlName: XML_NODE_NAME$f,
34434
34431
  sdNodeOrKeyName: SD_ATTR_KEY$4,
34435
34432
  attributes
34436
34433
  };
34437
34434
  };
34438
- const decode$l = (params2) => {
34435
+ const decode$m = (params2) => {
34439
34436
  const { tableRowProperties = {} } = params2.node.attrs || {};
34440
34437
  const elements = decodeProperties(propertyTranslatorsBySdName$2, tableRowProperties);
34441
34438
  const newNode = {
@@ -34447,6 +34444,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34447
34444
  return newNode;
34448
34445
  };
34449
34446
  const propertyTranslators$3 = [
34447
+ translator$T,
34450
34448
  translator$S,
34451
34449
  translator$R,
34452
34450
  translator$Q,
@@ -34457,8 +34455,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34457
34455
  translator$L,
34458
34456
  translator$K,
34459
34457
  translator$J,
34460
- translator$I,
34461
- translator$H
34458
+ translator$I
34462
34459
  ];
34463
34460
  const propertyTranslatorsByXmlName$2 = {};
34464
34461
  propertyTranslators$3.forEach((translator2) => {
@@ -34468,25 +34465,25 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34468
34465
  propertyTranslators$3.forEach((translator2) => {
34469
34466
  propertyTranslatorsBySdName$2[translator2.sdNodeOrKeyName] = translator2;
34470
34467
  });
34471
- const config$c = {
34472
- xmlName: XML_NODE_NAME$e,
34468
+ const config$d = {
34469
+ xmlName: XML_NODE_NAME$f,
34473
34470
  sdNodeOrKeyName: SD_ATTR_KEY$4,
34474
34471
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
34475
- encode: encode$l,
34476
- decode: decode$l
34472
+ encode: encode$m,
34473
+ decode: decode$m
34477
34474
  };
34478
- const translator$G = NodeTranslator.from(config$c);
34479
- const XML_NODE_NAME$d = "w:tr";
34480
- const SD_NODE_NAME$9 = "tableRow";
34481
- const validXmlAttributes$8 = ["w:rsidDel", "w:rsidR", "w:rsidRPr", "w:rsidTr", "w14:paraId", "w14:textId"].map(
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(
34482
34479
  (xmlName) => createAttributeHandler(xmlName)
34483
34480
  );
34484
- const encode$k = (params2, encodedAttrs) => {
34481
+ const encode$l = (params2, encodedAttrs) => {
34485
34482
  const { row } = params2.extraParams;
34486
34483
  let tableRowProperties = {};
34487
34484
  const tPr = row.elements.find((el) => el.name === "w:trPr");
34488
34485
  if (tPr) {
34489
- ({ attributes: tableRowProperties } = translator$G.encode({
34486
+ ({ attributes: tableRowProperties } = translator$H.encode({
34490
34487
  ...params2,
34491
34488
  nodes: [tPr]
34492
34489
  }));
@@ -34499,7 +34496,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34499
34496
  let currentColumnIndex = 0;
34500
34497
  const content = cellNodes?.map((n) => {
34501
34498
  let columnWidth = gridColumnWidths?.[currentColumnIndex] || null;
34502
- const result = translator$7.encode({
34499
+ const result = translator$8.encode({
34503
34500
  ...params2,
34504
34501
  extraParams: {
34505
34502
  ...params2.extraParams,
@@ -34521,7 +34518,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34521
34518
  };
34522
34519
  return newNode;
34523
34520
  };
34524
- const decode$k = (params2, decodedAttrs) => {
34521
+ const decode$l = (params2, decodedAttrs) => {
34525
34522
  const { node } = params2;
34526
34523
  const elements = translateChildNodes(params2);
34527
34524
  if (node.attrs?.tableRowProperties) {
@@ -34533,7 +34530,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34533
34530
  }
34534
34531
  }
34535
34532
  tableRowProperties["cantSplit"] = node.attrs["cantSplit"];
34536
- const trPr = translator$G.decode({
34533
+ const trPr = translator$H.decode({
34537
34534
  ...params2,
34538
34535
  node: { ...node, attrs: { ...node.attrs, tableRowProperties } }
34539
34536
  });
@@ -34545,22 +34542,22 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34545
34542
  elements
34546
34543
  };
34547
34544
  };
34548
- const config$b = {
34549
- xmlName: XML_NODE_NAME$d,
34550
- sdNodeOrKeyName: SD_NODE_NAME$9,
34545
+ const config$c = {
34546
+ xmlName: XML_NODE_NAME$e,
34547
+ sdNodeOrKeyName: SD_NODE_NAME$a,
34551
34548
  type: NodeTranslator.translatorTypes.NODE,
34552
- encode: encode$k,
34553
- decode: decode$k,
34554
- attributes: validXmlAttributes$8
34549
+ encode: encode$l,
34550
+ decode: decode$l,
34551
+ attributes: validXmlAttributes$9
34555
34552
  };
34556
- const translator$F = NodeTranslator.from(config$b);
34557
- const translator$E = NodeTranslator.from({
34553
+ const translator$G = NodeTranslator.from(config$c);
34554
+ const translator$F = NodeTranslator.from({
34558
34555
  xmlName: "w:bidiVisual",
34559
34556
  sdNodeOrKeyName: "rightToLeft",
34560
34557
  encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
34561
34558
  decode: ({ node }) => node.attrs.rightToLeft ? { attributes: {} } : void 0
34562
34559
  });
34563
- const translator$D = NodeTranslator.from({
34560
+ const translator$E = NodeTranslator.from({
34564
34561
  xmlName: "w:shd",
34565
34562
  sdNodeOrKeyName: "shading",
34566
34563
  attributes: [
@@ -34582,11 +34579,11 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34582
34579
  return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
34583
34580
  }
34584
34581
  });
34585
- const translator$C = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblCaption", "caption"));
34586
- const translator$B = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblDescription", "description"));
34587
- const translator$A = NodeTranslator.from(createMeasurementPropertyHandler("w:tblInd", "tableIndent"));
34588
- const translator$z = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblLayout", "tableLayout", "w:type"));
34589
- const translator$y = NodeTranslator.from({
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({
34590
34587
  xmlName: "w:tblLook",
34591
34588
  sdNodeOrKeyName: "tblLook",
34592
34589
  attributes: ["w:firstColumn", "w:firstRow", "w:lastColumn", "w:lastRow", "w:noHBand", "w:noVBand"].map((attr) => createAttributeHandler(attr, null, parseBoolean, booleanToString)).concat([createAttributeHandler("w:val")]),
@@ -34598,16 +34595,16 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34598
34595
  return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
34599
34596
  }
34600
34597
  });
34601
- const translator$x = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblOverlap", "overlap"));
34602
- const translator$w = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblStyle", "tableStyleId"));
34603
- const translator$v = NodeTranslator.from(
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(
34604
34601
  createSingleAttrPropertyHandler("w:tblStyleColBandSize", "tableStyleColBandSize")
34605
34602
  );
34606
- const translator$u = NodeTranslator.from(
34603
+ const translator$v = NodeTranslator.from(
34607
34604
  createSingleAttrPropertyHandler("w:tblStyleRowBandSize", "tableStyleRowBandSize")
34608
34605
  );
34609
- const translator$t = NodeTranslator.from(createMeasurementPropertyHandler("w:tblW", "tableWidth"));
34610
- const translator$s = NodeTranslator.from({
34606
+ const translator$u = NodeTranslator.from(createMeasurementPropertyHandler("w:tblW", "tableWidth"));
34607
+ const translator$t = NodeTranslator.from({
34611
34608
  xmlName: "w:tblpPr",
34612
34609
  sdNodeOrKeyName: "floatingTableProperties",
34613
34610
  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))),
@@ -34619,29 +34616,29 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34619
34616
  return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
34620
34617
  }
34621
34618
  });
34622
- const translator$r = NodeTranslator.from(createBorderPropertyHandler("w:bottom"));
34623
- const translator$q = NodeTranslator.from(createMeasurementPropertyHandler("w:bottom", "marginBottom"));
34624
- const translator$p = NodeTranslator.from(createBorderPropertyHandler("w:end"));
34625
- const translator$o = NodeTranslator.from(createMeasurementPropertyHandler("w:end", "marginEnd"));
34626
- const translator$n = NodeTranslator.from(createBorderPropertyHandler("w:insideH"));
34627
- const translator$m = NodeTranslator.from(createBorderPropertyHandler("w:insideV"));
34628
- const translator$l = NodeTranslator.from(createBorderPropertyHandler("w:left"));
34629
- const translator$k = NodeTranslator.from(createMeasurementPropertyHandler("w:left", "marginLeft"));
34630
- const translator$j = NodeTranslator.from(createBorderPropertyHandler("w:right"));
34631
- const translator$i = NodeTranslator.from(createMeasurementPropertyHandler("w:right", "marginRight"));
34632
- const translator$h = NodeTranslator.from(createBorderPropertyHandler("w:start"));
34633
- const translator$g = NodeTranslator.from(createMeasurementPropertyHandler("w:start", "marginStart"));
34634
- const translator$f = NodeTranslator.from(createBorderPropertyHandler("w:top"));
34635
- const translator$e = NodeTranslator.from(createMeasurementPropertyHandler("w:top", "marginTop"));
34636
- const XML_NODE_NAME$c = "w:tblBorders";
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";
34637
34634
  const SD_ATTR_KEY$3 = "borders";
34638
- const encode$j = (params2) => {
34635
+ const encode$k = (params2) => {
34639
34636
  const { nodes } = params2;
34640
34637
  const node = nodes[0];
34641
34638
  const attributes = encodeProperties(node, tblBordersTranslatorsByXmlName);
34642
34639
  return Object.keys(attributes).length > 0 ? attributes : void 0;
34643
34640
  };
34644
- const decode$j = (params2) => {
34641
+ const decode$k = (params2) => {
34645
34642
  const { borders = {} } = params2.node.attrs || {};
34646
34643
  const elements = decodeProperties(tblBordersTranslatorsBySdName, borders);
34647
34644
  const newNode = {
@@ -34653,14 +34650,14 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34653
34650
  return newNode;
34654
34651
  };
34655
34652
  const propertyTranslators$2 = [
34656
- translator$r,
34657
- translator$p,
34653
+ translator$s,
34654
+ translator$q,
34655
+ translator$o,
34658
34656
  translator$n,
34659
34657
  translator$m,
34660
- translator$l,
34661
- translator$j,
34662
- translator$h,
34663
- translator$f
34658
+ translator$k,
34659
+ translator$i,
34660
+ translator$g
34664
34661
  ];
34665
34662
  const tblBordersTranslatorsByXmlName = {};
34666
34663
  const tblBordersTranslatorsBySdName = {};
@@ -34668,27 +34665,27 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34668
34665
  tblBordersTranslatorsByXmlName[translator2.xmlName] = translator2;
34669
34666
  tblBordersTranslatorsBySdName[translator2.sdNodeOrKeyName] = translator2;
34670
34667
  });
34671
- const translator$d = NodeTranslator.from({
34672
- xmlName: XML_NODE_NAME$c,
34668
+ const translator$e = NodeTranslator.from({
34669
+ xmlName: XML_NODE_NAME$d,
34673
34670
  sdNodeOrKeyName: SD_ATTR_KEY$3,
34674
34671
  type: NodeTranslator.translatorTypes.NODE,
34675
34672
  attributes: [],
34676
- encode: encode$j,
34677
- decode: decode$j
34673
+ encode: encode$k,
34674
+ decode: decode$k
34678
34675
  });
34679
- const XML_NODE_NAME$b = "w:tblCellMar";
34676
+ const XML_NODE_NAME$c = "w:tblCellMar";
34680
34677
  const SD_ATTR_KEY$2 = "cellMargins";
34681
- const encode$i = (params2) => {
34678
+ const encode$j = (params2) => {
34682
34679
  const { nodes } = params2;
34683
34680
  const node = nodes[0];
34684
34681
  const attributes = encodeProperties(node, propertyTranslatorsByXmlName$1);
34685
34682
  return Object.keys(attributes).length > 0 ? attributes : void 0;
34686
34683
  };
34687
- const decode$i = (params2) => {
34684
+ const decode$j = (params2) => {
34688
34685
  const { cellMargins = {} } = params2.node.attrs || {};
34689
34686
  const elements = decodeProperties(propertyTranslatorsBySdName$1, cellMargins);
34690
34687
  const newNode = {
34691
- name: XML_NODE_NAME$b,
34688
+ name: XML_NODE_NAME$c,
34692
34689
  type: "element",
34693
34690
  attributes: {},
34694
34691
  elements
@@ -34696,12 +34693,12 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34696
34693
  return newNode;
34697
34694
  };
34698
34695
  const propertyTranslators$1 = [
34699
- translator$q,
34700
- translator$o,
34701
- translator$k,
34702
- translator$i,
34703
- translator$g,
34704
- translator$e
34696
+ translator$r,
34697
+ translator$p,
34698
+ translator$l,
34699
+ translator$j,
34700
+ translator$h,
34701
+ translator$f
34705
34702
  ];
34706
34703
  const propertyTranslatorsByXmlName$1 = {};
34707
34704
  const propertyTranslatorsBySdName$1 = {};
@@ -34709,27 +34706,27 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34709
34706
  propertyTranslatorsByXmlName$1[translator2.xmlName] = translator2;
34710
34707
  propertyTranslatorsBySdName$1[translator2.sdNodeOrKeyName] = translator2;
34711
34708
  });
34712
- const translator$c = NodeTranslator.from({
34713
- xmlName: XML_NODE_NAME$b,
34709
+ const translator$d = NodeTranslator.from({
34710
+ xmlName: XML_NODE_NAME$c,
34714
34711
  sdNodeOrKeyName: SD_ATTR_KEY$2,
34715
34712
  type: NodeTranslator.translatorTypes.NODE,
34716
34713
  attributes: [],
34717
- encode: encode$i,
34718
- decode: decode$i
34714
+ encode: encode$j,
34715
+ decode: decode$j
34719
34716
  });
34720
- const XML_NODE_NAME$a = "w:tblPr";
34717
+ const XML_NODE_NAME$b = "w:tblPr";
34721
34718
  const SD_ATTR_KEY$1 = "tableProperties";
34722
- const encode$h = (params2) => {
34719
+ const encode$i = (params2) => {
34723
34720
  const { nodes } = params2;
34724
34721
  const node = nodes[0];
34725
34722
  const attributes = encodeProperties(node, propertyTranslatorsByXmlName);
34726
34723
  return {
34727
- xmlName: XML_NODE_NAME$a,
34724
+ xmlName: XML_NODE_NAME$b,
34728
34725
  sdNodeOrKeyName: SD_ATTR_KEY$1,
34729
34726
  attributes
34730
34727
  };
34731
34728
  };
34732
- const decode$h = (params2) => {
34729
+ const decode$i = (params2) => {
34733
34730
  const { tableProperties = {} } = params2.node.attrs || {};
34734
34731
  const elements = decodeProperties(propertyTranslatorsBySdName, tableProperties);
34735
34732
  const newNode = {
@@ -34741,11 +34738,12 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34741
34738
  return newNode;
34742
34739
  };
34743
34740
  const propertyTranslators = [
34741
+ translator$F,
34742
+ translator$N,
34744
34743
  translator$E,
34745
- translator$M,
34746
34744
  translator$D,
34745
+ translator$M,
34747
34746
  translator$C,
34748
- translator$L,
34749
34747
  translator$B,
34750
34748
  translator$A,
34751
34749
  translator$z,
@@ -34755,9 +34753,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34755
34753
  translator$v,
34756
34754
  translator$u,
34757
34755
  translator$t,
34758
- translator$s,
34759
- translator$d,
34760
- translator$c
34756
+ translator$e,
34757
+ translator$d
34761
34758
  ];
34762
34759
  const propertyTranslatorsByXmlName = {};
34763
34760
  const propertyTranslatorsBySdName = {};
@@ -34765,14 +34762,14 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34765
34762
  propertyTranslatorsByXmlName[translator2.xmlName] = translator2;
34766
34763
  propertyTranslatorsBySdName[translator2.sdNodeOrKeyName] = translator2;
34767
34764
  });
34768
- const config$a = {
34769
- xmlName: XML_NODE_NAME$a,
34765
+ const config$b = {
34766
+ xmlName: XML_NODE_NAME$b,
34770
34767
  sdNodeOrKeyName: SD_ATTR_KEY$1,
34771
- encode: encode$h,
34772
- decode: decode$h
34768
+ encode: encode$i,
34769
+ decode: decode$i
34773
34770
  };
34774
- const translator$b = NodeTranslator.from(config$a);
34775
- const translator$a = NodeTranslator.from(
34771
+ const translator$c = NodeTranslator.from(config$b);
34772
+ const translator$b = NodeTranslator.from(
34776
34773
  createSingleAttrPropertyHandler("w:gridCol", "col", "w:w", parseInteger, integerToString)
34777
34774
  );
34778
34775
  const DEFAULT_COLUMN_WIDTH_PX = 100;
@@ -34822,20 +34819,20 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34822
34819
  }
34823
34820
  return Math.max(fallbackWidthTwips, cellMinWidthTwips);
34824
34821
  };
34825
- const XML_NODE_NAME$9 = "w:tblGrid";
34822
+ const XML_NODE_NAME$a = "w:tblGrid";
34826
34823
  const SD_ATTR_KEY = "grid";
34827
34824
  const cellMinWidth = pixelsToTwips(10);
34828
- const encode$g = (params2) => {
34825
+ const encode$h = (params2) => {
34829
34826
  const { nodes } = params2;
34830
34827
  const node = nodes[0];
34831
- const attributes = encodeProperties(node, { [translator$a.xmlName]: translator$a }, true);
34828
+ const attributes = encodeProperties(node, { [translator$b.xmlName]: translator$b }, true);
34832
34829
  return {
34833
- xmlName: XML_NODE_NAME$9,
34830
+ xmlName: XML_NODE_NAME$a,
34834
34831
  sdNodeOrKeyName: SD_ATTR_KEY,
34835
34832
  attributes
34836
34833
  };
34837
34834
  };
34838
- const decode$g = (params2) => {
34835
+ const decode$h = (params2) => {
34839
34836
  const { grid: rawGrid } = params2.node.attrs || {};
34840
34837
  const grid = Array.isArray(rawGrid) ? rawGrid : [];
34841
34838
  const { firstRow = {} } = params2.extraParams || {};
@@ -34854,10 +34851,10 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34854
34851
  numericWidth = fallbackColumnWidthTwips;
34855
34852
  }
34856
34853
  numericWidth = Math.max(numericWidth, cellMinWidth);
34857
- const decoded = translator$a.decode({
34854
+ const decoded = translator$b.decode({
34858
34855
  node: { type: (
34859
34856
  /** @type {string} */
34860
- translator$a.sdNodeOrKeyName
34857
+ translator$b.sdNodeOrKeyName
34861
34858
  ), attrs: { col: numericWidth } }
34862
34859
  });
34863
34860
  if (decoded) elements.push(decoded);
@@ -34892,39 +34889,100 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34892
34889
  columnIndex++;
34893
34890
  }
34894
34891
  const newNode = {
34895
- name: XML_NODE_NAME$9,
34892
+ name: XML_NODE_NAME$a,
34896
34893
  attributes: {},
34897
34894
  elements
34898
34895
  };
34899
34896
  return newNode;
34900
34897
  };
34901
- const config$9 = {
34902
- xmlName: XML_NODE_NAME$9,
34898
+ const config$a = {
34899
+ xmlName: XML_NODE_NAME$a,
34903
34900
  sdNodeOrKeyName: SD_ATTR_KEY,
34904
- encode: encode$g,
34905
- decode: decode$g
34901
+ encode: encode$h,
34902
+ decode: decode$h
34906
34903
  };
34907
- const translator$9 = NodeTranslator.from(config$9);
34908
- const XML_NODE_NAME$8 = "w:tbl";
34909
- const SD_NODE_NAME$8 = "table";
34910
- const encode$f = (params2, encodedAttrs) => {
34904
+ const translator$a = NodeTranslator.from(config$a);
34905
+ const DEFAULT_PAGE_WIDTH_TWIPS = 12240;
34906
+ const DEFAULT_PAGE_MARGIN_TWIPS = 1440;
34907
+ const DEFAULT_CONTENT_WIDTH_TWIPS = DEFAULT_PAGE_WIDTH_TWIPS - 2 * DEFAULT_PAGE_MARGIN_TWIPS;
34908
+ const MIN_COLUMN_WIDTH_TWIPS = pixelsToTwips(10);
34909
+ const pctToPercent = (value) => {
34910
+ if (value == null) return null;
34911
+ return value / 50;
34912
+ };
34913
+ const resolveContentWidthTwips = () => DEFAULT_CONTENT_WIDTH_TWIPS;
34914
+ const resolveMeasurementWidthPx = (measurement) => {
34915
+ if (!measurement || typeof measurement.value !== "number" || measurement.value <= 0) return null;
34916
+ const { value, type: type2 } = measurement;
34917
+ if (!type2 || type2 === "auto") return null;
34918
+ if (type2 === "dxa") return twipsToPixels(value);
34919
+ if (type2 === "pct") {
34920
+ const percent2 = pctToPercent(value);
34921
+ if (percent2 == null || percent2 <= 0) return null;
34922
+ const widthTwips = resolveContentWidthTwips() * percent2 / 100;
34923
+ return twipsToPixels(widthTwips);
34924
+ }
34925
+ return null;
34926
+ };
34927
+ const countColumnsInRow = (row) => {
34928
+ if (!row?.elements?.length) return 0;
34929
+ return row.elements.reduce((count, element) => {
34930
+ if (element.name !== "w:tc") return count;
34931
+ const tcPr = element.elements?.find((el) => el.name === "w:tcPr");
34932
+ const gridSpan = tcPr?.elements?.find((el) => el.name === "w:gridSpan");
34933
+ const spanValue = parseInt(gridSpan?.attributes?.["w:val"] || "1", 10);
34934
+ return count + (Number.isFinite(spanValue) && spanValue > 0 ? spanValue : 1);
34935
+ }, 0);
34936
+ };
34937
+ const clampColumnWidthTwips = (value) => Math.max(Math.round(value), MIN_COLUMN_WIDTH_TWIPS);
34938
+ const createFallbackGrid = (columnCount, columnWidthTwips) => Array.from({ length: columnCount }, () => ({ col: clampColumnWidthTwips(columnWidthTwips) }));
34939
+ const buildFallbackGridForTable = ({ params: params2, rows, tableWidth, tableWidthMeasurement }) => {
34940
+ const firstRow = rows.find((row) => row.elements?.some((el) => el.name === "w:tc"));
34941
+ const columnCount = countColumnsInRow(firstRow);
34942
+ if (!columnCount) return null;
34943
+ const schemaDefaultPx = getSchemaDefaultColumnWidthPx(
34944
+ /** @type {any} */
34945
+ params2
34946
+ );
34947
+ const minimumColumnWidthPx = Number.isFinite(schemaDefaultPx) && schemaDefaultPx > 0 ? schemaDefaultPx : DEFAULT_COLUMN_WIDTH_PX;
34948
+ let totalWidthPx;
34949
+ if (tableWidthMeasurement) {
34950
+ const resolved = resolveMeasurementWidthPx(tableWidthMeasurement);
34951
+ if (resolved != null) totalWidthPx = resolved;
34952
+ }
34953
+ if (totalWidthPx == null && tableWidth?.width && tableWidth.width > 0) {
34954
+ totalWidthPx = tableWidth.width;
34955
+ }
34956
+ if (totalWidthPx == null) {
34957
+ totalWidthPx = minimumColumnWidthPx * columnCount;
34958
+ }
34959
+ const rawColumnWidthPx = Math.max(totalWidthPx / columnCount, minimumColumnWidthPx);
34960
+ const columnWidthTwips = clampColumnWidthTwips(pixelsToTwips(rawColumnWidthPx));
34961
+ const fallbackColumnWidthPx = twipsToPixels(columnWidthTwips);
34962
+ return {
34963
+ grid: createFallbackGrid(columnCount, columnWidthTwips),
34964
+ columnWidths: Array(columnCount).fill(fallbackColumnWidthPx)
34965
+ };
34966
+ };
34967
+ const XML_NODE_NAME$9 = "w:tbl";
34968
+ const SD_NODE_NAME$9 = "table";
34969
+ const encode$g = (params2, encodedAttrs) => {
34911
34970
  const { nodes } = params2;
34912
34971
  const node = nodes[0];
34913
34972
  const tblPr = node.elements.find((el) => el.name === "w:tblPr");
34914
34973
  if (tblPr) {
34915
- const encodedProperties = translator$b.encode({ ...params2, nodes: [tblPr] });
34974
+ const encodedProperties = translator$c.encode({ ...params2, nodes: [tblPr] });
34916
34975
  encodedAttrs["tableProperties"] = encodedProperties?.attributes || {};
34917
34976
  }
34918
34977
  const tblGrid = node.elements.find((el) => el.name === "w:tblGrid");
34919
34978
  if (tblGrid) {
34920
- encodedAttrs["grid"] = translator$9.encode({ ...params2, nodes: [tblGrid] }).attributes;
34979
+ encodedAttrs["grid"] = translator$a.encode({ ...params2, nodes: [tblGrid] }).attributes;
34921
34980
  }
34922
34981
  [
34923
34982
  "tableStyleId",
34924
34983
  "justification",
34925
34984
  "tableLayout",
34926
34985
  ["tableIndent", ({ value, type: type2 }) => ({ width: twipsToPixels(value), type: type2 })],
34927
- ["tableWidth", ({ value, type: type2 }) => ({ width: twipsToPixels(value), type: type2 })],
34928
34986
  ["tableCellSpacing", ({ value, type: type2 }) => ({ w: String(value), type: type2 })]
34929
34987
  ].forEach((prop) => {
34930
34988
  let key2;
@@ -34942,6 +35000,21 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34942
35000
  if (encodedAttrs.tableCellSpacing) {
34943
35001
  encodedAttrs["borderCollapse"] = "separate";
34944
35002
  }
35003
+ if (encodedAttrs.tableProperties?.tableWidth) {
35004
+ const tableWidthMeasurement = encodedAttrs.tableProperties.tableWidth;
35005
+ const widthPx = twipsToPixels(tableWidthMeasurement.value);
35006
+ if (widthPx != null) {
35007
+ encodedAttrs.tableWidth = {
35008
+ width: widthPx,
35009
+ type: tableWidthMeasurement.type
35010
+ };
35011
+ } else if (tableWidthMeasurement.type === "auto") {
35012
+ encodedAttrs.tableWidth = {
35013
+ width: 0,
35014
+ type: tableWidthMeasurement.type
35015
+ };
35016
+ }
35017
+ }
34945
35018
  const { borders, rowBorders } = _processTableBorders(encodedAttrs.tableProperties?.borders || {});
34946
35019
  const referencedStyles = _getReferencedTableStyles(encodedAttrs.tableStyleId, params2);
34947
35020
  if (referencedStyles?.cellMargins && !encodedAttrs.tableProperties?.cellMargins) {
@@ -34955,10 +35028,22 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34955
35028
  const borderRowData = Object.assign({}, referencedStyles?.rowBorders || {}, rowBorders || {});
34956
35029
  encodedAttrs["borders"] = borderData;
34957
35030
  const tblStyleTag = tblPr?.elements?.find((el) => el.name === "w:tblStyle");
34958
- const columnWidths = (encodedAttrs["grid"] ?? []).map((item) => twipsToPixels(item.col));
35031
+ let columnWidths = Array.isArray(encodedAttrs["grid"]) ? encodedAttrs["grid"].map((item) => twipsToPixels(item.col)) : [];
35032
+ if (!columnWidths.length) {
35033
+ const fallback = buildFallbackGridForTable({
35034
+ params: params2,
35035
+ rows,
35036
+ tableWidth: encodedAttrs.tableWidth,
35037
+ tableWidthMeasurement: encodedAttrs.tableProperties?.tableWidth
35038
+ });
35039
+ if (fallback) {
35040
+ encodedAttrs.grid = fallback.grid;
35041
+ columnWidths = fallback.columnWidths;
35042
+ }
35043
+ }
34959
35044
  const content = [];
34960
35045
  rows.forEach((row) => {
34961
- const result = translator$F.encode({
35046
+ const result = translator$G.encode({
34962
35047
  ...params2,
34963
35048
  nodes: [row],
34964
35049
  extraParams: {
@@ -34977,13 +35062,13 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34977
35062
  attrs: encodedAttrs
34978
35063
  };
34979
35064
  };
34980
- const decode$f = (params2, decodedAttrs) => {
35065
+ const decode$g = (params2, decodedAttrs) => {
34981
35066
  params2.node = preProcessVerticalMergeCells(params2.node, params2);
34982
35067
  const { node } = params2;
34983
35068
  const elements = translateChildNodes(params2);
34984
35069
  const firstRow = node.content?.find((n) => n.type === "tableRow");
34985
35070
  const properties = node.attrs.grid;
34986
- const element = translator$9.decode({
35071
+ const element = translator$a.decode({
34987
35072
  ...params2,
34988
35073
  node: { ...node, attrs: { ...node.attrs, grid: properties } },
34989
35074
  extraParams: {
@@ -34993,7 +35078,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34993
35078
  if (element) elements.unshift(element);
34994
35079
  if (node.attrs?.tableProperties) {
34995
35080
  const properties2 = { ...node.attrs.tableProperties };
34996
- const element2 = translator$b.decode({
35081
+ const element2 = translator$c.decode({
34997
35082
  ...params2,
34998
35083
  node: { ...node, attrs: { ...node.attrs, tableProperties: properties2 } }
34999
35084
  });
@@ -35059,7 +35144,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
35059
35144
  if (baseTblPr && baseTblPr.elements) {
35060
35145
  tblPr.elements.push(...baseTblPr.elements);
35061
35146
  }
35062
- const tableProperties = translator$b.encode({ ...params2, nodes: [tblPr] }).attributes;
35147
+ const tableProperties = translator$c.encode({ ...params2, nodes: [tblPr] }).attributes;
35063
35148
  const { borders, rowBorders } = _processTableBorders(tableProperties.borders || {});
35064
35149
  if (borders) stylesToReturn.borders = borders;
35065
35150
  if (rowBorders) stylesToReturn.rowBorders = rowBorders;
@@ -35076,16 +35161,16 @@ Please report this to https://github.com/markedjs/marked.`, e) {
35076
35161
  }
35077
35162
  return stylesToReturn;
35078
35163
  }
35079
- const config$8 = {
35080
- xmlName: XML_NODE_NAME$8,
35081
- sdNodeOrKeyName: SD_NODE_NAME$8,
35164
+ const config$9 = {
35165
+ xmlName: XML_NODE_NAME$9,
35166
+ sdNodeOrKeyName: SD_NODE_NAME$9,
35082
35167
  type: NodeTranslator.translatorTypes.NODE,
35083
- encode: encode$f,
35084
- decode: decode$f,
35168
+ encode: encode$g,
35169
+ decode: decode$g,
35085
35170
  attributes: []
35086
35171
  };
35087
- const translator$8 = NodeTranslator.from(config$8);
35088
- const tableNodeHandlerEntity = generateV2HandlerEntity("tableNodeHandler", translator$8);
35172
+ const translator$9 = NodeTranslator.from(config$9);
35173
+ const tableNodeHandlerEntity = generateV2HandlerEntity("tableNodeHandler", translator$9);
35089
35174
  function getReferencedTableStyles(tblStyleTag, docx) {
35090
35175
  if (!tblStyleTag) return null;
35091
35176
  const stylesToReturn = {};
@@ -35447,10 +35532,10 @@ Please report this to https://github.com/markedjs/marked.`, e) {
35447
35532
  if (left2 != null) elements.push({ name: "w:left", attributes: { "w:w": pixelsToTwips(left2) } });
35448
35533
  return elements;
35449
35534
  }
35450
- const XML_NODE_NAME$7 = "w:tc";
35451
- const SD_NODE_NAME$7 = "tableCell";
35452
- const validXmlAttributes$7 = [];
35453
- function encode$e(params2, encodedAttrs) {
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) {
35454
35539
  const {
35455
35540
  node,
35456
35541
  table,
@@ -35477,31 +35562,31 @@ Please report this to https://github.com/markedjs/marked.`, e) {
35477
35562
  }
35478
35563
  return schemaNode;
35479
35564
  }
35480
- function decode$e(params2, decodedAttrs) {
35565
+ function decode$f(params2, decodedAttrs) {
35481
35566
  const translated = translateTableCell(params2);
35482
35567
  if (decodedAttrs && Object.keys(decodedAttrs).length) {
35483
35568
  translated.attributes = { ...translated.attributes || {}, ...decodedAttrs };
35484
35569
  }
35485
35570
  return translated;
35486
35571
  }
35487
- const config$7 = {
35488
- xmlName: XML_NODE_NAME$7,
35489
- sdNodeOrKeyName: SD_NODE_NAME$7,
35572
+ const config$8 = {
35573
+ xmlName: XML_NODE_NAME$8,
35574
+ sdNodeOrKeyName: SD_NODE_NAME$8,
35490
35575
  type: NodeTranslator.translatorTypes.NODE,
35491
- encode: encode$e,
35492
- decode: decode$e,
35493
- attributes: validXmlAttributes$7
35576
+ encode: encode$f,
35577
+ decode: decode$f,
35578
+ attributes: validXmlAttributes$8
35494
35579
  };
35495
- const translator$7 = NodeTranslator.from(config$7);
35496
- const XML_NODE_NAME$6 = "w:hyperlink";
35497
- const SD_NODE_NAME$6 = "link";
35580
+ const translator$8 = NodeTranslator.from(config$8);
35581
+ const XML_NODE_NAME$7 = "w:hyperlink";
35582
+ const SD_NODE_NAME$7 = "link";
35498
35583
  const _createAttributeHandler = (xmlName, sdName) => ({
35499
35584
  xmlName,
35500
35585
  sdName,
35501
35586
  encode: (attributes) => attributes[xmlName],
35502
35587
  decode: (attributes) => attributes[sdName]
35503
35588
  });
35504
- const validXmlAttributes$6 = [
35589
+ const validXmlAttributes$7 = [
35505
35590
  _createAttributeHandler("w:anchor", "anchor"),
35506
35591
  _createAttributeHandler("w:docLocation", "docLocation"),
35507
35592
  {
@@ -35514,7 +35599,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
35514
35599
  _createAttributeHandler("r:id", "rId"),
35515
35600
  _createAttributeHandler("w:tgtFrame", "target")
35516
35601
  ];
35517
- const encode$d = (params2, encodedAttrs) => {
35602
+ const encode$e = (params2, encodedAttrs) => {
35518
35603
  const { nodes, docx, nodeListHandler } = params2;
35519
35604
  const node = nodes[0];
35520
35605
  let href = _resolveHref(docx, encodedAttrs);
@@ -35580,7 +35665,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
35580
35665
  }
35581
35666
  return href;
35582
35667
  };
35583
- function decode$d(params2) {
35668
+ function decode$e(params2) {
35584
35669
  const { node } = params2;
35585
35670
  const linkMark = node.marks.find((m2) => m2.type === "link");
35586
35671
  const linkAttrs = this.decodeAttributes({ ...params2, node: linkMark });
@@ -35624,15 +35709,15 @@ Please report this to https://github.com/markedjs/marked.`, e) {
35624
35709
  });
35625
35710
  return rId;
35626
35711
  }
35627
- const config$6 = {
35628
- xmlName: XML_NODE_NAME$6,
35629
- sdNodeOrKeyName: SD_NODE_NAME$6,
35712
+ const config$7 = {
35713
+ xmlName: XML_NODE_NAME$7,
35714
+ sdNodeOrKeyName: SD_NODE_NAME$7,
35630
35715
  type: NodeTranslator.translatorTypes.NODE,
35631
- encode: encode$d,
35632
- decode: decode$d,
35633
- attributes: validXmlAttributes$6
35716
+ encode: encode$e,
35717
+ decode: decode$e,
35718
+ attributes: validXmlAttributes$7
35634
35719
  };
35635
- const translator$6 = NodeTranslator.from(config$6);
35720
+ const translator$7 = NodeTranslator.from(config$7);
35636
35721
  function parseTagValueJSON(json) {
35637
35722
  if (typeof json !== "string") {
35638
35723
  return {};
@@ -36427,32 +36512,32 @@ Please report this to https://github.com/markedjs/marked.`, e) {
36427
36512
  elements: [...anchorElements, ...elementsWithWrap]
36428
36513
  };
36429
36514
  }
36430
- const XML_NODE_NAME$5 = "wp:anchor";
36431
- const SD_NODE_NAME$5 = ["image"];
36432
- const validXmlAttributes$5 = ["distT", "distB", "distL", "distR"].map((xmlName) => createAttributeHandler(xmlName));
36433
- function encode$c(params2) {
36515
+ const XML_NODE_NAME$6 = "wp:anchor";
36516
+ const SD_NODE_NAME$6 = ["image"];
36517
+ const validXmlAttributes$6 = ["distT", "distB", "distL", "distR"].map((xmlName) => createAttributeHandler(xmlName));
36518
+ function encode$d(params2) {
36434
36519
  const { node } = params2.extraParams;
36435
36520
  if (!node || !node.type) {
36436
36521
  return null;
36437
36522
  }
36438
36523
  return handleAnchorNode(params2);
36439
36524
  }
36440
- function decode$c(params2) {
36525
+ function decode$d(params2) {
36441
36526
  const { node } = params2;
36442
36527
  if (!node || !node.type) {
36443
36528
  return null;
36444
36529
  }
36445
36530
  return translateAnchorNode(params2);
36446
36531
  }
36447
- const config$5 = {
36448
- xmlName: XML_NODE_NAME$5,
36449
- sdNodeOrKeyName: SD_NODE_NAME$5,
36532
+ const config$6 = {
36533
+ xmlName: XML_NODE_NAME$6,
36534
+ sdNodeOrKeyName: SD_NODE_NAME$6,
36450
36535
  type: NodeTranslator.translatorTypes.NODE,
36451
- encode: encode$c,
36452
- decode: decode$c,
36453
- attributes: validXmlAttributes$5
36536
+ encode: encode$d,
36537
+ decode: decode$d,
36538
+ attributes: validXmlAttributes$6
36454
36539
  };
36455
- const translator$5 = NodeTranslator.from(config$5);
36540
+ const translator$6 = NodeTranslator.from(config$6);
36456
36541
  function handleInlineNode(params2) {
36457
36542
  const { node } = params2.extraParams;
36458
36543
  if (node.name !== "wp:inline") {
@@ -36468,41 +36553,41 @@ Please report this to https://github.com/markedjs/marked.`, e) {
36468
36553
  elements: nodeElements.elements
36469
36554
  };
36470
36555
  }
36471
- const XML_NODE_NAME$4 = "wp:inline";
36472
- const SD_NODE_NAME$4 = ["image"];
36473
- const validXmlAttributes$4 = ["distT", "distB", "distL", "distR"].map((xmlName) => createAttributeHandler(xmlName));
36474
- function encode$b(params2) {
36556
+ const XML_NODE_NAME$5 = "wp:inline";
36557
+ const SD_NODE_NAME$5 = ["image"];
36558
+ const validXmlAttributes$5 = ["distT", "distB", "distL", "distR"].map((xmlName) => createAttributeHandler(xmlName));
36559
+ function encode$c(params2) {
36475
36560
  const { node } = params2.extraParams;
36476
36561
  if (!node || !node.type) {
36477
36562
  return null;
36478
36563
  }
36479
36564
  return handleInlineNode(params2);
36480
36565
  }
36481
- function decode$b(params2) {
36566
+ function decode$c(params2) {
36482
36567
  const { node } = params2;
36483
36568
  if (!node || !node.type) {
36484
36569
  return null;
36485
36570
  }
36486
36571
  return translateInlineNode(params2);
36487
36572
  }
36488
- const config$4 = {
36489
- xmlName: XML_NODE_NAME$4,
36490
- sdNodeOrKeyName: SD_NODE_NAME$4,
36573
+ const config$5 = {
36574
+ xmlName: XML_NODE_NAME$5,
36575
+ sdNodeOrKeyName: SD_NODE_NAME$5,
36491
36576
  type: NodeTranslator.translatorTypes.NODE,
36492
- encode: encode$b,
36493
- decode: decode$b,
36494
- attributes: validXmlAttributes$4
36577
+ encode: encode$c,
36578
+ decode: decode$c,
36579
+ attributes: validXmlAttributes$5
36495
36580
  };
36496
- const translator$4 = NodeTranslator.from(config$4);
36497
- const XML_NODE_NAME$3 = "w:drawing";
36498
- const SD_NODE_NAME$3 = [];
36499
- const validXmlAttributes$3 = [];
36500
- function encode$a(params2) {
36581
+ const translator$5 = NodeTranslator.from(config$5);
36582
+ const XML_NODE_NAME$4 = "w:drawing";
36583
+ const SD_NODE_NAME$4 = [];
36584
+ const validXmlAttributes$4 = [];
36585
+ function encode$b(params2) {
36501
36586
  const nodes = params2.nodes;
36502
36587
  const node = nodes[0];
36503
36588
  const translatorByChildName = {
36504
- "wp:anchor": translator$5,
36505
- "wp:inline": translator$4
36589
+ "wp:anchor": translator$6,
36590
+ "wp:inline": translator$5
36506
36591
  };
36507
36592
  return node.elements.reduce((acc, child) => {
36508
36593
  if (acc) return acc;
@@ -36511,12 +36596,12 @@ Please report this to https://github.com/markedjs/marked.`, e) {
36511
36596
  return translator2.encode({ ...params2, extraParams: { node: child } }) || acc;
36512
36597
  }, null);
36513
36598
  }
36514
- function decode$a(params2) {
36599
+ function decode$b(params2) {
36515
36600
  const { node } = params2;
36516
36601
  if (!node || !node.type) {
36517
36602
  return null;
36518
36603
  }
36519
- const childTranslator = node.attrs.isAnchor ? translator$5 : translator$4;
36604
+ const childTranslator = node.attrs.isAnchor ? translator$6 : translator$5;
36520
36605
  const resultNode = childTranslator.decode(params2);
36521
36606
  return wrapTextInRun(
36522
36607
  {
@@ -36526,15 +36611,15 @@ Please report this to https://github.com/markedjs/marked.`, e) {
36526
36611
  []
36527
36612
  );
36528
36613
  }
36529
- const config$3 = {
36530
- xmlName: XML_NODE_NAME$3,
36531
- sdNodeOrKeyName: SD_NODE_NAME$3,
36614
+ const config$4 = {
36615
+ xmlName: XML_NODE_NAME$4,
36616
+ sdNodeOrKeyName: SD_NODE_NAME$4,
36532
36617
  type: NodeTranslator.translatorTypes.NODE,
36533
- encode: encode$a,
36534
- decode: decode$a,
36535
- attributes: validXmlAttributes$3
36618
+ encode: encode$b,
36619
+ decode: decode$b,
36620
+ attributes: validXmlAttributes$4
36536
36621
  };
36537
- const translator$3 = NodeTranslator.from(config$3);
36622
+ const translator$4 = NodeTranslator.from(config$4);
36538
36623
  class CommandService {
36539
36624
  /**
36540
36625
  * @param {import('./commands/types/index.js').CommandServiceOptions} props
@@ -37872,7 +37957,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
37872
37957
  return getTextNodeForExport(attrs.displayLabel, [...marks, ...marksFromAttrs], params2);
37873
37958
  }
37874
37959
  function prepareImageAnnotation(params2, imageSize) {
37875
- return translator$3.decode({
37960
+ return translator$4.decode({
37876
37961
  ...params2,
37877
37962
  imageSize
37878
37963
  });
@@ -38109,10 +38194,10 @@ Please report this to https://github.com/markedjs/marked.`, e) {
38109
38194
  };
38110
38195
  return result;
38111
38196
  }
38112
- const XML_NODE_NAME$2 = "w:sdt";
38113
- const SD_NODE_NAME$2 = ["fieldAnnotation", "structuredContent", "structuredContentBlock", "documentSection"];
38114
- const validXmlAttributes$2 = [];
38115
- function encode$9(params2) {
38197
+ const XML_NODE_NAME$3 = "w:sdt";
38198
+ const SD_NODE_NAME$3 = ["fieldAnnotation", "structuredContent", "structuredContentBlock", "documentSection"];
38199
+ const validXmlAttributes$3 = [];
38200
+ function encode$a(params2) {
38116
38201
  const nodes = params2.nodes;
38117
38202
  const node = nodes[0];
38118
38203
  const { type: sdtType, handler: handler2 } = sdtNodeTypeStrategy(node);
@@ -38122,7 +38207,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
38122
38207
  const result = handler2(params2);
38123
38208
  return result;
38124
38209
  }
38125
- function decode$9(params2) {
38210
+ function decode$a(params2) {
38126
38211
  const { node } = params2;
38127
38212
  if (!node || !node.type) {
38128
38213
  return null;
@@ -38138,85 +38223,85 @@ Please report this to https://github.com/markedjs/marked.`, e) {
38138
38223
  const result = decoder();
38139
38224
  return result;
38140
38225
  }
38141
- const config$2 = {
38142
- xmlName: XML_NODE_NAME$2,
38143
- sdNodeOrKeyName: SD_NODE_NAME$2,
38226
+ const config$3 = {
38227
+ xmlName: XML_NODE_NAME$3,
38228
+ sdNodeOrKeyName: SD_NODE_NAME$3,
38144
38229
  type: NodeTranslator.translatorTypes.NODE,
38145
- encode: encode$9,
38146
- decode: decode$9,
38147
- attributes: validXmlAttributes$2
38230
+ encode: encode$a,
38231
+ decode: decode$a,
38232
+ attributes: validXmlAttributes$3
38148
38233
  };
38149
- const translator$2 = NodeTranslator.from(config$2);
38150
- const encode$8 = (attributes) => {
38234
+ const translator$3 = NodeTranslator.from(config$3);
38235
+ const encode$9 = (attributes) => {
38151
38236
  return attributes["w:id"];
38152
38237
  };
38153
- const decode$8 = (attrs) => {
38238
+ const decode$9 = (attrs) => {
38154
38239
  return attrs.id;
38155
38240
  };
38156
38241
  const attrConfig$6 = Object.freeze({
38157
38242
  xmlName: "w:id",
38158
38243
  sdName: "id",
38159
- encode: encode$8,
38160
- decode: decode$8
38244
+ encode: encode$9,
38245
+ decode: decode$9
38161
38246
  });
38162
- const encode$7 = (attributes) => {
38247
+ const encode$8 = (attributes) => {
38163
38248
  return attributes["w:name"];
38164
38249
  };
38165
- const decode$7 = (attrs) => {
38250
+ const decode$8 = (attrs) => {
38166
38251
  return attrs.name;
38167
38252
  };
38168
38253
  const attrConfig$5 = Object.freeze({
38169
38254
  xmlName: "w:name",
38170
38255
  sdName: "name",
38171
- encode: encode$7,
38172
- decode: decode$7
38256
+ encode: encode$8,
38257
+ decode: decode$8
38173
38258
  });
38174
- const encode$6 = (attributes) => {
38259
+ const encode$7 = (attributes) => {
38175
38260
  return attributes["w:colFirst"];
38176
38261
  };
38177
- const decode$6 = (attrs) => {
38262
+ const decode$7 = (attrs) => {
38178
38263
  return attrs.colFirst;
38179
38264
  };
38180
38265
  const attrConfig$4 = Object.freeze({
38181
38266
  xmlName: "w:colFirst",
38182
38267
  sdName: "colFirst",
38183
- encode: encode$6,
38184
- decode: decode$6
38268
+ encode: encode$7,
38269
+ decode: decode$7
38185
38270
  });
38186
- const encode$5 = (attributes) => {
38271
+ const encode$6 = (attributes) => {
38187
38272
  return attributes["w:colLast"];
38188
38273
  };
38189
- const decode$5 = (attrs) => {
38274
+ const decode$6 = (attrs) => {
38190
38275
  return attrs.colLast;
38191
38276
  };
38192
38277
  const attrConfig$3 = Object.freeze({
38193
38278
  xmlName: "w:colLast",
38194
38279
  sdName: "colLast",
38195
- encode: encode$5,
38196
- decode: decode$5
38280
+ encode: encode$6,
38281
+ decode: decode$6
38197
38282
  });
38198
- const encode$4 = (attributes) => {
38283
+ const encode$5 = (attributes) => {
38199
38284
  return attributes["w:displacedByCustomXml"];
38200
38285
  };
38201
- const decode$4 = (attrs) => {
38286
+ const decode$5 = (attrs) => {
38202
38287
  return attrs.displacedByCustomXml;
38203
38288
  };
38204
38289
  const attrConfig$2 = Object.freeze({
38205
38290
  xmlName: "w:displacedByCustomXml",
38206
38291
  sdName: "displacedByCustomXml",
38207
- encode: encode$4,
38208
- decode: decode$4
38292
+ encode: encode$5,
38293
+ decode: decode$5
38209
38294
  });
38210
- const validXmlAttributes$1 = [attrConfig$6, attrConfig$5, attrConfig$4, attrConfig$3, attrConfig$2];
38211
- const XML_NODE_NAME$1 = "w:bookmarkStart";
38212
- const SD_NODE_NAME$1 = "bookmarkStart";
38213
- const encode$3 = (params2, encodedAttrs = {}) => {
38295
+ const validXmlAttributes$2 = [attrConfig$6, attrConfig$5, attrConfig$4, attrConfig$3, attrConfig$2];
38296
+ const XML_NODE_NAME$2 = "w:bookmarkStart";
38297
+ const SD_NODE_NAME$2 = "bookmarkStart";
38298
+ const encode$4 = (params2, encodedAttrs = {}) => {
38214
38299
  return {
38215
38300
  type: "bookmarkStart",
38216
38301
  attrs: encodedAttrs
38217
38302
  };
38218
38303
  };
38219
- const decode$3 = (params2, decodedAttrs = {}) => {
38304
+ const decode$4 = (params2, decodedAttrs = {}) => {
38220
38305
  const result = {
38221
38306
  name: "w:bookmarkStart",
38222
38307
  elements: []
@@ -38226,49 +38311,49 @@ Please report this to https://github.com/markedjs/marked.`, e) {
38226
38311
  }
38227
38312
  return result;
38228
38313
  };
38229
- const config$1 = {
38230
- xmlName: XML_NODE_NAME$1,
38231
- sdNodeOrKeyName: SD_NODE_NAME$1,
38314
+ const config$2 = {
38315
+ xmlName: XML_NODE_NAME$2,
38316
+ sdNodeOrKeyName: SD_NODE_NAME$2,
38232
38317
  type: NodeTranslator.translatorTypes.NODE,
38233
- encode: encode$3,
38234
- decode: decode$3,
38235
- attributes: validXmlAttributes$1
38318
+ encode: encode$4,
38319
+ decode: decode$4,
38320
+ attributes: validXmlAttributes$2
38236
38321
  };
38237
- const translator$1 = NodeTranslator.from(config$1);
38238
- const encode$2 = (attributes) => {
38322
+ const translator$2 = NodeTranslator.from(config$2);
38323
+ const encode$3 = (attributes) => {
38239
38324
  return attributes["w:id"];
38240
38325
  };
38241
- const decode$2 = (attrs) => {
38326
+ const decode$3 = (attrs) => {
38242
38327
  return attrs.id;
38243
38328
  };
38244
38329
  const attrConfig$1 = Object.freeze({
38245
38330
  xmlName: "w:id",
38246
38331
  sdName: "id",
38247
- encode: encode$2,
38248
- decode: decode$2
38332
+ encode: encode$3,
38333
+ decode: decode$3
38249
38334
  });
38250
- const encode$1 = (attributes) => {
38335
+ const encode$2 = (attributes) => {
38251
38336
  return attributes["w:displacedByCustomXml"];
38252
38337
  };
38253
- const decode$1 = (attrs) => {
38338
+ const decode$2 = (attrs) => {
38254
38339
  return attrs.displacedByCustomXml;
38255
38340
  };
38256
38341
  const attrConfig = Object.freeze({
38257
38342
  xmlName: "w:displacedByCustomXml",
38258
38343
  sdName: "displacedByCustomXml",
38259
- encode: encode$1,
38260
- decode: decode$1
38344
+ encode: encode$2,
38345
+ decode: decode$2
38261
38346
  });
38262
- const validXmlAttributes = [attrConfig$1, attrConfig];
38263
- const XML_NODE_NAME = "w:bookmarkEnd";
38264
- const SD_NODE_NAME = "bookmarkEnd";
38265
- const encode$18 = (params2, encodedAttrs = {}) => {
38347
+ const validXmlAttributes$1 = [attrConfig$1, attrConfig];
38348
+ const XML_NODE_NAME$1 = "w:bookmarkEnd";
38349
+ const SD_NODE_NAME$1 = "bookmarkEnd";
38350
+ const encode$1 = (params2, encodedAttrs = {}) => {
38266
38351
  return {
38267
38352
  type: "bookmarkEnd",
38268
38353
  attrs: encodedAttrs
38269
38354
  };
38270
38355
  };
38271
- const decode = (params2, decodedAttrs = {}) => {
38356
+ const decode$1 = (params2, decodedAttrs = {}) => {
38272
38357
  const result = {
38273
38358
  name: "w:bookmarkEnd",
38274
38359
  elements: []
@@ -38278,15 +38363,121 @@ Please report this to https://github.com/markedjs/marked.`, e) {
38278
38363
  }
38279
38364
  return result;
38280
38365
  };
38366
+ const config$1 = {
38367
+ xmlName: XML_NODE_NAME$1,
38368
+ sdNodeOrKeyName: SD_NODE_NAME$1,
38369
+ type: NodeTranslator.translatorTypes.NODE,
38370
+ encode: encode$1,
38371
+ decode: decode$1,
38372
+ attributes: validXmlAttributes$1
38373
+ };
38374
+ const translator$1 = NodeTranslator.from(config$1);
38375
+ const XML_NODE_NAME = "mc:AlternateContent";
38376
+ const SD_NODE_NAME = [];
38377
+ const validXmlAttributes = [];
38378
+ function encode$19(params2) {
38379
+ const { nodeListHandler } = params2;
38380
+ const { node } = params2.extraParams;
38381
+ if (!node || !node.type) {
38382
+ return null;
38383
+ }
38384
+ const allowedNamespaces = ["wps", "wp14", "w14", "w15"];
38385
+ const wpsNode = node.elements.find(
38386
+ (el) => el.name === "mc:Choice" && allowedNamespaces.includes(el.attributes["Requires"])
38387
+ );
38388
+ if (!wpsNode) {
38389
+ return null;
38390
+ }
38391
+ const contents = wpsNode.elements;
38392
+ return nodeListHandler.handler({
38393
+ ...params2,
38394
+ nodes: contents,
38395
+ path: [...params2.path || [], wpsNode]
38396
+ });
38397
+ }
38398
+ function decode(params2) {
38399
+ const { node } = params2;
38400
+ const { drawingContent } = node.attrs;
38401
+ const drawing = {
38402
+ name: "w:drawing",
38403
+ elements: [...drawingContent ? [...drawingContent.elements || []] : []]
38404
+ };
38405
+ const choice = {
38406
+ name: "mc:Choice",
38407
+ attributes: { Requires: "wps" },
38408
+ elements: [drawing]
38409
+ };
38410
+ return {
38411
+ name: "mc:AlternateContent",
38412
+ elements: [choice]
38413
+ };
38414
+ }
38281
38415
  const config = {
38282
38416
  xmlName: XML_NODE_NAME,
38283
38417
  sdNodeOrKeyName: SD_NODE_NAME,
38284
38418
  type: NodeTranslator.translatorTypes.NODE,
38285
- encode: encode$18,
38419
+ encode: encode$19,
38286
38420
  decode,
38287
38421
  attributes: validXmlAttributes
38288
38422
  };
38289
38423
  const translator = NodeTranslator.from(config);
38424
+ const DEFAULT_SECTION_PROPS_TWIPS = Object.freeze({
38425
+ pageSize: Object.freeze({ width: "12240", height: "15840" }),
38426
+ pageMargins: Object.freeze({
38427
+ top: "1440",
38428
+ right: "1440",
38429
+ bottom: "1440",
38430
+ left: "1440",
38431
+ header: "720",
38432
+ footer: "720",
38433
+ gutter: "0"
38434
+ })
38435
+ });
38436
+ const ensureSectionLayoutDefaults = (sectPr, converter) => {
38437
+ if (!sectPr) {
38438
+ return {
38439
+ type: "element",
38440
+ name: "w:sectPr",
38441
+ elements: []
38442
+ };
38443
+ }
38444
+ if (!sectPr.elements) sectPr.elements = [];
38445
+ const ensureChild = (name) => {
38446
+ let child = sectPr.elements.find((n) => n.name === name);
38447
+ if (!child) {
38448
+ child = {
38449
+ type: "element",
38450
+ name,
38451
+ elements: [],
38452
+ attributes: {}
38453
+ };
38454
+ sectPr.elements.push(child);
38455
+ } else {
38456
+ if (!child.elements) child.elements = [];
38457
+ if (!child.attributes) child.attributes = {};
38458
+ }
38459
+ return child;
38460
+ };
38461
+ const pageSize = converter?.pageStyles?.pageSize;
38462
+ const pgSz = ensureChild("w:pgSz");
38463
+ if (pageSize?.width != null) pgSz.attributes["w:w"] = String(inchesToTwips(pageSize.width));
38464
+ if (pageSize?.height != null) pgSz.attributes["w:h"] = String(inchesToTwips(pageSize.height));
38465
+ if (pgSz.attributes["w:w"] == null) pgSz.attributes["w:w"] = DEFAULT_SECTION_PROPS_TWIPS.pageSize.width;
38466
+ if (pgSz.attributes["w:h"] == null) pgSz.attributes["w:h"] = DEFAULT_SECTION_PROPS_TWIPS.pageSize.height;
38467
+ const pageMargins = converter?.pageStyles?.pageMargins;
38468
+ const pgMar = ensureChild("w:pgMar");
38469
+ if (pageMargins) {
38470
+ Object.entries(pageMargins).forEach(([key2, value]) => {
38471
+ const converted = inchesToTwips(value);
38472
+ if (converted != null) pgMar.attributes[`w:${key2}`] = String(converted);
38473
+ });
38474
+ }
38475
+ Object.entries(DEFAULT_SECTION_PROPS_TWIPS.pageMargins).forEach(([key2, value]) => {
38476
+ const attrKey = `w:${key2}`;
38477
+ if (pgMar.attributes[attrKey] == null) pgMar.attributes[attrKey] = value;
38478
+ });
38479
+ return sectPr;
38480
+ };
38290
38481
  const isLineBreakOnlyRun = (node) => {
38291
38482
  if (!node) return false;
38292
38483
  if (node.type === "lineBreak" || node.type === "hardBreak") return true;
@@ -38301,30 +38492,30 @@ Please report this to https://github.com/markedjs/marked.`, e) {
38301
38492
  doc: translateDocumentNode,
38302
38493
  body: translateBodyNode,
38303
38494
  heading: translateHeadingNode,
38304
- paragraph: translator$12,
38305
- run: translator$T,
38495
+ paragraph: translator$13,
38496
+ run: translator$U,
38306
38497
  text: translateTextNode,
38307
38498
  bulletList: translateList,
38308
38499
  orderedList: translateList,
38309
- lineBreak: translator$15,
38310
- table: translator$8,
38311
- tableRow: translator$F,
38312
- tableCell: translator$7,
38313
- bookmarkStart: translator$1,
38314
- bookmarkEnd: translator,
38315
- fieldAnnotation: translator$2,
38316
- tab: translator$13,
38317
- image: translator$3,
38318
- hardBreak: translator$15,
38500
+ lineBreak: translator$16,
38501
+ table: translator$9,
38502
+ tableRow: translator$G,
38503
+ tableCell: translator$8,
38504
+ bookmarkStart: translator$2,
38505
+ bookmarkEnd: translator$1,
38506
+ fieldAnnotation: translator$3,
38507
+ tab: translator$14,
38508
+ image: translator$4,
38509
+ hardBreak: translator$16,
38319
38510
  commentRangeStart: () => translateCommentNode(params2, "Start"),
38320
38511
  commentRangeEnd: () => translateCommentNode(params2, "End"),
38321
38512
  commentReference: () => null,
38322
38513
  shapeContainer: translateShapeContainer,
38323
38514
  shapeTextbox: translateShapeTextbox,
38324
38515
  contentBlock: translateContentBlock,
38325
- structuredContent: translator$2,
38326
- structuredContentBlock: translator$2,
38327
- documentSection: translator$2,
38516
+ structuredContent: translator$3,
38517
+ structuredContentBlock: translator$3,
38518
+ documentSection: translator$3,
38328
38519
  "page-number": translatePageNumberNode,
38329
38520
  "total-page-number": translateTotalPageNumberNode
38330
38521
  };
@@ -38339,28 +38530,30 @@ Please report this to https://github.com/markedjs/marked.`, e) {
38339
38530
  return handler2(params2);
38340
38531
  }
38341
38532
  function translateBodyNode(params2) {
38342
- let sectPr = params2.bodyNode?.elements.find((n) => n.name === "w:sectPr") || {};
38533
+ let sectPr = params2.bodyNode?.elements?.find((n) => n.name === "w:sectPr");
38534
+ if (!sectPr) {
38535
+ sectPr = {
38536
+ type: "element",
38537
+ name: "w:sectPr",
38538
+ elements: []
38539
+ };
38540
+ } else if (!sectPr.elements) {
38541
+ sectPr = { ...sectPr, elements: [] };
38542
+ }
38543
+ sectPr = ensureSectionLayoutDefaults(sectPr, params2.converter);
38343
38544
  if (params2.converter) {
38344
- const hasHeader = sectPr?.elements?.some((n) => n.name === "w:headerReference");
38545
+ const hasHeader = sectPr.elements?.some((n) => n.name === "w:headerReference");
38345
38546
  const hasDefaultHeader = params2.converter.headerIds?.default;
38346
38547
  if (!hasHeader && hasDefaultHeader && !params2.editor.options.isHeaderOrFooter) {
38347
38548
  const defaultHeader = generateDefaultHeaderFooter("header", params2.converter.headerIds?.default);
38348
38549
  sectPr.elements.push(defaultHeader);
38349
38550
  }
38350
- const hasFooter = sectPr?.elements?.some((n) => n.name === "w:footerReference");
38551
+ const hasFooter = sectPr.elements?.some((n) => n.name === "w:footerReference");
38351
38552
  const hasDefaultFooter = params2.converter.footerIds?.default;
38352
38553
  if (!hasFooter && hasDefaultFooter && !params2.editor.options.isHeaderOrFooter) {
38353
38554
  const defaultFooter = generateDefaultHeaderFooter("footer", params2.converter.footerIds?.default);
38354
38555
  sectPr.elements.push(defaultFooter);
38355
38556
  }
38356
- const newMargins = params2.converter.pageStyles.pageMargins;
38357
- const sectPrMargins = sectPr.elements.find((n) => n.name === "w:pgMar");
38358
- const { attributes } = sectPrMargins;
38359
- Object.entries(newMargins).forEach(([key2, value]) => {
38360
- const convertedValue = inchesToTwips(value);
38361
- attributes[`w:${key2}`] = convertedValue;
38362
- });
38363
- sectPrMargins.attributes = attributes;
38364
38557
  }
38365
38558
  const elements = translateChildNodes(params2);
38366
38559
  if (params2.isHeaderFooter) {
@@ -38663,7 +38856,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
38663
38856
  const isTrackedNode = node.marks?.some((m2) => trackedMarks.includes(m2.type));
38664
38857
  if (isTrackedNode) return translateTrackedNode(params2);
38665
38858
  const isLinkNode = node.marks?.some((m2) => m2.type === "link");
38666
- if (isLinkNode) return translator$6.decode(params2);
38859
+ if (isLinkNode) return translator$7.decode(params2);
38667
38860
  const { text, marks = [] } = node;
38668
38861
  return getTextNodeForExport(text, marks, params2);
38669
38862
  }
@@ -38969,7 +39162,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
38969
39162
  markElement.type = "element";
38970
39163
  break;
38971
39164
  case "underline": {
38972
- const translated = translator$$.decode({
39165
+ const translated = translator$10.decode({
38973
39166
  node: {
38974
39167
  attrs: {
38975
39168
  underlineType: attrs.underlineType ?? attrs.underline ?? null,
@@ -39033,7 +39226,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
39033
39226
  break;
39034
39227
  case "highlight": {
39035
39228
  const highlightValue = attrs.color ?? attrs.highlight ?? null;
39036
- const translated = translator$14.decode({ node: { attrs: { highlight: highlightValue } } });
39229
+ const translated = translator$15.decode({ node: { attrs: { highlight: highlightValue } } });
39037
39230
  return translated || {};
39038
39231
  }
39039
39232
  }
@@ -39089,23 +39282,11 @@ Please report this to https://github.com/markedjs/marked.`, e) {
39089
39282
  }
39090
39283
  function translateContentBlock(params2) {
39091
39284
  const { node } = params2;
39092
- const { drawingContent, vmlAttributes, horizontalRule } = node.attrs;
39285
+ const { vmlAttributes, horizontalRule } = node.attrs;
39093
39286
  if (vmlAttributes || horizontalRule) {
39094
39287
  return translateVRectContentBlock(params2);
39095
39288
  }
39096
- const drawing = {
39097
- name: "w:drawing",
39098
- elements: [...drawingContent ? [...drawingContent.elements || []] : []]
39099
- };
39100
- const choice = {
39101
- name: "mc:Choice",
39102
- attributes: { Requires: "wps" },
39103
- elements: [drawing]
39104
- };
39105
- const alternateContent = {
39106
- name: "mc:AlternateContent",
39107
- elements: [choice]
39108
- };
39289
+ const alternateContent = translator.decode(params2);
39109
39290
  return wrapTextInRun(alternateContent);
39110
39291
  }
39111
39292
  function translateVRectContentBlock(params2) {
@@ -39309,7 +39490,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
39309
39490
  if (mainNode.name === "w:drawing") node = mainNode;
39310
39491
  else node = mainNode.elements.find((el) => el.name === "w:drawing");
39311
39492
  if (!node) return { nodes: [], consumed: 0 };
39312
- const schemaNode = translator$3.encode(params2);
39493
+ const schemaNode = translator$4.encode(params2);
39313
39494
  const newNodes = schemaNode ? [schemaNode] : [];
39314
39495
  return { nodes: newNodes, consumed: 1 };
39315
39496
  };
@@ -39411,8 +39592,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
39411
39592
  handlerName: "trackChangeNodeHandler",
39412
39593
  handler: handleTrackChangeNode
39413
39594
  };
39414
- const hyperlinkNodeHandlerEntity = generateV2HandlerEntity("hyperlinkNodeHandler", translator$6);
39415
- const runNodeHandlerEntity = generateV2HandlerEntity("runNodeHandler", translator$T);
39595
+ const hyperlinkNodeHandlerEntity = generateV2HandlerEntity("hyperlinkNodeHandler", translator$7);
39596
+ const runNodeHandlerEntity = generateV2HandlerEntity("runNodeHandler", translator$U);
39416
39597
  const handleTextNode = (params2) => {
39417
39598
  const { nodes, insideTrackChange } = params2;
39418
39599
  if (nodes.length === 0 || !(nodes[0].name === "w:t" || insideTrackChange && nodes[0].name === "w:delText")) {
@@ -39453,7 +39634,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
39453
39634
  if (nodes.length === 0 || nodes[0].name !== "w:p") {
39454
39635
  return { nodes: [], consumed: 0 };
39455
39636
  }
39456
- const schemaNode = translator$12.encode(params2);
39637
+ const schemaNode = translator$13.encode(params2);
39457
39638
  const newNodes = schemaNode ? [schemaNode] : [];
39458
39639
  return { nodes: newNodes, consumed: 1 };
39459
39640
  };
@@ -39466,7 +39647,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
39466
39647
  if (nodes.length === 0 || nodes[0].name !== "w:sdt") {
39467
39648
  return { nodes: [], consumed: 0 };
39468
39649
  }
39469
- const result = translator$2.encode(params2);
39650
+ const result = translator$3.encode(params2);
39470
39651
  if (!result) {
39471
39652
  return { nodes: [], consumed: 0 };
39472
39653
  }
@@ -39556,7 +39737,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
39556
39737
  if (nodes.length === 0 || nodes[0].name !== "w:br") {
39557
39738
  return { nodes: [], consumed: 0 };
39558
39739
  }
39559
- const result = translator$15.encode(params2);
39740
+ const result = translator$16.encode(params2);
39560
39741
  if (!result) return { nodes: [], consumed: 0 };
39561
39742
  return {
39562
39743
  nodes: [result],
@@ -39628,7 +39809,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
39628
39809
  if (isCustomMarkBookmark(nodes[0], params2.editor)) {
39629
39810
  return handleBookmarkNode(params2);
39630
39811
  }
39631
- const node = translator$1.encode(params2);
39812
+ const node = translator$2.encode(params2);
39632
39813
  if (!node) return { nodes: [], consumed: 0 };
39633
39814
  return { nodes: [node], consumed: 1 };
39634
39815
  };
@@ -39660,7 +39841,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
39660
39841
  if (!nodes.length || nodes[0].name !== "w:bookmarkEnd") {
39661
39842
  return { nodes: [], consumed: 0 };
39662
39843
  }
39663
- const node = translator.encode(params2);
39844
+ const node = translator$1.encode(params2);
39664
39845
  if (!node) return { nodes: [], consumed: 0 };
39665
39846
  return { nodes: [node], consumed: 1 };
39666
39847
  };
@@ -39668,32 +39849,86 @@ Please report this to https://github.com/markedjs/marked.`, e) {
39668
39849
  handlerName: "w:bookmarkEndTranslator",
39669
39850
  handler: handleBookmarkEndNode
39670
39851
  };
39852
+ const ALTERNATE_CONTENT_NODE = "mc:AlternateContent";
39853
+ const SUPPORTED_REQUIRES = /* @__PURE__ */ new Set([
39854
+ "wps",
39855
+ "wp14",
39856
+ "w14",
39857
+ "w15",
39858
+ "w16",
39859
+ "w16cex",
39860
+ "w16cid",
39861
+ "w16du",
39862
+ "w16sdtdh",
39863
+ "w16sdtfl",
39864
+ "w16se"
39865
+ ]);
39866
+ const skipHandlerResponse = { nodes: [], consumed: 0 };
39867
+ const isAlternateContentNode = (node) => node?.name === ALTERNATE_CONTENT_NODE;
39868
+ const isSupportedChoice = (choice) => {
39869
+ if (!choice?.attributes) return false;
39870
+ const requires = choice.attributes.Requires || choice.attributes.requires;
39871
+ if (!requires) return false;
39872
+ return requires.split(/\s+/).filter(Boolean).some((namespace2) => SUPPORTED_REQUIRES.has(namespace2));
39873
+ };
39874
+ const resolveAlternateContentElements = (alternateContent) => {
39875
+ if (!alternateContent?.elements?.length) return null;
39876
+ const choices = alternateContent.elements.filter((el) => el.name === "mc:Choice");
39877
+ const fallback = alternateContent.elements.find((el) => el.name === "mc:Fallback");
39878
+ const supportedChoice = choices.find(isSupportedChoice);
39879
+ const selectedElements = supportedChoice?.elements || fallback?.elements || choices[0]?.elements;
39880
+ if (!selectedElements) return null;
39881
+ return carbonCopy(selectedElements);
39882
+ };
39883
+ const buildNodeWithoutAlternateContent = (node) => {
39884
+ const { elements } = node || {};
39885
+ if (!elements?.length) return null;
39886
+ let replaced = false;
39887
+ const updatedElements = [];
39888
+ elements.forEach((element) => {
39889
+ if (isAlternateContentNode(element)) {
39890
+ const resolved = resolveAlternateContentElements(element);
39891
+ if (resolved) {
39892
+ updatedElements.push(...resolved);
39893
+ replaced = true;
39894
+ return;
39895
+ }
39896
+ updatedElements.push(carbonCopy(element));
39897
+ return;
39898
+ }
39899
+ updatedElements.push(carbonCopy(element));
39900
+ });
39901
+ if (!replaced) return null;
39902
+ const clone = carbonCopy(node);
39903
+ clone.elements = updatedElements;
39904
+ return clone;
39905
+ };
39671
39906
  const handleAlternateChoice = (params2) => {
39672
- const skipHandlerResponse = { nodes: [], consumed: 0 };
39673
39907
  const { nodes, nodeListHandler } = params2;
39674
- if (nodes.length === 0 || nodes[0].name !== "w:p") {
39908
+ if (!nodes?.length) {
39675
39909
  return skipHandlerResponse;
39676
39910
  }
39677
- const mainNode = nodes[0];
39678
- const node = mainNode?.elements?.find((el) => el.name === "w:r");
39679
- const hasAltChoice = node?.elements?.some((el) => el.name === "mc:AlternateContent");
39680
- if (!hasAltChoice) {
39681
- return skipHandlerResponse;
39911
+ const [currentNode] = nodes;
39912
+ if (isAlternateContentNode(currentNode)) {
39913
+ const resolvedElements = resolveAlternateContentElements(currentNode);
39914
+ if (!resolvedElements) {
39915
+ return skipHandlerResponse;
39916
+ }
39917
+ const result2 = nodeListHandler.handler({
39918
+ ...params2,
39919
+ nodes: resolvedElements,
39920
+ path: [...params2.path || [], currentNode]
39921
+ });
39922
+ return { nodes: result2, consumed: 1 };
39682
39923
  }
39683
- const altChoiceNode = node.elements.find((el) => el.name === "mc:AlternateContent");
39684
- node.elements.findIndex((el) => el.name === "mc:AlternateContent");
39685
- const allowedNamespaces = ["wps", "wp14", "w14", "w15"];
39686
- const wpsNode = altChoiceNode.elements.find(
39687
- (el) => el.name === "mc:Choice" && allowedNamespaces.includes(el.attributes["Requires"])
39688
- );
39689
- if (!wpsNode) {
39924
+ const sanitizedNode = buildNodeWithoutAlternateContent(currentNode);
39925
+ if (!sanitizedNode) {
39690
39926
  return skipHandlerResponse;
39691
39927
  }
39692
- const contents = wpsNode.elements;
39693
39928
  const result = nodeListHandler.handler({
39694
39929
  ...params2,
39695
- nodes: contents,
39696
- path: [...params2.path || [], wpsNode]
39930
+ nodes: [sanitizedNode],
39931
+ path: [...params2.path || [], sanitizedNode]
39697
39932
  });
39698
39933
  return { nodes: result, consumed: 1 };
39699
39934
  };
@@ -40272,7 +40507,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
40272
40507
  if (!nodes.length || nodes[0].name !== "w:tab") {
40273
40508
  return { nodes: [], consumed: 0 };
40274
40509
  }
40275
- const node = translator$13.encode(params2);
40510
+ const node = translator$14.encode(params2);
40276
40511
  return { nodes: [node], consumed: 1 };
40277
40512
  };
40278
40513
  const tabNodeEntityHandler = {
@@ -40306,6 +40541,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
40306
40541
  const nodeListHandler = defaultNodeListHandler();
40307
40542
  const bodyNode = json.elements[0].elements.find((el) => el.name === "w:body");
40308
40543
  if (bodyNode) {
40544
+ ensureSectionProperties(bodyNode);
40309
40545
  const node = bodyNode;
40310
40546
  const contentElements = node.elements?.filter((n) => n.name !== "w:sectPr") ?? [];
40311
40547
  const content = pruneIgnoredNodes(contentElements);
@@ -40539,6 +40775,59 @@ Please report this to https://github.com/markedjs/marked.`, e) {
40539
40775
  styles.alternateHeaders = isAlternatingHeadersOddEven(docx);
40540
40776
  return styles;
40541
40777
  }
40778
+ const DEFAULT_SECTION_PROPS = Object.freeze({
40779
+ pageSize: Object.freeze({ width: "12240", height: "15840" }),
40780
+ pageMargins: Object.freeze({
40781
+ top: "1440",
40782
+ right: "1440",
40783
+ bottom: "1440",
40784
+ left: "1440",
40785
+ header: "720",
40786
+ footer: "720",
40787
+ gutter: "0"
40788
+ })
40789
+ });
40790
+ function ensureSectionProperties(bodyNode, converter) {
40791
+ if (!bodyNode.elements) bodyNode.elements = [];
40792
+ let sectPr = bodyNode.elements.find((el) => el.name === "w:sectPr");
40793
+ if (!sectPr) {
40794
+ sectPr = {
40795
+ type: "element",
40796
+ name: "w:sectPr",
40797
+ elements: []
40798
+ };
40799
+ bodyNode.elements.push(sectPr);
40800
+ } else if (!sectPr.elements) {
40801
+ sectPr.elements = [];
40802
+ }
40803
+ const ensureChild = (name, factory) => {
40804
+ let child = sectPr.elements.find((el) => el.name === name);
40805
+ if (!child) {
40806
+ child = factory();
40807
+ sectPr.elements.push(child);
40808
+ } else if (!child.attributes) {
40809
+ child.attributes = {};
40810
+ }
40811
+ return child;
40812
+ };
40813
+ const pgSz = ensureChild("w:pgSz", () => ({
40814
+ type: "element",
40815
+ name: "w:pgSz",
40816
+ attributes: {}
40817
+ }));
40818
+ pgSz.attributes["w:w"] = pgSz.attributes["w:w"] ?? DEFAULT_SECTION_PROPS.pageSize.width;
40819
+ pgSz.attributes["w:h"] = pgSz.attributes["w:h"] ?? DEFAULT_SECTION_PROPS.pageSize.height;
40820
+ const pgMar = ensureChild("w:pgMar", () => ({
40821
+ type: "element",
40822
+ name: "w:pgMar",
40823
+ attributes: {}
40824
+ }));
40825
+ Object.entries(DEFAULT_SECTION_PROPS.pageMargins).forEach(([key2, value]) => {
40826
+ const attrKey = `w:${key2}`;
40827
+ if (pgMar.attributes[attrKey] == null) pgMar.attributes[attrKey] = value;
40828
+ });
40829
+ return sectPr;
40830
+ }
40542
40831
  function getStyleDefinitions(docx) {
40543
40832
  const styles = docx["word/styles.xml"];
40544
40833
  if (!styles) return [];
@@ -40731,6 +41020,36 @@ Please report this to https://github.com/markedjs/marked.`, e) {
40731
41020
  auto: "sans-serif"
40732
41021
  });
40733
41022
  const DEFAULT_GENERIC_FALLBACK = "sans-serif";
41023
+ const DEFAULT_FONT_SIZE_PT = 10;
41024
+ const collectRunDefaultProperties = (runProps, { allowOverrideTypeface = true, allowOverrideSize = true, themeResolver, state: state2 }) => {
41025
+ if (!runProps?.elements?.length || !state2) return;
41026
+ const fontsNode = runProps.elements.find((el) => el.name === "w:rFonts");
41027
+ if (fontsNode?.attributes) {
41028
+ const themeName = fontsNode.attributes["w:asciiTheme"];
41029
+ if (themeName) {
41030
+ const themeInfo = themeResolver?.(themeName) || {};
41031
+ if ((allowOverrideTypeface || !state2.typeface) && themeInfo.typeface) state2.typeface = themeInfo.typeface;
41032
+ if ((allowOverrideTypeface || !state2.panose) && themeInfo.panose) state2.panose = themeInfo.panose;
41033
+ }
41034
+ const ascii = fontsNode.attributes["w:ascii"];
41035
+ if ((allowOverrideTypeface || !state2.typeface) && ascii) {
41036
+ state2.typeface = ascii;
41037
+ }
41038
+ }
41039
+ const sizeNode = runProps.elements.find((el) => el.name === "w:sz");
41040
+ if (sizeNode?.attributes?.["w:val"]) {
41041
+ const sizeTwips = Number(sizeNode.attributes["w:val"]);
41042
+ if (Number.isFinite(sizeTwips)) {
41043
+ if (state2.fallbackSzTwips === void 0) state2.fallbackSzTwips = sizeTwips;
41044
+ const sizePt = sizeTwips / 2;
41045
+ if (allowOverrideSize || state2.fontSizePt === void 0) state2.fontSizePt = sizePt;
41046
+ }
41047
+ }
41048
+ const kernNode = runProps.elements.find((el) => el.name === "w:kern");
41049
+ if (kernNode?.attributes?.["w:val"]) {
41050
+ if (allowOverrideSize || state2.kern === void 0) state2.kern = kernNode.attributes["w:val"];
41051
+ }
41052
+ };
40734
41053
  const _SuperConverter = class _SuperConverter2 {
40735
41054
  constructor(params2 = null) {
40736
41055
  __privateAdd$2(this, _SuperConverter_instances);
@@ -40836,7 +41155,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
40836
41155
  return;
40837
41156
  }
40838
41157
  }
40839
- static updateDocumentVersion(docx = this.convertedXml, version2 = "0.20.2") {
41158
+ static updateDocumentVersion(docx = this.convertedXml, version2 = "0.21.1") {
40840
41159
  const customLocation = "docProps/custom.xml";
40841
41160
  if (!docx[customLocation]) {
40842
41161
  docx[customLocation] = generateCustomXml();
@@ -40858,49 +41177,45 @@ Please report this to https://github.com/markedjs/marked.`, e) {
40858
41177
  }
40859
41178
  getDocumentDefaultStyles() {
40860
41179
  const styles = this.convertedXml["word/styles.xml"];
40861
- if (!styles) return {};
40862
- const defaults = styles.elements[0].elements.find((el) => el.name === "w:docDefaults");
40863
- const rDefault = defaults.elements.find((el) => el.name === "w:rPrDefault");
40864
- if (!rDefault.elements) return {};
40865
- const rElements = rDefault.elements[0].elements;
40866
- const rFonts = rElements?.find((el) => el.name === "w:rFonts");
40867
- if ("elements" in rDefault) {
40868
- const fontThemeName = rElements.find((el) => el.name === "w:rFonts")?.attributes["w:asciiTheme"];
40869
- let typeface, panose, fontSizeNormal;
40870
- if (fontThemeName) {
40871
- const fontInfo = this.getThemeInfo(fontThemeName);
40872
- typeface = fontInfo.typeface;
40873
- panose = fontInfo.panose;
40874
- } else if (rFonts) {
40875
- typeface = rFonts?.attributes["w:ascii"];
40876
- }
40877
- const paragraphDefaults = styles.elements[0].elements.filter((el) => {
40878
- return el.name === "w:style" && el.attributes["w:styleId"] === "Normal";
40879
- }) || [];
40880
- paragraphDefaults.forEach((el) => {
40881
- const rPr = el.elements.find((el2) => el2.name === "w:rPr");
40882
- const fonts = rPr?.elements?.find((el2) => el2.name === "w:rFonts");
40883
- typeface = fonts?.attributes["w:ascii"];
40884
- fontSizeNormal = Number(rPr?.elements?.find((el2) => el2.name === "w:sz")?.attributes["w:val"]) / 2;
40885
- });
40886
- const rPrDefaults = defaults?.elements?.find((el) => el.name === "w:rPrDefault");
40887
- if (rPrDefaults) {
40888
- const rPr = rPrDefaults.elements?.find((el) => el.name === "w:rPr");
40889
- const fonts = rPr?.elements?.find((el) => el.name === "w:rFonts");
40890
- if (fonts?.attributes?.["w:ascii"]) {
40891
- typeface = fonts.attributes["w:ascii"];
40892
- }
40893
- const fontSizeRaw = rPr?.elements?.find((el) => el.name === "w:sz")?.attributes?.["w:val"];
40894
- if (!fontSizeNormal && fontSizeRaw) {
40895
- fontSizeNormal = Number(fontSizeRaw) / 2;
40896
- }
40897
- }
40898
- const fallbackSz = Number(rElements.find((el) => el.name === "w:sz")?.attributes?.["w:val"]);
40899
- const fontSizePt = fontSizeNormal ?? (Number.isFinite(fallbackSz) ? fallbackSz / 2 : void 0) ?? 10;
40900
- const kern = rElements.find((el) => el.name === "w:kern")?.attributes["w:val"];
40901
- const fontFamilyCss = _SuperConverter2.toCssFontFamily(typeface, this.convertedXml);
40902
- return { fontSizePt, kern, typeface, panose, fontFamilyCss };
40903
- }
41180
+ const styleRoot = styles?.elements?.[0];
41181
+ const styleElements = styleRoot?.elements || [];
41182
+ if (!styleElements.length) return {};
41183
+ const defaults = styleElements.find((el) => el.name === "w:docDefaults");
41184
+ const normalStyle = styleElements.find((el) => el.name === "w:style" && el.attributes?.["w:styleId"] === "Normal");
41185
+ const defaultsState = {
41186
+ typeface: void 0,
41187
+ panose: void 0,
41188
+ fontSizePt: void 0,
41189
+ kern: void 0,
41190
+ fallbackSzTwips: void 0
41191
+ };
41192
+ const docDefaultRun = defaults?.elements?.find((el) => el.name === "w:rPrDefault");
41193
+ const docDefaultProps = docDefaultRun?.elements?.find((el) => el.name === "w:rPr") ?? docDefaultRun;
41194
+ collectRunDefaultProperties(docDefaultProps, {
41195
+ allowOverrideTypeface: true,
41196
+ allowOverrideSize: true,
41197
+ themeResolver: (theme) => this.getThemeInfo(theme),
41198
+ state: defaultsState
41199
+ });
41200
+ const normalRunProps = normalStyle?.elements?.find((el) => el.name === "w:rPr") ?? null;
41201
+ collectRunDefaultProperties(normalRunProps, {
41202
+ allowOverrideTypeface: true,
41203
+ allowOverrideSize: true,
41204
+ themeResolver: (theme) => this.getThemeInfo(theme),
41205
+ state: defaultsState
41206
+ });
41207
+ if (defaultsState.fontSizePt === void 0) {
41208
+ if (Number.isFinite(defaultsState.fallbackSzTwips)) defaultsState.fontSizePt = defaultsState.fallbackSzTwips / 2;
41209
+ else defaultsState.fontSizePt = DEFAULT_FONT_SIZE_PT;
41210
+ }
41211
+ const fontFamilyCss = defaultsState.typeface ? _SuperConverter2.toCssFontFamily(defaultsState.typeface, this.convertedXml) : void 0;
41212
+ const result = {};
41213
+ if (defaultsState.fontSizePt !== void 0) result.fontSizePt = defaultsState.fontSizePt;
41214
+ if (defaultsState.kern !== void 0) result.kern = defaultsState.kern;
41215
+ if (defaultsState.typeface) result.typeface = defaultsState.typeface;
41216
+ if (defaultsState.panose) result.panose = defaultsState.panose;
41217
+ if (fontFamilyCss) result.fontFamilyCss = fontFamilyCss;
41218
+ return result;
40904
41219
  }
40905
41220
  getDocumentFonts() {
40906
41221
  const fontTable = this.convertedXml["word/fontTable.xml"];
@@ -41329,7 +41644,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
41329
41644
  function generateCustomXml() {
41330
41645
  return DEFAULT_CUSTOM_XML;
41331
41646
  }
41332
- function generateSuperdocVersion(pid = 2, version2 = "0.20.2") {
41647
+ function generateSuperdocVersion(pid = 2, version2 = "0.21.1") {
41333
41648
  return {
41334
41649
  type: "element",
41335
41650
  name: "property",
@@ -43767,14 +44082,19 @@ Please report this to https://github.com/markedjs/marked.`, e) {
43767
44082
  /**
43768
44083
  * Update [Content_Types].xml with extensions of new Image annotations
43769
44084
  */
43770
- async updateContentTypes(docx, media, fromJson) {
44085
+ async updateContentTypes(docx, media, fromJson, updatedDocs = {}) {
44086
+ const additionalPartNames = Object.keys(updatedDocs || {});
43771
44087
  const newMediaTypes = Object.keys(media).map((name) => {
43772
44088
  return this.getFileExtension(name);
43773
44089
  }).filter(Boolean);
43774
44090
  const contentTypesPath = "[Content_Types].xml";
43775
44091
  let contentTypesXml;
43776
44092
  if (fromJson) {
43777
- contentTypesXml = docx.files.find((file) => file.name === contentTypesPath)?.content || "";
44093
+ if (Array.isArray(docx.files)) {
44094
+ contentTypesXml = docx.files.find((file) => file.name === contentTypesPath)?.content || "";
44095
+ } else {
44096
+ contentTypesXml = docx.files?.[contentTypesPath] || "";
44097
+ }
43778
44098
  } else contentTypesXml = await docx.file(contentTypesPath).async("string");
43779
44099
  let typesString = "";
43780
44100
  const defaultMediaTypes = getContentTypesFromXml(contentTypesXml);
@@ -43800,24 +44120,39 @@ Please report this to https://github.com/markedjs/marked.`, e) {
43800
44120
  const hasCommentsExtensible = types2.elements?.some(
43801
44121
  (el) => el.name === "Override" && el.attributes.PartName === "/word/commentsExtensible.xml"
43802
44122
  );
43803
- if (docx.files["word/comments.xml"]) {
44123
+ const hasFile = (filename) => {
44124
+ if (!docx?.files) return false;
44125
+ if (!fromJson) return Boolean(docx.files[filename]);
44126
+ if (Array.isArray(docx.files)) return docx.files.some((file) => file.name === filename);
44127
+ return Boolean(docx.files[filename]);
44128
+ };
44129
+ if (hasFile("word/comments.xml")) {
43804
44130
  const commentsDef = `<Override PartName="/word/comments.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml" />`;
43805
44131
  if (!hasComments) typesString += commentsDef;
43806
44132
  }
43807
- if (docx.files["word/commentsExtended.xml"]) {
44133
+ if (hasFile("word/commentsExtended.xml")) {
43808
44134
  const commentsExtendedDef = `<Override PartName="/word/commentsExtended.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtended+xml" />`;
43809
44135
  if (!hasCommentsExtended) typesString += commentsExtendedDef;
43810
44136
  }
43811
- if (docx.files["word/commentsIds.xml"]) {
44137
+ if (hasFile("word/commentsIds.xml")) {
43812
44138
  const commentsIdsDef = `<Override PartName="/word/commentsIds.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.commentsIds+xml" />`;
43813
44139
  if (!hasCommentsIds) typesString += commentsIdsDef;
43814
44140
  }
43815
- if (docx.files["word/commentsExtensible.xml"]) {
44141
+ if (hasFile("word/commentsExtensible.xml")) {
43816
44142
  const commentsExtendedDef = `<Override PartName="/word/commentsExtensible.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtensible+xml" />`;
43817
44143
  if (!hasCommentsExtensible) typesString += commentsExtendedDef;
43818
44144
  }
43819
- Object.keys(docx.files).forEach((name) => {
43820
- if (name.includes(".rels") || !name.includes("header") && !name.includes("footer")) return;
44145
+ const partNames = new Set(additionalPartNames);
44146
+ if (docx?.files) {
44147
+ if (fromJson && Array.isArray(docx.files)) {
44148
+ docx.files.forEach((file) => partNames.add(file.name));
44149
+ } else {
44150
+ Object.keys(docx.files).forEach((key2) => partNames.add(key2));
44151
+ }
44152
+ }
44153
+ partNames.forEach((name) => {
44154
+ if (name.includes(".rels")) return;
44155
+ if (!name.includes("header") && !name.includes("footer")) return;
43821
44156
  const hasExtensible = types2.elements?.some(
43822
44157
  (el) => el.name === "Override" && el.attributes.PartName === `/${name}`
43823
44158
  );
@@ -43828,7 +44163,48 @@ Please report this to https://github.com/markedjs/marked.`, e) {
43828
44163
  }
43829
44164
  });
43830
44165
  const beginningString = '<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">';
43831
- const updatedContentTypesXml = contentTypesXml.replace(beginningString, `${beginningString}${typesString}`);
44166
+ let updatedContentTypesXml = contentTypesXml.replace(beginningString, `${beginningString}${typesString}`);
44167
+ let relationshipsXml = updatedDocs["word/_rels/document.xml.rels"];
44168
+ if (!relationshipsXml) {
44169
+ if (fromJson) {
44170
+ if (Array.isArray(docx.files)) {
44171
+ relationshipsXml = docx.files.find((file) => file.name === "word/_rels/document.xml.rels")?.content;
44172
+ } else {
44173
+ relationshipsXml = docx.files?.["word/_rels/document.xml.rels"];
44174
+ }
44175
+ } else {
44176
+ relationshipsXml = await docx.file("word/_rels/document.xml.rels")?.async("string");
44177
+ }
44178
+ }
44179
+ if (relationshipsXml) {
44180
+ try {
44181
+ const relJson = xmljs.xml2js(relationshipsXml, { compact: false });
44182
+ const relationships = relJson.elements?.find((el) => el.name === "Relationships");
44183
+ relationships?.elements?.forEach((rel) => {
44184
+ const type2 = rel.attributes?.Type;
44185
+ const target = rel.attributes?.Target;
44186
+ if (!type2 || !target) return;
44187
+ const isHeader = type2.includes("/header");
44188
+ const isFooter = type2.includes("/footer");
44189
+ if (!isHeader && !isFooter) return;
44190
+ let sanitizedTarget = target.replace(/^\.\//, "");
44191
+ if (sanitizedTarget.startsWith("../")) sanitizedTarget = sanitizedTarget.slice(3);
44192
+ if (sanitizedTarget.startsWith("/")) sanitizedTarget = sanitizedTarget.slice(1);
44193
+ const partName = sanitizedTarget.startsWith("word/") ? sanitizedTarget : `word/${sanitizedTarget}`;
44194
+ partNames.add(partName);
44195
+ });
44196
+ } catch (error) {
44197
+ console.warn("Failed to parse document relationships while updating content types", error);
44198
+ }
44199
+ }
44200
+ partNames.forEach((name) => {
44201
+ if (name.includes(".rels")) return;
44202
+ if (!name.includes("header") && !name.includes("footer")) return;
44203
+ if (updatedContentTypesXml.includes(`PartName="/${name}"`)) return;
44204
+ const type2 = name.includes("header") ? "header" : "footer";
44205
+ const extendedDef = `<Override PartName="/${name}" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.${type2}+xml"/>`;
44206
+ updatedContentTypesXml = updatedContentTypesXml.replace("</Types>", `${extendedDef}</Types>`);
44207
+ });
43832
44208
  if (fromJson) return updatedContentTypesXml;
43833
44209
  docx.file(contentTypesPath, updatedContentTypesXml);
43834
44210
  }
@@ -43869,7 +44245,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
43869
44245
  for (const [fontName, fontUintArray] of Object.entries(fonts)) {
43870
44246
  zip.file(fontName, fontUintArray);
43871
44247
  }
43872
- await this.updateContentTypes(zip, media);
44248
+ await this.updateContentTypes(zip, media, false, updatedDocs);
43873
44249
  return zip;
43874
44250
  }
43875
44251
  /**
@@ -43895,7 +44271,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
43895
44271
  Object.keys(media).forEach((path) => {
43896
44272
  unzippedOriginalDocx.file(path, media[path]);
43897
44273
  });
43898
- await this.updateContentTypes(unzippedOriginalDocx, media);
44274
+ await this.updateContentTypes(unzippedOriginalDocx, media, false, updatedDocs);
43899
44275
  return unzippedOriginalDocx;
43900
44276
  }
43901
44277
  }
@@ -55553,9 +55929,11 @@ Please report this to https://github.com/markedjs/marked.`, e) {
55553
55929
  item.editor.view.dom.setAttribute("documentmode", documentMode);
55554
55930
  });
55555
55931
  if (isEditMode) {
55556
- const pm = document.querySelector(".ProseMirror");
55557
- pm.classList.add("header-footer-edit");
55558
- pm.setAttribute("aria-readonly", true);
55932
+ const pm = editor.view?.dom || editor.options.element?.querySelector?.(".ProseMirror");
55933
+ if (pm) {
55934
+ pm.classList.add("header-footer-edit");
55935
+ pm.setAttribute("aria-readonly", true);
55936
+ }
55559
55937
  }
55560
55938
  if (focusedSectionEditor) {
55561
55939
  focusedSectionEditor.view.focus();
@@ -56585,6 +56963,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
56585
56963
  const mappedRowStart = tr.mapping.map(absoluteRowStart);
56586
56964
  const rowEnd = mappedRowStart + rowNode.nodeSize;
56587
56965
  tr.replaceWith(mappedRowStart, rowEnd, Fragment.from(newRows));
56966
+ tr.setMeta("tableGeneration", true);
56588
56967
  } catch (error) {
56589
56968
  console.error("Error during row generation:", error);
56590
56969
  throw error;
@@ -56989,7 +57368,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
56989
57368
  }
56990
57369
  function findRemovedFieldAnnotations(tr) {
56991
57370
  let removedNodes = [];
56992
- if (!tr.steps.length || tr.meta && !Object.keys(tr.meta).every((meta) => ["inputType", "uiEvent", "paste"].includes(meta)) || ["historyUndo", "historyRedo"].includes(tr.getMeta("inputType")) || ["drop"].includes(tr.getMeta("uiEvent")) || tr.getMeta("fieldAnnotationUpdate") === true) {
57371
+ if (!tr.steps.length || tr.meta && !Object.keys(tr.meta).every((meta) => ["inputType", "uiEvent", "paste"].includes(meta)) || ["historyUndo", "historyRedo"].includes(tr.getMeta("inputType")) || ["drop"].includes(tr.getMeta("uiEvent")) || tr.getMeta("fieldAnnotationUpdate") === true || tr.getMeta("tableGeneration") === true) {
56993
57372
  return removedNodes;
56994
57373
  }
56995
57374
  const hasDeletion = transactionDeletedAnything(tr);
@@ -58167,7 +58546,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
58167
58546
  setDocumentMode(documentMode) {
58168
58547
  let cleanedMode = documentMode?.toLowerCase() || "editing";
58169
58548
  if (!this.extensionService || !this.state) return;
58170
- const pm = document.querySelector(".ProseMirror");
58549
+ const pm = this.view?.dom || this.options.element?.querySelector?.(".ProseMirror");
58171
58550
  if (this.options.role === "viewer") cleanedMode = "viewing";
58172
58551
  if (this.options.role === "suggester" && cleanedMode === "editing") cleanedMode = "suggesting";
58173
58552
  if (cleanedMode === "viewing") {
@@ -58397,6 +58776,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
58397
58776
  element.style.isolation = "isolate";
58398
58777
  proseMirror.style.outline = "none";
58399
58778
  proseMirror.style.border = "none";
58779
+ element.style.backgroundColor = "#fff";
58780
+ proseMirror.style.backgroundColor = "#fff";
58400
58781
  const { typeface, fontSizePt, fontFamilyCss } = this.converter.getDocumentDefaultStyles() ?? {};
58401
58782
  const resolvedFontFamily = fontFamilyCss || typeface;
58402
58783
  if (resolvedFontFamily) {
@@ -58653,7 +59034,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
58653
59034
  files: this.options.content
58654
59035
  },
58655
59036
  media,
58656
- true
59037
+ true,
59038
+ updatedDocs
58657
59039
  );
58658
59040
  return updatedDocs;
58659
59041
  }
@@ -58719,7 +59101,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
58719
59101
  * @returns {Object | void} Migration results
58720
59102
  */
58721
59103
  processCollaborationMigrations() {
58722
- console.debug("[checkVersionMigrations] Current editor version", "0.20.2");
59104
+ console.debug("[checkVersionMigrations] Current editor version", "0.21.1");
58723
59105
  if (!this.options.ydoc) return;
58724
59106
  const metaMap = this.options.ydoc.getMap("meta");
58725
59107
  let docVersion = metaMap.get("version");
@@ -59139,9 +59521,11 @@ Please report this to https://github.com/markedjs/marked.`, e) {
59139
59521
  isEditMode: false,
59140
59522
  documentMode: this.options.documentMode
59141
59523
  });
59142
- const pm = document.querySelector(".ProseMirror");
59143
- pm.classList.remove("header-footer-edit");
59144
- pm.setAttribute("aria-readonly", false);
59524
+ const pm = this.view?.dom || this.options.element?.querySelector?.(".ProseMirror");
59525
+ if (pm) {
59526
+ pm.classList.remove("header-footer-edit");
59527
+ pm.setAttribute("aria-readonly", false);
59528
+ }
59145
59529
  }
59146
59530
  setWordSelection(view, pos);
59147
59531
  }
@@ -61196,6 +61580,30 @@ Please report this to https://github.com/markedjs/marked.`, e) {
61196
61580
  }
61197
61581
  return result;
61198
61582
  };
61583
+ const isKeyboardInvocation = (event) => {
61584
+ return event.type === "contextmenu" && typeof event.detail === "number" && event.detail === 0 && (event.button === 0 || event.button === void 0) && event.clientX === 0 && event.clientY === 0;
61585
+ };
61586
+ const prefersNativeMenu = (event) => {
61587
+ if (!event) return false;
61588
+ if (event.ctrlKey || event.metaKey) {
61589
+ return true;
61590
+ }
61591
+ return isKeyboardInvocation(event);
61592
+ };
61593
+ const shouldAllowNativeContextMenu = (event) => {
61594
+ return prefersNativeMenu(event);
61595
+ };
61596
+ const shouldBypassContextMenu = shouldAllowNativeContextMenu;
61597
+ const DEFAULT_SELECTION_STATE = Object.freeze({
61598
+ focused: false,
61599
+ preservedSelection: null,
61600
+ showVisualSelection: false,
61601
+ skipFocusReset: false
61602
+ });
61603
+ const normalizeSelectionState = (state2 = {}) => ({
61604
+ ...DEFAULT_SELECTION_STATE,
61605
+ ...state2
61606
+ });
61199
61607
  const CustomSelectionPluginKey = new PluginKey("CustomSelection");
61200
61608
  const handleClickOutside = (event, editor) => {
61201
61609
  const editorElem = editor?.options?.element;
@@ -61233,11 +61641,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
61233
61641
  const customSelectionPlugin = new Plugin({
61234
61642
  key: CustomSelectionPluginKey,
61235
61643
  state: {
61236
- init: () => ({
61237
- focused: false,
61238
- preservedSelection: null,
61239
- showVisualSelection: false
61240
- }),
61644
+ init: () => ({ ...DEFAULT_SELECTION_STATE }),
61241
61645
  apply: (tr, value) => {
61242
61646
  const meta = getFocusMeta(tr);
61243
61647
  if (meta !== void 0) {
@@ -61258,6 +61662,9 @@ Please report this to https://github.com/markedjs/marked.`, e) {
61258
61662
  props: {
61259
61663
  handleDOMEvents: {
61260
61664
  contextmenu: (view, event) => {
61665
+ if (shouldAllowNativeContextMenu(event)) {
61666
+ return false;
61667
+ }
61261
61668
  event.preventDefault();
61262
61669
  const { selection } = view.state;
61263
61670
  if (!selection.empty) {
@@ -61265,7 +61672,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
61265
61672
  setFocusMeta(view.state.tr, {
61266
61673
  focused: true,
61267
61674
  preservedSelection: selection,
61268
- showVisualSelection: true
61675
+ showVisualSelection: true,
61676
+ skipFocusReset: true
61269
61677
  })
61270
61678
  );
61271
61679
  }
@@ -61276,6 +61684,9 @@ Please report this to https://github.com/markedjs/marked.`, e) {
61276
61684
  },
61277
61685
  mousedown: (view, event) => {
61278
61686
  if (event.button === 2) {
61687
+ if (shouldAllowNativeContextMenu(event)) {
61688
+ return false;
61689
+ }
61279
61690
  event.preventDefault();
61280
61691
  const { selection: selection2 } = view.state;
61281
61692
  if (!selection2.empty) {
@@ -61283,7 +61694,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
61283
61694
  setFocusMeta(view.state.tr, {
61284
61695
  focused: true,
61285
61696
  preservedSelection: selection2,
61286
- showVisualSelection: true
61697
+ showVisualSelection: true,
61698
+ skipFocusReset: true
61287
61699
  })
61288
61700
  );
61289
61701
  this.editor.setOptions({
@@ -61306,7 +61718,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
61306
61718
  setFocusMeta(view.state.tr, {
61307
61719
  focused: true,
61308
61720
  preservedSelection: selection,
61309
- showVisualSelection: true
61721
+ showVisualSelection: true,
61722
+ skipFocusReset: false
61310
61723
  })
61311
61724
  );
61312
61725
  this.editor.setOptions({
@@ -61324,7 +61737,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
61324
61737
  setFocusMeta(view.state.tr, {
61325
61738
  focused: true,
61326
61739
  preservedSelection: selection,
61327
- showVisualSelection: true
61740
+ showVisualSelection: true,
61741
+ skipFocusReset: false
61328
61742
  })
61329
61743
  );
61330
61744
  }
@@ -61335,7 +61749,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
61335
61749
  setFocusMeta(view.state.tr, {
61336
61750
  focused: false,
61337
61751
  preservedSelection: null,
61338
- showVisualSelection: false
61752
+ showVisualSelection: false,
61753
+ skipFocusReset: false
61339
61754
  })
61340
61755
  );
61341
61756
  if (!selection.empty && !this.editor.options.element?.contains(target)) {
@@ -61352,12 +61767,20 @@ Please report this to https://github.com/markedjs/marked.`, e) {
61352
61767
  const isElement2 = target instanceof Element;
61353
61768
  const isToolbarBtn = isElement2 && isToolbarButton(target);
61354
61769
  const isToolbarInp = isElement2 && isToolbarInput(target);
61770
+ const focusState = getFocusState(view.state);
61771
+ if (focusState?.skipFocusReset) {
61772
+ view.dispatch(
61773
+ setFocusMeta(view.state.tr, normalizeSelectionState({ ...focusState, skipFocusReset: false }))
61774
+ );
61775
+ return false;
61776
+ }
61355
61777
  if (!isToolbarBtn && !isToolbarInp) {
61356
61778
  view.dispatch(
61357
61779
  setFocusMeta(view.state.tr, {
61358
61780
  focused: false,
61359
61781
  preservedSelection: null,
61360
- showVisualSelection: false
61782
+ showVisualSelection: false,
61783
+ skipFocusReset: false
61361
61784
  })
61362
61785
  );
61363
61786
  }
@@ -61368,12 +61791,16 @@ Please report this to https://github.com/markedjs/marked.`, e) {
61368
61791
  const isToolbarBtn = isElement2 && isToolbarButton(target);
61369
61792
  const isToolbarInp = isElement2 && isToolbarInput(target);
61370
61793
  const state2 = getFocusState(view.state);
61794
+ if (state2?.skipFocusReset) {
61795
+ return false;
61796
+ }
61371
61797
  if (isToolbarBtn || isToolbarInp) {
61372
61798
  view.dispatch(
61373
61799
  setFocusMeta(view.state.tr, {
61374
61800
  focused: true,
61375
61801
  preservedSelection: state2.preservedSelection || view.state.selection,
61376
- showVisualSelection: true
61802
+ showVisualSelection: true,
61803
+ skipFocusReset: false
61377
61804
  })
61378
61805
  );
61379
61806
  } else {
@@ -61381,7 +61808,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
61381
61808
  setFocusMeta(view.state.tr, {
61382
61809
  focused: false,
61383
61810
  preservedSelection: null,
61384
- showVisualSelection: false
61811
+ showVisualSelection: false,
61812
+ skipFocusReset: false
61385
61813
  })
61386
61814
  );
61387
61815
  }
@@ -77156,7 +77584,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
77156
77584
  const prevSelection = prevState.selection;
77157
77585
  if (selection.from !== prevSelection.from || selection.to !== prevSelection.to) {
77158
77586
  setTimeout(() => {
77159
- const selectedResizableWrapper = document.querySelector(".sd-editor-resizable-wrapper");
77587
+ const searchRoot = editorView?.dom;
77588
+ const selectedResizableWrapper = searchRoot?.querySelector(".sd-editor-resizable-wrapper");
77160
77589
  if (selectedResizableWrapper) {
77161
77590
  showResizeHandles(view2, selectedResizableWrapper);
77162
77591
  } else {
@@ -90692,7 +91121,7 @@ ${style2}
90692
91121
  if (!argument) return;
90693
91122
  item.onActivate({ zoom: argument });
90694
91123
  this.emit("superdoc-command", { item, argument });
90695
- const layers = document.querySelector(this.superdoc.config.selector)?.querySelector(".layers");
91124
+ const layers = this.superdoc.element?.querySelector(".layers");
90696
91125
  if (!layers) return;
90697
91126
  const isMobileDevice = typeof screen.orientation !== "undefined";
90698
91127
  const isSmallScreen = window.matchMedia("(max-width: 834px)").matches;
@@ -91267,6 +91696,115 @@ ${style2}
91267
91696
  this.updateToolbarState();
91268
91697
  }
91269
91698
  };
91699
+ const onMarginClickCursorChange = (event, editor) => {
91700
+ const y2 = event.clientY;
91701
+ const x = event.clientX;
91702
+ const { view } = editor;
91703
+ const editorRect = view.dom.getBoundingClientRect();
91704
+ let coords = {
91705
+ left: 0,
91706
+ top: y2
91707
+ };
91708
+ let isRightMargin = false;
91709
+ if (x > editorRect.right) {
91710
+ coords.left = editorRect.left + editorRect.width - 1;
91711
+ isRightMargin = true;
91712
+ } else if (x < editorRect.left) {
91713
+ coords.left = editorRect.left;
91714
+ }
91715
+ const pos = view.posAtCoords(coords)?.pos;
91716
+ if (pos) {
91717
+ let cursorPos = pos;
91718
+ if (isRightMargin) {
91719
+ const $pos = view.state.doc.resolve(pos);
91720
+ const charOffset = $pos.textOffset;
91721
+ const node = view.state.doc.nodeAt(pos);
91722
+ const text = node?.text;
91723
+ const charAtPos = text?.charAt(charOffset);
91724
+ cursorPos = node?.isText && charAtPos !== " " ? pos - 1 : pos;
91725
+ }
91726
+ const transaction = view.state.tr.setSelection(TextSelection$1.create(view.state.doc, cursorPos));
91727
+ view.dispatch(transaction);
91728
+ view.focus();
91729
+ }
91730
+ };
91731
+ const checkNodeSpecificClicks = (editor, event, popoverControls) => {
91732
+ if (!editor) return;
91733
+ if (selectionHasNodeOrMark(editor.view.state, "link", { requireEnds: true })) {
91734
+ popoverControls.component = LinkInput;
91735
+ popoverControls.position = {
91736
+ left: `${event.clientX - editor.element.getBoundingClientRect().left}px`,
91737
+ top: `${event.clientY - editor.element.getBoundingClientRect().top + 15}px`
91738
+ };
91739
+ popoverControls.props = {
91740
+ showInput: true
91741
+ };
91742
+ popoverControls.visible = true;
91743
+ }
91744
+ };
91745
+ function selectionHasNodeOrMark(state2, name, options = {}) {
91746
+ const { requireEnds = false } = options;
91747
+ const $from = state2.selection.$from;
91748
+ const $to = state2.selection.$to;
91749
+ if (requireEnds) {
91750
+ for (let d2 = $from.depth; d2 > 0; d2--) {
91751
+ if ($from.node(d2).type.name === name) {
91752
+ return true;
91753
+ }
91754
+ }
91755
+ for (let d2 = $to.depth; d2 > 0; d2--) {
91756
+ if ($to.node(d2).type.name === name) {
91757
+ return true;
91758
+ }
91759
+ }
91760
+ } else {
91761
+ for (let d2 = $from.depth; d2 > 0; d2--) {
91762
+ if ($from.node(d2).type.name === name) {
91763
+ return true;
91764
+ }
91765
+ }
91766
+ }
91767
+ const markType = state2.schema.marks[name];
91768
+ if (markType) {
91769
+ const { from: from2, to, empty: empty2 } = state2.selection;
91770
+ if (requireEnds) {
91771
+ const fromMarks = markType.isInSet($from.marks());
91772
+ const toMarks = markType.isInSet($to.marks());
91773
+ if (fromMarks || toMarks) {
91774
+ return true;
91775
+ }
91776
+ if (empty2 && markType.isInSet(state2.storedMarks || $from.marks())) {
91777
+ return true;
91778
+ }
91779
+ } else {
91780
+ if (empty2) {
91781
+ if (markType.isInSet(state2.storedMarks || $from.marks())) {
91782
+ return true;
91783
+ }
91784
+ } else {
91785
+ let hasMark = false;
91786
+ state2.doc.nodesBetween(from2, to, (node) => {
91787
+ if (markType.isInSet(node.marks)) {
91788
+ hasMark = true;
91789
+ return false;
91790
+ }
91791
+ });
91792
+ if (hasMark) return true;
91793
+ }
91794
+ }
91795
+ }
91796
+ return false;
91797
+ }
91798
+ function moveCursorToMouseEvent(event, editor) {
91799
+ const { view } = editor;
91800
+ const coords = { left: event.clientX, top: event.clientY };
91801
+ const pos = view.posAtCoords(coords)?.pos;
91802
+ if (typeof pos === "number") {
91803
+ const tr = view.state.tr.setSelection(TextSelection$1.create(view.state.doc, pos));
91804
+ view.dispatch(tr);
91805
+ view.focus();
91806
+ }
91807
+ }
91270
91808
  const ICONS = {
91271
91809
  addRowBefore: plusIconSvg,
91272
91810
  addRowAfter: plusIconSvg,
@@ -91466,6 +92004,30 @@ ${style2}
91466
92004
  return baseProps;
91467
92005
  }
91468
92006
  };
92007
+ function normalizeClipboardContent(rawClipboardContent) {
92008
+ if (!rawClipboardContent) {
92009
+ return {
92010
+ html: null,
92011
+ text: null,
92012
+ hasContent: false,
92013
+ raw: null
92014
+ };
92015
+ }
92016
+ const html = typeof rawClipboardContent.html === "string" ? rawClipboardContent.html : null;
92017
+ const text = typeof rawClipboardContent.text === "string" ? rawClipboardContent.text : null;
92018
+ const hasHtml = !!html && html.trim().length > 0;
92019
+ const hasText = !!text && text.length > 0;
92020
+ const isObject2 = typeof rawClipboardContent === "object" && rawClipboardContent !== null;
92021
+ const fragmentSize = typeof rawClipboardContent.size === "number" ? rawClipboardContent.size : null;
92022
+ const nestedSize = isObject2 && rawClipboardContent.content && typeof rawClipboardContent.content.size === "number" ? rawClipboardContent.content.size : null;
92023
+ const hasFragmentContent = (fragmentSize ?? nestedSize ?? 0) > 0;
92024
+ return {
92025
+ html,
92026
+ text,
92027
+ hasContent: hasHtml || hasText || hasFragmentContent,
92028
+ raw: rawClipboardContent
92029
+ };
92030
+ }
91469
92031
  async function getEditorContext(editor, event) {
91470
92032
  const { view } = editor;
91471
92033
  const { state: state2 } = view;
@@ -91481,123 +92043,144 @@ ${style2}
91481
92043
  pos = from2;
91482
92044
  node = state2.doc.nodeAt(pos);
91483
92045
  }
91484
- const clipboardContent = await readFromClipboard(state2);
92046
+ const rawClipboardContent = await readFromClipboard(state2);
92047
+ const clipboardContent = normalizeClipboardContent(rawClipboardContent);
92048
+ const structureFromResolvedPos = pos !== null ? getStructureFromResolvedPos(state2, pos) : null;
92049
+ const isInTable2 = structureFromResolvedPos?.isInTable ?? selectionHasNodeOrMark(state2, "table", { requireEnds: true });
92050
+ const isInList = structureFromResolvedPos?.isInList ?? (selectionHasNodeOrMark(state2, "bulletList", { requireEnds: false }) || selectionHasNodeOrMark(state2, "orderedList", { requireEnds: false }));
92051
+ const isInSectionNode = structureFromResolvedPos?.isInSectionNode ?? selectionHasNodeOrMark(state2, "documentSection", { requireEnds: true });
92052
+ const currentNodeType = node?.type?.name || null;
92053
+ const activeMarks = [];
92054
+ if (event && pos !== null) {
92055
+ const $pos = state2.doc.resolve(pos);
92056
+ if ($pos.marks && typeof $pos.marks === "function") {
92057
+ $pos.marks().forEach((mark) => activeMarks.push(mark.type.name));
92058
+ }
92059
+ if (node && node.marks) {
92060
+ node.marks.forEach((mark) => activeMarks.push(mark.type.name));
92061
+ }
92062
+ } else {
92063
+ state2.storedMarks?.forEach((mark) => activeMarks.push(mark.type.name));
92064
+ state2.selection.$head.marks().forEach((mark) => activeMarks.push(mark.type.name));
92065
+ }
92066
+ const isTrackedChange = activeMarks.includes("trackInsert") || activeMarks.includes("trackDelete");
92067
+ let trackedChangeId = null;
92068
+ if (isTrackedChange && event && pos !== null) {
92069
+ const $pos = state2.doc.resolve(pos);
92070
+ const marksAtPos = $pos.marks();
92071
+ const trackedMark = marksAtPos.find((mark) => mark.type.name === "trackInsert" || mark.type.name === "trackDelete");
92072
+ if (trackedMark) {
92073
+ trackedChangeId = trackedMark.attrs.id;
92074
+ }
92075
+ }
92076
+ const cursorCoords = pos ? view.coordsAtPos(pos) : null;
92077
+ const cursorPosition = cursorCoords ? {
92078
+ x: cursorCoords.left,
92079
+ y: cursorCoords.top
92080
+ } : null;
91485
92081
  return {
91486
- editor,
92082
+ // Selection info
91487
92083
  selectedText,
92084
+ hasSelection: !empty2,
92085
+ selectionStart: from2,
92086
+ selectionEnd: to,
92087
+ // Document structure
92088
+ isInTable: isInTable2,
92089
+ isInList,
92090
+ isInSectionNode,
92091
+ currentNodeType,
92092
+ activeMarks,
92093
+ // Document state
92094
+ isTrackedChange,
92095
+ trackedChangeId,
92096
+ documentMode: editor.options?.documentMode || "editing",
92097
+ canUndo: computeCanUndo(editor, state2),
92098
+ canRedo: computeCanRedo(editor, state2),
92099
+ isEditable: editor.isEditable,
92100
+ // Clipboard
92101
+ clipboardContent,
92102
+ // Position and trigger info
92103
+ cursorPosition,
91488
92104
  pos,
91489
92105
  node,
91490
92106
  event,
91491
- clipboardContent
92107
+ // Editor reference for advanced use cases
92108
+ editor
91492
92109
  };
91493
92110
  }
91494
- const onMarginClickCursorChange = (event, editor) => {
91495
- const y2 = event.clientY;
91496
- const x = event.clientX;
91497
- const { view } = editor;
91498
- const editorRect = view.dom.getBoundingClientRect();
91499
- let coords = {
91500
- left: 0,
91501
- top: y2
91502
- };
91503
- let isRightMargin = false;
91504
- if (x > editorRect.right) {
91505
- coords.left = editorRect.left + editorRect.width - 1;
91506
- isRightMargin = true;
91507
- } else if (x < editorRect.left) {
91508
- coords.left = editorRect.left;
92111
+ function computeCanUndo(editor, state2) {
92112
+ if (typeof editor?.can === "function") {
92113
+ try {
92114
+ const can = editor.can();
92115
+ if (can && typeof can.undo === "function") {
92116
+ return !!can.undo();
92117
+ }
92118
+ } catch (error) {
92119
+ console.warn("[SlashMenu] Unable to determine undo availability via editor.can():", error);
92120
+ }
91509
92121
  }
91510
- const pos = view.posAtCoords(coords)?.pos;
91511
- if (pos) {
91512
- let cursorPos = pos;
91513
- if (isRightMargin) {
91514
- const $pos = view.state.doc.resolve(pos);
91515
- const charOffset = $pos.textOffset;
91516
- const node = view.state.doc.nodeAt(pos);
91517
- const text = node?.text;
91518
- const charAtPos = text?.charAt(charOffset);
91519
- cursorPos = node?.isText && charAtPos !== " " ? pos - 1 : pos;
92122
+ if (isCollaborationEnabled(editor)) {
92123
+ try {
92124
+ const undoManager = yUndoPluginKey.getState(state2)?.undoManager;
92125
+ return !!undoManager && undoManager.undoStack.length > 0;
92126
+ } catch (error) {
92127
+ console.warn("[SlashMenu] Unable to determine undo availability via y-prosemirror:", error);
91520
92128
  }
91521
- const transaction = view.state.tr.setSelection(TextSelection$1.create(view.state.doc, cursorPos));
91522
- view.dispatch(transaction);
91523
- view.focus();
91524
92129
  }
91525
- };
91526
- const checkNodeSpecificClicks = (editor, event, popoverControls) => {
91527
- if (!editor) return;
91528
- if (selectionHasNodeOrMark(editor.view.state, "link", { requireEnds: true })) {
91529
- popoverControls.component = LinkInput;
91530
- popoverControls.position = {
91531
- left: `${event.clientX - editor.element.getBoundingClientRect().left}px`,
91532
- top: `${event.clientY - editor.element.getBoundingClientRect().top + 15}px`
91533
- };
91534
- popoverControls.props = {
91535
- showInput: true
91536
- };
91537
- popoverControls.visible = true;
92130
+ try {
92131
+ return undoDepth(state2) > 0;
92132
+ } catch (error) {
92133
+ console.warn("[SlashMenu] Unable to determine undo availability via history plugin:", error);
92134
+ return false;
91538
92135
  }
91539
- };
91540
- function selectionHasNodeOrMark(state2, name, options = {}) {
91541
- const { requireEnds = false } = options;
91542
- const $from = state2.selection.$from;
91543
- const $to = state2.selection.$to;
91544
- if (requireEnds) {
91545
- for (let d2 = $from.depth; d2 > 0; d2--) {
91546
- if ($from.node(d2).type.name === name) {
91547
- return true;
91548
- }
91549
- }
91550
- for (let d2 = $to.depth; d2 > 0; d2--) {
91551
- if ($to.node(d2).type.name === name) {
91552
- return true;
91553
- }
91554
- }
91555
- } else {
91556
- for (let d2 = $from.depth; d2 > 0; d2--) {
91557
- if ($from.node(d2).type.name === name) {
91558
- return true;
92136
+ }
92137
+ function computeCanRedo(editor, state2) {
92138
+ if (typeof editor?.can === "function") {
92139
+ try {
92140
+ const can = editor.can();
92141
+ if (can && typeof can.redo === "function") {
92142
+ return !!can.redo();
91559
92143
  }
92144
+ } catch (error) {
92145
+ console.warn("[SlashMenu] Unable to determine redo availability via editor.can():", error);
91560
92146
  }
91561
92147
  }
91562
- const markType = state2.schema.marks[name];
91563
- if (markType) {
91564
- const { from: from2, to, empty: empty2 } = state2.selection;
91565
- if (requireEnds) {
91566
- const fromMarks = markType.isInSet($from.marks());
91567
- const toMarks = markType.isInSet($to.marks());
91568
- if (fromMarks || toMarks) {
91569
- return true;
91570
- }
91571
- if (empty2 && markType.isInSet(state2.storedMarks || $from.marks())) {
91572
- return true;
91573
- }
91574
- } else {
91575
- if (empty2) {
91576
- if (markType.isInSet(state2.storedMarks || $from.marks())) {
91577
- return true;
91578
- }
91579
- } else {
91580
- let hasMark = false;
91581
- state2.doc.nodesBetween(from2, to, (node) => {
91582
- if (markType.isInSet(node.marks)) {
91583
- hasMark = true;
91584
- return false;
91585
- }
91586
- });
91587
- if (hasMark) return true;
91588
- }
92148
+ if (isCollaborationEnabled(editor)) {
92149
+ try {
92150
+ const undoManager = yUndoPluginKey.getState(state2)?.undoManager;
92151
+ return !!undoManager && undoManager.redoStack.length > 0;
92152
+ } catch (error) {
92153
+ console.warn("[SlashMenu] Unable to determine redo availability via y-prosemirror:", error);
91589
92154
  }
91590
92155
  }
91591
- return false;
92156
+ try {
92157
+ return redoDepth(state2) > 0;
92158
+ } catch (error) {
92159
+ console.warn("[SlashMenu] Unable to determine redo availability via history plugin:", error);
92160
+ return false;
92161
+ }
91592
92162
  }
91593
- function moveCursorToMouseEvent(event, editor) {
91594
- const { view } = editor;
91595
- const coords = { left: event.clientX, top: event.clientY };
91596
- const pos = view.posAtCoords(coords)?.pos;
91597
- if (typeof pos === "number") {
91598
- const tr = view.state.tr.setSelection(TextSelection$1.create(view.state.doc, pos));
91599
- view.dispatch(tr);
91600
- view.focus();
92163
+ function isCollaborationEnabled(editor) {
92164
+ return Boolean(editor?.options?.collaborationProvider && editor?.options?.ydoc);
92165
+ }
92166
+ function getStructureFromResolvedPos(state2, pos) {
92167
+ try {
92168
+ const $pos = state2.doc.resolve(pos);
92169
+ const ancestors = /* @__PURE__ */ new Set();
92170
+ for (let depth = $pos.depth; depth > 0; depth--) {
92171
+ ancestors.add($pos.node(depth).type.name);
92172
+ }
92173
+ const isInList = ancestors.has("bulletList") || ancestors.has("orderedList");
92174
+ const isInTable2 = ancestors.has("table") || ancestors.has("tableRow") || ancestors.has("tableCell") || ancestors.has("tableHeader");
92175
+ const isInSectionNode = ancestors.has("documentSection");
92176
+ return {
92177
+ isInTable: isInTable2,
92178
+ isInList,
92179
+ isInSectionNode
92180
+ };
92181
+ } catch (error) {
92182
+ console.warn("[SlashMenu] Unable to resolve position for structural context:", error);
92183
+ return null;
91601
92184
  }
91602
92185
  }
91603
92186
  const isModuleEnabled = (editorOptions, moduleName) => {
@@ -91611,8 +92194,52 @@ ${style2}
91611
92194
  return true;
91612
92195
  }
91613
92196
  };
92197
+ function applyCustomMenuConfiguration(defaultSections, context) {
92198
+ const { editor } = context;
92199
+ const slashMenuConfig = editor.options?.slashMenuConfig;
92200
+ if (!slashMenuConfig) {
92201
+ return defaultSections;
92202
+ }
92203
+ let sections = [];
92204
+ if (slashMenuConfig.includeDefaultItems !== false) {
92205
+ sections = [...defaultSections];
92206
+ }
92207
+ if (slashMenuConfig.customItems && Array.isArray(slashMenuConfig.customItems)) {
92208
+ sections = [...sections, ...slashMenuConfig.customItems];
92209
+ }
92210
+ if (typeof slashMenuConfig.menuProvider === "function") {
92211
+ try {
92212
+ sections = slashMenuConfig.menuProvider(context, sections) || sections;
92213
+ } catch (error) {
92214
+ console.warn("[SlashMenu] Error in custom menuProvider:", error);
92215
+ }
92216
+ }
92217
+ return sections;
92218
+ }
92219
+ function filterCustomItems(sections, context) {
92220
+ return sections.map((section) => {
92221
+ const filteredItems = section.items.filter((item) => {
92222
+ if (typeof item.showWhen === "function") {
92223
+ try {
92224
+ return item.showWhen(context);
92225
+ } catch (error) {
92226
+ console.warn(`[SlashMenu] Error in showWhen for item ${item.id}:`, error);
92227
+ return false;
92228
+ }
92229
+ }
92230
+ return true;
92231
+ });
92232
+ return {
92233
+ ...section,
92234
+ items: filteredItems
92235
+ };
92236
+ }).filter((section) => section.items.length > 0);
92237
+ }
91614
92238
  function getItems(context) {
91615
92239
  const { editor, selectedText, trigger: trigger2, clipboardContent } = context;
92240
+ const clipboardHasContent = Boolean(
92241
+ clipboardContent?.hasContent || clipboardContent?.html || clipboardContent?.text || typeof clipboardContent?.size === "number" && clipboardContent.size > 0 || clipboardContent && typeof clipboardContent?.content?.size === "number" && clipboardContent.content.size > 0 || clipboardContent?.raw && typeof clipboardContent.raw.size === "number" && clipboardContent.raw.size > 0 || clipboardContent?.raw && typeof clipboardContent.raw?.content?.size === "number" && clipboardContent.raw.content.size > 0
92242
+ );
91616
92243
  const isInTable2 = selectionHasNodeOrMark(editor.view.state, "table", { requireEnds: true });
91617
92244
  const isInSectionNode = selectionHasNodeOrMark(editor.view.state, "documentSection", { requireEnds: true });
91618
92245
  const sections = [
@@ -91749,12 +92376,13 @@ ${style2}
91749
92376
  ]
91750
92377
  }
91751
92378
  ];
91752
- const filteredSections = sections.map((section) => {
92379
+ let allSections = applyCustomMenuConfiguration(sections, context);
92380
+ const filteredSections = allSections.map((section) => {
91753
92381
  const filteredItems = section.items.filter((item) => {
91754
92382
  if (item.requiresModule && !isModuleEnabled(editor?.options, item.requiresModule)) return false;
91755
92383
  if (item.requiresSelection && !selectedText) return false;
91756
92384
  if (!item.allowedTriggers.includes(trigger2)) return false;
91757
- if (item.requiresClipboard && !clipboardContent) return false;
92385
+ if (item.requiresClipboard && !clipboardHasContent) return false;
91758
92386
  if (item.requiresTableParent && !isInTable2 || item.id === "insert-table" && isInTable2) return false;
91759
92387
  if (item.requiresSectionParent && !isInSectionNode) return false;
91760
92388
  return true;
@@ -91764,7 +92392,8 @@ ${style2}
91764
92392
  items: filteredItems
91765
92393
  };
91766
92394
  }).filter((section) => section.items.length > 0);
91767
- return filteredSections;
92395
+ const finalSections = filterCustomItems(filteredSections, context);
92396
+ return finalSections;
91768
92397
  }
91769
92398
  const _hoisted_1$3$1 = { class: "slash-menu-items" };
91770
92399
  const _hoisted_2$1$1 = {
@@ -91799,6 +92428,7 @@ ${style2}
91799
92428
  const menuRef = ref$1(null);
91800
92429
  const sections = ref$1([]);
91801
92430
  const selectedId = ref$1(null);
92431
+ const currentContext = ref$1(null);
91802
92432
  const handleEditorUpdate = () => {
91803
92433
  if (!props.editor?.isEditable && isOpen.value) {
91804
92434
  closeMenu({ restoreCursor: false });
@@ -91844,6 +92474,44 @@ ${style2}
91844
92474
  selectedId.value = newItems[0].id;
91845
92475
  }
91846
92476
  });
92477
+ const customItemRefs = /* @__PURE__ */ new Map();
92478
+ const setCustomItemRef = (el, item) => {
92479
+ if (el && item.render) {
92480
+ customItemRefs.set(item.id, { element: el, item });
92481
+ nextTick(() => {
92482
+ renderCustomItem(item.id);
92483
+ });
92484
+ }
92485
+ };
92486
+ const renderCustomItem = async (itemId) => {
92487
+ const refData = customItemRefs.get(itemId);
92488
+ if (!refData || refData.element.hasCustomContent) return;
92489
+ const { element, item } = refData;
92490
+ try {
92491
+ if (!currentContext.value) {
92492
+ currentContext.value = await getEditorContext(props.editor);
92493
+ }
92494
+ const context = currentContext.value;
92495
+ const customElement = item.render(context);
92496
+ if (customElement instanceof HTMLElement) {
92497
+ element.innerHTML = "";
92498
+ element.appendChild(customElement);
92499
+ element.hasCustomContent = true;
92500
+ }
92501
+ } catch (error) {
92502
+ console.warn(`[SlashMenu] Error rendering custom item ${itemId}:`, error);
92503
+ element.innerHTML = `<span>${item.label || "Custom Item"}</span>`;
92504
+ element.hasCustomContent = true;
92505
+ }
92506
+ };
92507
+ const cleanupCustomItems = () => {
92508
+ customItemRefs.forEach((refData) => {
92509
+ if (refData.element) {
92510
+ refData.element.hasCustomContent = false;
92511
+ }
92512
+ });
92513
+ customItemRefs.clear();
92514
+ };
91847
92515
  const handleGlobalKeyDown = (event) => {
91848
92516
  if (event.key === "Escape") {
91849
92517
  event.preventDefault();
@@ -91889,27 +92557,27 @@ ${style2}
91889
92557
  };
91890
92558
  const handleRightClick = async (event) => {
91891
92559
  const readOnly = !props.editor?.isEditable;
91892
- const isHoldingCtrl = event.ctrlKey;
91893
- if (readOnly || isHoldingCtrl) {
92560
+ if (readOnly || shouldBypassContextMenu(event)) {
91894
92561
  return;
91895
92562
  }
91896
92563
  event.preventDefault();
92564
+ const context = await getEditorContext(props.editor, event);
92565
+ currentContext.value = context;
92566
+ sections.value = getItems({ ...context, trigger: "click" });
92567
+ selectedId.value = flattenedItems.value[0]?.id || null;
92568
+ searchQuery.value = "";
91897
92569
  props.editor.view.dispatch(
91898
92570
  props.editor.view.state.tr.setMeta(SlashMenuPluginKey, {
91899
92571
  type: "open",
91900
- pos: props.editor.view.state.selection.from,
92572
+ pos: context?.pos ?? props.editor.view.state.selection.from,
91901
92573
  clientX: event.clientX,
91902
92574
  clientY: event.clientY
91903
92575
  })
91904
92576
  );
91905
- searchQuery.value = "";
91906
- const context = await getEditorContext(props.editor, event);
91907
- sections.value = getItems({ ...context, trigger: "click" });
91908
- selectedId.value = flattenedItems.value[0]?.id || null;
91909
92577
  };
91910
92578
  const executeCommand = async (item) => {
91911
92579
  if (props.editor) {
91912
- item.action ? await item.action(props.editor) : null;
92580
+ item.action ? await item.action(props.editor, currentContext.value) : null;
91913
92581
  if (item.component) {
91914
92582
  menuRef.value;
91915
92583
  const componentProps = getPropsByItemId(item.id, props);
@@ -91927,7 +92595,7 @@ ${style2}
91927
92595
  const closeMenu = (options = { restoreCursor: true }) => {
91928
92596
  if (props.editor?.view) {
91929
92597
  const pluginState = SlashMenuPluginKey.getState(props.editor.view.state);
91930
- const { anchorPos } = pluginState;
92598
+ const anchorPos = pluginState?.anchorPos;
91931
92599
  props.editor.view.dispatch(
91932
92600
  props.editor.view.state.tr.setMeta(SlashMenuPluginKey, {
91933
92601
  type: "close"
@@ -91940,6 +92608,8 @@ ${style2}
91940
92608
  props.editor.view.dispatch(tr);
91941
92609
  props.editor.view.focus();
91942
92610
  }
92611
+ cleanupCustomItems();
92612
+ currentContext.value = null;
91943
92613
  isOpen.value = false;
91944
92614
  searchQuery.value = "";
91945
92615
  sections.value = [];
@@ -91956,19 +92626,29 @@ ${style2}
91956
92626
  isOpen.value = true;
91957
92627
  menuPosition.value = event.menuPosition;
91958
92628
  searchQuery.value = "";
91959
- const context = await getEditorContext(props.editor);
91960
- sections.value = getItems({ ...context, trigger: "slash" });
91961
- selectedId.value = flattenedItems.value[0]?.id || null;
92629
+ if (!currentContext.value) {
92630
+ const context = await getEditorContext(props.editor);
92631
+ currentContext.value = context;
92632
+ sections.value = getItems({ ...context, trigger: "slash" });
92633
+ selectedId.value = flattenedItems.value[0]?.id || null;
92634
+ } else if (sections.value.length === 0) {
92635
+ const trigger2 = currentContext.value.event?.type === "contextmenu" ? "click" : "slash";
92636
+ sections.value = getItems({ ...currentContext.value, trigger: trigger2 });
92637
+ selectedId.value = flattenedItems.value[0]?.id || null;
92638
+ }
91962
92639
  });
91963
92640
  props.editor.view.dom.addEventListener("contextmenu", handleRightClick);
91964
92641
  props.editor.on("slashMenu:close", () => {
92642
+ cleanupCustomItems();
91965
92643
  isOpen.value = false;
91966
92644
  searchQuery.value = "";
92645
+ currentContext.value = null;
91967
92646
  });
91968
92647
  });
91969
92648
  onBeforeUnmount(() => {
91970
92649
  document.removeEventListener("keydown", handleGlobalKeyDown);
91971
92650
  document.removeEventListener("mousedown", handleGlobalOutsideClick);
92651
+ cleanupCustomItems();
91972
92652
  if (props.editor) {
91973
92653
  try {
91974
92654
  props.editor.off("slashMenu:open");
@@ -92015,12 +92695,19 @@ ${style2}
92015
92695
  class: normalizeClass(["slash-menu-item", { "is-selected": item.id === selectedId.value }]),
92016
92696
  onClick: ($event) => executeCommand(item)
92017
92697
  }, [
92018
- item.icon ? (openBlock(), createElementBlock("span", {
92698
+ item.render ? (openBlock(), createElementBlock("div", {
92019
92699
  key: 0,
92020
- class: "slash-menu-item-icon",
92021
- innerHTML: item.icon
92022
- }, null, 8, _hoisted_4$5)) : createCommentVNode("", true),
92023
- createBaseVNode("span", null, toDisplayString(item.label), 1)
92700
+ ref_for: true,
92701
+ ref: (el) => setCustomItemRef(el, item),
92702
+ class: "slash-menu-custom-item"
92703
+ }, null, 512)) : (openBlock(), createElementBlock(Fragment$1, { key: 1 }, [
92704
+ item.icon ? (openBlock(), createElementBlock("span", {
92705
+ key: 0,
92706
+ class: "slash-menu-item-icon",
92707
+ innerHTML: item.icon
92708
+ }, null, 8, _hoisted_4$5)) : createCommentVNode("", true),
92709
+ createBaseVNode("span", null, toDisplayString(item.label), 1)
92710
+ ], 64))
92024
92711
  ], 10, _hoisted_3$1$1);
92025
92712
  }), 128))
92026
92713
  ], 64);
@@ -92715,34 +93402,76 @@ ${style2}
92715
93402
  }
92716
93403
  };
92717
93404
  const SuperInput = /* @__PURE__ */ _export_sfc$1(_sfc_main$i, [["__scopeId", "data-v-4d5cff52"]]);
93405
+ const additionalHandlers = Object.freeze({
93406
+ "mc:AlternateContent": translator,
93407
+ "w:b": translator$12,
93408
+ "w:bidiVisual": translator$F,
93409
+ "w:bookmarkEnd": translator$1,
93410
+ "w:bookmarkStart": translator$2,
93411
+ "w:bottom": translator$s,
93412
+ "w:br": translator$16,
93413
+ "w:cantSplit": translator$T,
93414
+ "w:cnfStyle": translator$S,
93415
+ "w:color": translator$_,
93416
+ "w:divId": translator$R,
93417
+ "w:drawing": translator$4,
93418
+ "w:end": translator$q,
93419
+ "w:gridAfter": translator$Q,
93420
+ "w:gridBefore": translator$P,
93421
+ "w:gridCol": translator$b,
93422
+ "w:hidden": translator$O,
93423
+ "w:highlight": translator$15,
93424
+ "w:hyperlink": translator$7,
93425
+ "w:i": translator$11,
93426
+ "w:insideH": translator$o,
93427
+ "w:insideV": translator$n,
93428
+ "w:jc": translator$N,
93429
+ "w:left": translator$m,
93430
+ "w:p": translator$13,
93431
+ "w:r": translator$U,
93432
+ "w:rFonts": translator$Z,
93433
+ "w:rPr": translator$V,
93434
+ "w:rStyle": translator$Y,
93435
+ "w:right": translator$k,
93436
+ "w:sdt": translator$3,
93437
+ "w:shd": translator$E,
93438
+ "w:start": translator$i,
93439
+ "w:strike": translator$$,
93440
+ "w:sz": translator$X,
93441
+ "w:szCs": translator$W,
93442
+ "w:tab": translator$14,
93443
+ "w:tbl": translator$9,
93444
+ "w:tblBorders": translator$e,
93445
+ "w:tblCaption": translator$D,
93446
+ "w:tblCellMar": translator$d,
93447
+ "w:tblCellSpacing": translator$M,
93448
+ "w:tblDescription": translator$C,
93449
+ "w:tblGrid": translator$a,
93450
+ "w:tblHeader": translator$L,
93451
+ "w:tblInd": translator$B,
93452
+ "w:tblLayout": translator$A,
93453
+ "w:tblLook": translator$z,
93454
+ "w:tblOverlap": translator$y,
93455
+ "w:tblPr": translator$c,
93456
+ "w:tblStyle": translator$x,
93457
+ "w:tblStyleColBandSize": translator$w,
93458
+ "w:tblStyleRowBandSize": translator$v,
93459
+ "w:tblW": translator$u,
93460
+ "w:tblpPr": translator$t,
93461
+ "w:tc": translator$8,
93462
+ "w:top": translator$g,
93463
+ "w:tr": translator$G,
93464
+ "w:trHeight": translator$K,
93465
+ "w:trPr": translator$H,
93466
+ "w:u": translator$10,
93467
+ "w:wAfter": translator$J,
93468
+ "w:wBefore": translator$I,
93469
+ "wp:anchor": translator$6,
93470
+ "wp:inline": translator$5
93471
+ });
92718
93472
  const baseHandlers = {
92719
93473
  ...runPropertyTranslators,
92720
- "w:br": translator$15,
92721
- "w:cantSplit": translator$S,
92722
- "w:cnfStyle": translator$R,
92723
- "w:divId": translator$Q,
92724
- "w:gridAfter": translator$P,
92725
- "w:gridBefore": translator$O,
92726
- "w:hidden": translator$N,
92727
- "w:hyperlink": translator$6,
92728
- "w:jc": translator$M,
92729
- "w:p": translator$12,
92730
- "w:r": translator$T,
92731
- "w:rPr": translator$U,
92732
- "w:sdt": translator$2,
92733
- "w:tab": translator$13,
92734
- "w:tblCellSpacing": translator$L,
92735
- "w:tblHeader": translator$K,
92736
- "w:tc": translator$7,
92737
- "w:tr": translator$F,
92738
- "w:trHeight": translator$J,
92739
- "w:trPr": translator$G,
92740
- "w:wAfter": translator$I,
92741
- "w:wBefore": translator$H,
92742
- "wp:anchor": translator$5,
92743
- "wp:inline": translator$4,
92744
- "w:bookmarkStart": translator$1,
92745
- "w:bookmarkEnd": translator
93474
+ ...additionalHandlers
92746
93475
  };
92747
93476
  const registeredHandlers = Object.freeze(baseHandlers);
92748
93477
  const Extensions = {
@@ -109582,6 +110311,7 @@ ${style2}
109582
110311
  annotations: proxy.$superdoc.config.annotations,
109583
110312
  isCommentsEnabled: proxy.$superdoc.config.modules?.comments,
109584
110313
  isAiEnabled: proxy.$superdoc.config.modules?.ai,
110314
+ slashMenuConfig: proxy.$superdoc.config.modules?.slashMenu,
109585
110315
  onBeforeCreate: onEditorBeforeCreate,
109586
110316
  onCreate: onEditorCreate,
109587
110317
  onDestroy: onEditorDestroy,
@@ -109943,7 +110673,7 @@ ${style2}
109943
110673
  };
109944
110674
  }
109945
110675
  };
109946
- const App = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-07532c12"]]);
110676
+ const App = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-dbfba5b9"]]);
109947
110677
  const createSuperdocVueApp = () => {
109948
110678
  const app = createApp(App);
109949
110679
  const pinia = createPinia();
@@ -110045,7 +110775,7 @@ ${style2}
110045
110775
  this.config.colors = shuffleArray(this.config.colors);
110046
110776
  this.userColorMap = /* @__PURE__ */ new Map();
110047
110777
  this.colorIndex = 0;
110048
- this.version = "0.20.2";
110778
+ this.version = "0.21.1";
110049
110779
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
110050
110780
  this.superdocId = config2.superdocId || v4();
110051
110781
  this.colors = this.config.colors;
@@ -110060,6 +110790,9 @@ ${style2}
110060
110790
  this.isDev = this.config.isDev || false;
110061
110791
  this.activeEditor = null;
110062
110792
  this.comments = [];
110793
+ if (!this.config.selector) {
110794
+ throw new Error("SuperDoc: selector is required");
110795
+ }
110063
110796
  this.app.mount(this.config.selector);
110064
110797
  this.readyEditors = 0;
110065
110798
  this.isLocked = this.config.isLocked || false;
@@ -110079,6 +110812,16 @@ ${style2}
110079
110812
  users: this.users
110080
110813
  };
110081
110814
  }
110815
+ /**
110816
+ * Get the SuperDoc container element
110817
+ * @returns {HTMLElement | null}
110818
+ */
110819
+ get element() {
110820
+ if (typeof this.config.selector === "string") {
110821
+ return document.querySelector(this.config.selector);
110822
+ }
110823
+ return this.config.selector;
110824
+ }
110082
110825
  #patchNaiveUIStyles() {
110083
110826
  const cspNonce = this.config.cspNonce;
110084
110827
  const originalCreateElement = document.createElement;
@@ -110102,10 +110845,16 @@ ${style2}
110102
110845
  }
110103
110846
  if (hasDocumentConfig) {
110104
110847
  const normalized = normalizeDocumentEntry(this.config.document);
110105
- this.config.documents = [normalized];
110848
+ this.config.documents = [
110849
+ {
110850
+ id: v4(),
110851
+ ...normalized
110852
+ }
110853
+ ];
110106
110854
  } else if (hasDocumentUrl) {
110107
110855
  this.config.documents = [
110108
110856
  {
110857
+ id: v4(),
110109
110858
  type: DOCX,
110110
110859
  url: this.config.document,
110111
110860
  name: "document.docx",
@@ -110113,33 +110862,34 @@ ${style2}
110113
110862
  }
110114
110863
  ];
110115
110864
  } else if (hasDocumentFile) {
110865
+ const normalized = normalizeDocumentEntry(this.config.document);
110116
110866
  this.config.documents = [
110117
110867
  {
110118
- type: this.config.document.type,
110119
- data: this.config.document,
110120
- name: this.config.document.name,
110121
- isNewFile: true
110868
+ id: v4(),
110869
+ ...normalized
110122
110870
  }
110123
110871
  ];
110124
110872
  } else if (hasDocumentBlob) {
110125
- const docType = this.config.document.type || DOCX;
110126
- let extension = ".docx";
110127
- if (docType === PDF) {
110128
- extension = ".pdf";
110129
- } else if (docType === HTML) {
110130
- extension = ".html";
110131
- }
110873
+ const normalized = normalizeDocumentEntry(this.config.document);
110132
110874
  this.config.documents = [
110133
110875
  {
110134
- type: docType,
110135
- data: this.config.document,
110136
- name: `document${extension}`,
110137
- isNewFile: true
110876
+ id: v4(),
110877
+ ...normalized
110138
110878
  }
110139
110879
  ];
110140
110880
  }
110141
110881
  if (Array.isArray(this.config.documents) && this.config.documents.length > 0) {
110142
- this.config.documents = this.config.documents.map((d2) => normalizeDocumentEntry(d2));
110882
+ this.config.documents = this.config.documents.map((d2) => {
110883
+ const normalized = normalizeDocumentEntry(d2);
110884
+ if (!normalized || typeof normalized !== "object") {
110885
+ return normalized;
110886
+ }
110887
+ const existingId = typeof normalized === "object" && "id" in normalized && normalized.id || d2 && typeof d2 === "object" && "id" in d2 && d2.id;
110888
+ return {
110889
+ ...normalized,
110890
+ id: existingId || v4()
110891
+ };
110892
+ });
110143
110893
  }
110144
110894
  }
110145
110895
  #initVueApp() {