@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
@@ -24316,37 +24316,37 @@ const _NodeTranslator = class _NodeTranslator2 {
24316
24316
  };
24317
24317
  __publicField$2(_NodeTranslator, "translatorTypes", TranslatorTypes);
24318
24318
  let NodeTranslator = _NodeTranslator;
24319
- const encode$17 = (attributes) => {
24319
+ const encode$18 = (attributes) => {
24320
24320
  return attributes["w:type"];
24321
24321
  };
24322
- const decode$_ = (attrs) => {
24322
+ const decode$$ = (attrs) => {
24323
24323
  const { lineBreakType } = attrs;
24324
24324
  return lineBreakType;
24325
24325
  };
24326
24326
  const attrConfig$F = Object.freeze({
24327
24327
  xmlName: "w:type",
24328
24328
  sdName: "lineBreakType",
24329
- encode: encode$17,
24330
- decode: decode$_
24329
+ encode: encode$18,
24330
+ decode: decode$$
24331
24331
  });
24332
- const encode$16 = (attributes) => {
24332
+ const encode$17 = (attributes) => {
24333
24333
  const xmlAttrValue = attributes["w:clear"];
24334
24334
  return xmlAttrValue;
24335
24335
  };
24336
- const decode$Z = (attrs) => {
24336
+ const decode$_ = (attrs) => {
24337
24337
  const { clear } = attrs;
24338
24338
  return clear;
24339
24339
  };
24340
24340
  const attrConfig$E = Object.freeze({
24341
24341
  xmlName: "w:clear",
24342
24342
  sdName: "clear",
24343
- encode: encode$16,
24344
- decode: decode$Z
24343
+ encode: encode$17,
24344
+ decode: decode$_
24345
24345
  });
24346
- const validXmlAttributes$l = [attrConfig$F, attrConfig$E];
24347
- const XML_NODE_NAME$t = "w:br";
24348
- const SD_NODE_NAME$c = "lineBreak";
24349
- const encode$15 = (_2, encodedAttrs) => {
24346
+ const validXmlAttributes$m = [attrConfig$F, attrConfig$E];
24347
+ const XML_NODE_NAME$u = "w:br";
24348
+ const SD_NODE_NAME$d = "lineBreak";
24349
+ const encode$16 = (_2, encodedAttrs) => {
24350
24350
  const isPageBreak = encodedAttrs?.lineBreakType === "page";
24351
24351
  const translated = {
24352
24352
  type: isPageBreak ? "hardBreak" : "lineBreak"
@@ -24356,7 +24356,7 @@ const encode$15 = (_2, encodedAttrs) => {
24356
24356
  }
24357
24357
  return translated;
24358
24358
  };
24359
- const decode$Y = (params2, decodedAttrs) => {
24359
+ const decode$Z = (params2, decodedAttrs) => {
24360
24360
  const { node } = params2;
24361
24361
  if (!node) return;
24362
24362
  const wBreak = { name: "w:br" };
@@ -24373,39 +24373,39 @@ const decode$Y = (params2, decodedAttrs) => {
24373
24373
  };
24374
24374
  return translated;
24375
24375
  };
24376
- const config$r = {
24377
- xmlName: XML_NODE_NAME$t,
24378
- sdNodeOrKeyName: SD_NODE_NAME$c,
24376
+ const config$s = {
24377
+ xmlName: XML_NODE_NAME$u,
24378
+ sdNodeOrKeyName: SD_NODE_NAME$d,
24379
24379
  type: NodeTranslator.translatorTypes.NODE,
24380
- encode: encode$15,
24381
- decode: decode$Y,
24382
- attributes: validXmlAttributes$l
24380
+ encode: encode$16,
24381
+ decode: decode$Z,
24382
+ attributes: validXmlAttributes$m
24383
24383
  };
24384
- const translator$15 = NodeTranslator.from(config$r);
24385
- const encode$14 = (attributes) => attributes?.["w:val"];
24386
- const decode$X = (attrs) => attrs?.highlight;
24384
+ const translator$16 = NodeTranslator.from(config$s);
24385
+ const encode$15 = (attributes) => attributes?.["w:val"];
24386
+ const decode$Y = (attrs) => attrs?.highlight;
24387
24387
  const attrConfig$D = Object.freeze({
24388
24388
  xmlName: "w:val",
24389
24389
  sdName: "highlight",
24390
- encode: encode$14,
24391
- decode: decode$X
24390
+ encode: encode$15,
24391
+ decode: decode$Y
24392
24392
  });
24393
- const validXmlAttributes$k = [attrConfig$D];
24394
- const XML_NODE_NAME$s = "w:highlight";
24393
+ const validXmlAttributes$l = [attrConfig$D];
24394
+ const XML_NODE_NAME$t = "w:highlight";
24395
24395
  const SD_ATTR_KEY$f = "highlight";
24396
24396
  const DISABLED_TOKENS = /* @__PURE__ */ new Set(["transparent", "none", "inherit"]);
24397
- const encode$13 = (params2, encodedAttrs = {}) => {
24397
+ const encode$14 = (params2, encodedAttrs = {}) => {
24398
24398
  const { nodes } = params2;
24399
24399
  const node = nodes?.[0];
24400
24400
  const value = encodedAttrs.highlight ?? node?.attributes?.["w:val"];
24401
24401
  return {
24402
24402
  type: "attr",
24403
- xmlName: XML_NODE_NAME$s,
24403
+ xmlName: XML_NODE_NAME$t,
24404
24404
  sdNodeOrKeyName: SD_ATTR_KEY$f,
24405
24405
  attributes: { "w:val": value ?? null }
24406
24406
  };
24407
24407
  };
24408
- const decode$W = (params2) => {
24408
+ const decode$X = (params2) => {
24409
24409
  const attrs = params2?.node?.attrs || {};
24410
24410
  const highlightValue = attrs.highlight ?? attrs.color ?? null;
24411
24411
  if (!highlightValue) return void 0;
@@ -24413,14 +24413,14 @@ const decode$W = (params2) => {
24413
24413
  if (!normalizedValue) return void 0;
24414
24414
  if (DISABLED_TOKENS.has(normalizedValue)) {
24415
24415
  return {
24416
- name: XML_NODE_NAME$s,
24416
+ name: XML_NODE_NAME$t,
24417
24417
  attributes: { "w:val": "none" }
24418
24418
  };
24419
24419
  }
24420
24420
  const keyword = getDocxHighlightKeywordFromHex(highlightValue);
24421
24421
  if (keyword) {
24422
24422
  return {
24423
- name: XML_NODE_NAME$s,
24423
+ name: XML_NODE_NAME$t,
24424
24424
  attributes: { "w:val": keyword }
24425
24425
  };
24426
24426
  }
@@ -24435,63 +24435,63 @@ const decode$W = (params2) => {
24435
24435
  }
24436
24436
  };
24437
24437
  };
24438
- const config$q = {
24439
- xmlName: XML_NODE_NAME$s,
24438
+ const config$r = {
24439
+ xmlName: XML_NODE_NAME$t,
24440
24440
  sdNodeOrKeyName: SD_ATTR_KEY$f,
24441
24441
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
24442
- encode: encode$13,
24443
- decode: decode$W,
24444
- attributes: validXmlAttributes$k
24442
+ encode: encode$14,
24443
+ decode: decode$X,
24444
+ attributes: validXmlAttributes$l
24445
24445
  };
24446
- const translator$14 = NodeTranslator.from(config$q);
24447
- const encode$12 = (attributes) => {
24446
+ const translator$15 = NodeTranslator.from(config$r);
24447
+ const encode$13 = (attributes) => {
24448
24448
  return attributes["w:val"];
24449
24449
  };
24450
- const decode$V = (attrs) => {
24450
+ const decode$W = (attrs) => {
24451
24451
  const { tabSize } = attrs || {};
24452
24452
  return tabSize;
24453
24453
  };
24454
24454
  const attrConfig$C = Object.freeze({
24455
24455
  xmlName: "w:val",
24456
24456
  sdName: "tabSize",
24457
- encode: encode$12,
24458
- decode: decode$V
24457
+ encode: encode$13,
24458
+ decode: decode$W
24459
24459
  });
24460
- const encode$11 = (attributes) => {
24460
+ const encode$12 = (attributes) => {
24461
24461
  return attributes["w:leader"];
24462
24462
  };
24463
- const decode$U = (attrs) => {
24463
+ const decode$V = (attrs) => {
24464
24464
  const { leader } = attrs || {};
24465
24465
  return leader;
24466
24466
  };
24467
24467
  const attrConfig$B = Object.freeze({
24468
24468
  xmlName: "w:leader",
24469
24469
  sdName: "leader",
24470
- encode: encode$11,
24471
- decode: decode$U
24470
+ encode: encode$12,
24471
+ decode: decode$V
24472
24472
  });
24473
- const encode$10 = (attributes) => {
24473
+ const encode$11 = (attributes) => {
24474
24474
  return attributes["w:pos"];
24475
24475
  };
24476
- const decode$T = (attrs) => {
24476
+ const decode$U = (attrs) => {
24477
24477
  const { pos } = attrs || {};
24478
24478
  return pos;
24479
24479
  };
24480
24480
  const attrConfig$A = Object.freeze({
24481
24481
  xmlName: "w:pos",
24482
24482
  sdName: "pos",
24483
- encode: encode$10,
24484
- decode: decode$T
24483
+ encode: encode$11,
24484
+ decode: decode$U
24485
24485
  });
24486
- const validXmlAttributes$j = [attrConfig$C, attrConfig$A, attrConfig$B];
24487
- const XML_NODE_NAME$r = "w:tab";
24488
- const SD_NODE_NAME$b = "tab";
24489
- const encode$$ = (_2, encodedAttrs = {}) => {
24486
+ const validXmlAttributes$k = [attrConfig$C, attrConfig$A, attrConfig$B];
24487
+ const XML_NODE_NAME$s = "w:tab";
24488
+ const SD_NODE_NAME$c = "tab";
24489
+ const encode$10 = (_2, encodedAttrs = {}) => {
24490
24490
  const translated = { type: "tab" };
24491
24491
  if (encodedAttrs) translated.attrs = { ...encodedAttrs };
24492
24492
  return translated;
24493
24493
  };
24494
- const decode$S = (params2, decodedAttrs = {}) => {
24494
+ const decode$T = (params2, decodedAttrs = {}) => {
24495
24495
  const { node } = params2 || {};
24496
24496
  if (!node) return;
24497
24497
  const wTab = { name: "w:tab" };
@@ -24507,15 +24507,15 @@ const decode$S = (params2, decodedAttrs = {}) => {
24507
24507
  }
24508
24508
  return translated;
24509
24509
  };
24510
- const config$p = {
24511
- xmlName: XML_NODE_NAME$r,
24512
- sdNodeOrKeyName: SD_NODE_NAME$b,
24510
+ const config$q = {
24511
+ xmlName: XML_NODE_NAME$s,
24512
+ sdNodeOrKeyName: SD_NODE_NAME$c,
24513
24513
  type: NodeTranslator.translatorTypes.NODE,
24514
- encode: encode$$,
24515
- decode: decode$S,
24516
- attributes: validXmlAttributes$j
24514
+ encode: encode$10,
24515
+ decode: decode$T,
24516
+ attributes: validXmlAttributes$k
24517
24517
  };
24518
- const translator$13 = NodeTranslator.from(config$p);
24518
+ const translator$14 = NodeTranslator.from(config$q);
24519
24519
  const mergeTextNodes = (nodes) => {
24520
24520
  if (!nodes || !Array.isArray(nodes)) {
24521
24521
  return nodes;
@@ -24839,17 +24839,16 @@ const getParagraphSpacing = (node, docx, styleId = "", marks = [], options = {})
24839
24839
  };
24840
24840
  const getDefaultParagraphStyle = (docx, styleId = "") => {
24841
24841
  const styles = docx["word/styles.xml"];
24842
- if (!styles) {
24842
+ const rootElements = styles?.elements?.[0]?.elements;
24843
+ if (!rootElements?.length) {
24843
24844
  return {};
24844
24845
  }
24845
- const defaults = styles.elements[0].elements?.find((el) => el.name === "w:docDefaults");
24846
- const pDefault = defaults.elements.find((el) => el.name === "w:pPrDefault");
24846
+ const defaults = rootElements.find((el) => el.name === "w:docDefaults");
24847
+ const pDefault = defaults?.elements?.find((el) => el.name === "w:pPrDefault") || {};
24847
24848
  const pPrDefault = pDefault?.elements?.find((el) => el.name === "w:pPr");
24848
24849
  const pPrDefaultSpacingTag = pPrDefault?.elements?.find((el) => el.name === "w:spacing") || {};
24849
24850
  const pPrDefaultIndentTag = pPrDefault?.elements?.find((el) => el.name === "w:ind") || {};
24850
- const stylesNormal = styles.elements[0].elements?.find(
24851
- (el) => el.name === "w:style" && el.attributes["w:styleId"] === "Normal"
24852
- );
24851
+ const stylesNormal = rootElements.find((el) => el.name === "w:style" && el.attributes["w:styleId"] === "Normal");
24853
24852
  const pPrNormal = stylesNormal?.elements?.find((el) => el.name === "w:pPr");
24854
24853
  const pPrNormalSpacingTag = pPrNormal?.elements?.find((el) => el.name === "w:spacing") || {};
24855
24854
  const pPrNormalIndentTag = pPrNormal?.elements?.find((el) => el.name === "w:ind") || {};
@@ -24858,9 +24857,7 @@ const getDefaultParagraphStyle = (docx, styleId = "") => {
24858
24857
  let pPrStyleIdIndentTag = {};
24859
24858
  let pPrStyleJc = {};
24860
24859
  if (styleId) {
24861
- const stylesById = styles.elements[0].elements?.find(
24862
- (el) => el.name === "w:style" && el.attributes["w:styleId"] === styleId
24863
- );
24860
+ const stylesById = rootElements.find((el) => el.name === "w:style" && el.attributes["w:styleId"] === styleId);
24864
24861
  const pPrById = stylesById?.elements?.find((el) => el.name === "w:pPr");
24865
24862
  pPrStyleIdSpacingTag = pPrById?.elements?.find((el) => el.name === "w:spacing") || {};
24866
24863
  pPrStyleIdIndentTag = pPrById?.elements?.find((el) => el.name === "w:ind") || {};
@@ -25130,91 +25127,91 @@ const handleParagraphNode$1 = (params2) => {
25130
25127
  }
25131
25128
  return schemaNode;
25132
25129
  };
25133
- const encode$_ = (attributes) => {
25130
+ const encode$$ = (attributes) => {
25134
25131
  return attributes["w:rsidDel"];
25135
25132
  };
25136
- const decode$R = (attrs) => {
25133
+ const decode$S = (attrs) => {
25137
25134
  return attrs.rsidDel;
25138
25135
  };
25139
25136
  const attrConfig$z = Object.freeze({
25140
25137
  xmlName: "w:rsidDel",
25141
25138
  sdName: "rsidDel",
25142
- encode: encode$_,
25143
- decode: decode$R
25139
+ encode: encode$$,
25140
+ decode: decode$S
25144
25141
  });
25145
- const encode$Z = (attributes) => {
25142
+ const encode$_ = (attributes) => {
25146
25143
  return attributes["w:rsidP"];
25147
25144
  };
25148
- const decode$Q = (attrs) => {
25145
+ const decode$R = (attrs) => {
25149
25146
  return attrs.rsidP;
25150
25147
  };
25151
25148
  const attrConfig$y = Object.freeze({
25152
25149
  xmlName: "w:rsidP",
25153
25150
  sdName: "rsidP",
25154
- encode: encode$Z,
25155
- decode: decode$Q
25151
+ encode: encode$_,
25152
+ decode: decode$R
25156
25153
  });
25157
- const encode$Y = (attributes) => {
25154
+ const encode$Z = (attributes) => {
25158
25155
  return attributes["w:rsidR"];
25159
25156
  };
25160
- const decode$P = (attrs) => {
25157
+ const decode$Q = (attrs) => {
25161
25158
  return attrs.rsidR;
25162
25159
  };
25163
25160
  const attrConfig$x = Object.freeze({
25164
25161
  xmlName: "w:rsidR",
25165
25162
  sdName: "rsidR",
25166
- encode: encode$Y,
25167
- decode: decode$P
25163
+ encode: encode$Z,
25164
+ decode: decode$Q
25168
25165
  });
25169
- const encode$X = (attributes) => {
25166
+ const encode$Y = (attributes) => {
25170
25167
  return attributes["w:rsidRPr"];
25171
25168
  };
25172
- const decode$O = (attrs) => {
25169
+ const decode$P = (attrs) => {
25173
25170
  return attrs.rsidRPr;
25174
25171
  };
25175
25172
  const attrConfig$w = Object.freeze({
25176
25173
  xmlName: "w:rsidRPr",
25177
25174
  sdName: "rsidRPr",
25178
- encode: encode$X,
25179
- decode: decode$O
25175
+ encode: encode$Y,
25176
+ decode: decode$P
25180
25177
  });
25181
- const encode$W = (attributes) => {
25178
+ const encode$X = (attributes) => {
25182
25179
  return attributes["w:rsidRDefault"];
25183
25180
  };
25184
- const decode$N = (attrs) => {
25181
+ const decode$O = (attrs) => {
25185
25182
  return attrs.rsidRDefault;
25186
25183
  };
25187
25184
  const attrConfig$v = Object.freeze({
25188
25185
  xmlName: "w:rsidRDefault",
25189
25186
  sdName: "rsidRDefault",
25190
- encode: encode$W,
25191
- decode: decode$N
25187
+ encode: encode$X,
25188
+ decode: decode$O
25192
25189
  });
25193
- const encode$V = (attributes) => {
25190
+ const encode$W = (attributes) => {
25194
25191
  return attributes["w14:paraId"];
25195
25192
  };
25196
- const decode$M = (attrs) => {
25193
+ const decode$N = (attrs) => {
25197
25194
  return attrs.paraId;
25198
25195
  };
25199
25196
  const attrConfig$u = Object.freeze({
25200
25197
  xmlName: "w14:paraId",
25201
25198
  sdName: "paraId",
25202
- encode: encode$V,
25203
- decode: decode$M
25199
+ encode: encode$W,
25200
+ decode: decode$N
25204
25201
  });
25205
- const encode$U = (attributes) => {
25202
+ const encode$V = (attributes) => {
25206
25203
  return attributes["w14:textId"];
25207
25204
  };
25208
- const decode$L = (attrs) => {
25205
+ const decode$M = (attrs) => {
25209
25206
  return attrs.textId;
25210
25207
  };
25211
25208
  const attrConfig$t = Object.freeze({
25212
25209
  xmlName: "w14:textId",
25213
25210
  sdName: "textId",
25214
- encode: encode$U,
25215
- decode: decode$L
25211
+ encode: encode$V,
25212
+ decode: decode$M
25216
25213
  });
25217
- const validXmlAttributes$i = [
25214
+ const validXmlAttributes$j = [
25218
25215
  attrConfig$u,
25219
25216
  attrConfig$t,
25220
25217
  attrConfig$x,
@@ -25223,9 +25220,9 @@ const validXmlAttributes$i = [
25223
25220
  attrConfig$w,
25224
25221
  attrConfig$z
25225
25222
  ];
25226
- const XML_NODE_NAME$q = "w:p";
25227
- const SD_NODE_NAME$a = "paragraph";
25228
- const encode$T = (params2, encodedAttrs = {}) => {
25223
+ const XML_NODE_NAME$r = "w:p";
25224
+ const SD_NODE_NAME$b = "paragraph";
25225
+ const encode$U = (params2, encodedAttrs = {}) => {
25229
25226
  const node = handleParagraphNode$1(params2);
25230
25227
  if (!node) return void 0;
25231
25228
  if (encodedAttrs && Object.keys(encodedAttrs).length) {
@@ -25233,7 +25230,7 @@ const encode$T = (params2, encodedAttrs = {}) => {
25233
25230
  }
25234
25231
  return node;
25235
25232
  };
25236
- const decode$K = (params2, decodedAttrs = {}) => {
25233
+ const decode$L = (params2, decodedAttrs = {}) => {
25237
25234
  const translated = translateParagraphNode(params2);
25238
25235
  if (!translated) return void 0;
25239
25236
  if (decodedAttrs && Object.keys(decodedAttrs).length) {
@@ -25241,16 +25238,16 @@ const decode$K = (params2, decodedAttrs = {}) => {
25241
25238
  }
25242
25239
  return translated;
25243
25240
  };
25244
- const config$o = {
25245
- xmlName: XML_NODE_NAME$q,
25246
- sdNodeOrKeyName: SD_NODE_NAME$a,
25241
+ const config$p = {
25242
+ xmlName: XML_NODE_NAME$r,
25243
+ sdNodeOrKeyName: SD_NODE_NAME$b,
25247
25244
  type: NodeTranslator.translatorTypes.NODE,
25248
- encode: encode$T,
25249
- decode: decode$K,
25250
- attributes: validXmlAttributes$i
25245
+ encode: encode$U,
25246
+ decode: decode$L,
25247
+ attributes: validXmlAttributes$j
25251
25248
  };
25252
- const translator$12 = NodeTranslator.from(config$o);
25253
- const encode$S = (attributes) => {
25249
+ const translator$13 = NodeTranslator.from(config$p);
25250
+ const encode$T = (attributes) => {
25254
25251
  const raw = attributes?.["w:val"];
25255
25252
  if (raw === void 0 || raw === null) return void 0;
25256
25253
  if (typeof raw === "boolean") return raw;
@@ -25260,20 +25257,20 @@ const encode$S = (attributes) => {
25260
25257
  if (val === "1" || val === "true" || val === "on") return true;
25261
25258
  return void 0;
25262
25259
  };
25263
- const decode$J = (runProps) => {
25260
+ const decode$K = (runProps) => {
25264
25261
  if (runProps?.bold === false) return "0";
25265
25262
  return void 0;
25266
25263
  };
25267
25264
  const attrConfig$s = Object.freeze({
25268
25265
  xmlName: "w:val",
25269
25266
  sdName: "bold",
25270
- encode: encode$S,
25271
- decode: decode$J
25267
+ encode: encode$T,
25268
+ decode: decode$K
25272
25269
  });
25273
- const validXmlAttributes$h = [attrConfig$s];
25274
- const XML_NODE_NAME$p = "w:b";
25270
+ const validXmlAttributes$i = [attrConfig$s];
25271
+ const XML_NODE_NAME$q = "w:b";
25275
25272
  const SD_ATTR_KEY$e = "bold";
25276
- const encode$R = (params2, encodedAttrs = {}) => {
25273
+ const encode$S = (params2, encodedAttrs = {}) => {
25277
25274
  const { nodes } = params2;
25278
25275
  const node = nodes[0];
25279
25276
  if (!node) return void 0;
@@ -25285,85 +25282,85 @@ const encode$R = (params2, encodedAttrs = {}) => {
25285
25282
  else attributes = node.attributes || {};
25286
25283
  return {
25287
25284
  type: "attr",
25288
- xmlName: XML_NODE_NAME$p,
25285
+ xmlName: XML_NODE_NAME$q,
25289
25286
  sdNodeOrKeyName: SD_ATTR_KEY$e,
25290
25287
  attributes
25291
25288
  };
25292
25289
  };
25293
- const config$n = {
25294
- xmlName: XML_NODE_NAME$p,
25290
+ const config$o = {
25291
+ xmlName: XML_NODE_NAME$q,
25295
25292
  sdNodeOrKeyName: SD_ATTR_KEY$e,
25296
25293
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25297
- encode: encode$R,
25298
- attributes: validXmlAttributes$h
25294
+ encode: encode$S,
25295
+ attributes: validXmlAttributes$i
25299
25296
  };
25300
- const translator$11 = NodeTranslator.from(config$n);
25301
- const XML_NODE_NAME$o = "w:i";
25297
+ const translator$12 = NodeTranslator.from(config$o);
25298
+ const XML_NODE_NAME$p = "w:i";
25302
25299
  const SD_ATTR_KEY$d = "italic";
25303
- const encode$Q = (params2) => {
25300
+ const encode$R = (params2) => {
25304
25301
  const { nodes } = params2;
25305
25302
  const node = nodes?.[0];
25306
25303
  if (!node) return void 0;
25307
25304
  return {
25308
25305
  type: "attr",
25309
- xmlName: XML_NODE_NAME$o,
25306
+ xmlName: XML_NODE_NAME$p,
25310
25307
  sdNodeOrKeyName: SD_ATTR_KEY$d,
25311
25308
  attributes: {
25312
25309
  "w:val": node.attributes?.["w:val"] ?? null
25313
25310
  }
25314
25311
  };
25315
25312
  };
25316
- const config$m = {
25317
- xmlName: XML_NODE_NAME$o,
25313
+ const config$n = {
25314
+ xmlName: XML_NODE_NAME$p,
25318
25315
  sdNodeOrKeyName: SD_ATTR_KEY$d,
25319
25316
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25320
- encode: encode$Q
25317
+ encode: encode$R
25321
25318
  };
25322
- const translator$10 = NodeTranslator.from(config$m);
25323
- const encode$P = (attributes) => attributes?.["w:val"];
25324
- const decode$I = (attrs) => attrs?.underline;
25319
+ const translator$11 = NodeTranslator.from(config$n);
25320
+ const encode$Q = (attributes) => attributes?.["w:val"];
25321
+ const decode$J = (attrs) => attrs?.underline;
25325
25322
  const attrConfig$r = Object.freeze({
25326
25323
  xmlName: "w:val",
25327
25324
  sdName: "underline",
25328
- encode: encode$P,
25329
- decode: decode$I
25325
+ encode: encode$Q,
25326
+ decode: decode$J
25330
25327
  });
25331
- const encode$O = (attributes) => attributes?.["w:color"];
25332
- const decode$H = (attrs) => attrs?.color;
25328
+ const encode$P = (attributes) => attributes?.["w:color"];
25329
+ const decode$I = (attrs) => attrs?.color;
25333
25330
  const attrConfig$q = Object.freeze({
25334
25331
  xmlName: "w:color",
25335
25332
  sdName: "color",
25336
- encode: encode$O,
25337
- decode: decode$H
25333
+ encode: encode$P,
25334
+ decode: decode$I
25338
25335
  });
25339
- const encode$N = (attributes) => attributes?.["w:themeColor"];
25340
- const decode$G = (attrs) => attrs?.themeColor;
25336
+ const encode$O = (attributes) => attributes?.["w:themeColor"];
25337
+ const decode$H = (attrs) => attrs?.themeColor;
25341
25338
  const attrConfig$p = Object.freeze({
25342
25339
  xmlName: "w:themeColor",
25343
25340
  sdName: "themeColor",
25344
- encode: encode$N,
25345
- decode: decode$G
25341
+ encode: encode$O,
25342
+ decode: decode$H
25346
25343
  });
25347
- const encode$M = (attributes) => attributes?.["w:themeTint"];
25348
- const decode$F = (attrs) => attrs?.themeTint;
25344
+ const encode$N = (attributes) => attributes?.["w:themeTint"];
25345
+ const decode$G = (attrs) => attrs?.themeTint;
25349
25346
  const attrConfig$o = Object.freeze({
25350
25347
  xmlName: "w:themeTint",
25351
25348
  sdName: "themeTint",
25352
- encode: encode$M,
25353
- decode: decode$F
25349
+ encode: encode$N,
25350
+ decode: decode$G
25354
25351
  });
25355
- const encode$L = (attributes) => attributes?.["w:themeShade"];
25356
- const decode$E = (attrs) => attrs?.themeShade;
25352
+ const encode$M = (attributes) => attributes?.["w:themeShade"];
25353
+ const decode$F = (attrs) => attrs?.themeShade;
25357
25354
  const attrConfig$n = Object.freeze({
25358
25355
  xmlName: "w:themeShade",
25359
25356
  sdName: "themeShade",
25360
- encode: encode$L,
25361
- decode: decode$E
25357
+ encode: encode$M,
25358
+ decode: decode$F
25362
25359
  });
25363
- const validXmlAttributes$g = [attrConfig$r, attrConfig$q, attrConfig$p, attrConfig$o, attrConfig$n];
25364
- const XML_NODE_NAME$n = "w:u";
25360
+ const validXmlAttributes$h = [attrConfig$r, attrConfig$q, attrConfig$p, attrConfig$o, attrConfig$n];
25361
+ const XML_NODE_NAME$o = "w:u";
25365
25362
  const SD_ATTR_KEY$c = "underline";
25366
- const encode$K = (params2, encodedAttrs = {}) => {
25363
+ const encode$L = (params2, encodedAttrs = {}) => {
25367
25364
  const { nodes } = params2;
25368
25365
  const node = nodes?.[0];
25369
25366
  const sourceAttrs = node?.attributes || {};
@@ -25379,12 +25376,12 @@ const encode$K = (params2, encodedAttrs = {}) => {
25379
25376
  if (themeShade !== void 0 && themeShade !== null) attributes["w:themeShade"] = themeShade;
25380
25377
  return {
25381
25378
  type: "attr",
25382
- xmlName: XML_NODE_NAME$n,
25379
+ xmlName: XML_NODE_NAME$o,
25383
25380
  sdNodeOrKeyName: SD_ATTR_KEY$c,
25384
25381
  attributes
25385
25382
  };
25386
25383
  };
25387
- const decode$D = (params2) => {
25384
+ const decode$E = (params2) => {
25388
25385
  const attrs = params2?.node?.attrs || {};
25389
25386
  const underlineType = attrs.underlineType ?? attrs.underline ?? null;
25390
25387
  const color = attrs.underlineColor ?? attrs.color ?? null;
@@ -25402,20 +25399,20 @@ const decode$D = (params2) => {
25402
25399
  if (themeTint) attributes["w:themeTint"] = themeTint;
25403
25400
  if (themeShade) attributes["w:themeShade"] = themeShade;
25404
25401
  return {
25405
- name: XML_NODE_NAME$n,
25402
+ name: XML_NODE_NAME$o,
25406
25403
  attributes
25407
25404
  };
25408
25405
  };
25409
- const config$l = {
25410
- xmlName: XML_NODE_NAME$n,
25406
+ const config$m = {
25407
+ xmlName: XML_NODE_NAME$o,
25411
25408
  sdNodeOrKeyName: SD_ATTR_KEY$c,
25412
25409
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25413
- encode: encode$K,
25414
- decode: decode$D,
25415
- attributes: validXmlAttributes$g
25410
+ encode: encode$L,
25411
+ decode: decode$E,
25412
+ attributes: validXmlAttributes$h
25416
25413
  };
25417
- const translator$$ = NodeTranslator.from(config$l);
25418
- const encode$J = (attributes) => {
25414
+ const translator$10 = NodeTranslator.from(config$m);
25415
+ const encode$K = (attributes) => {
25419
25416
  const raw = attributes?.["w:val"];
25420
25417
  if (raw === void 0 || raw === null) return void 0;
25421
25418
  if (typeof raw === "boolean") return raw;
@@ -25425,20 +25422,20 @@ const encode$J = (attributes) => {
25425
25422
  if (val === "1" || val === "true" || val === "on") return true;
25426
25423
  return void 0;
25427
25424
  };
25428
- const decode$C = (attrs) => {
25425
+ const decode$D = (attrs) => {
25429
25426
  if (attrs?.strike === false) return "0";
25430
25427
  return void 0;
25431
25428
  };
25432
25429
  const attrConfig$m = Object.freeze({
25433
25430
  xmlName: "w:val",
25434
25431
  sdName: "strike",
25435
- encode: encode$J,
25436
- decode: decode$C
25432
+ encode: encode$K,
25433
+ decode: decode$D
25437
25434
  });
25438
- const validXmlAttributes$f = [attrConfig$m];
25439
- const XML_NODE_NAME$m = "w:strike";
25435
+ const validXmlAttributes$g = [attrConfig$m];
25436
+ const XML_NODE_NAME$n = "w:strike";
25440
25437
  const SD_ATTR_KEY$b = "strike";
25441
- const encode$I = (params2, encodedAttrs = {}) => {
25438
+ const encode$J = (params2, encodedAttrs = {}) => {
25442
25439
  const { nodes } = params2;
25443
25440
  const node = nodes?.[0];
25444
25441
  if (!node) return void 0;
@@ -25451,55 +25448,55 @@ const encode$I = (params2, encodedAttrs = {}) => {
25451
25448
  else if (val === true && attributes["w:val"] === void 0) delete attributes["w:val"];
25452
25449
  return {
25453
25450
  type: "attr",
25454
- xmlName: XML_NODE_NAME$m,
25451
+ xmlName: XML_NODE_NAME$n,
25455
25452
  sdNodeOrKeyName: SD_ATTR_KEY$b,
25456
25453
  attributes
25457
25454
  };
25458
25455
  };
25459
- const config$k = {
25460
- xmlName: XML_NODE_NAME$m,
25456
+ const config$l = {
25457
+ xmlName: XML_NODE_NAME$n,
25461
25458
  sdNodeOrKeyName: SD_ATTR_KEY$b,
25462
25459
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25463
- encode: encode$I,
25464
- attributes: validXmlAttributes$f
25460
+ encode: encode$J,
25461
+ attributes: validXmlAttributes$g
25465
25462
  };
25466
- const translator$_ = NodeTranslator.from(config$k);
25467
- const encode$H = (attributes) => attributes?.["w:val"];
25468
- const decode$B = (attrs) => attrs?.color;
25463
+ const translator$$ = NodeTranslator.from(config$l);
25464
+ const encode$I = (attributes) => attributes?.["w:val"];
25465
+ const decode$C = (attrs) => attrs?.color;
25469
25466
  const attrConfig$l = Object.freeze({
25470
25467
  xmlName: "w:val",
25471
25468
  sdName: "color",
25472
- encode: encode$H,
25473
- decode: decode$B
25469
+ encode: encode$I,
25470
+ decode: decode$C
25474
25471
  });
25475
- const encode$G = (attributes) => attributes?.["w:themeColor"];
25476
- const decode$A = (attrs) => attrs?.themeColor;
25472
+ const encode$H = (attributes) => attributes?.["w:themeColor"];
25473
+ const decode$B = (attrs) => attrs?.themeColor;
25477
25474
  const attrConfig$k = Object.freeze({
25478
25475
  xmlName: "w:themeColor",
25479
25476
  sdName: "themeColor",
25480
- encode: encode$G,
25481
- decode: decode$A
25477
+ encode: encode$H,
25478
+ decode: decode$B
25482
25479
  });
25483
- const encode$F = (attributes) => attributes?.["w:themeTint"];
25484
- const decode$z = (attrs) => attrs?.themeTint;
25480
+ const encode$G = (attributes) => attributes?.["w:themeTint"];
25481
+ const decode$A = (attrs) => attrs?.themeTint;
25485
25482
  const attrConfig$j = Object.freeze({
25486
25483
  xmlName: "w:themeTint",
25487
25484
  sdName: "themeTint",
25488
- encode: encode$F,
25489
- decode: decode$z
25485
+ encode: encode$G,
25486
+ decode: decode$A
25490
25487
  });
25491
- const encode$E = (attributes) => attributes?.["w:themeShade"];
25492
- const decode$y = (attrs) => attrs?.themeShade;
25488
+ const encode$F = (attributes) => attributes?.["w:themeShade"];
25489
+ const decode$z = (attrs) => attrs?.themeShade;
25493
25490
  const attrConfig$i = Object.freeze({
25494
25491
  xmlName: "w:themeShade",
25495
25492
  sdName: "themeShade",
25496
- encode: encode$E,
25497
- decode: decode$y
25493
+ encode: encode$F,
25494
+ decode: decode$z
25498
25495
  });
25499
- const validXmlAttributes$e = [attrConfig$l, attrConfig$k, attrConfig$j, attrConfig$i];
25500
- const XML_NODE_NAME$l = "w:color";
25496
+ const validXmlAttributes$f = [attrConfig$l, attrConfig$k, attrConfig$j, attrConfig$i];
25497
+ const XML_NODE_NAME$m = "w:color";
25501
25498
  const SD_ATTR_KEY$a = "color";
25502
- const encode$D = (params2, encodedAttrs = {}) => {
25499
+ const encode$E = (params2, encodedAttrs = {}) => {
25503
25500
  const { nodes } = params2;
25504
25501
  const node = nodes?.[0];
25505
25502
  const sourceAttrs = node?.attributes || {};
@@ -25514,63 +25511,63 @@ const encode$D = (params2, encodedAttrs = {}) => {
25514
25511
  if (themeShade !== void 0 && themeShade !== null) attributes["w:themeShade"] = themeShade;
25515
25512
  return {
25516
25513
  type: "attr",
25517
- xmlName: XML_NODE_NAME$l,
25514
+ xmlName: XML_NODE_NAME$m,
25518
25515
  sdNodeOrKeyName: SD_ATTR_KEY$a,
25519
25516
  attributes
25520
25517
  };
25521
25518
  };
25522
- const config$j = {
25523
- xmlName: XML_NODE_NAME$l,
25519
+ const config$k = {
25520
+ xmlName: XML_NODE_NAME$m,
25524
25521
  sdNodeOrKeyName: SD_ATTR_KEY$a,
25525
25522
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25526
- encode: encode$D,
25527
- attributes: validXmlAttributes$e
25523
+ encode: encode$E,
25524
+ attributes: validXmlAttributes$f
25528
25525
  };
25529
- const translator$Z = NodeTranslator.from(config$j);
25530
- const encode$C = (attributes) => attributes?.["w:eastAsia"];
25531
- const decode$x = (attrs) => attrs?.eastAsia;
25526
+ const translator$_ = NodeTranslator.from(config$k);
25527
+ const encode$D = (attributes) => attributes?.["w:eastAsia"];
25528
+ const decode$y = (attrs) => attrs?.eastAsia;
25532
25529
  const attrConfig$h = Object.freeze({
25533
25530
  xmlName: "w:eastAsia",
25534
25531
  sdName: "eastAsia",
25535
- encode: encode$C,
25536
- decode: decode$x
25532
+ encode: encode$D,
25533
+ decode: decode$y
25537
25534
  });
25538
- const encode$B = (attributes) => attributes?.["w:ascii"];
25539
- const decode$w = (attrs) => attrs?.ascii;
25535
+ const encode$C = (attributes) => attributes?.["w:ascii"];
25536
+ const decode$x = (attrs) => attrs?.ascii;
25540
25537
  const attrConfig$g = Object.freeze({
25541
25538
  xmlName: "w:ascii",
25542
25539
  sdName: "ascii",
25543
- encode: encode$B,
25544
- decode: decode$w
25540
+ encode: encode$C,
25541
+ decode: decode$x
25545
25542
  });
25546
- const encode$A = (attributes) => attributes?.["w:hAnsi"];
25547
- const decode$v = (attrs) => attrs?.hAnsi;
25543
+ const encode$B = (attributes) => attributes?.["w:hAnsi"];
25544
+ const decode$w = (attrs) => attrs?.hAnsi;
25548
25545
  const attrConfig$f = Object.freeze({
25549
25546
  xmlName: "w:hAnsi",
25550
25547
  sdName: "hAnsi",
25551
- encode: encode$A,
25552
- decode: decode$v
25548
+ encode: encode$B,
25549
+ decode: decode$w
25553
25550
  });
25554
- const encode$z = (attributes) => attributes?.["w:cs"];
25555
- const decode$u = (attrs) => attrs?.cs;
25551
+ const encode$A = (attributes) => attributes?.["w:cs"];
25552
+ const decode$v = (attrs) => attrs?.cs;
25556
25553
  const attrConfig$e = Object.freeze({
25557
25554
  xmlName: "w:cs",
25558
25555
  sdName: "cs",
25559
- encode: encode$z,
25560
- decode: decode$u
25556
+ encode: encode$A,
25557
+ decode: decode$v
25561
25558
  });
25562
- const encode$y = (attributes) => attributes?.["w:val"];
25563
- const decode$t = (attrs) => attrs?.value;
25559
+ const encode$z = (attributes) => attributes?.["w:val"];
25560
+ const decode$u = (attrs) => attrs?.value;
25564
25561
  const attrConfig$d = Object.freeze({
25565
25562
  xmlName: "w:val",
25566
25563
  sdName: "value",
25567
- encode: encode$y,
25568
- decode: decode$t
25564
+ encode: encode$z,
25565
+ decode: decode$u
25569
25566
  });
25570
- const validXmlAttributes$d = [attrConfig$h, attrConfig$g, attrConfig$f, attrConfig$e, attrConfig$d];
25571
- const XML_NODE_NAME$k = "w:rFonts";
25567
+ const validXmlAttributes$e = [attrConfig$h, attrConfig$g, attrConfig$f, attrConfig$e, attrConfig$d];
25568
+ const XML_NODE_NAME$l = "w:rFonts";
25572
25569
  const SD_ATTR_KEY$9 = "fontFamily";
25573
- const encode$x = (params2, encodedAttrs = {}) => {
25570
+ const encode$y = (params2, encodedAttrs = {}) => {
25574
25571
  const { nodes } = params2;
25575
25572
  const node = nodes?.[0];
25576
25573
  const sourceAttrs = node?.attributes || {};
@@ -25596,120 +25593,120 @@ const encode$x = (params2, encodedAttrs = {}) => {
25596
25593
  if (attributes["w:val"] === void 0) delete attributes["w:val"];
25597
25594
  return {
25598
25595
  type: "attr",
25599
- xmlName: XML_NODE_NAME$k,
25596
+ xmlName: XML_NODE_NAME$l,
25600
25597
  sdNodeOrKeyName: SD_ATTR_KEY$9,
25601
25598
  attributes
25602
25599
  };
25603
25600
  };
25604
- const config$i = {
25605
- xmlName: XML_NODE_NAME$k,
25601
+ const config$j = {
25602
+ xmlName: XML_NODE_NAME$l,
25606
25603
  sdNodeOrKeyName: SD_ATTR_KEY$9,
25607
25604
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25608
- encode: encode$x,
25609
- attributes: validXmlAttributes$d
25605
+ encode: encode$y,
25606
+ attributes: validXmlAttributes$e
25610
25607
  };
25611
- const translator$Y = NodeTranslator.from(config$i);
25612
- const encode$w = (attributes) => attributes?.["w:val"];
25613
- const decode$s = (attrs) => attrs?.styleId;
25608
+ const translator$Z = NodeTranslator.from(config$j);
25609
+ const encode$x = (attributes) => attributes?.["w:val"];
25610
+ const decode$t = (attrs) => attrs?.styleId;
25614
25611
  const attrConfig$c = Object.freeze({
25615
25612
  xmlName: "w:val",
25616
25613
  sdName: "styleId",
25617
- encode: encode$w,
25618
- decode: decode$s
25614
+ encode: encode$x,
25615
+ decode: decode$t
25619
25616
  });
25620
- const validXmlAttributes$c = [attrConfig$c];
25621
- const XML_NODE_NAME$j = "w:rStyle";
25617
+ const validXmlAttributes$d = [attrConfig$c];
25618
+ const XML_NODE_NAME$k = "w:rStyle";
25622
25619
  const SD_ATTR_KEY$8 = "styleId";
25623
- const encode$v = (params2, encodedAttrs = {}) => {
25620
+ const encode$w = (params2, encodedAttrs = {}) => {
25624
25621
  const { nodes } = params2;
25625
25622
  const node = nodes?.[0];
25626
25623
  const value = encodedAttrs.styleId ?? node?.attributes?.["w:val"];
25627
25624
  return {
25628
25625
  type: "attr",
25629
- xmlName: XML_NODE_NAME$j,
25626
+ xmlName: XML_NODE_NAME$k,
25630
25627
  sdNodeOrKeyName: SD_ATTR_KEY$8,
25631
25628
  attributes: { "w:val": value ?? null }
25632
25629
  };
25633
25630
  };
25634
- const config$h = {
25635
- xmlName: XML_NODE_NAME$j,
25631
+ const config$i = {
25632
+ xmlName: XML_NODE_NAME$k,
25636
25633
  sdNodeOrKeyName: SD_ATTR_KEY$8,
25637
25634
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25638
- encode: encode$v,
25639
- attributes: validXmlAttributes$c
25635
+ encode: encode$w,
25636
+ attributes: validXmlAttributes$d
25640
25637
  };
25641
- const translator$X = NodeTranslator.from(config$h);
25642
- const encode$u = (attributes) => attributes?.["w:val"];
25643
- const decode$r = (attrs) => attrs?.fontSize;
25638
+ const translator$Y = NodeTranslator.from(config$i);
25639
+ const encode$v = (attributes) => attributes?.["w:val"];
25640
+ const decode$s = (attrs) => attrs?.fontSize;
25644
25641
  const attrConfig$b = Object.freeze({
25645
25642
  xmlName: "w:val",
25646
25643
  sdName: "fontSize",
25647
- encode: encode$u,
25648
- decode: decode$r
25644
+ encode: encode$v,
25645
+ decode: decode$s
25649
25646
  });
25650
- const validXmlAttributes$b = [attrConfig$b];
25651
- const XML_NODE_NAME$i = "w:sz";
25647
+ const validXmlAttributes$c = [attrConfig$b];
25648
+ const XML_NODE_NAME$j = "w:sz";
25652
25649
  const SD_ATTR_KEY$7 = "fontSize";
25653
- const encode$t = (params2, encodedAttrs = {}) => {
25650
+ const encode$u = (params2, encodedAttrs = {}) => {
25654
25651
  const { nodes } = params2;
25655
25652
  const node = nodes?.[0];
25656
25653
  const value = encodedAttrs.fontSize ?? node?.attributes?.["w:val"];
25657
25654
  return {
25658
25655
  type: "attr",
25659
- xmlName: XML_NODE_NAME$i,
25656
+ xmlName: XML_NODE_NAME$j,
25660
25657
  sdNodeOrKeyName: SD_ATTR_KEY$7,
25661
25658
  attributes: { "w:val": value ?? null }
25662
25659
  };
25663
25660
  };
25664
- const config$g = {
25665
- xmlName: XML_NODE_NAME$i,
25661
+ const config$h = {
25662
+ xmlName: XML_NODE_NAME$j,
25666
25663
  sdNodeOrKeyName: SD_ATTR_KEY$7,
25667
25664
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25668
- encode: encode$t,
25669
- attributes: validXmlAttributes$b
25665
+ encode: encode$u,
25666
+ attributes: validXmlAttributes$c
25670
25667
  };
25671
- const translator$W = NodeTranslator.from(config$g);
25672
- const encode$s = (attributes) => attributes?.["w:val"];
25673
- const decode$q = (attrs) => attrs?.fontSizeCs;
25668
+ const translator$X = NodeTranslator.from(config$h);
25669
+ const encode$t = (attributes) => attributes?.["w:val"];
25670
+ const decode$r = (attrs) => attrs?.fontSizeCs;
25674
25671
  const attrConfig$a = Object.freeze({
25675
25672
  xmlName: "w:val",
25676
25673
  sdName: "fontSizeCs",
25677
- encode: encode$s,
25678
- decode: decode$q
25674
+ encode: encode$t,
25675
+ decode: decode$r
25679
25676
  });
25680
- const validXmlAttributes$a = [attrConfig$a];
25681
- const XML_NODE_NAME$h = "w:szCs";
25677
+ const validXmlAttributes$b = [attrConfig$a];
25678
+ const XML_NODE_NAME$i = "w:szCs";
25682
25679
  const SD_ATTR_KEY$6 = "fontSizeCs";
25683
- const encode$r = (params2, encodedAttrs = {}) => {
25680
+ const encode$s = (params2, encodedAttrs = {}) => {
25684
25681
  const { nodes } = params2;
25685
25682
  const node = nodes?.[0];
25686
25683
  const value = encodedAttrs.fontSizeCs ?? node?.attributes?.["w:val"];
25687
25684
  return {
25688
25685
  type: "attr",
25689
- xmlName: XML_NODE_NAME$h,
25686
+ xmlName: XML_NODE_NAME$i,
25690
25687
  sdNodeOrKeyName: SD_ATTR_KEY$6,
25691
25688
  attributes: { "w:val": value ?? null }
25692
25689
  };
25693
25690
  };
25694
- const config$f = {
25695
- xmlName: XML_NODE_NAME$h,
25691
+ const config$g = {
25692
+ xmlName: XML_NODE_NAME$i,
25696
25693
  sdNodeOrKeyName: SD_ATTR_KEY$6,
25697
25694
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25698
- encode: encode$r,
25699
- attributes: validXmlAttributes$a
25695
+ encode: encode$s,
25696
+ attributes: validXmlAttributes$b
25700
25697
  };
25701
- const translator$V = NodeTranslator.from(config$f);
25698
+ const translator$W = NodeTranslator.from(config$g);
25702
25699
  const runPropertyTranslators = Object.freeze({
25703
- "w:b": translator$11,
25704
- "w:i": translator$10,
25705
- "w:u": translator$$,
25706
- "w:strike": translator$_,
25707
- "w:color": translator$Z,
25708
- "w:highlight": translator$14,
25709
- "w:rFonts": translator$Y,
25710
- "w:rStyle": translator$X,
25711
- "w:sz": translator$W,
25712
- "w:szCs": translator$V
25700
+ "w:b": translator$12,
25701
+ "w:i": translator$11,
25702
+ "w:u": translator$10,
25703
+ "w:strike": translator$$,
25704
+ "w:color": translator$_,
25705
+ "w:highlight": translator$15,
25706
+ "w:rFonts": translator$Z,
25707
+ "w:rStyle": translator$Y,
25708
+ "w:sz": translator$X,
25709
+ "w:szCs": translator$W
25713
25710
  });
25714
25711
  const rawRunPropertyXmlNames = Object.freeze(["w:lang", "w:shd"]);
25715
25712
  const RAW_CHILD_NAME_SET = new Set(rawRunPropertyXmlNames);
@@ -25723,9 +25720,9 @@ const toRunPropertyEntry = (candidate) => {
25723
25720
  attributes: { ...candidate.attributes || {} }
25724
25721
  };
25725
25722
  };
25726
- const XML_NODE_NAME$g = "w:rPr";
25723
+ const XML_NODE_NAME$h = "w:rPr";
25727
25724
  const SD_ATTR_KEY$5 = "runProperties";
25728
- const encode$q = (params2) => {
25725
+ const encode$r = (params2) => {
25729
25726
  const { nodes } = params2;
25730
25727
  const node = nodes?.[0] || {};
25731
25728
  const contents = Array.isArray(node.elements) ? node.elements : [];
@@ -25759,16 +25756,16 @@ const encode$q = (params2) => {
25759
25756
  attributes: runPropsArray
25760
25757
  };
25761
25758
  };
25762
- const config$e = {
25763
- xmlName: XML_NODE_NAME$g,
25759
+ const config$f = {
25760
+ xmlName: XML_NODE_NAME$h,
25764
25761
  sdNodeOrKeyName: SD_ATTR_KEY$5,
25765
25762
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25766
- encode: encode$q
25763
+ encode: encode$r
25767
25764
  };
25768
- const translator$U = NodeTranslator.from(config$e);
25765
+ const translator$V = NodeTranslator.from(config$f);
25769
25766
  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;
25770
25767
  const containsEastAsianCharacters = (text) => EAST_ASIAN_CHARACTER_REGEX.test(text);
25771
- const collectRunProperties = (params2, rPrNode, translator2 = translator$U) => {
25768
+ const collectRunProperties = (params2, rPrNode, translator2 = translator$V) => {
25772
25769
  if (!rPrNode) return { entries: [], hadRPr: false, styleChangeMarks: [] };
25773
25770
  const result = translator2.encode({ ...params2, nodes: [rPrNode] }) || {};
25774
25771
  let entries = [];
@@ -26230,46 +26227,46 @@ const ensureTrackedWrapper = (runs, trackingMarksByType = /* @__PURE__ */ new Ma
26230
26227
  }
26231
26228
  return runs;
26232
26229
  };
26233
- const encode$p = (attributes) => {
26230
+ const encode$q = (attributes) => {
26234
26231
  return attributes["w:rsidR"];
26235
26232
  };
26236
- const decode$p = (attrs) => {
26233
+ const decode$q = (attrs) => {
26237
26234
  return attrs.rsidR;
26238
26235
  };
26239
26236
  const attrConfig$9 = Object.freeze({
26240
26237
  xmlName: "w:rsidR",
26241
26238
  sdName: "rsidR",
26242
- encode: encode$p,
26243
- decode: decode$p
26239
+ encode: encode$q,
26240
+ decode: decode$q
26244
26241
  });
26245
- const encode$o = (attributes) => {
26242
+ const encode$p = (attributes) => {
26246
26243
  return attributes["w:rsidRPr"];
26247
26244
  };
26248
- const decode$o = (attrs) => {
26245
+ const decode$p = (attrs) => {
26249
26246
  return attrs.rsidRPr;
26250
26247
  };
26251
26248
  const attrConfig$8 = Object.freeze({
26252
26249
  xmlName: "w:rsidRPr",
26253
26250
  sdName: "rsidRPr",
26254
- encode: encode$o,
26255
- decode: decode$o
26251
+ encode: encode$p,
26252
+ decode: decode$p
26256
26253
  });
26257
- const encode$n = (attributes) => {
26254
+ const encode$o = (attributes) => {
26258
26255
  return attributes["w:rsidDel"];
26259
26256
  };
26260
- const decode$n = (attrs) => {
26257
+ const decode$o = (attrs) => {
26261
26258
  return attrs.rsidDel;
26262
26259
  };
26263
26260
  const attrConfig$7 = Object.freeze({
26264
26261
  xmlName: "w:rsidDel",
26265
26262
  sdName: "rsidDel",
26266
- encode: encode$n,
26267
- decode: decode$n
26263
+ encode: encode$o,
26264
+ decode: decode$o
26268
26265
  });
26269
- const validXmlAttributes$9 = [attrConfig$9, attrConfig$8, attrConfig$7];
26270
- const XML_NODE_NAME$f = "w:r";
26266
+ const validXmlAttributes$a = [attrConfig$9, attrConfig$8, attrConfig$7];
26267
+ const XML_NODE_NAME$g = "w:r";
26271
26268
  const SD_KEY_NAME = "run";
26272
- const encode$m = (params2, encodedAttrs = {}) => {
26269
+ const encode$n = (params2, encodedAttrs = {}) => {
26273
26270
  const { nodes = [], nodeListHandler } = params2 || {};
26274
26271
  const runNode = nodes[0];
26275
26272
  if (!runNode) return void 0;
@@ -26317,7 +26314,7 @@ const encode$m = (params2, encodedAttrs = {}) => {
26317
26314
  }
26318
26315
  return runNodeResult;
26319
26316
  };
26320
- const decode$m = (params2, decodedAttrs = {}) => {
26317
+ const decode$n = (params2, decodedAttrs = {}) => {
26321
26318
  const { node } = params2 || {};
26322
26319
  if (!node) return void 0;
26323
26320
  const { runNode: runNodeForExport, trackingMarksByType } = prepareRunTrackingContext(node);
@@ -26374,7 +26371,7 @@ const decode$m = (params2, decodedAttrs = {}) => {
26374
26371
  runs.push(trackedClone);
26375
26372
  return;
26376
26373
  }
26377
- const runWrapper = { name: XML_NODE_NAME$f, elements: [] };
26374
+ const runWrapper = { name: XML_NODE_NAME$g, elements: [] };
26378
26375
  applyBaseRunProps(runWrapper);
26379
26376
  if (!Array.isArray(runWrapper.elements)) runWrapper.elements = [];
26380
26377
  runWrapper.elements.push(cloneXmlNode(child));
@@ -26382,7 +26379,7 @@ const decode$m = (params2, decodedAttrs = {}) => {
26382
26379
  });
26383
26380
  const trackedRuns = ensureTrackedWrapper(runs, trackingMarksByType);
26384
26381
  if (!trackedRuns.length) {
26385
- const emptyRun = { name: XML_NODE_NAME$f, elements: [] };
26382
+ const emptyRun = { name: XML_NODE_NAME$g, elements: [] };
26386
26383
  applyBaseRunProps(emptyRun);
26387
26384
  trackedRuns.push(emptyRun);
26388
26385
  }
@@ -26396,15 +26393,15 @@ const decode$m = (params2, decodedAttrs = {}) => {
26396
26393
  }
26397
26394
  return trackedRuns;
26398
26395
  };
26399
- const config$d = {
26400
- xmlName: XML_NODE_NAME$f,
26396
+ const config$e = {
26397
+ xmlName: XML_NODE_NAME$g,
26401
26398
  sdNodeOrKeyName: SD_KEY_NAME,
26402
26399
  type: NodeTranslator.translatorTypes.NODE,
26403
- encode: encode$m,
26404
- decode: decode$m,
26405
- attributes: validXmlAttributes$9
26400
+ encode: encode$n,
26401
+ decode: decode$n,
26402
+ attributes: validXmlAttributes$a
26406
26403
  };
26407
- const translator$T = NodeTranslator.from(config$d);
26404
+ const translator$U = NodeTranslator.from(config$e);
26408
26405
  const generateV2HandlerEntity = (handlerName, translator2) => ({
26409
26406
  handlerName,
26410
26407
  handler: (params2) => {
@@ -26578,13 +26575,13 @@ function preProcessVerticalMergeCells(table, { editorSchema }) {
26578
26575
  }
26579
26576
  return table;
26580
26577
  }
26581
- const translator$S = NodeTranslator.from({
26578
+ const translator$T = NodeTranslator.from({
26582
26579
  xmlName: "w:cantSplit",
26583
26580
  sdNodeOrKeyName: "cantSplit",
26584
26581
  encode: ({ nodes }) => ["1", "true"].includes(nodes[0].attributes?.["w:val"] ?? "1"),
26585
26582
  decode: ({ node }) => node.attrs?.cantSplit ? { attributes: {} } : void 0
26586
26583
  });
26587
- const translator$R = NodeTranslator.from({
26584
+ const translator$S = NodeTranslator.from({
26588
26585
  xmlName: "w:cnfStyle",
26589
26586
  sdNodeOrKeyName: "cnfStyle",
26590
26587
  attributes: [
@@ -26610,8 +26607,8 @@ const translator$R = NodeTranslator.from({
26610
26607
  return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
26611
26608
  }
26612
26609
  });
26613
- const translator$Q = NodeTranslator.from(createSingleAttrPropertyHandler("w:divId"));
26614
- const translator$P = NodeTranslator.from(
26610
+ const translator$R = NodeTranslator.from(createSingleAttrPropertyHandler("w:divId"));
26611
+ const translator$Q = NodeTranslator.from(
26615
26612
  createSingleAttrPropertyHandler(
26616
26613
  "w:gridAfter",
26617
26614
  null,
@@ -26620,7 +26617,7 @@ const translator$P = NodeTranslator.from(
26620
26617
  (v2) => integerToString(v2)
26621
26618
  )
26622
26619
  );
26623
- const translator$O = NodeTranslator.from(
26620
+ const translator$P = NodeTranslator.from(
26624
26621
  createSingleAttrPropertyHandler(
26625
26622
  "w:gridBefore",
26626
26623
  null,
@@ -26629,21 +26626,21 @@ const translator$O = NodeTranslator.from(
26629
26626
  (v2) => integerToString(v2)
26630
26627
  )
26631
26628
  );
26632
- const translator$N = NodeTranslator.from({
26629
+ const translator$O = NodeTranslator.from({
26633
26630
  xmlName: "w:hidden",
26634
26631
  sdNodeOrKeyName: "hidden",
26635
26632
  encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
26636
26633
  decode: ({ node }) => node.attrs.hidden ? { attributes: {} } : void 0
26637
26634
  });
26638
- const translator$M = NodeTranslator.from(createSingleAttrPropertyHandler("w:jc", "justification"));
26639
- const translator$L = NodeTranslator.from(createMeasurementPropertyHandler("w:tblCellSpacing", "tableCellSpacing"));
26640
- const translator$K = NodeTranslator.from({
26635
+ const translator$N = NodeTranslator.from(createSingleAttrPropertyHandler("w:jc", "justification"));
26636
+ const translator$M = NodeTranslator.from(createMeasurementPropertyHandler("w:tblCellSpacing", "tableCellSpacing"));
26637
+ const translator$L = NodeTranslator.from({
26641
26638
  xmlName: "w:tblHeader",
26642
26639
  sdNodeOrKeyName: "repeatHeader",
26643
26640
  encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
26644
26641
  decode: ({ node }) => node.attrs.repeatHeader ? { attributes: {} } : void 0
26645
26642
  });
26646
- const translator$J = NodeTranslator.from({
26643
+ const translator$K = NodeTranslator.from({
26647
26644
  xmlName: "w:trHeight",
26648
26645
  sdNodeOrKeyName: "rowHeight",
26649
26646
  encode: ({ nodes }) => {
@@ -26670,11 +26667,11 @@ const translator$J = NodeTranslator.from({
26670
26667
  return Object.keys(heightAttrs).length > 0 ? { attributes: heightAttrs } : void 0;
26671
26668
  }
26672
26669
  });
26673
- const translator$I = NodeTranslator.from(createMeasurementPropertyHandler("w:wAfter"));
26674
- const translator$H = NodeTranslator.from(createMeasurementPropertyHandler("w:wBefore"));
26675
- const XML_NODE_NAME$e = "w:trPr";
26670
+ const translator$J = NodeTranslator.from(createMeasurementPropertyHandler("w:wAfter"));
26671
+ const translator$I = NodeTranslator.from(createMeasurementPropertyHandler("w:wBefore"));
26672
+ const XML_NODE_NAME$f = "w:trPr";
26676
26673
  const SD_ATTR_KEY$4 = "tableRowProperties";
26677
- const encode$l = (params2) => {
26674
+ const encode$m = (params2) => {
26678
26675
  const { nodes } = params2;
26679
26676
  const node = nodes[0];
26680
26677
  let attributes = {
@@ -26688,12 +26685,12 @@ const encode$l = (params2) => {
26688
26685
  };
26689
26686
  return {
26690
26687
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
26691
- xmlName: XML_NODE_NAME$e,
26688
+ xmlName: XML_NODE_NAME$f,
26692
26689
  sdNodeOrKeyName: SD_ATTR_KEY$4,
26693
26690
  attributes
26694
26691
  };
26695
26692
  };
26696
- const decode$l = (params2) => {
26693
+ const decode$m = (params2) => {
26697
26694
  const { tableRowProperties = {} } = params2.node.attrs || {};
26698
26695
  const elements = decodeProperties(propertyTranslatorsBySdName$2, tableRowProperties);
26699
26696
  const newNode = {
@@ -26705,6 +26702,7 @@ const decode$l = (params2) => {
26705
26702
  return newNode;
26706
26703
  };
26707
26704
  const propertyTranslators$3 = [
26705
+ translator$T,
26708
26706
  translator$S,
26709
26707
  translator$R,
26710
26708
  translator$Q,
@@ -26715,8 +26713,7 @@ const propertyTranslators$3 = [
26715
26713
  translator$L,
26716
26714
  translator$K,
26717
26715
  translator$J,
26718
- translator$I,
26719
- translator$H
26716
+ translator$I
26720
26717
  ];
26721
26718
  const propertyTranslatorsByXmlName$2 = {};
26722
26719
  propertyTranslators$3.forEach((translator2) => {
@@ -26726,25 +26723,25 @@ const propertyTranslatorsBySdName$2 = {};
26726
26723
  propertyTranslators$3.forEach((translator2) => {
26727
26724
  propertyTranslatorsBySdName$2[translator2.sdNodeOrKeyName] = translator2;
26728
26725
  });
26729
- const config$c = {
26730
- xmlName: XML_NODE_NAME$e,
26726
+ const config$d = {
26727
+ xmlName: XML_NODE_NAME$f,
26731
26728
  sdNodeOrKeyName: SD_ATTR_KEY$4,
26732
26729
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
26733
- encode: encode$l,
26734
- decode: decode$l
26730
+ encode: encode$m,
26731
+ decode: decode$m
26735
26732
  };
26736
- const translator$G = NodeTranslator.from(config$c);
26737
- const XML_NODE_NAME$d = "w:tr";
26738
- const SD_NODE_NAME$9 = "tableRow";
26739
- const validXmlAttributes$8 = ["w:rsidDel", "w:rsidR", "w:rsidRPr", "w:rsidTr", "w14:paraId", "w14:textId"].map(
26733
+ const translator$H = NodeTranslator.from(config$d);
26734
+ const XML_NODE_NAME$e = "w:tr";
26735
+ const SD_NODE_NAME$a = "tableRow";
26736
+ const validXmlAttributes$9 = ["w:rsidDel", "w:rsidR", "w:rsidRPr", "w:rsidTr", "w14:paraId", "w14:textId"].map(
26740
26737
  (xmlName) => createAttributeHandler(xmlName)
26741
26738
  );
26742
- const encode$k = (params2, encodedAttrs) => {
26739
+ const encode$l = (params2, encodedAttrs) => {
26743
26740
  const { row } = params2.extraParams;
26744
26741
  let tableRowProperties = {};
26745
26742
  const tPr = row.elements.find((el) => el.name === "w:trPr");
26746
26743
  if (tPr) {
26747
- ({ attributes: tableRowProperties } = translator$G.encode({
26744
+ ({ attributes: tableRowProperties } = translator$H.encode({
26748
26745
  ...params2,
26749
26746
  nodes: [tPr]
26750
26747
  }));
@@ -26757,7 +26754,7 @@ const encode$k = (params2, encodedAttrs) => {
26757
26754
  let currentColumnIndex = 0;
26758
26755
  const content = cellNodes?.map((n) => {
26759
26756
  let columnWidth = gridColumnWidths?.[currentColumnIndex] || null;
26760
- const result = translator$7.encode({
26757
+ const result = translator$8.encode({
26761
26758
  ...params2,
26762
26759
  extraParams: {
26763
26760
  ...params2.extraParams,
@@ -26779,7 +26776,7 @@ const encode$k = (params2, encodedAttrs) => {
26779
26776
  };
26780
26777
  return newNode;
26781
26778
  };
26782
- const decode$k = (params2, decodedAttrs) => {
26779
+ const decode$l = (params2, decodedAttrs) => {
26783
26780
  const { node } = params2;
26784
26781
  const elements = translateChildNodes(params2);
26785
26782
  if (node.attrs?.tableRowProperties) {
@@ -26791,7 +26788,7 @@ const decode$k = (params2, decodedAttrs) => {
26791
26788
  }
26792
26789
  }
26793
26790
  tableRowProperties["cantSplit"] = node.attrs["cantSplit"];
26794
- const trPr = translator$G.decode({
26791
+ const trPr = translator$H.decode({
26795
26792
  ...params2,
26796
26793
  node: { ...node, attrs: { ...node.attrs, tableRowProperties } }
26797
26794
  });
@@ -26803,22 +26800,22 @@ const decode$k = (params2, decodedAttrs) => {
26803
26800
  elements
26804
26801
  };
26805
26802
  };
26806
- const config$b = {
26807
- xmlName: XML_NODE_NAME$d,
26808
- sdNodeOrKeyName: SD_NODE_NAME$9,
26803
+ const config$c = {
26804
+ xmlName: XML_NODE_NAME$e,
26805
+ sdNodeOrKeyName: SD_NODE_NAME$a,
26809
26806
  type: NodeTranslator.translatorTypes.NODE,
26810
- encode: encode$k,
26811
- decode: decode$k,
26812
- attributes: validXmlAttributes$8
26807
+ encode: encode$l,
26808
+ decode: decode$l,
26809
+ attributes: validXmlAttributes$9
26813
26810
  };
26814
- const translator$F = NodeTranslator.from(config$b);
26815
- const translator$E = NodeTranslator.from({
26811
+ const translator$G = NodeTranslator.from(config$c);
26812
+ const translator$F = NodeTranslator.from({
26816
26813
  xmlName: "w:bidiVisual",
26817
26814
  sdNodeOrKeyName: "rightToLeft",
26818
26815
  encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
26819
26816
  decode: ({ node }) => node.attrs.rightToLeft ? { attributes: {} } : void 0
26820
26817
  });
26821
- const translator$D = NodeTranslator.from({
26818
+ const translator$E = NodeTranslator.from({
26822
26819
  xmlName: "w:shd",
26823
26820
  sdNodeOrKeyName: "shading",
26824
26821
  attributes: [
@@ -26840,11 +26837,11 @@ const translator$D = NodeTranslator.from({
26840
26837
  return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
26841
26838
  }
26842
26839
  });
26843
- const translator$C = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblCaption", "caption"));
26844
- const translator$B = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblDescription", "description"));
26845
- const translator$A = NodeTranslator.from(createMeasurementPropertyHandler("w:tblInd", "tableIndent"));
26846
- const translator$z = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblLayout", "tableLayout", "w:type"));
26847
- const translator$y = NodeTranslator.from({
26840
+ const translator$D = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblCaption", "caption"));
26841
+ const translator$C = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblDescription", "description"));
26842
+ const translator$B = NodeTranslator.from(createMeasurementPropertyHandler("w:tblInd", "tableIndent"));
26843
+ const translator$A = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblLayout", "tableLayout", "w:type"));
26844
+ const translator$z = NodeTranslator.from({
26848
26845
  xmlName: "w:tblLook",
26849
26846
  sdNodeOrKeyName: "tblLook",
26850
26847
  attributes: ["w:firstColumn", "w:firstRow", "w:lastColumn", "w:lastRow", "w:noHBand", "w:noVBand"].map((attr) => createAttributeHandler(attr, null, parseBoolean, booleanToString)).concat([createAttributeHandler("w:val")]),
@@ -26856,16 +26853,16 @@ const translator$y = NodeTranslator.from({
26856
26853
  return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
26857
26854
  }
26858
26855
  });
26859
- const translator$x = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblOverlap", "overlap"));
26860
- const translator$w = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblStyle", "tableStyleId"));
26861
- const translator$v = NodeTranslator.from(
26856
+ const translator$y = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblOverlap", "overlap"));
26857
+ const translator$x = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblStyle", "tableStyleId"));
26858
+ const translator$w = NodeTranslator.from(
26862
26859
  createSingleAttrPropertyHandler("w:tblStyleColBandSize", "tableStyleColBandSize")
26863
26860
  );
26864
- const translator$u = NodeTranslator.from(
26861
+ const translator$v = NodeTranslator.from(
26865
26862
  createSingleAttrPropertyHandler("w:tblStyleRowBandSize", "tableStyleRowBandSize")
26866
26863
  );
26867
- const translator$t = NodeTranslator.from(createMeasurementPropertyHandler("w:tblW", "tableWidth"));
26868
- const translator$s = NodeTranslator.from({
26864
+ const translator$u = NodeTranslator.from(createMeasurementPropertyHandler("w:tblW", "tableWidth"));
26865
+ const translator$t = NodeTranslator.from({
26869
26866
  xmlName: "w:tblpPr",
26870
26867
  sdNodeOrKeyName: "floatingTableProperties",
26871
26868
  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))),
@@ -26877,29 +26874,29 @@ const translator$s = NodeTranslator.from({
26877
26874
  return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
26878
26875
  }
26879
26876
  });
26880
- const translator$r = NodeTranslator.from(createBorderPropertyHandler("w:bottom"));
26881
- const translator$q = NodeTranslator.from(createMeasurementPropertyHandler("w:bottom", "marginBottom"));
26882
- const translator$p = NodeTranslator.from(createBorderPropertyHandler("w:end"));
26883
- const translator$o = NodeTranslator.from(createMeasurementPropertyHandler("w:end", "marginEnd"));
26884
- const translator$n = NodeTranslator.from(createBorderPropertyHandler("w:insideH"));
26885
- const translator$m = NodeTranslator.from(createBorderPropertyHandler("w:insideV"));
26886
- const translator$l = NodeTranslator.from(createBorderPropertyHandler("w:left"));
26887
- const translator$k = NodeTranslator.from(createMeasurementPropertyHandler("w:left", "marginLeft"));
26888
- const translator$j = NodeTranslator.from(createBorderPropertyHandler("w:right"));
26889
- const translator$i = NodeTranslator.from(createMeasurementPropertyHandler("w:right", "marginRight"));
26890
- const translator$h = NodeTranslator.from(createBorderPropertyHandler("w:start"));
26891
- const translator$g = NodeTranslator.from(createMeasurementPropertyHandler("w:start", "marginStart"));
26892
- const translator$f = NodeTranslator.from(createBorderPropertyHandler("w:top"));
26893
- const translator$e = NodeTranslator.from(createMeasurementPropertyHandler("w:top", "marginTop"));
26894
- const XML_NODE_NAME$c = "w:tblBorders";
26877
+ const translator$s = NodeTranslator.from(createBorderPropertyHandler("w:bottom"));
26878
+ const translator$r = NodeTranslator.from(createMeasurementPropertyHandler("w:bottom", "marginBottom"));
26879
+ const translator$q = NodeTranslator.from(createBorderPropertyHandler("w:end"));
26880
+ const translator$p = NodeTranslator.from(createMeasurementPropertyHandler("w:end", "marginEnd"));
26881
+ const translator$o = NodeTranslator.from(createBorderPropertyHandler("w:insideH"));
26882
+ const translator$n = NodeTranslator.from(createBorderPropertyHandler("w:insideV"));
26883
+ const translator$m = NodeTranslator.from(createBorderPropertyHandler("w:left"));
26884
+ const translator$l = NodeTranslator.from(createMeasurementPropertyHandler("w:left", "marginLeft"));
26885
+ const translator$k = NodeTranslator.from(createBorderPropertyHandler("w:right"));
26886
+ const translator$j = NodeTranslator.from(createMeasurementPropertyHandler("w:right", "marginRight"));
26887
+ const translator$i = NodeTranslator.from(createBorderPropertyHandler("w:start"));
26888
+ const translator$h = NodeTranslator.from(createMeasurementPropertyHandler("w:start", "marginStart"));
26889
+ const translator$g = NodeTranslator.from(createBorderPropertyHandler("w:top"));
26890
+ const translator$f = NodeTranslator.from(createMeasurementPropertyHandler("w:top", "marginTop"));
26891
+ const XML_NODE_NAME$d = "w:tblBorders";
26895
26892
  const SD_ATTR_KEY$3 = "borders";
26896
- const encode$j = (params2) => {
26893
+ const encode$k = (params2) => {
26897
26894
  const { nodes } = params2;
26898
26895
  const node = nodes[0];
26899
26896
  const attributes = encodeProperties(node, tblBordersTranslatorsByXmlName);
26900
26897
  return Object.keys(attributes).length > 0 ? attributes : void 0;
26901
26898
  };
26902
- const decode$j = (params2) => {
26899
+ const decode$k = (params2) => {
26903
26900
  const { borders = {} } = params2.node.attrs || {};
26904
26901
  const elements = decodeProperties(tblBordersTranslatorsBySdName, borders);
26905
26902
  const newNode = {
@@ -26911,14 +26908,14 @@ const decode$j = (params2) => {
26911
26908
  return newNode;
26912
26909
  };
26913
26910
  const propertyTranslators$2 = [
26914
- translator$r,
26915
- translator$p,
26911
+ translator$s,
26912
+ translator$q,
26913
+ translator$o,
26916
26914
  translator$n,
26917
26915
  translator$m,
26918
- translator$l,
26919
- translator$j,
26920
- translator$h,
26921
- translator$f
26916
+ translator$k,
26917
+ translator$i,
26918
+ translator$g
26922
26919
  ];
26923
26920
  const tblBordersTranslatorsByXmlName = {};
26924
26921
  const tblBordersTranslatorsBySdName = {};
@@ -26926,27 +26923,27 @@ propertyTranslators$2.forEach((translator2) => {
26926
26923
  tblBordersTranslatorsByXmlName[translator2.xmlName] = translator2;
26927
26924
  tblBordersTranslatorsBySdName[translator2.sdNodeOrKeyName] = translator2;
26928
26925
  });
26929
- const translator$d = NodeTranslator.from({
26930
- xmlName: XML_NODE_NAME$c,
26926
+ const translator$e = NodeTranslator.from({
26927
+ xmlName: XML_NODE_NAME$d,
26931
26928
  sdNodeOrKeyName: SD_ATTR_KEY$3,
26932
26929
  type: NodeTranslator.translatorTypes.NODE,
26933
26930
  attributes: [],
26934
- encode: encode$j,
26935
- decode: decode$j
26931
+ encode: encode$k,
26932
+ decode: decode$k
26936
26933
  });
26937
- const XML_NODE_NAME$b = "w:tblCellMar";
26934
+ const XML_NODE_NAME$c = "w:tblCellMar";
26938
26935
  const SD_ATTR_KEY$2 = "cellMargins";
26939
- const encode$i = (params2) => {
26936
+ const encode$j = (params2) => {
26940
26937
  const { nodes } = params2;
26941
26938
  const node = nodes[0];
26942
26939
  const attributes = encodeProperties(node, propertyTranslatorsByXmlName$1);
26943
26940
  return Object.keys(attributes).length > 0 ? attributes : void 0;
26944
26941
  };
26945
- const decode$i = (params2) => {
26942
+ const decode$j = (params2) => {
26946
26943
  const { cellMargins = {} } = params2.node.attrs || {};
26947
26944
  const elements = decodeProperties(propertyTranslatorsBySdName$1, cellMargins);
26948
26945
  const newNode = {
26949
- name: XML_NODE_NAME$b,
26946
+ name: XML_NODE_NAME$c,
26950
26947
  type: "element",
26951
26948
  attributes: {},
26952
26949
  elements
@@ -26954,12 +26951,12 @@ const decode$i = (params2) => {
26954
26951
  return newNode;
26955
26952
  };
26956
26953
  const propertyTranslators$1 = [
26957
- translator$q,
26958
- translator$o,
26959
- translator$k,
26960
- translator$i,
26961
- translator$g,
26962
- translator$e
26954
+ translator$r,
26955
+ translator$p,
26956
+ translator$l,
26957
+ translator$j,
26958
+ translator$h,
26959
+ translator$f
26963
26960
  ];
26964
26961
  const propertyTranslatorsByXmlName$1 = {};
26965
26962
  const propertyTranslatorsBySdName$1 = {};
@@ -26967,27 +26964,27 @@ propertyTranslators$1.forEach((translator2) => {
26967
26964
  propertyTranslatorsByXmlName$1[translator2.xmlName] = translator2;
26968
26965
  propertyTranslatorsBySdName$1[translator2.sdNodeOrKeyName] = translator2;
26969
26966
  });
26970
- const translator$c = NodeTranslator.from({
26971
- xmlName: XML_NODE_NAME$b,
26967
+ const translator$d = NodeTranslator.from({
26968
+ xmlName: XML_NODE_NAME$c,
26972
26969
  sdNodeOrKeyName: SD_ATTR_KEY$2,
26973
26970
  type: NodeTranslator.translatorTypes.NODE,
26974
26971
  attributes: [],
26975
- encode: encode$i,
26976
- decode: decode$i
26972
+ encode: encode$j,
26973
+ decode: decode$j
26977
26974
  });
26978
- const XML_NODE_NAME$a = "w:tblPr";
26975
+ const XML_NODE_NAME$b = "w:tblPr";
26979
26976
  const SD_ATTR_KEY$1 = "tableProperties";
26980
- const encode$h = (params2) => {
26977
+ const encode$i = (params2) => {
26981
26978
  const { nodes } = params2;
26982
26979
  const node = nodes[0];
26983
26980
  const attributes = encodeProperties(node, propertyTranslatorsByXmlName);
26984
26981
  return {
26985
- xmlName: XML_NODE_NAME$a,
26982
+ xmlName: XML_NODE_NAME$b,
26986
26983
  sdNodeOrKeyName: SD_ATTR_KEY$1,
26987
26984
  attributes
26988
26985
  };
26989
26986
  };
26990
- const decode$h = (params2) => {
26987
+ const decode$i = (params2) => {
26991
26988
  const { tableProperties = {} } = params2.node.attrs || {};
26992
26989
  const elements = decodeProperties(propertyTranslatorsBySdName, tableProperties);
26993
26990
  const newNode = {
@@ -26999,11 +26996,12 @@ const decode$h = (params2) => {
26999
26996
  return newNode;
27000
26997
  };
27001
26998
  const propertyTranslators = [
26999
+ translator$F,
27000
+ translator$N,
27002
27001
  translator$E,
27003
- translator$M,
27004
27002
  translator$D,
27003
+ translator$M,
27005
27004
  translator$C,
27006
- translator$L,
27007
27005
  translator$B,
27008
27006
  translator$A,
27009
27007
  translator$z,
@@ -27013,9 +27011,8 @@ const propertyTranslators = [
27013
27011
  translator$v,
27014
27012
  translator$u,
27015
27013
  translator$t,
27016
- translator$s,
27017
- translator$d,
27018
- translator$c
27014
+ translator$e,
27015
+ translator$d
27019
27016
  ];
27020
27017
  const propertyTranslatorsByXmlName = {};
27021
27018
  const propertyTranslatorsBySdName = {};
@@ -27023,14 +27020,14 @@ propertyTranslators.forEach((translator2) => {
27023
27020
  propertyTranslatorsByXmlName[translator2.xmlName] = translator2;
27024
27021
  propertyTranslatorsBySdName[translator2.sdNodeOrKeyName] = translator2;
27025
27022
  });
27026
- const config$a = {
27027
- xmlName: XML_NODE_NAME$a,
27023
+ const config$b = {
27024
+ xmlName: XML_NODE_NAME$b,
27028
27025
  sdNodeOrKeyName: SD_ATTR_KEY$1,
27029
- encode: encode$h,
27030
- decode: decode$h
27026
+ encode: encode$i,
27027
+ decode: decode$i
27031
27028
  };
27032
- const translator$b = NodeTranslator.from(config$a);
27033
- const translator$a = NodeTranslator.from(
27029
+ const translator$c = NodeTranslator.from(config$b);
27030
+ const translator$b = NodeTranslator.from(
27034
27031
  createSingleAttrPropertyHandler("w:gridCol", "col", "w:w", parseInteger, integerToString)
27035
27032
  );
27036
27033
  const DEFAULT_COLUMN_WIDTH_PX = 100;
@@ -27080,20 +27077,20 @@ const resolveFallbackColumnWidthTwips = (params2, totalColumns, cellMinWidthTwip
27080
27077
  }
27081
27078
  return Math.max(fallbackWidthTwips, cellMinWidthTwips);
27082
27079
  };
27083
- const XML_NODE_NAME$9 = "w:tblGrid";
27080
+ const XML_NODE_NAME$a = "w:tblGrid";
27084
27081
  const SD_ATTR_KEY = "grid";
27085
27082
  const cellMinWidth = pixelsToTwips(10);
27086
- const encode$g = (params2) => {
27083
+ const encode$h = (params2) => {
27087
27084
  const { nodes } = params2;
27088
27085
  const node = nodes[0];
27089
- const attributes = encodeProperties(node, { [translator$a.xmlName]: translator$a }, true);
27086
+ const attributes = encodeProperties(node, { [translator$b.xmlName]: translator$b }, true);
27090
27087
  return {
27091
- xmlName: XML_NODE_NAME$9,
27088
+ xmlName: XML_NODE_NAME$a,
27092
27089
  sdNodeOrKeyName: SD_ATTR_KEY,
27093
27090
  attributes
27094
27091
  };
27095
27092
  };
27096
- const decode$g = (params2) => {
27093
+ const decode$h = (params2) => {
27097
27094
  const { grid: rawGrid } = params2.node.attrs || {};
27098
27095
  const grid = Array.isArray(rawGrid) ? rawGrid : [];
27099
27096
  const { firstRow = {} } = params2.extraParams || {};
@@ -27112,10 +27109,10 @@ const decode$g = (params2) => {
27112
27109
  numericWidth = fallbackColumnWidthTwips;
27113
27110
  }
27114
27111
  numericWidth = Math.max(numericWidth, cellMinWidth);
27115
- const decoded = translator$a.decode({
27112
+ const decoded = translator$b.decode({
27116
27113
  node: { type: (
27117
27114
  /** @type {string} */
27118
- translator$a.sdNodeOrKeyName
27115
+ translator$b.sdNodeOrKeyName
27119
27116
  ), attrs: { col: numericWidth } }
27120
27117
  });
27121
27118
  if (decoded) elements.push(decoded);
@@ -27150,39 +27147,100 @@ const decode$g = (params2) => {
27150
27147
  columnIndex++;
27151
27148
  }
27152
27149
  const newNode = {
27153
- name: XML_NODE_NAME$9,
27150
+ name: XML_NODE_NAME$a,
27154
27151
  attributes: {},
27155
27152
  elements
27156
27153
  };
27157
27154
  return newNode;
27158
27155
  };
27159
- const config$9 = {
27160
- xmlName: XML_NODE_NAME$9,
27156
+ const config$a = {
27157
+ xmlName: XML_NODE_NAME$a,
27161
27158
  sdNodeOrKeyName: SD_ATTR_KEY,
27162
- encode: encode$g,
27163
- decode: decode$g
27159
+ encode: encode$h,
27160
+ decode: decode$h
27164
27161
  };
27165
- const translator$9 = NodeTranslator.from(config$9);
27166
- const XML_NODE_NAME$8 = "w:tbl";
27167
- const SD_NODE_NAME$8 = "table";
27168
- const encode$f = (params2, encodedAttrs) => {
27162
+ const translator$a = NodeTranslator.from(config$a);
27163
+ const DEFAULT_PAGE_WIDTH_TWIPS = 12240;
27164
+ const DEFAULT_PAGE_MARGIN_TWIPS = 1440;
27165
+ const DEFAULT_CONTENT_WIDTH_TWIPS = DEFAULT_PAGE_WIDTH_TWIPS - 2 * DEFAULT_PAGE_MARGIN_TWIPS;
27166
+ const MIN_COLUMN_WIDTH_TWIPS = pixelsToTwips(10);
27167
+ const pctToPercent = (value) => {
27168
+ if (value == null) return null;
27169
+ return value / 50;
27170
+ };
27171
+ const resolveContentWidthTwips = () => DEFAULT_CONTENT_WIDTH_TWIPS;
27172
+ const resolveMeasurementWidthPx = (measurement) => {
27173
+ if (!measurement || typeof measurement.value !== "number" || measurement.value <= 0) return null;
27174
+ const { value, type: type2 } = measurement;
27175
+ if (!type2 || type2 === "auto") return null;
27176
+ if (type2 === "dxa") return twipsToPixels(value);
27177
+ if (type2 === "pct") {
27178
+ const percent2 = pctToPercent(value);
27179
+ if (percent2 == null || percent2 <= 0) return null;
27180
+ const widthTwips = resolveContentWidthTwips() * percent2 / 100;
27181
+ return twipsToPixels(widthTwips);
27182
+ }
27183
+ return null;
27184
+ };
27185
+ const countColumnsInRow = (row) => {
27186
+ if (!row?.elements?.length) return 0;
27187
+ return row.elements.reduce((count, element) => {
27188
+ if (element.name !== "w:tc") return count;
27189
+ const tcPr = element.elements?.find((el) => el.name === "w:tcPr");
27190
+ const gridSpan = tcPr?.elements?.find((el) => el.name === "w:gridSpan");
27191
+ const spanValue = parseInt(gridSpan?.attributes?.["w:val"] || "1", 10);
27192
+ return count + (Number.isFinite(spanValue) && spanValue > 0 ? spanValue : 1);
27193
+ }, 0);
27194
+ };
27195
+ const clampColumnWidthTwips = (value) => Math.max(Math.round(value), MIN_COLUMN_WIDTH_TWIPS);
27196
+ const createFallbackGrid = (columnCount, columnWidthTwips) => Array.from({ length: columnCount }, () => ({ col: clampColumnWidthTwips(columnWidthTwips) }));
27197
+ const buildFallbackGridForTable = ({ params: params2, rows, tableWidth, tableWidthMeasurement }) => {
27198
+ const firstRow = rows.find((row) => row.elements?.some((el) => el.name === "w:tc"));
27199
+ const columnCount = countColumnsInRow(firstRow);
27200
+ if (!columnCount) return null;
27201
+ const schemaDefaultPx = getSchemaDefaultColumnWidthPx(
27202
+ /** @type {any} */
27203
+ params2
27204
+ );
27205
+ const minimumColumnWidthPx = Number.isFinite(schemaDefaultPx) && schemaDefaultPx > 0 ? schemaDefaultPx : DEFAULT_COLUMN_WIDTH_PX;
27206
+ let totalWidthPx;
27207
+ if (tableWidthMeasurement) {
27208
+ const resolved = resolveMeasurementWidthPx(tableWidthMeasurement);
27209
+ if (resolved != null) totalWidthPx = resolved;
27210
+ }
27211
+ if (totalWidthPx == null && tableWidth?.width && tableWidth.width > 0) {
27212
+ totalWidthPx = tableWidth.width;
27213
+ }
27214
+ if (totalWidthPx == null) {
27215
+ totalWidthPx = minimumColumnWidthPx * columnCount;
27216
+ }
27217
+ const rawColumnWidthPx = Math.max(totalWidthPx / columnCount, minimumColumnWidthPx);
27218
+ const columnWidthTwips = clampColumnWidthTwips(pixelsToTwips(rawColumnWidthPx));
27219
+ const fallbackColumnWidthPx = twipsToPixels(columnWidthTwips);
27220
+ return {
27221
+ grid: createFallbackGrid(columnCount, columnWidthTwips),
27222
+ columnWidths: Array(columnCount).fill(fallbackColumnWidthPx)
27223
+ };
27224
+ };
27225
+ const XML_NODE_NAME$9 = "w:tbl";
27226
+ const SD_NODE_NAME$9 = "table";
27227
+ const encode$g = (params2, encodedAttrs) => {
27169
27228
  const { nodes } = params2;
27170
27229
  const node = nodes[0];
27171
27230
  const tblPr = node.elements.find((el) => el.name === "w:tblPr");
27172
27231
  if (tblPr) {
27173
- const encodedProperties = translator$b.encode({ ...params2, nodes: [tblPr] });
27232
+ const encodedProperties = translator$c.encode({ ...params2, nodes: [tblPr] });
27174
27233
  encodedAttrs["tableProperties"] = encodedProperties?.attributes || {};
27175
27234
  }
27176
27235
  const tblGrid = node.elements.find((el) => el.name === "w:tblGrid");
27177
27236
  if (tblGrid) {
27178
- encodedAttrs["grid"] = translator$9.encode({ ...params2, nodes: [tblGrid] }).attributes;
27237
+ encodedAttrs["grid"] = translator$a.encode({ ...params2, nodes: [tblGrid] }).attributes;
27179
27238
  }
27180
27239
  [
27181
27240
  "tableStyleId",
27182
27241
  "justification",
27183
27242
  "tableLayout",
27184
27243
  ["tableIndent", ({ value, type: type2 }) => ({ width: twipsToPixels(value), type: type2 })],
27185
- ["tableWidth", ({ value, type: type2 }) => ({ width: twipsToPixels(value), type: type2 })],
27186
27244
  ["tableCellSpacing", ({ value, type: type2 }) => ({ w: String(value), type: type2 })]
27187
27245
  ].forEach((prop) => {
27188
27246
  let key2;
@@ -27200,6 +27258,21 @@ const encode$f = (params2, encodedAttrs) => {
27200
27258
  if (encodedAttrs.tableCellSpacing) {
27201
27259
  encodedAttrs["borderCollapse"] = "separate";
27202
27260
  }
27261
+ if (encodedAttrs.tableProperties?.tableWidth) {
27262
+ const tableWidthMeasurement = encodedAttrs.tableProperties.tableWidth;
27263
+ const widthPx = twipsToPixels(tableWidthMeasurement.value);
27264
+ if (widthPx != null) {
27265
+ encodedAttrs.tableWidth = {
27266
+ width: widthPx,
27267
+ type: tableWidthMeasurement.type
27268
+ };
27269
+ } else if (tableWidthMeasurement.type === "auto") {
27270
+ encodedAttrs.tableWidth = {
27271
+ width: 0,
27272
+ type: tableWidthMeasurement.type
27273
+ };
27274
+ }
27275
+ }
27203
27276
  const { borders, rowBorders } = _processTableBorders(encodedAttrs.tableProperties?.borders || {});
27204
27277
  const referencedStyles = _getReferencedTableStyles(encodedAttrs.tableStyleId, params2);
27205
27278
  if (referencedStyles?.cellMargins && !encodedAttrs.tableProperties?.cellMargins) {
@@ -27213,10 +27286,22 @@ const encode$f = (params2, encodedAttrs) => {
27213
27286
  const borderRowData = Object.assign({}, referencedStyles?.rowBorders || {}, rowBorders || {});
27214
27287
  encodedAttrs["borders"] = borderData;
27215
27288
  const tblStyleTag = tblPr?.elements?.find((el) => el.name === "w:tblStyle");
27216
- const columnWidths = (encodedAttrs["grid"] ?? []).map((item) => twipsToPixels(item.col));
27289
+ let columnWidths = Array.isArray(encodedAttrs["grid"]) ? encodedAttrs["grid"].map((item) => twipsToPixels(item.col)) : [];
27290
+ if (!columnWidths.length) {
27291
+ const fallback = buildFallbackGridForTable({
27292
+ params: params2,
27293
+ rows,
27294
+ tableWidth: encodedAttrs.tableWidth,
27295
+ tableWidthMeasurement: encodedAttrs.tableProperties?.tableWidth
27296
+ });
27297
+ if (fallback) {
27298
+ encodedAttrs.grid = fallback.grid;
27299
+ columnWidths = fallback.columnWidths;
27300
+ }
27301
+ }
27217
27302
  const content = [];
27218
27303
  rows.forEach((row) => {
27219
- const result = translator$F.encode({
27304
+ const result = translator$G.encode({
27220
27305
  ...params2,
27221
27306
  nodes: [row],
27222
27307
  extraParams: {
@@ -27235,13 +27320,13 @@ const encode$f = (params2, encodedAttrs) => {
27235
27320
  attrs: encodedAttrs
27236
27321
  };
27237
27322
  };
27238
- const decode$f = (params2, decodedAttrs) => {
27323
+ const decode$g = (params2, decodedAttrs) => {
27239
27324
  params2.node = preProcessVerticalMergeCells(params2.node, params2);
27240
27325
  const { node } = params2;
27241
27326
  const elements = translateChildNodes(params2);
27242
27327
  const firstRow = node.content?.find((n) => n.type === "tableRow");
27243
27328
  const properties = node.attrs.grid;
27244
- const element = translator$9.decode({
27329
+ const element = translator$a.decode({
27245
27330
  ...params2,
27246
27331
  node: { ...node, attrs: { ...node.attrs, grid: properties } },
27247
27332
  extraParams: {
@@ -27251,7 +27336,7 @@ const decode$f = (params2, decodedAttrs) => {
27251
27336
  if (element) elements.unshift(element);
27252
27337
  if (node.attrs?.tableProperties) {
27253
27338
  const properties2 = { ...node.attrs.tableProperties };
27254
- const element2 = translator$b.decode({
27339
+ const element2 = translator$c.decode({
27255
27340
  ...params2,
27256
27341
  node: { ...node, attrs: { ...node.attrs, tableProperties: properties2 } }
27257
27342
  });
@@ -27317,7 +27402,7 @@ function _getReferencedTableStyles(tableStyleReference, params2) {
27317
27402
  if (baseTblPr && baseTblPr.elements) {
27318
27403
  tblPr.elements.push(...baseTblPr.elements);
27319
27404
  }
27320
- const tableProperties = translator$b.encode({ ...params2, nodes: [tblPr] }).attributes;
27405
+ const tableProperties = translator$c.encode({ ...params2, nodes: [tblPr] }).attributes;
27321
27406
  const { borders, rowBorders } = _processTableBorders(tableProperties.borders || {});
27322
27407
  if (borders) stylesToReturn.borders = borders;
27323
27408
  if (rowBorders) stylesToReturn.rowBorders = rowBorders;
@@ -27334,16 +27419,16 @@ function _getReferencedTableStyles(tableStyleReference, params2) {
27334
27419
  }
27335
27420
  return stylesToReturn;
27336
27421
  }
27337
- const config$8 = {
27338
- xmlName: XML_NODE_NAME$8,
27339
- sdNodeOrKeyName: SD_NODE_NAME$8,
27422
+ const config$9 = {
27423
+ xmlName: XML_NODE_NAME$9,
27424
+ sdNodeOrKeyName: SD_NODE_NAME$9,
27340
27425
  type: NodeTranslator.translatorTypes.NODE,
27341
- encode: encode$f,
27342
- decode: decode$f,
27426
+ encode: encode$g,
27427
+ decode: decode$g,
27343
27428
  attributes: []
27344
27429
  };
27345
- const translator$8 = NodeTranslator.from(config$8);
27346
- const tableNodeHandlerEntity = generateV2HandlerEntity("tableNodeHandler", translator$8);
27430
+ const translator$9 = NodeTranslator.from(config$9);
27431
+ const tableNodeHandlerEntity = generateV2HandlerEntity("tableNodeHandler", translator$9);
27347
27432
  function getReferencedTableStyles(tblStyleTag, docx) {
27348
27433
  if (!tblStyleTag) return null;
27349
27434
  const stylesToReturn = {};
@@ -27705,10 +27790,10 @@ function generateCellMargins(cellMargins) {
27705
27790
  if (left2 != null) elements.push({ name: "w:left", attributes: { "w:w": pixelsToTwips(left2) } });
27706
27791
  return elements;
27707
27792
  }
27708
- const XML_NODE_NAME$7 = "w:tc";
27709
- const SD_NODE_NAME$7 = "tableCell";
27710
- const validXmlAttributes$7 = [];
27711
- function encode$e(params2, encodedAttrs) {
27793
+ const XML_NODE_NAME$8 = "w:tc";
27794
+ const SD_NODE_NAME$8 = "tableCell";
27795
+ const validXmlAttributes$8 = [];
27796
+ function encode$f(params2, encodedAttrs) {
27712
27797
  const {
27713
27798
  node,
27714
27799
  table,
@@ -27735,31 +27820,31 @@ function encode$e(params2, encodedAttrs) {
27735
27820
  }
27736
27821
  return schemaNode;
27737
27822
  }
27738
- function decode$e(params2, decodedAttrs) {
27823
+ function decode$f(params2, decodedAttrs) {
27739
27824
  const translated = translateTableCell(params2);
27740
27825
  if (decodedAttrs && Object.keys(decodedAttrs).length) {
27741
27826
  translated.attributes = { ...translated.attributes || {}, ...decodedAttrs };
27742
27827
  }
27743
27828
  return translated;
27744
27829
  }
27745
- const config$7 = {
27746
- xmlName: XML_NODE_NAME$7,
27747
- sdNodeOrKeyName: SD_NODE_NAME$7,
27830
+ const config$8 = {
27831
+ xmlName: XML_NODE_NAME$8,
27832
+ sdNodeOrKeyName: SD_NODE_NAME$8,
27748
27833
  type: NodeTranslator.translatorTypes.NODE,
27749
- encode: encode$e,
27750
- decode: decode$e,
27751
- attributes: validXmlAttributes$7
27834
+ encode: encode$f,
27835
+ decode: decode$f,
27836
+ attributes: validXmlAttributes$8
27752
27837
  };
27753
- const translator$7 = NodeTranslator.from(config$7);
27754
- const XML_NODE_NAME$6 = "w:hyperlink";
27755
- const SD_NODE_NAME$6 = "link";
27838
+ const translator$8 = NodeTranslator.from(config$8);
27839
+ const XML_NODE_NAME$7 = "w:hyperlink";
27840
+ const SD_NODE_NAME$7 = "link";
27756
27841
  const _createAttributeHandler = (xmlName, sdName) => ({
27757
27842
  xmlName,
27758
27843
  sdName,
27759
27844
  encode: (attributes) => attributes[xmlName],
27760
27845
  decode: (attributes) => attributes[sdName]
27761
27846
  });
27762
- const validXmlAttributes$6 = [
27847
+ const validXmlAttributes$7 = [
27763
27848
  _createAttributeHandler("w:anchor", "anchor"),
27764
27849
  _createAttributeHandler("w:docLocation", "docLocation"),
27765
27850
  {
@@ -27772,7 +27857,7 @@ const validXmlAttributes$6 = [
27772
27857
  _createAttributeHandler("r:id", "rId"),
27773
27858
  _createAttributeHandler("w:tgtFrame", "target")
27774
27859
  ];
27775
- const encode$d = (params2, encodedAttrs) => {
27860
+ const encode$e = (params2, encodedAttrs) => {
27776
27861
  const { nodes, docx, nodeListHandler } = params2;
27777
27862
  const node = nodes[0];
27778
27863
  let href = _resolveHref(docx, encodedAttrs);
@@ -27838,7 +27923,7 @@ const _resolveHref = (docx, encodedAttrs) => {
27838
27923
  }
27839
27924
  return href;
27840
27925
  };
27841
- function decode$d(params2) {
27926
+ function decode$e(params2) {
27842
27927
  const { node } = params2;
27843
27928
  const linkMark = node.marks.find((m2) => m2.type === "link");
27844
27929
  const linkAttrs = this.decodeAttributes({ ...params2, node: linkMark });
@@ -27882,15 +27967,15 @@ function _addNewLinkRelationship(params2, link, rId) {
27882
27967
  });
27883
27968
  return rId;
27884
27969
  }
27885
- const config$6 = {
27886
- xmlName: XML_NODE_NAME$6,
27887
- sdNodeOrKeyName: SD_NODE_NAME$6,
27970
+ const config$7 = {
27971
+ xmlName: XML_NODE_NAME$7,
27972
+ sdNodeOrKeyName: SD_NODE_NAME$7,
27888
27973
  type: NodeTranslator.translatorTypes.NODE,
27889
- encode: encode$d,
27890
- decode: decode$d,
27891
- attributes: validXmlAttributes$6
27974
+ encode: encode$e,
27975
+ decode: decode$e,
27976
+ attributes: validXmlAttributes$7
27892
27977
  };
27893
- const translator$6 = NodeTranslator.from(config$6);
27978
+ const translator$7 = NodeTranslator.from(config$7);
27894
27979
  function parseTagValueJSON(json) {
27895
27980
  if (typeof json !== "string") {
27896
27981
  return {};
@@ -28685,32 +28770,32 @@ function translateAnchorNode(params2) {
28685
28770
  elements: [...anchorElements, ...elementsWithWrap]
28686
28771
  };
28687
28772
  }
28688
- const XML_NODE_NAME$5 = "wp:anchor";
28689
- const SD_NODE_NAME$5 = ["image"];
28690
- const validXmlAttributes$5 = ["distT", "distB", "distL", "distR"].map((xmlName) => createAttributeHandler(xmlName));
28691
- function encode$c(params2) {
28773
+ const XML_NODE_NAME$6 = "wp:anchor";
28774
+ const SD_NODE_NAME$6 = ["image"];
28775
+ const validXmlAttributes$6 = ["distT", "distB", "distL", "distR"].map((xmlName) => createAttributeHandler(xmlName));
28776
+ function encode$d(params2) {
28692
28777
  const { node } = params2.extraParams;
28693
28778
  if (!node || !node.type) {
28694
28779
  return null;
28695
28780
  }
28696
28781
  return handleAnchorNode(params2);
28697
28782
  }
28698
- function decode$c(params2) {
28783
+ function decode$d(params2) {
28699
28784
  const { node } = params2;
28700
28785
  if (!node || !node.type) {
28701
28786
  return null;
28702
28787
  }
28703
28788
  return translateAnchorNode(params2);
28704
28789
  }
28705
- const config$5 = {
28706
- xmlName: XML_NODE_NAME$5,
28707
- sdNodeOrKeyName: SD_NODE_NAME$5,
28790
+ const config$6 = {
28791
+ xmlName: XML_NODE_NAME$6,
28792
+ sdNodeOrKeyName: SD_NODE_NAME$6,
28708
28793
  type: NodeTranslator.translatorTypes.NODE,
28709
- encode: encode$c,
28710
- decode: decode$c,
28711
- attributes: validXmlAttributes$5
28794
+ encode: encode$d,
28795
+ decode: decode$d,
28796
+ attributes: validXmlAttributes$6
28712
28797
  };
28713
- const translator$5 = NodeTranslator.from(config$5);
28798
+ const translator$6 = NodeTranslator.from(config$6);
28714
28799
  function handleInlineNode(params2) {
28715
28800
  const { node } = params2.extraParams;
28716
28801
  if (node.name !== "wp:inline") {
@@ -28726,41 +28811,41 @@ function translateInlineNode(params2) {
28726
28811
  elements: nodeElements.elements
28727
28812
  };
28728
28813
  }
28729
- const XML_NODE_NAME$4 = "wp:inline";
28730
- const SD_NODE_NAME$4 = ["image"];
28731
- const validXmlAttributes$4 = ["distT", "distB", "distL", "distR"].map((xmlName) => createAttributeHandler(xmlName));
28732
- function encode$b(params2) {
28814
+ const XML_NODE_NAME$5 = "wp:inline";
28815
+ const SD_NODE_NAME$5 = ["image"];
28816
+ const validXmlAttributes$5 = ["distT", "distB", "distL", "distR"].map((xmlName) => createAttributeHandler(xmlName));
28817
+ function encode$c(params2) {
28733
28818
  const { node } = params2.extraParams;
28734
28819
  if (!node || !node.type) {
28735
28820
  return null;
28736
28821
  }
28737
28822
  return handleInlineNode(params2);
28738
28823
  }
28739
- function decode$b(params2) {
28824
+ function decode$c(params2) {
28740
28825
  const { node } = params2;
28741
28826
  if (!node || !node.type) {
28742
28827
  return null;
28743
28828
  }
28744
28829
  return translateInlineNode(params2);
28745
28830
  }
28746
- const config$4 = {
28747
- xmlName: XML_NODE_NAME$4,
28748
- sdNodeOrKeyName: SD_NODE_NAME$4,
28831
+ const config$5 = {
28832
+ xmlName: XML_NODE_NAME$5,
28833
+ sdNodeOrKeyName: SD_NODE_NAME$5,
28749
28834
  type: NodeTranslator.translatorTypes.NODE,
28750
- encode: encode$b,
28751
- decode: decode$b,
28752
- attributes: validXmlAttributes$4
28835
+ encode: encode$c,
28836
+ decode: decode$c,
28837
+ attributes: validXmlAttributes$5
28753
28838
  };
28754
- const translator$4 = NodeTranslator.from(config$4);
28755
- const XML_NODE_NAME$3 = "w:drawing";
28756
- const SD_NODE_NAME$3 = [];
28757
- const validXmlAttributes$3 = [];
28758
- function encode$a(params2) {
28839
+ const translator$5 = NodeTranslator.from(config$5);
28840
+ const XML_NODE_NAME$4 = "w:drawing";
28841
+ const SD_NODE_NAME$4 = [];
28842
+ const validXmlAttributes$4 = [];
28843
+ function encode$b(params2) {
28759
28844
  const nodes = params2.nodes;
28760
28845
  const node = nodes[0];
28761
28846
  const translatorByChildName = {
28762
- "wp:anchor": translator$5,
28763
- "wp:inline": translator$4
28847
+ "wp:anchor": translator$6,
28848
+ "wp:inline": translator$5
28764
28849
  };
28765
28850
  return node.elements.reduce((acc, child) => {
28766
28851
  if (acc) return acc;
@@ -28769,12 +28854,12 @@ function encode$a(params2) {
28769
28854
  return translator2.encode({ ...params2, extraParams: { node: child } }) || acc;
28770
28855
  }, null);
28771
28856
  }
28772
- function decode$a(params2) {
28857
+ function decode$b(params2) {
28773
28858
  const { node } = params2;
28774
28859
  if (!node || !node.type) {
28775
28860
  return null;
28776
28861
  }
28777
- const childTranslator = node.attrs.isAnchor ? translator$5 : translator$4;
28862
+ const childTranslator = node.attrs.isAnchor ? translator$6 : translator$5;
28778
28863
  const resultNode = childTranslator.decode(params2);
28779
28864
  return wrapTextInRun(
28780
28865
  {
@@ -28784,15 +28869,15 @@ function decode$a(params2) {
28784
28869
  []
28785
28870
  );
28786
28871
  }
28787
- const config$3 = {
28788
- xmlName: XML_NODE_NAME$3,
28789
- sdNodeOrKeyName: SD_NODE_NAME$3,
28872
+ const config$4 = {
28873
+ xmlName: XML_NODE_NAME$4,
28874
+ sdNodeOrKeyName: SD_NODE_NAME$4,
28790
28875
  type: NodeTranslator.translatorTypes.NODE,
28791
- encode: encode$a,
28792
- decode: decode$a,
28793
- attributes: validXmlAttributes$3
28876
+ encode: encode$b,
28877
+ decode: decode$b,
28878
+ attributes: validXmlAttributes$4
28794
28879
  };
28795
- const translator$3 = NodeTranslator.from(config$3);
28880
+ const translator$4 = NodeTranslator.from(config$4);
28796
28881
  class CommandService {
28797
28882
  /**
28798
28883
  * @param {import('./commands/types/index.js').CommandServiceOptions} props
@@ -30130,7 +30215,7 @@ function prepareTextAnnotation(params2) {
30130
30215
  return getTextNodeForExport(attrs.displayLabel, [...marks, ...marksFromAttrs], params2);
30131
30216
  }
30132
30217
  function prepareImageAnnotation(params2, imageSize) {
30133
- return translator$3.decode({
30218
+ return translator$4.decode({
30134
30219
  ...params2,
30135
30220
  imageSize
30136
30221
  });
@@ -30367,10 +30452,10 @@ function translateStructuredContent(params2) {
30367
30452
  };
30368
30453
  return result;
30369
30454
  }
30370
- const XML_NODE_NAME$2 = "w:sdt";
30371
- const SD_NODE_NAME$2 = ["fieldAnnotation", "structuredContent", "structuredContentBlock", "documentSection"];
30372
- const validXmlAttributes$2 = [];
30373
- function encode$9(params2) {
30455
+ const XML_NODE_NAME$3 = "w:sdt";
30456
+ const SD_NODE_NAME$3 = ["fieldAnnotation", "structuredContent", "structuredContentBlock", "documentSection"];
30457
+ const validXmlAttributes$3 = [];
30458
+ function encode$a(params2) {
30374
30459
  const nodes = params2.nodes;
30375
30460
  const node = nodes[0];
30376
30461
  const { type: sdtType, handler: handler2 } = sdtNodeTypeStrategy(node);
@@ -30380,7 +30465,7 @@ function encode$9(params2) {
30380
30465
  const result = handler2(params2);
30381
30466
  return result;
30382
30467
  }
30383
- function decode$9(params2) {
30468
+ function decode$a(params2) {
30384
30469
  const { node } = params2;
30385
30470
  if (!node || !node.type) {
30386
30471
  return null;
@@ -30396,85 +30481,85 @@ function decode$9(params2) {
30396
30481
  const result = decoder();
30397
30482
  return result;
30398
30483
  }
30399
- const config$2 = {
30400
- xmlName: XML_NODE_NAME$2,
30401
- sdNodeOrKeyName: SD_NODE_NAME$2,
30484
+ const config$3 = {
30485
+ xmlName: XML_NODE_NAME$3,
30486
+ sdNodeOrKeyName: SD_NODE_NAME$3,
30402
30487
  type: NodeTranslator.translatorTypes.NODE,
30403
- encode: encode$9,
30404
- decode: decode$9,
30405
- attributes: validXmlAttributes$2
30488
+ encode: encode$a,
30489
+ decode: decode$a,
30490
+ attributes: validXmlAttributes$3
30406
30491
  };
30407
- const translator$2 = NodeTranslator.from(config$2);
30408
- const encode$8 = (attributes) => {
30492
+ const translator$3 = NodeTranslator.from(config$3);
30493
+ const encode$9 = (attributes) => {
30409
30494
  return attributes["w:id"];
30410
30495
  };
30411
- const decode$8 = (attrs) => {
30496
+ const decode$9 = (attrs) => {
30412
30497
  return attrs.id;
30413
30498
  };
30414
30499
  const attrConfig$6 = Object.freeze({
30415
30500
  xmlName: "w:id",
30416
30501
  sdName: "id",
30417
- encode: encode$8,
30418
- decode: decode$8
30502
+ encode: encode$9,
30503
+ decode: decode$9
30419
30504
  });
30420
- const encode$7 = (attributes) => {
30505
+ const encode$8 = (attributes) => {
30421
30506
  return attributes["w:name"];
30422
30507
  };
30423
- const decode$7 = (attrs) => {
30508
+ const decode$8 = (attrs) => {
30424
30509
  return attrs.name;
30425
30510
  };
30426
30511
  const attrConfig$5 = Object.freeze({
30427
30512
  xmlName: "w:name",
30428
30513
  sdName: "name",
30429
- encode: encode$7,
30430
- decode: decode$7
30514
+ encode: encode$8,
30515
+ decode: decode$8
30431
30516
  });
30432
- const encode$6 = (attributes) => {
30517
+ const encode$7 = (attributes) => {
30433
30518
  return attributes["w:colFirst"];
30434
30519
  };
30435
- const decode$6 = (attrs) => {
30520
+ const decode$7 = (attrs) => {
30436
30521
  return attrs.colFirst;
30437
30522
  };
30438
30523
  const attrConfig$4 = Object.freeze({
30439
30524
  xmlName: "w:colFirst",
30440
30525
  sdName: "colFirst",
30441
- encode: encode$6,
30442
- decode: decode$6
30526
+ encode: encode$7,
30527
+ decode: decode$7
30443
30528
  });
30444
- const encode$5 = (attributes) => {
30529
+ const encode$6 = (attributes) => {
30445
30530
  return attributes["w:colLast"];
30446
30531
  };
30447
- const decode$5 = (attrs) => {
30532
+ const decode$6 = (attrs) => {
30448
30533
  return attrs.colLast;
30449
30534
  };
30450
30535
  const attrConfig$3 = Object.freeze({
30451
30536
  xmlName: "w:colLast",
30452
30537
  sdName: "colLast",
30453
- encode: encode$5,
30454
- decode: decode$5
30538
+ encode: encode$6,
30539
+ decode: decode$6
30455
30540
  });
30456
- const encode$4 = (attributes) => {
30541
+ const encode$5 = (attributes) => {
30457
30542
  return attributes["w:displacedByCustomXml"];
30458
30543
  };
30459
- const decode$4 = (attrs) => {
30544
+ const decode$5 = (attrs) => {
30460
30545
  return attrs.displacedByCustomXml;
30461
30546
  };
30462
30547
  const attrConfig$2 = Object.freeze({
30463
30548
  xmlName: "w:displacedByCustomXml",
30464
30549
  sdName: "displacedByCustomXml",
30465
- encode: encode$4,
30466
- decode: decode$4
30550
+ encode: encode$5,
30551
+ decode: decode$5
30467
30552
  });
30468
- const validXmlAttributes$1 = [attrConfig$6, attrConfig$5, attrConfig$4, attrConfig$3, attrConfig$2];
30469
- const XML_NODE_NAME$1 = "w:bookmarkStart";
30470
- const SD_NODE_NAME$1 = "bookmarkStart";
30471
- const encode$3 = (params2, encodedAttrs = {}) => {
30553
+ const validXmlAttributes$2 = [attrConfig$6, attrConfig$5, attrConfig$4, attrConfig$3, attrConfig$2];
30554
+ const XML_NODE_NAME$2 = "w:bookmarkStart";
30555
+ const SD_NODE_NAME$2 = "bookmarkStart";
30556
+ const encode$4 = (params2, encodedAttrs = {}) => {
30472
30557
  return {
30473
30558
  type: "bookmarkStart",
30474
30559
  attrs: encodedAttrs
30475
30560
  };
30476
30561
  };
30477
- const decode$3 = (params2, decodedAttrs = {}) => {
30562
+ const decode$4 = (params2, decodedAttrs = {}) => {
30478
30563
  const result = {
30479
30564
  name: "w:bookmarkStart",
30480
30565
  elements: []
@@ -30484,49 +30569,49 @@ const decode$3 = (params2, decodedAttrs = {}) => {
30484
30569
  }
30485
30570
  return result;
30486
30571
  };
30487
- const config$1 = {
30488
- xmlName: XML_NODE_NAME$1,
30489
- sdNodeOrKeyName: SD_NODE_NAME$1,
30572
+ const config$2 = {
30573
+ xmlName: XML_NODE_NAME$2,
30574
+ sdNodeOrKeyName: SD_NODE_NAME$2,
30490
30575
  type: NodeTranslator.translatorTypes.NODE,
30491
- encode: encode$3,
30492
- decode: decode$3,
30493
- attributes: validXmlAttributes$1
30576
+ encode: encode$4,
30577
+ decode: decode$4,
30578
+ attributes: validXmlAttributes$2
30494
30579
  };
30495
- const translator$1 = NodeTranslator.from(config$1);
30496
- const encode$2 = (attributes) => {
30580
+ const translator$2 = NodeTranslator.from(config$2);
30581
+ const encode$3 = (attributes) => {
30497
30582
  return attributes["w:id"];
30498
30583
  };
30499
- const decode$2 = (attrs) => {
30584
+ const decode$3 = (attrs) => {
30500
30585
  return attrs.id;
30501
30586
  };
30502
30587
  const attrConfig$1 = Object.freeze({
30503
30588
  xmlName: "w:id",
30504
30589
  sdName: "id",
30505
- encode: encode$2,
30506
- decode: decode$2
30590
+ encode: encode$3,
30591
+ decode: decode$3
30507
30592
  });
30508
- const encode$1 = (attributes) => {
30593
+ const encode$2 = (attributes) => {
30509
30594
  return attributes["w:displacedByCustomXml"];
30510
30595
  };
30511
- const decode$1 = (attrs) => {
30596
+ const decode$2 = (attrs) => {
30512
30597
  return attrs.displacedByCustomXml;
30513
30598
  };
30514
30599
  const attrConfig = Object.freeze({
30515
30600
  xmlName: "w:displacedByCustomXml",
30516
30601
  sdName: "displacedByCustomXml",
30517
- encode: encode$1,
30518
- decode: decode$1
30602
+ encode: encode$2,
30603
+ decode: decode$2
30519
30604
  });
30520
- const validXmlAttributes = [attrConfig$1, attrConfig];
30521
- const XML_NODE_NAME = "w:bookmarkEnd";
30522
- const SD_NODE_NAME = "bookmarkEnd";
30523
- const encode$18 = (params2, encodedAttrs = {}) => {
30605
+ const validXmlAttributes$1 = [attrConfig$1, attrConfig];
30606
+ const XML_NODE_NAME$1 = "w:bookmarkEnd";
30607
+ const SD_NODE_NAME$1 = "bookmarkEnd";
30608
+ const encode$1 = (params2, encodedAttrs = {}) => {
30524
30609
  return {
30525
30610
  type: "bookmarkEnd",
30526
30611
  attrs: encodedAttrs
30527
30612
  };
30528
30613
  };
30529
- const decode = (params2, decodedAttrs = {}) => {
30614
+ const decode$1 = (params2, decodedAttrs = {}) => {
30530
30615
  const result = {
30531
30616
  name: "w:bookmarkEnd",
30532
30617
  elements: []
@@ -30536,15 +30621,121 @@ const decode = (params2, decodedAttrs = {}) => {
30536
30621
  }
30537
30622
  return result;
30538
30623
  };
30624
+ const config$1 = {
30625
+ xmlName: XML_NODE_NAME$1,
30626
+ sdNodeOrKeyName: SD_NODE_NAME$1,
30627
+ type: NodeTranslator.translatorTypes.NODE,
30628
+ encode: encode$1,
30629
+ decode: decode$1,
30630
+ attributes: validXmlAttributes$1
30631
+ };
30632
+ const translator$1 = NodeTranslator.from(config$1);
30633
+ const XML_NODE_NAME = "mc:AlternateContent";
30634
+ const SD_NODE_NAME = [];
30635
+ const validXmlAttributes = [];
30636
+ function encode$19(params2) {
30637
+ const { nodeListHandler } = params2;
30638
+ const { node } = params2.extraParams;
30639
+ if (!node || !node.type) {
30640
+ return null;
30641
+ }
30642
+ const allowedNamespaces = ["wps", "wp14", "w14", "w15"];
30643
+ const wpsNode = node.elements.find(
30644
+ (el) => el.name === "mc:Choice" && allowedNamespaces.includes(el.attributes["Requires"])
30645
+ );
30646
+ if (!wpsNode) {
30647
+ return null;
30648
+ }
30649
+ const contents = wpsNode.elements;
30650
+ return nodeListHandler.handler({
30651
+ ...params2,
30652
+ nodes: contents,
30653
+ path: [...params2.path || [], wpsNode]
30654
+ });
30655
+ }
30656
+ function decode(params2) {
30657
+ const { node } = params2;
30658
+ const { drawingContent } = node.attrs;
30659
+ const drawing = {
30660
+ name: "w:drawing",
30661
+ elements: [...drawingContent ? [...drawingContent.elements || []] : []]
30662
+ };
30663
+ const choice = {
30664
+ name: "mc:Choice",
30665
+ attributes: { Requires: "wps" },
30666
+ elements: [drawing]
30667
+ };
30668
+ return {
30669
+ name: "mc:AlternateContent",
30670
+ elements: [choice]
30671
+ };
30672
+ }
30539
30673
  const config = {
30540
30674
  xmlName: XML_NODE_NAME,
30541
30675
  sdNodeOrKeyName: SD_NODE_NAME,
30542
30676
  type: NodeTranslator.translatorTypes.NODE,
30543
- encode: encode$18,
30677
+ encode: encode$19,
30544
30678
  decode,
30545
30679
  attributes: validXmlAttributes
30546
30680
  };
30547
30681
  const translator = NodeTranslator.from(config);
30682
+ const DEFAULT_SECTION_PROPS_TWIPS = Object.freeze({
30683
+ pageSize: Object.freeze({ width: "12240", height: "15840" }),
30684
+ pageMargins: Object.freeze({
30685
+ top: "1440",
30686
+ right: "1440",
30687
+ bottom: "1440",
30688
+ left: "1440",
30689
+ header: "720",
30690
+ footer: "720",
30691
+ gutter: "0"
30692
+ })
30693
+ });
30694
+ const ensureSectionLayoutDefaults = (sectPr, converter) => {
30695
+ if (!sectPr) {
30696
+ return {
30697
+ type: "element",
30698
+ name: "w:sectPr",
30699
+ elements: []
30700
+ };
30701
+ }
30702
+ if (!sectPr.elements) sectPr.elements = [];
30703
+ const ensureChild = (name) => {
30704
+ let child = sectPr.elements.find((n) => n.name === name);
30705
+ if (!child) {
30706
+ child = {
30707
+ type: "element",
30708
+ name,
30709
+ elements: [],
30710
+ attributes: {}
30711
+ };
30712
+ sectPr.elements.push(child);
30713
+ } else {
30714
+ if (!child.elements) child.elements = [];
30715
+ if (!child.attributes) child.attributes = {};
30716
+ }
30717
+ return child;
30718
+ };
30719
+ const pageSize = converter?.pageStyles?.pageSize;
30720
+ const pgSz = ensureChild("w:pgSz");
30721
+ if (pageSize?.width != null) pgSz.attributes["w:w"] = String(inchesToTwips(pageSize.width));
30722
+ if (pageSize?.height != null) pgSz.attributes["w:h"] = String(inchesToTwips(pageSize.height));
30723
+ if (pgSz.attributes["w:w"] == null) pgSz.attributes["w:w"] = DEFAULT_SECTION_PROPS_TWIPS.pageSize.width;
30724
+ if (pgSz.attributes["w:h"] == null) pgSz.attributes["w:h"] = DEFAULT_SECTION_PROPS_TWIPS.pageSize.height;
30725
+ const pageMargins = converter?.pageStyles?.pageMargins;
30726
+ const pgMar = ensureChild("w:pgMar");
30727
+ if (pageMargins) {
30728
+ Object.entries(pageMargins).forEach(([key2, value]) => {
30729
+ const converted = inchesToTwips(value);
30730
+ if (converted != null) pgMar.attributes[`w:${key2}`] = String(converted);
30731
+ });
30732
+ }
30733
+ Object.entries(DEFAULT_SECTION_PROPS_TWIPS.pageMargins).forEach(([key2, value]) => {
30734
+ const attrKey = `w:${key2}`;
30735
+ if (pgMar.attributes[attrKey] == null) pgMar.attributes[attrKey] = value;
30736
+ });
30737
+ return sectPr;
30738
+ };
30548
30739
  const isLineBreakOnlyRun = (node) => {
30549
30740
  if (!node) return false;
30550
30741
  if (node.type === "lineBreak" || node.type === "hardBreak") return true;
@@ -30559,30 +30750,30 @@ function exportSchemaToJson(params2) {
30559
30750
  doc: translateDocumentNode,
30560
30751
  body: translateBodyNode,
30561
30752
  heading: translateHeadingNode,
30562
- paragraph: translator$12,
30563
- run: translator$T,
30753
+ paragraph: translator$13,
30754
+ run: translator$U,
30564
30755
  text: translateTextNode,
30565
30756
  bulletList: translateList,
30566
30757
  orderedList: translateList,
30567
- lineBreak: translator$15,
30568
- table: translator$8,
30569
- tableRow: translator$F,
30570
- tableCell: translator$7,
30571
- bookmarkStart: translator$1,
30572
- bookmarkEnd: translator,
30573
- fieldAnnotation: translator$2,
30574
- tab: translator$13,
30575
- image: translator$3,
30576
- hardBreak: translator$15,
30758
+ lineBreak: translator$16,
30759
+ table: translator$9,
30760
+ tableRow: translator$G,
30761
+ tableCell: translator$8,
30762
+ bookmarkStart: translator$2,
30763
+ bookmarkEnd: translator$1,
30764
+ fieldAnnotation: translator$3,
30765
+ tab: translator$14,
30766
+ image: translator$4,
30767
+ hardBreak: translator$16,
30577
30768
  commentRangeStart: () => translateCommentNode(params2, "Start"),
30578
30769
  commentRangeEnd: () => translateCommentNode(params2, "End"),
30579
30770
  commentReference: () => null,
30580
30771
  shapeContainer: translateShapeContainer,
30581
30772
  shapeTextbox: translateShapeTextbox,
30582
30773
  contentBlock: translateContentBlock,
30583
- structuredContent: translator$2,
30584
- structuredContentBlock: translator$2,
30585
- documentSection: translator$2,
30774
+ structuredContent: translator$3,
30775
+ structuredContentBlock: translator$3,
30776
+ documentSection: translator$3,
30586
30777
  "page-number": translatePageNumberNode,
30587
30778
  "total-page-number": translateTotalPageNumberNode
30588
30779
  };
@@ -30597,28 +30788,30 @@ function exportSchemaToJson(params2) {
30597
30788
  return handler2(params2);
30598
30789
  }
30599
30790
  function translateBodyNode(params2) {
30600
- let sectPr = params2.bodyNode?.elements.find((n) => n.name === "w:sectPr") || {};
30791
+ let sectPr = params2.bodyNode?.elements?.find((n) => n.name === "w:sectPr");
30792
+ if (!sectPr) {
30793
+ sectPr = {
30794
+ type: "element",
30795
+ name: "w:sectPr",
30796
+ elements: []
30797
+ };
30798
+ } else if (!sectPr.elements) {
30799
+ sectPr = { ...sectPr, elements: [] };
30800
+ }
30801
+ sectPr = ensureSectionLayoutDefaults(sectPr, params2.converter);
30601
30802
  if (params2.converter) {
30602
- const hasHeader = sectPr?.elements?.some((n) => n.name === "w:headerReference");
30803
+ const hasHeader = sectPr.elements?.some((n) => n.name === "w:headerReference");
30603
30804
  const hasDefaultHeader = params2.converter.headerIds?.default;
30604
30805
  if (!hasHeader && hasDefaultHeader && !params2.editor.options.isHeaderOrFooter) {
30605
30806
  const defaultHeader = generateDefaultHeaderFooter("header", params2.converter.headerIds?.default);
30606
30807
  sectPr.elements.push(defaultHeader);
30607
30808
  }
30608
- const hasFooter = sectPr?.elements?.some((n) => n.name === "w:footerReference");
30809
+ const hasFooter = sectPr.elements?.some((n) => n.name === "w:footerReference");
30609
30810
  const hasDefaultFooter = params2.converter.footerIds?.default;
30610
30811
  if (!hasFooter && hasDefaultFooter && !params2.editor.options.isHeaderOrFooter) {
30611
30812
  const defaultFooter = generateDefaultHeaderFooter("footer", params2.converter.footerIds?.default);
30612
30813
  sectPr.elements.push(defaultFooter);
30613
30814
  }
30614
- const newMargins = params2.converter.pageStyles.pageMargins;
30615
- const sectPrMargins = sectPr.elements.find((n) => n.name === "w:pgMar");
30616
- const { attributes } = sectPrMargins;
30617
- Object.entries(newMargins).forEach(([key2, value]) => {
30618
- const convertedValue = inchesToTwips(value);
30619
- attributes[`w:${key2}`] = convertedValue;
30620
- });
30621
- sectPrMargins.attributes = attributes;
30622
30815
  }
30623
30816
  const elements = translateChildNodes(params2);
30624
30817
  if (params2.isHeaderFooter) {
@@ -30921,7 +31114,7 @@ function translateTextNode(params2) {
30921
31114
  const isTrackedNode = node.marks?.some((m2) => trackedMarks.includes(m2.type));
30922
31115
  if (isTrackedNode) return translateTrackedNode(params2);
30923
31116
  const isLinkNode = node.marks?.some((m2) => m2.type === "link");
30924
- if (isLinkNode) return translator$6.decode(params2);
31117
+ if (isLinkNode) return translator$7.decode(params2);
30925
31118
  const { text, marks = [] } = node;
30926
31119
  return getTextNodeForExport(text, marks, params2);
30927
31120
  }
@@ -31227,7 +31420,7 @@ function translateMark(mark) {
31227
31420
  markElement.type = "element";
31228
31421
  break;
31229
31422
  case "underline": {
31230
- const translated = translator$$.decode({
31423
+ const translated = translator$10.decode({
31231
31424
  node: {
31232
31425
  attrs: {
31233
31426
  underlineType: attrs.underlineType ?? attrs.underline ?? null,
@@ -31291,7 +31484,7 @@ function translateMark(mark) {
31291
31484
  break;
31292
31485
  case "highlight": {
31293
31486
  const highlightValue = attrs.color ?? attrs.highlight ?? null;
31294
- const translated = translator$14.decode({ node: { attrs: { highlight: highlightValue } } });
31487
+ const translated = translator$15.decode({ node: { attrs: { highlight: highlightValue } } });
31295
31488
  return translated || {};
31296
31489
  }
31297
31490
  }
@@ -31347,23 +31540,11 @@ function translateShapeTextbox(params2) {
31347
31540
  }
31348
31541
  function translateContentBlock(params2) {
31349
31542
  const { node } = params2;
31350
- const { drawingContent, vmlAttributes, horizontalRule } = node.attrs;
31543
+ const { vmlAttributes, horizontalRule } = node.attrs;
31351
31544
  if (vmlAttributes || horizontalRule) {
31352
31545
  return translateVRectContentBlock(params2);
31353
31546
  }
31354
- const drawing = {
31355
- name: "w:drawing",
31356
- elements: [...drawingContent ? [...drawingContent.elements || []] : []]
31357
- };
31358
- const choice = {
31359
- name: "mc:Choice",
31360
- attributes: { Requires: "wps" },
31361
- elements: [drawing]
31362
- };
31363
- const alternateContent = {
31364
- name: "mc:AlternateContent",
31365
- elements: [choice]
31366
- };
31547
+ const alternateContent = translator.decode(params2);
31367
31548
  return wrapTextInRun(alternateContent);
31368
31549
  }
31369
31550
  function translateVRectContentBlock(params2) {
@@ -31567,7 +31748,7 @@ const handleDrawingNode = (params2) => {
31567
31748
  if (mainNode.name === "w:drawing") node = mainNode;
31568
31749
  else node = mainNode.elements.find((el) => el.name === "w:drawing");
31569
31750
  if (!node) return { nodes: [], consumed: 0 };
31570
- const schemaNode = translator$3.encode(params2);
31751
+ const schemaNode = translator$4.encode(params2);
31571
31752
  const newNodes = schemaNode ? [schemaNode] : [];
31572
31753
  return { nodes: newNodes, consumed: 1 };
31573
31754
  };
@@ -31669,8 +31850,8 @@ const trackChangeNodeHandlerEntity = {
31669
31850
  handlerName: "trackChangeNodeHandler",
31670
31851
  handler: handleTrackChangeNode
31671
31852
  };
31672
- const hyperlinkNodeHandlerEntity = generateV2HandlerEntity("hyperlinkNodeHandler", translator$6);
31673
- const runNodeHandlerEntity = generateV2HandlerEntity("runNodeHandler", translator$T);
31853
+ const hyperlinkNodeHandlerEntity = generateV2HandlerEntity("hyperlinkNodeHandler", translator$7);
31854
+ const runNodeHandlerEntity = generateV2HandlerEntity("runNodeHandler", translator$U);
31674
31855
  const handleTextNode = (params2) => {
31675
31856
  const { nodes, insideTrackChange } = params2;
31676
31857
  if (nodes.length === 0 || !(nodes[0].name === "w:t" || insideTrackChange && nodes[0].name === "w:delText")) {
@@ -31711,7 +31892,7 @@ const handleParagraphNode = (params2) => {
31711
31892
  if (nodes.length === 0 || nodes[0].name !== "w:p") {
31712
31893
  return { nodes: [], consumed: 0 };
31713
31894
  }
31714
- const schemaNode = translator$12.encode(params2);
31895
+ const schemaNode = translator$13.encode(params2);
31715
31896
  const newNodes = schemaNode ? [schemaNode] : [];
31716
31897
  return { nodes: newNodes, consumed: 1 };
31717
31898
  };
@@ -31724,7 +31905,7 @@ const handleSdtNode = (params2) => {
31724
31905
  if (nodes.length === 0 || nodes[0].name !== "w:sdt") {
31725
31906
  return { nodes: [], consumed: 0 };
31726
31907
  }
31727
- const result = translator$2.encode(params2);
31908
+ const result = translator$3.encode(params2);
31728
31909
  if (!result) {
31729
31910
  return { nodes: [], consumed: 0 };
31730
31911
  }
@@ -31814,7 +31995,7 @@ const handler = (params2) => {
31814
31995
  if (nodes.length === 0 || nodes[0].name !== "w:br") {
31815
31996
  return { nodes: [], consumed: 0 };
31816
31997
  }
31817
- const result = translator$15.encode(params2);
31998
+ const result = translator$16.encode(params2);
31818
31999
  if (!result) return { nodes: [], consumed: 0 };
31819
32000
  return {
31820
32001
  nodes: [result],
@@ -31886,7 +32067,7 @@ const handleBookmarkStartNode = (params2) => {
31886
32067
  if (isCustomMarkBookmark(nodes[0], params2.editor)) {
31887
32068
  return handleBookmarkNode(params2);
31888
32069
  }
31889
- const node = translator$1.encode(params2);
32070
+ const node = translator$2.encode(params2);
31890
32071
  if (!node) return { nodes: [], consumed: 0 };
31891
32072
  return { nodes: [node], consumed: 1 };
31892
32073
  };
@@ -31918,7 +32099,7 @@ const handleBookmarkEndNode = (params2) => {
31918
32099
  if (!nodes.length || nodes[0].name !== "w:bookmarkEnd") {
31919
32100
  return { nodes: [], consumed: 0 };
31920
32101
  }
31921
- const node = translator.encode(params2);
32102
+ const node = translator$1.encode(params2);
31922
32103
  if (!node) return { nodes: [], consumed: 0 };
31923
32104
  return { nodes: [node], consumed: 1 };
31924
32105
  };
@@ -31926,32 +32107,86 @@ const bookmarkEndNodeHandlerEntity = {
31926
32107
  handlerName: "w:bookmarkEndTranslator",
31927
32108
  handler: handleBookmarkEndNode
31928
32109
  };
32110
+ const ALTERNATE_CONTENT_NODE = "mc:AlternateContent";
32111
+ const SUPPORTED_REQUIRES = /* @__PURE__ */ new Set([
32112
+ "wps",
32113
+ "wp14",
32114
+ "w14",
32115
+ "w15",
32116
+ "w16",
32117
+ "w16cex",
32118
+ "w16cid",
32119
+ "w16du",
32120
+ "w16sdtdh",
32121
+ "w16sdtfl",
32122
+ "w16se"
32123
+ ]);
32124
+ const skipHandlerResponse = { nodes: [], consumed: 0 };
32125
+ const isAlternateContentNode = (node) => node?.name === ALTERNATE_CONTENT_NODE;
32126
+ const isSupportedChoice = (choice) => {
32127
+ if (!choice?.attributes) return false;
32128
+ const requires = choice.attributes.Requires || choice.attributes.requires;
32129
+ if (!requires) return false;
32130
+ return requires.split(/\s+/).filter(Boolean).some((namespace2) => SUPPORTED_REQUIRES.has(namespace2));
32131
+ };
32132
+ const resolveAlternateContentElements = (alternateContent) => {
32133
+ if (!alternateContent?.elements?.length) return null;
32134
+ const choices = alternateContent.elements.filter((el) => el.name === "mc:Choice");
32135
+ const fallback = alternateContent.elements.find((el) => el.name === "mc:Fallback");
32136
+ const supportedChoice = choices.find(isSupportedChoice);
32137
+ const selectedElements = supportedChoice?.elements || fallback?.elements || choices[0]?.elements;
32138
+ if (!selectedElements) return null;
32139
+ return carbonCopy(selectedElements);
32140
+ };
32141
+ const buildNodeWithoutAlternateContent = (node) => {
32142
+ const { elements } = node || {};
32143
+ if (!elements?.length) return null;
32144
+ let replaced = false;
32145
+ const updatedElements = [];
32146
+ elements.forEach((element) => {
32147
+ if (isAlternateContentNode(element)) {
32148
+ const resolved = resolveAlternateContentElements(element);
32149
+ if (resolved) {
32150
+ updatedElements.push(...resolved);
32151
+ replaced = true;
32152
+ return;
32153
+ }
32154
+ updatedElements.push(carbonCopy(element));
32155
+ return;
32156
+ }
32157
+ updatedElements.push(carbonCopy(element));
32158
+ });
32159
+ if (!replaced) return null;
32160
+ const clone = carbonCopy(node);
32161
+ clone.elements = updatedElements;
32162
+ return clone;
32163
+ };
31929
32164
  const handleAlternateChoice = (params2) => {
31930
- const skipHandlerResponse = { nodes: [], consumed: 0 };
31931
32165
  const { nodes, nodeListHandler } = params2;
31932
- if (nodes.length === 0 || nodes[0].name !== "w:p") {
32166
+ if (!nodes?.length) {
31933
32167
  return skipHandlerResponse;
31934
32168
  }
31935
- const mainNode = nodes[0];
31936
- const node = mainNode?.elements?.find((el) => el.name === "w:r");
31937
- const hasAltChoice = node?.elements?.some((el) => el.name === "mc:AlternateContent");
31938
- if (!hasAltChoice) {
31939
- return skipHandlerResponse;
32169
+ const [currentNode] = nodes;
32170
+ if (isAlternateContentNode(currentNode)) {
32171
+ const resolvedElements = resolveAlternateContentElements(currentNode);
32172
+ if (!resolvedElements) {
32173
+ return skipHandlerResponse;
32174
+ }
32175
+ const result2 = nodeListHandler.handler({
32176
+ ...params2,
32177
+ nodes: resolvedElements,
32178
+ path: [...params2.path || [], currentNode]
32179
+ });
32180
+ return { nodes: result2, consumed: 1 };
31940
32181
  }
31941
- const altChoiceNode = node.elements.find((el) => el.name === "mc:AlternateContent");
31942
- node.elements.findIndex((el) => el.name === "mc:AlternateContent");
31943
- const allowedNamespaces = ["wps", "wp14", "w14", "w15"];
31944
- const wpsNode = altChoiceNode.elements.find(
31945
- (el) => el.name === "mc:Choice" && allowedNamespaces.includes(el.attributes["Requires"])
31946
- );
31947
- if (!wpsNode) {
32182
+ const sanitizedNode = buildNodeWithoutAlternateContent(currentNode);
32183
+ if (!sanitizedNode) {
31948
32184
  return skipHandlerResponse;
31949
32185
  }
31950
- const contents = wpsNode.elements;
31951
32186
  const result = nodeListHandler.handler({
31952
32187
  ...params2,
31953
- nodes: contents,
31954
- path: [...params2.path || [], wpsNode]
32188
+ nodes: [sanitizedNode],
32189
+ path: [...params2.path || [], sanitizedNode]
31955
32190
  });
31956
32191
  return { nodes: result, consumed: 1 };
31957
32192
  };
@@ -32557,7 +32792,7 @@ const handleTabNode = (params2) => {
32557
32792
  if (!nodes.length || nodes[0].name !== "w:tab") {
32558
32793
  return { nodes: [], consumed: 0 };
32559
32794
  }
32560
- const node = translator$13.encode(params2);
32795
+ const node = translator$14.encode(params2);
32561
32796
  return { nodes: [node], consumed: 1 };
32562
32797
  };
32563
32798
  const tabNodeEntityHandler = {
@@ -32591,6 +32826,7 @@ const createDocumentJson = (docx, converter, editor) => {
32591
32826
  const nodeListHandler = defaultNodeListHandler();
32592
32827
  const bodyNode = json.elements[0].elements.find((el) => el.name === "w:body");
32593
32828
  if (bodyNode) {
32829
+ ensureSectionProperties(bodyNode);
32594
32830
  const node = bodyNode;
32595
32831
  const contentElements = node.elements?.filter((n) => n.name !== "w:sectPr") ?? [];
32596
32832
  const content = pruneIgnoredNodes(contentElements);
@@ -32824,6 +33060,59 @@ function getDocumentStyles(node, docx, converter, editor) {
32824
33060
  styles.alternateHeaders = isAlternatingHeadersOddEven(docx);
32825
33061
  return styles;
32826
33062
  }
33063
+ const DEFAULT_SECTION_PROPS = Object.freeze({
33064
+ pageSize: Object.freeze({ width: "12240", height: "15840" }),
33065
+ pageMargins: Object.freeze({
33066
+ top: "1440",
33067
+ right: "1440",
33068
+ bottom: "1440",
33069
+ left: "1440",
33070
+ header: "720",
33071
+ footer: "720",
33072
+ gutter: "0"
33073
+ })
33074
+ });
33075
+ function ensureSectionProperties(bodyNode, converter) {
33076
+ if (!bodyNode.elements) bodyNode.elements = [];
33077
+ let sectPr = bodyNode.elements.find((el) => el.name === "w:sectPr");
33078
+ if (!sectPr) {
33079
+ sectPr = {
33080
+ type: "element",
33081
+ name: "w:sectPr",
33082
+ elements: []
33083
+ };
33084
+ bodyNode.elements.push(sectPr);
33085
+ } else if (!sectPr.elements) {
33086
+ sectPr.elements = [];
33087
+ }
33088
+ const ensureChild = (name, factory) => {
33089
+ let child = sectPr.elements.find((el) => el.name === name);
33090
+ if (!child) {
33091
+ child = factory();
33092
+ sectPr.elements.push(child);
33093
+ } else if (!child.attributes) {
33094
+ child.attributes = {};
33095
+ }
33096
+ return child;
33097
+ };
33098
+ const pgSz = ensureChild("w:pgSz", () => ({
33099
+ type: "element",
33100
+ name: "w:pgSz",
33101
+ attributes: {}
33102
+ }));
33103
+ pgSz.attributes["w:w"] = pgSz.attributes["w:w"] ?? DEFAULT_SECTION_PROPS.pageSize.width;
33104
+ pgSz.attributes["w:h"] = pgSz.attributes["w:h"] ?? DEFAULT_SECTION_PROPS.pageSize.height;
33105
+ const pgMar = ensureChild("w:pgMar", () => ({
33106
+ type: "element",
33107
+ name: "w:pgMar",
33108
+ attributes: {}
33109
+ }));
33110
+ Object.entries(DEFAULT_SECTION_PROPS.pageMargins).forEach(([key2, value]) => {
33111
+ const attrKey = `w:${key2}`;
33112
+ if (pgMar.attributes[attrKey] == null) pgMar.attributes[attrKey] = value;
33113
+ });
33114
+ return sectPr;
33115
+ }
32827
33116
  function getStyleDefinitions(docx) {
32828
33117
  const styles = docx["word/styles.xml"];
32829
33118
  if (!styles) return [];
@@ -33016,6 +33305,36 @@ const FONT_FAMILY_FALLBACKS = Object.freeze({
33016
33305
  auto: "sans-serif"
33017
33306
  });
33018
33307
  const DEFAULT_GENERIC_FALLBACK = "sans-serif";
33308
+ const DEFAULT_FONT_SIZE_PT = 10;
33309
+ const collectRunDefaultProperties = (runProps, { allowOverrideTypeface = true, allowOverrideSize = true, themeResolver, state: state2 }) => {
33310
+ if (!runProps?.elements?.length || !state2) return;
33311
+ const fontsNode = runProps.elements.find((el) => el.name === "w:rFonts");
33312
+ if (fontsNode?.attributes) {
33313
+ const themeName = fontsNode.attributes["w:asciiTheme"];
33314
+ if (themeName) {
33315
+ const themeInfo = themeResolver?.(themeName) || {};
33316
+ if ((allowOverrideTypeface || !state2.typeface) && themeInfo.typeface) state2.typeface = themeInfo.typeface;
33317
+ if ((allowOverrideTypeface || !state2.panose) && themeInfo.panose) state2.panose = themeInfo.panose;
33318
+ }
33319
+ const ascii = fontsNode.attributes["w:ascii"];
33320
+ if ((allowOverrideTypeface || !state2.typeface) && ascii) {
33321
+ state2.typeface = ascii;
33322
+ }
33323
+ }
33324
+ const sizeNode = runProps.elements.find((el) => el.name === "w:sz");
33325
+ if (sizeNode?.attributes?.["w:val"]) {
33326
+ const sizeTwips = Number(sizeNode.attributes["w:val"]);
33327
+ if (Number.isFinite(sizeTwips)) {
33328
+ if (state2.fallbackSzTwips === void 0) state2.fallbackSzTwips = sizeTwips;
33329
+ const sizePt = sizeTwips / 2;
33330
+ if (allowOverrideSize || state2.fontSizePt === void 0) state2.fontSizePt = sizePt;
33331
+ }
33332
+ }
33333
+ const kernNode = runProps.elements.find((el) => el.name === "w:kern");
33334
+ if (kernNode?.attributes?.["w:val"]) {
33335
+ if (allowOverrideSize || state2.kern === void 0) state2.kern = kernNode.attributes["w:val"];
33336
+ }
33337
+ };
33019
33338
  const _SuperConverter = class _SuperConverter2 {
33020
33339
  constructor(params2 = null) {
33021
33340
  __privateAdd$2(this, _SuperConverter_instances);
@@ -33121,7 +33440,7 @@ const _SuperConverter = class _SuperConverter2 {
33121
33440
  return;
33122
33441
  }
33123
33442
  }
33124
- static updateDocumentVersion(docx = this.convertedXml, version2 = "0.20.2") {
33443
+ static updateDocumentVersion(docx = this.convertedXml, version2 = "0.21.1") {
33125
33444
  const customLocation = "docProps/custom.xml";
33126
33445
  if (!docx[customLocation]) {
33127
33446
  docx[customLocation] = generateCustomXml();
@@ -33143,49 +33462,45 @@ const _SuperConverter = class _SuperConverter2 {
33143
33462
  }
33144
33463
  getDocumentDefaultStyles() {
33145
33464
  const styles = this.convertedXml["word/styles.xml"];
33146
- if (!styles) return {};
33147
- const defaults = styles.elements[0].elements.find((el) => el.name === "w:docDefaults");
33148
- const rDefault = defaults.elements.find((el) => el.name === "w:rPrDefault");
33149
- if (!rDefault.elements) return {};
33150
- const rElements = rDefault.elements[0].elements;
33151
- const rFonts = rElements?.find((el) => el.name === "w:rFonts");
33152
- if ("elements" in rDefault) {
33153
- const fontThemeName = rElements.find((el) => el.name === "w:rFonts")?.attributes["w:asciiTheme"];
33154
- let typeface, panose, fontSizeNormal;
33155
- if (fontThemeName) {
33156
- const fontInfo = this.getThemeInfo(fontThemeName);
33157
- typeface = fontInfo.typeface;
33158
- panose = fontInfo.panose;
33159
- } else if (rFonts) {
33160
- typeface = rFonts?.attributes["w:ascii"];
33161
- }
33162
- const paragraphDefaults = styles.elements[0].elements.filter((el) => {
33163
- return el.name === "w:style" && el.attributes["w:styleId"] === "Normal";
33164
- }) || [];
33165
- paragraphDefaults.forEach((el) => {
33166
- const rPr = el.elements.find((el2) => el2.name === "w:rPr");
33167
- const fonts = rPr?.elements?.find((el2) => el2.name === "w:rFonts");
33168
- typeface = fonts?.attributes["w:ascii"];
33169
- fontSizeNormal = Number(rPr?.elements?.find((el2) => el2.name === "w:sz")?.attributes["w:val"]) / 2;
33170
- });
33171
- const rPrDefaults = defaults?.elements?.find((el) => el.name === "w:rPrDefault");
33172
- if (rPrDefaults) {
33173
- const rPr = rPrDefaults.elements?.find((el) => el.name === "w:rPr");
33174
- const fonts = rPr?.elements?.find((el) => el.name === "w:rFonts");
33175
- if (fonts?.attributes?.["w:ascii"]) {
33176
- typeface = fonts.attributes["w:ascii"];
33177
- }
33178
- const fontSizeRaw = rPr?.elements?.find((el) => el.name === "w:sz")?.attributes?.["w:val"];
33179
- if (!fontSizeNormal && fontSizeRaw) {
33180
- fontSizeNormal = Number(fontSizeRaw) / 2;
33181
- }
33182
- }
33183
- const fallbackSz = Number(rElements.find((el) => el.name === "w:sz")?.attributes?.["w:val"]);
33184
- const fontSizePt = fontSizeNormal ?? (Number.isFinite(fallbackSz) ? fallbackSz / 2 : void 0) ?? 10;
33185
- const kern = rElements.find((el) => el.name === "w:kern")?.attributes["w:val"];
33186
- const fontFamilyCss = _SuperConverter2.toCssFontFamily(typeface, this.convertedXml);
33187
- return { fontSizePt, kern, typeface, panose, fontFamilyCss };
33188
- }
33465
+ const styleRoot = styles?.elements?.[0];
33466
+ const styleElements = styleRoot?.elements || [];
33467
+ if (!styleElements.length) return {};
33468
+ const defaults = styleElements.find((el) => el.name === "w:docDefaults");
33469
+ const normalStyle = styleElements.find((el) => el.name === "w:style" && el.attributes?.["w:styleId"] === "Normal");
33470
+ const defaultsState = {
33471
+ typeface: void 0,
33472
+ panose: void 0,
33473
+ fontSizePt: void 0,
33474
+ kern: void 0,
33475
+ fallbackSzTwips: void 0
33476
+ };
33477
+ const docDefaultRun = defaults?.elements?.find((el) => el.name === "w:rPrDefault");
33478
+ const docDefaultProps = docDefaultRun?.elements?.find((el) => el.name === "w:rPr") ?? docDefaultRun;
33479
+ collectRunDefaultProperties(docDefaultProps, {
33480
+ allowOverrideTypeface: true,
33481
+ allowOverrideSize: true,
33482
+ themeResolver: (theme) => this.getThemeInfo(theme),
33483
+ state: defaultsState
33484
+ });
33485
+ const normalRunProps = normalStyle?.elements?.find((el) => el.name === "w:rPr") ?? null;
33486
+ collectRunDefaultProperties(normalRunProps, {
33487
+ allowOverrideTypeface: true,
33488
+ allowOverrideSize: true,
33489
+ themeResolver: (theme) => this.getThemeInfo(theme),
33490
+ state: defaultsState
33491
+ });
33492
+ if (defaultsState.fontSizePt === void 0) {
33493
+ if (Number.isFinite(defaultsState.fallbackSzTwips)) defaultsState.fontSizePt = defaultsState.fallbackSzTwips / 2;
33494
+ else defaultsState.fontSizePt = DEFAULT_FONT_SIZE_PT;
33495
+ }
33496
+ const fontFamilyCss = defaultsState.typeface ? _SuperConverter2.toCssFontFamily(defaultsState.typeface, this.convertedXml) : void 0;
33497
+ const result = {};
33498
+ if (defaultsState.fontSizePt !== void 0) result.fontSizePt = defaultsState.fontSizePt;
33499
+ if (defaultsState.kern !== void 0) result.kern = defaultsState.kern;
33500
+ if (defaultsState.typeface) result.typeface = defaultsState.typeface;
33501
+ if (defaultsState.panose) result.panose = defaultsState.panose;
33502
+ if (fontFamilyCss) result.fontFamilyCss = fontFamilyCss;
33503
+ return result;
33189
33504
  }
33190
33505
  getDocumentFonts() {
33191
33506
  const fontTable = this.convertedXml["word/fontTable.xml"];
@@ -33614,7 +33929,7 @@ function storeSuperdocVersion(docx) {
33614
33929
  function generateCustomXml() {
33615
33930
  return DEFAULT_CUSTOM_XML;
33616
33931
  }
33617
- function generateSuperdocVersion(pid = 2, version2 = "0.20.2") {
33932
+ function generateSuperdocVersion(pid = 2, version2 = "0.21.1") {
33618
33933
  return {
33619
33934
  type: "element",
33620
33935
  name: "property",
@@ -36052,14 +36367,19 @@ class DocxZipper {
36052
36367
  /**
36053
36368
  * Update [Content_Types].xml with extensions of new Image annotations
36054
36369
  */
36055
- async updateContentTypes(docx, media, fromJson) {
36370
+ async updateContentTypes(docx, media, fromJson, updatedDocs = {}) {
36371
+ const additionalPartNames = Object.keys(updatedDocs || {});
36056
36372
  const newMediaTypes = Object.keys(media).map((name) => {
36057
36373
  return this.getFileExtension(name);
36058
36374
  }).filter(Boolean);
36059
36375
  const contentTypesPath = "[Content_Types].xml";
36060
36376
  let contentTypesXml;
36061
36377
  if (fromJson) {
36062
- contentTypesXml = docx.files.find((file) => file.name === contentTypesPath)?.content || "";
36378
+ if (Array.isArray(docx.files)) {
36379
+ contentTypesXml = docx.files.find((file) => file.name === contentTypesPath)?.content || "";
36380
+ } else {
36381
+ contentTypesXml = docx.files?.[contentTypesPath] || "";
36382
+ }
36063
36383
  } else contentTypesXml = await docx.file(contentTypesPath).async("string");
36064
36384
  let typesString = "";
36065
36385
  const defaultMediaTypes = getContentTypesFromXml(contentTypesXml);
@@ -36085,24 +36405,39 @@ class DocxZipper {
36085
36405
  const hasCommentsExtensible = types2.elements?.some(
36086
36406
  (el) => el.name === "Override" && el.attributes.PartName === "/word/commentsExtensible.xml"
36087
36407
  );
36088
- if (docx.files["word/comments.xml"]) {
36408
+ const hasFile = (filename) => {
36409
+ if (!docx?.files) return false;
36410
+ if (!fromJson) return Boolean(docx.files[filename]);
36411
+ if (Array.isArray(docx.files)) return docx.files.some((file) => file.name === filename);
36412
+ return Boolean(docx.files[filename]);
36413
+ };
36414
+ if (hasFile("word/comments.xml")) {
36089
36415
  const commentsDef = `<Override PartName="/word/comments.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml" />`;
36090
36416
  if (!hasComments) typesString += commentsDef;
36091
36417
  }
36092
- if (docx.files["word/commentsExtended.xml"]) {
36418
+ if (hasFile("word/commentsExtended.xml")) {
36093
36419
  const commentsExtendedDef = `<Override PartName="/word/commentsExtended.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtended+xml" />`;
36094
36420
  if (!hasCommentsExtended) typesString += commentsExtendedDef;
36095
36421
  }
36096
- if (docx.files["word/commentsIds.xml"]) {
36422
+ if (hasFile("word/commentsIds.xml")) {
36097
36423
  const commentsIdsDef = `<Override PartName="/word/commentsIds.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.commentsIds+xml" />`;
36098
36424
  if (!hasCommentsIds) typesString += commentsIdsDef;
36099
36425
  }
36100
- if (docx.files["word/commentsExtensible.xml"]) {
36426
+ if (hasFile("word/commentsExtensible.xml")) {
36101
36427
  const commentsExtendedDef = `<Override PartName="/word/commentsExtensible.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtensible+xml" />`;
36102
36428
  if (!hasCommentsExtensible) typesString += commentsExtendedDef;
36103
36429
  }
36104
- Object.keys(docx.files).forEach((name) => {
36105
- if (name.includes(".rels") || !name.includes("header") && !name.includes("footer")) return;
36430
+ const partNames = new Set(additionalPartNames);
36431
+ if (docx?.files) {
36432
+ if (fromJson && Array.isArray(docx.files)) {
36433
+ docx.files.forEach((file) => partNames.add(file.name));
36434
+ } else {
36435
+ Object.keys(docx.files).forEach((key2) => partNames.add(key2));
36436
+ }
36437
+ }
36438
+ partNames.forEach((name) => {
36439
+ if (name.includes(".rels")) return;
36440
+ if (!name.includes("header") && !name.includes("footer")) return;
36106
36441
  const hasExtensible = types2.elements?.some(
36107
36442
  (el) => el.name === "Override" && el.attributes.PartName === `/${name}`
36108
36443
  );
@@ -36113,7 +36448,48 @@ class DocxZipper {
36113
36448
  }
36114
36449
  });
36115
36450
  const beginningString = '<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">';
36116
- const updatedContentTypesXml = contentTypesXml.replace(beginningString, `${beginningString}${typesString}`);
36451
+ let updatedContentTypesXml = contentTypesXml.replace(beginningString, `${beginningString}${typesString}`);
36452
+ let relationshipsXml = updatedDocs["word/_rels/document.xml.rels"];
36453
+ if (!relationshipsXml) {
36454
+ if (fromJson) {
36455
+ if (Array.isArray(docx.files)) {
36456
+ relationshipsXml = docx.files.find((file) => file.name === "word/_rels/document.xml.rels")?.content;
36457
+ } else {
36458
+ relationshipsXml = docx.files?.["word/_rels/document.xml.rels"];
36459
+ }
36460
+ } else {
36461
+ relationshipsXml = await docx.file("word/_rels/document.xml.rels")?.async("string");
36462
+ }
36463
+ }
36464
+ if (relationshipsXml) {
36465
+ try {
36466
+ const relJson = xmljs.xml2js(relationshipsXml, { compact: false });
36467
+ const relationships = relJson.elements?.find((el) => el.name === "Relationships");
36468
+ relationships?.elements?.forEach((rel) => {
36469
+ const type2 = rel.attributes?.Type;
36470
+ const target = rel.attributes?.Target;
36471
+ if (!type2 || !target) return;
36472
+ const isHeader = type2.includes("/header");
36473
+ const isFooter = type2.includes("/footer");
36474
+ if (!isHeader && !isFooter) return;
36475
+ let sanitizedTarget = target.replace(/^\.\//, "");
36476
+ if (sanitizedTarget.startsWith("../")) sanitizedTarget = sanitizedTarget.slice(3);
36477
+ if (sanitizedTarget.startsWith("/")) sanitizedTarget = sanitizedTarget.slice(1);
36478
+ const partName = sanitizedTarget.startsWith("word/") ? sanitizedTarget : `word/${sanitizedTarget}`;
36479
+ partNames.add(partName);
36480
+ });
36481
+ } catch (error) {
36482
+ console.warn("Failed to parse document relationships while updating content types", error);
36483
+ }
36484
+ }
36485
+ partNames.forEach((name) => {
36486
+ if (name.includes(".rels")) return;
36487
+ if (!name.includes("header") && !name.includes("footer")) return;
36488
+ if (updatedContentTypesXml.includes(`PartName="/${name}"`)) return;
36489
+ const type2 = name.includes("header") ? "header" : "footer";
36490
+ const extendedDef = `<Override PartName="/${name}" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.${type2}+xml"/>`;
36491
+ updatedContentTypesXml = updatedContentTypesXml.replace("</Types>", `${extendedDef}</Types>`);
36492
+ });
36117
36493
  if (fromJson) return updatedContentTypesXml;
36118
36494
  docx.file(contentTypesPath, updatedContentTypesXml);
36119
36495
  }
@@ -36154,7 +36530,7 @@ class DocxZipper {
36154
36530
  for (const [fontName, fontUintArray] of Object.entries(fonts)) {
36155
36531
  zip.file(fontName, fontUintArray);
36156
36532
  }
36157
- await this.updateContentTypes(zip, media);
36533
+ await this.updateContentTypes(zip, media, false, updatedDocs);
36158
36534
  return zip;
36159
36535
  }
36160
36536
  /**
@@ -36180,7 +36556,7 @@ class DocxZipper {
36180
36556
  Object.keys(media).forEach((path) => {
36181
36557
  unzippedOriginalDocx.file(path, media[path]);
36182
36558
  });
36183
- await this.updateContentTypes(unzippedOriginalDocx, media);
36559
+ await this.updateContentTypes(unzippedOriginalDocx, media, false, updatedDocs);
36184
36560
  return unzippedOriginalDocx;
36185
36561
  }
36186
36562
  }
@@ -47838,9 +48214,11 @@ const toggleHeaderFooterEditMode = ({ editor, focusedSectionEditor, isEditMode,
47838
48214
  item.editor.view.dom.setAttribute("documentmode", documentMode);
47839
48215
  });
47840
48216
  if (isEditMode) {
47841
- const pm = document.querySelector(".ProseMirror");
47842
- pm.classList.add("header-footer-edit");
47843
- pm.setAttribute("aria-readonly", true);
48217
+ const pm = editor.view?.dom || editor.options.element?.querySelector?.(".ProseMirror");
48218
+ if (pm) {
48219
+ pm.classList.add("header-footer-edit");
48220
+ pm.setAttribute("aria-readonly", true);
48221
+ }
47844
48222
  }
47845
48223
  if (focusedSectionEditor) {
47846
48224
  focusedSectionEditor.view.focus();
@@ -48870,6 +49248,7 @@ const generateTableIfNecessary = ({ tableNode, annotationValues, tr, state: stat
48870
49248
  const mappedRowStart = tr.mapping.map(absoluteRowStart);
48871
49249
  const rowEnd = mappedRowStart + rowNode.nodeSize;
48872
49250
  tr.replaceWith(mappedRowStart, rowEnd, Fragment.from(newRows));
49251
+ tr.setMeta("tableGeneration", true);
48873
49252
  } catch (error) {
48874
49253
  console.error("Error during row generation:", error);
48875
49254
  throw error;
@@ -49274,7 +49653,7 @@ function findFieldAnnotationsBetween(from2, to, doc2) {
49274
49653
  }
49275
49654
  function findRemovedFieldAnnotations(tr) {
49276
49655
  let removedNodes = [];
49277
- 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) {
49656
+ 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) {
49278
49657
  return removedNodes;
49279
49658
  }
49280
49659
  const hasDeletion = transactionDeletedAnything(tr);
@@ -50452,7 +50831,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
50452
50831
  setDocumentMode(documentMode) {
50453
50832
  let cleanedMode = documentMode?.toLowerCase() || "editing";
50454
50833
  if (!this.extensionService || !this.state) return;
50455
- const pm = document.querySelector(".ProseMirror");
50834
+ const pm = this.view?.dom || this.options.element?.querySelector?.(".ProseMirror");
50456
50835
  if (this.options.role === "viewer") cleanedMode = "viewing";
50457
50836
  if (this.options.role === "suggester" && cleanedMode === "editing") cleanedMode = "suggesting";
50458
50837
  if (cleanedMode === "viewing") {
@@ -50682,6 +51061,8 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
50682
51061
  element.style.isolation = "isolate";
50683
51062
  proseMirror.style.outline = "none";
50684
51063
  proseMirror.style.border = "none";
51064
+ element.style.backgroundColor = "#fff";
51065
+ proseMirror.style.backgroundColor = "#fff";
50685
51066
  const { typeface, fontSizePt, fontFamilyCss } = this.converter.getDocumentDefaultStyles() ?? {};
50686
51067
  const resolvedFontFamily = fontFamilyCss || typeface;
50687
51068
  if (resolvedFontFamily) {
@@ -50938,7 +51319,8 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
50938
51319
  files: this.options.content
50939
51320
  },
50940
51321
  media,
50941
- true
51322
+ true,
51323
+ updatedDocs
50942
51324
  );
50943
51325
  return updatedDocs;
50944
51326
  }
@@ -51004,7 +51386,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
51004
51386
  * @returns {Object | void} Migration results
51005
51387
  */
51006
51388
  processCollaborationMigrations() {
51007
- console.debug("[checkVersionMigrations] Current editor version", "0.20.2");
51389
+ console.debug("[checkVersionMigrations] Current editor version", "0.21.1");
51008
51390
  if (!this.options.ydoc) return;
51009
51391
  const metaMap = this.options.ydoc.getMap("meta");
51010
51392
  let docVersion = metaMap.get("version");
@@ -51424,9 +51806,11 @@ createView_fn = function(element) {
51424
51806
  isEditMode: false,
51425
51807
  documentMode: this.options.documentMode
51426
51808
  });
51427
- const pm = document.querySelector(".ProseMirror");
51428
- pm.classList.remove("header-footer-edit");
51429
- pm.setAttribute("aria-readonly", false);
51809
+ const pm = this.view?.dom || this.options.element?.querySelector?.(".ProseMirror");
51810
+ if (pm) {
51811
+ pm.classList.remove("header-footer-edit");
51812
+ pm.setAttribute("aria-readonly", false);
51813
+ }
51430
51814
  }
51431
51815
  setWordSelection(view, pos);
51432
51816
  }
@@ -53481,6 +53865,30 @@ const intToJapaneseCounting = (num) => {
53481
53865
  }
53482
53866
  return result;
53483
53867
  };
53868
+ const isKeyboardInvocation = (event) => {
53869
+ return event.type === "contextmenu" && typeof event.detail === "number" && event.detail === 0 && (event.button === 0 || event.button === void 0) && event.clientX === 0 && event.clientY === 0;
53870
+ };
53871
+ const prefersNativeMenu = (event) => {
53872
+ if (!event) return false;
53873
+ if (event.ctrlKey || event.metaKey) {
53874
+ return true;
53875
+ }
53876
+ return isKeyboardInvocation(event);
53877
+ };
53878
+ const shouldAllowNativeContextMenu = (event) => {
53879
+ return prefersNativeMenu(event);
53880
+ };
53881
+ const shouldBypassContextMenu = shouldAllowNativeContextMenu;
53882
+ const DEFAULT_SELECTION_STATE = Object.freeze({
53883
+ focused: false,
53884
+ preservedSelection: null,
53885
+ showVisualSelection: false,
53886
+ skipFocusReset: false
53887
+ });
53888
+ const normalizeSelectionState = (state2 = {}) => ({
53889
+ ...DEFAULT_SELECTION_STATE,
53890
+ ...state2
53891
+ });
53484
53892
  const CustomSelectionPluginKey = new PluginKey("CustomSelection");
53485
53893
  const handleClickOutside = (event, editor) => {
53486
53894
  const editorElem = editor?.options?.element;
@@ -53518,11 +53926,7 @@ const CustomSelection = Extension.create({
53518
53926
  const customSelectionPlugin = new Plugin({
53519
53927
  key: CustomSelectionPluginKey,
53520
53928
  state: {
53521
- init: () => ({
53522
- focused: false,
53523
- preservedSelection: null,
53524
- showVisualSelection: false
53525
- }),
53929
+ init: () => ({ ...DEFAULT_SELECTION_STATE }),
53526
53930
  apply: (tr, value) => {
53527
53931
  const meta = getFocusMeta(tr);
53528
53932
  if (meta !== void 0) {
@@ -53543,6 +53947,9 @@ const CustomSelection = Extension.create({
53543
53947
  props: {
53544
53948
  handleDOMEvents: {
53545
53949
  contextmenu: (view, event) => {
53950
+ if (shouldAllowNativeContextMenu(event)) {
53951
+ return false;
53952
+ }
53546
53953
  event.preventDefault();
53547
53954
  const { selection } = view.state;
53548
53955
  if (!selection.empty) {
@@ -53550,7 +53957,8 @@ const CustomSelection = Extension.create({
53550
53957
  setFocusMeta(view.state.tr, {
53551
53958
  focused: true,
53552
53959
  preservedSelection: selection,
53553
- showVisualSelection: true
53960
+ showVisualSelection: true,
53961
+ skipFocusReset: true
53554
53962
  })
53555
53963
  );
53556
53964
  }
@@ -53561,6 +53969,9 @@ const CustomSelection = Extension.create({
53561
53969
  },
53562
53970
  mousedown: (view, event) => {
53563
53971
  if (event.button === 2) {
53972
+ if (shouldAllowNativeContextMenu(event)) {
53973
+ return false;
53974
+ }
53564
53975
  event.preventDefault();
53565
53976
  const { selection: selection2 } = view.state;
53566
53977
  if (!selection2.empty) {
@@ -53568,7 +53979,8 @@ const CustomSelection = Extension.create({
53568
53979
  setFocusMeta(view.state.tr, {
53569
53980
  focused: true,
53570
53981
  preservedSelection: selection2,
53571
- showVisualSelection: true
53982
+ showVisualSelection: true,
53983
+ skipFocusReset: true
53572
53984
  })
53573
53985
  );
53574
53986
  this.editor.setOptions({
@@ -53591,7 +54003,8 @@ const CustomSelection = Extension.create({
53591
54003
  setFocusMeta(view.state.tr, {
53592
54004
  focused: true,
53593
54005
  preservedSelection: selection,
53594
- showVisualSelection: true
54006
+ showVisualSelection: true,
54007
+ skipFocusReset: false
53595
54008
  })
53596
54009
  );
53597
54010
  this.editor.setOptions({
@@ -53609,7 +54022,8 @@ const CustomSelection = Extension.create({
53609
54022
  setFocusMeta(view.state.tr, {
53610
54023
  focused: true,
53611
54024
  preservedSelection: selection,
53612
- showVisualSelection: true
54025
+ showVisualSelection: true,
54026
+ skipFocusReset: false
53613
54027
  })
53614
54028
  );
53615
54029
  }
@@ -53620,7 +54034,8 @@ const CustomSelection = Extension.create({
53620
54034
  setFocusMeta(view.state.tr, {
53621
54035
  focused: false,
53622
54036
  preservedSelection: null,
53623
- showVisualSelection: false
54037
+ showVisualSelection: false,
54038
+ skipFocusReset: false
53624
54039
  })
53625
54040
  );
53626
54041
  if (!selection.empty && !this.editor.options.element?.contains(target)) {
@@ -53637,12 +54052,20 @@ const CustomSelection = Extension.create({
53637
54052
  const isElement2 = target instanceof Element;
53638
54053
  const isToolbarBtn = isElement2 && isToolbarButton(target);
53639
54054
  const isToolbarInp = isElement2 && isToolbarInput(target);
54055
+ const focusState = getFocusState(view.state);
54056
+ if (focusState?.skipFocusReset) {
54057
+ view.dispatch(
54058
+ setFocusMeta(view.state.tr, normalizeSelectionState({ ...focusState, skipFocusReset: false }))
54059
+ );
54060
+ return false;
54061
+ }
53640
54062
  if (!isToolbarBtn && !isToolbarInp) {
53641
54063
  view.dispatch(
53642
54064
  setFocusMeta(view.state.tr, {
53643
54065
  focused: false,
53644
54066
  preservedSelection: null,
53645
- showVisualSelection: false
54067
+ showVisualSelection: false,
54068
+ skipFocusReset: false
53646
54069
  })
53647
54070
  );
53648
54071
  }
@@ -53653,12 +54076,16 @@ const CustomSelection = Extension.create({
53653
54076
  const isToolbarBtn = isElement2 && isToolbarButton(target);
53654
54077
  const isToolbarInp = isElement2 && isToolbarInput(target);
53655
54078
  const state2 = getFocusState(view.state);
54079
+ if (state2?.skipFocusReset) {
54080
+ return false;
54081
+ }
53656
54082
  if (isToolbarBtn || isToolbarInp) {
53657
54083
  view.dispatch(
53658
54084
  setFocusMeta(view.state.tr, {
53659
54085
  focused: true,
53660
54086
  preservedSelection: state2.preservedSelection || view.state.selection,
53661
- showVisualSelection: true
54087
+ showVisualSelection: true,
54088
+ skipFocusReset: false
53662
54089
  })
53663
54090
  );
53664
54091
  } else {
@@ -53666,7 +54093,8 @@ const CustomSelection = Extension.create({
53666
54093
  setFocusMeta(view.state.tr, {
53667
54094
  focused: false,
53668
54095
  preservedSelection: null,
53669
- showVisualSelection: false
54096
+ showVisualSelection: false,
54097
+ skipFocusReset: false
53670
54098
  })
53671
54099
  );
53672
54100
  }
@@ -69441,7 +69869,8 @@ const nodeResizer = (nodeNames = ["image"], editor) => {
69441
69869
  const prevSelection = prevState.selection;
69442
69870
  if (selection.from !== prevSelection.from || selection.to !== prevSelection.to) {
69443
69871
  setTimeout(() => {
69444
- const selectedResizableWrapper = document.querySelector(".sd-editor-resizable-wrapper");
69872
+ const searchRoot = editorView?.dom;
69873
+ const selectedResizableWrapper = searchRoot?.querySelector(".sd-editor-resizable-wrapper");
69445
69874
  if (selectedResizableWrapper) {
69446
69875
  showResizeHandles(view2, selectedResizableWrapper);
69447
69876
  } else {
@@ -82977,7 +83406,7 @@ class SuperToolbar extends EventEmitter2 {
82977
83406
  if (!argument) return;
82978
83407
  item.onActivate({ zoom: argument });
82979
83408
  this.emit("superdoc-command", { item, argument });
82980
- const layers = document.querySelector(this.superdoc.config.selector)?.querySelector(".layers");
83409
+ const layers = this.superdoc.element?.querySelector(".layers");
82981
83410
  if (!layers) return;
82982
83411
  const isMobileDevice = typeof screen.orientation !== "undefined";
82983
83412
  const isSmallScreen = window.matchMedia("(max-width: 834px)").matches;
@@ -83552,6 +83981,115 @@ runCommandWithArgumentOnly_fn = function({ item, argument, noArgumentCallback =
83552
83981
  this.updateToolbarState();
83553
83982
  }
83554
83983
  };
83984
+ const onMarginClickCursorChange = (event, editor) => {
83985
+ const y2 = event.clientY;
83986
+ const x = event.clientX;
83987
+ const { view } = editor;
83988
+ const editorRect = view.dom.getBoundingClientRect();
83989
+ let coords = {
83990
+ left: 0,
83991
+ top: y2
83992
+ };
83993
+ let isRightMargin = false;
83994
+ if (x > editorRect.right) {
83995
+ coords.left = editorRect.left + editorRect.width - 1;
83996
+ isRightMargin = true;
83997
+ } else if (x < editorRect.left) {
83998
+ coords.left = editorRect.left;
83999
+ }
84000
+ const pos = view.posAtCoords(coords)?.pos;
84001
+ if (pos) {
84002
+ let cursorPos = pos;
84003
+ if (isRightMargin) {
84004
+ const $pos = view.state.doc.resolve(pos);
84005
+ const charOffset = $pos.textOffset;
84006
+ const node = view.state.doc.nodeAt(pos);
84007
+ const text = node?.text;
84008
+ const charAtPos = text?.charAt(charOffset);
84009
+ cursorPos = node?.isText && charAtPos !== " " ? pos - 1 : pos;
84010
+ }
84011
+ const transaction = view.state.tr.setSelection(TextSelection$1.create(view.state.doc, cursorPos));
84012
+ view.dispatch(transaction);
84013
+ view.focus();
84014
+ }
84015
+ };
84016
+ const checkNodeSpecificClicks = (editor, event, popoverControls) => {
84017
+ if (!editor) return;
84018
+ if (selectionHasNodeOrMark(editor.view.state, "link", { requireEnds: true })) {
84019
+ popoverControls.component = LinkInput;
84020
+ popoverControls.position = {
84021
+ left: `${event.clientX - editor.element.getBoundingClientRect().left}px`,
84022
+ top: `${event.clientY - editor.element.getBoundingClientRect().top + 15}px`
84023
+ };
84024
+ popoverControls.props = {
84025
+ showInput: true
84026
+ };
84027
+ popoverControls.visible = true;
84028
+ }
84029
+ };
84030
+ function selectionHasNodeOrMark(state2, name, options = {}) {
84031
+ const { requireEnds = false } = options;
84032
+ const $from = state2.selection.$from;
84033
+ const $to = state2.selection.$to;
84034
+ if (requireEnds) {
84035
+ for (let d2 = $from.depth; d2 > 0; d2--) {
84036
+ if ($from.node(d2).type.name === name) {
84037
+ return true;
84038
+ }
84039
+ }
84040
+ for (let d2 = $to.depth; d2 > 0; d2--) {
84041
+ if ($to.node(d2).type.name === name) {
84042
+ return true;
84043
+ }
84044
+ }
84045
+ } else {
84046
+ for (let d2 = $from.depth; d2 > 0; d2--) {
84047
+ if ($from.node(d2).type.name === name) {
84048
+ return true;
84049
+ }
84050
+ }
84051
+ }
84052
+ const markType = state2.schema.marks[name];
84053
+ if (markType) {
84054
+ const { from: from2, to, empty: empty2 } = state2.selection;
84055
+ if (requireEnds) {
84056
+ const fromMarks = markType.isInSet($from.marks());
84057
+ const toMarks = markType.isInSet($to.marks());
84058
+ if (fromMarks || toMarks) {
84059
+ return true;
84060
+ }
84061
+ if (empty2 && markType.isInSet(state2.storedMarks || $from.marks())) {
84062
+ return true;
84063
+ }
84064
+ } else {
84065
+ if (empty2) {
84066
+ if (markType.isInSet(state2.storedMarks || $from.marks())) {
84067
+ return true;
84068
+ }
84069
+ } else {
84070
+ let hasMark = false;
84071
+ state2.doc.nodesBetween(from2, to, (node) => {
84072
+ if (markType.isInSet(node.marks)) {
84073
+ hasMark = true;
84074
+ return false;
84075
+ }
84076
+ });
84077
+ if (hasMark) return true;
84078
+ }
84079
+ }
84080
+ }
84081
+ return false;
84082
+ }
84083
+ function moveCursorToMouseEvent(event, editor) {
84084
+ const { view } = editor;
84085
+ const coords = { left: event.clientX, top: event.clientY };
84086
+ const pos = view.posAtCoords(coords)?.pos;
84087
+ if (typeof pos === "number") {
84088
+ const tr = view.state.tr.setSelection(TextSelection$1.create(view.state.doc, pos));
84089
+ view.dispatch(tr);
84090
+ view.focus();
84091
+ }
84092
+ }
83555
84093
  const ICONS = {
83556
84094
  addRowBefore: plusIconSvg,
83557
84095
  addRowAfter: plusIconSvg,
@@ -83751,6 +84289,30 @@ const getPropsByItemId = (itemId, props) => {
83751
84289
  return baseProps;
83752
84290
  }
83753
84291
  };
84292
+ function normalizeClipboardContent(rawClipboardContent) {
84293
+ if (!rawClipboardContent) {
84294
+ return {
84295
+ html: null,
84296
+ text: null,
84297
+ hasContent: false,
84298
+ raw: null
84299
+ };
84300
+ }
84301
+ const html = typeof rawClipboardContent.html === "string" ? rawClipboardContent.html : null;
84302
+ const text = typeof rawClipboardContent.text === "string" ? rawClipboardContent.text : null;
84303
+ const hasHtml = !!html && html.trim().length > 0;
84304
+ const hasText = !!text && text.length > 0;
84305
+ const isObject2 = typeof rawClipboardContent === "object" && rawClipboardContent !== null;
84306
+ const fragmentSize = typeof rawClipboardContent.size === "number" ? rawClipboardContent.size : null;
84307
+ const nestedSize = isObject2 && rawClipboardContent.content && typeof rawClipboardContent.content.size === "number" ? rawClipboardContent.content.size : null;
84308
+ const hasFragmentContent = (fragmentSize ?? nestedSize ?? 0) > 0;
84309
+ return {
84310
+ html,
84311
+ text,
84312
+ hasContent: hasHtml || hasText || hasFragmentContent,
84313
+ raw: rawClipboardContent
84314
+ };
84315
+ }
83754
84316
  async function getEditorContext(editor, event) {
83755
84317
  const { view } = editor;
83756
84318
  const { state: state2 } = view;
@@ -83766,123 +84328,144 @@ async function getEditorContext(editor, event) {
83766
84328
  pos = from2;
83767
84329
  node = state2.doc.nodeAt(pos);
83768
84330
  }
83769
- const clipboardContent = await readFromClipboard(state2);
84331
+ const rawClipboardContent = await readFromClipboard(state2);
84332
+ const clipboardContent = normalizeClipboardContent(rawClipboardContent);
84333
+ const structureFromResolvedPos = pos !== null ? getStructureFromResolvedPos(state2, pos) : null;
84334
+ const isInTable2 = structureFromResolvedPos?.isInTable ?? selectionHasNodeOrMark(state2, "table", { requireEnds: true });
84335
+ const isInList = structureFromResolvedPos?.isInList ?? (selectionHasNodeOrMark(state2, "bulletList", { requireEnds: false }) || selectionHasNodeOrMark(state2, "orderedList", { requireEnds: false }));
84336
+ const isInSectionNode = structureFromResolvedPos?.isInSectionNode ?? selectionHasNodeOrMark(state2, "documentSection", { requireEnds: true });
84337
+ const currentNodeType = node?.type?.name || null;
84338
+ const activeMarks = [];
84339
+ if (event && pos !== null) {
84340
+ const $pos = state2.doc.resolve(pos);
84341
+ if ($pos.marks && typeof $pos.marks === "function") {
84342
+ $pos.marks().forEach((mark) => activeMarks.push(mark.type.name));
84343
+ }
84344
+ if (node && node.marks) {
84345
+ node.marks.forEach((mark) => activeMarks.push(mark.type.name));
84346
+ }
84347
+ } else {
84348
+ state2.storedMarks?.forEach((mark) => activeMarks.push(mark.type.name));
84349
+ state2.selection.$head.marks().forEach((mark) => activeMarks.push(mark.type.name));
84350
+ }
84351
+ const isTrackedChange = activeMarks.includes("trackInsert") || activeMarks.includes("trackDelete");
84352
+ let trackedChangeId = null;
84353
+ if (isTrackedChange && event && pos !== null) {
84354
+ const $pos = state2.doc.resolve(pos);
84355
+ const marksAtPos = $pos.marks();
84356
+ const trackedMark = marksAtPos.find((mark) => mark.type.name === "trackInsert" || mark.type.name === "trackDelete");
84357
+ if (trackedMark) {
84358
+ trackedChangeId = trackedMark.attrs.id;
84359
+ }
84360
+ }
84361
+ const cursorCoords = pos ? view.coordsAtPos(pos) : null;
84362
+ const cursorPosition = cursorCoords ? {
84363
+ x: cursorCoords.left,
84364
+ y: cursorCoords.top
84365
+ } : null;
83770
84366
  return {
83771
- editor,
84367
+ // Selection info
83772
84368
  selectedText,
84369
+ hasSelection: !empty2,
84370
+ selectionStart: from2,
84371
+ selectionEnd: to,
84372
+ // Document structure
84373
+ isInTable: isInTable2,
84374
+ isInList,
84375
+ isInSectionNode,
84376
+ currentNodeType,
84377
+ activeMarks,
84378
+ // Document state
84379
+ isTrackedChange,
84380
+ trackedChangeId,
84381
+ documentMode: editor.options?.documentMode || "editing",
84382
+ canUndo: computeCanUndo(editor, state2),
84383
+ canRedo: computeCanRedo(editor, state2),
84384
+ isEditable: editor.isEditable,
84385
+ // Clipboard
84386
+ clipboardContent,
84387
+ // Position and trigger info
84388
+ cursorPosition,
83773
84389
  pos,
83774
84390
  node,
83775
84391
  event,
83776
- clipboardContent
84392
+ // Editor reference for advanced use cases
84393
+ editor
83777
84394
  };
83778
84395
  }
83779
- const onMarginClickCursorChange = (event, editor) => {
83780
- const y2 = event.clientY;
83781
- const x = event.clientX;
83782
- const { view } = editor;
83783
- const editorRect = view.dom.getBoundingClientRect();
83784
- let coords = {
83785
- left: 0,
83786
- top: y2
83787
- };
83788
- let isRightMargin = false;
83789
- if (x > editorRect.right) {
83790
- coords.left = editorRect.left + editorRect.width - 1;
83791
- isRightMargin = true;
83792
- } else if (x < editorRect.left) {
83793
- coords.left = editorRect.left;
84396
+ function computeCanUndo(editor, state2) {
84397
+ if (typeof editor?.can === "function") {
84398
+ try {
84399
+ const can = editor.can();
84400
+ if (can && typeof can.undo === "function") {
84401
+ return !!can.undo();
84402
+ }
84403
+ } catch (error) {
84404
+ console.warn("[SlashMenu] Unable to determine undo availability via editor.can():", error);
84405
+ }
83794
84406
  }
83795
- const pos = view.posAtCoords(coords)?.pos;
83796
- if (pos) {
83797
- let cursorPos = pos;
83798
- if (isRightMargin) {
83799
- const $pos = view.state.doc.resolve(pos);
83800
- const charOffset = $pos.textOffset;
83801
- const node = view.state.doc.nodeAt(pos);
83802
- const text = node?.text;
83803
- const charAtPos = text?.charAt(charOffset);
83804
- cursorPos = node?.isText && charAtPos !== " " ? pos - 1 : pos;
84407
+ if (isCollaborationEnabled(editor)) {
84408
+ try {
84409
+ const undoManager = yUndoPluginKey.getState(state2)?.undoManager;
84410
+ return !!undoManager && undoManager.undoStack.length > 0;
84411
+ } catch (error) {
84412
+ console.warn("[SlashMenu] Unable to determine undo availability via y-prosemirror:", error);
83805
84413
  }
83806
- const transaction = view.state.tr.setSelection(TextSelection$1.create(view.state.doc, cursorPos));
83807
- view.dispatch(transaction);
83808
- view.focus();
83809
84414
  }
83810
- };
83811
- const checkNodeSpecificClicks = (editor, event, popoverControls) => {
83812
- if (!editor) return;
83813
- if (selectionHasNodeOrMark(editor.view.state, "link", { requireEnds: true })) {
83814
- popoverControls.component = LinkInput;
83815
- popoverControls.position = {
83816
- left: `${event.clientX - editor.element.getBoundingClientRect().left}px`,
83817
- top: `${event.clientY - editor.element.getBoundingClientRect().top + 15}px`
83818
- };
83819
- popoverControls.props = {
83820
- showInput: true
83821
- };
83822
- popoverControls.visible = true;
84415
+ try {
84416
+ return undoDepth(state2) > 0;
84417
+ } catch (error) {
84418
+ console.warn("[SlashMenu] Unable to determine undo availability via history plugin:", error);
84419
+ return false;
83823
84420
  }
83824
- };
83825
- function selectionHasNodeOrMark(state2, name, options = {}) {
83826
- const { requireEnds = false } = options;
83827
- const $from = state2.selection.$from;
83828
- const $to = state2.selection.$to;
83829
- if (requireEnds) {
83830
- for (let d2 = $from.depth; d2 > 0; d2--) {
83831
- if ($from.node(d2).type.name === name) {
83832
- return true;
83833
- }
83834
- }
83835
- for (let d2 = $to.depth; d2 > 0; d2--) {
83836
- if ($to.node(d2).type.name === name) {
83837
- return true;
83838
- }
83839
- }
83840
- } else {
83841
- for (let d2 = $from.depth; d2 > 0; d2--) {
83842
- if ($from.node(d2).type.name === name) {
83843
- return true;
84421
+ }
84422
+ function computeCanRedo(editor, state2) {
84423
+ if (typeof editor?.can === "function") {
84424
+ try {
84425
+ const can = editor.can();
84426
+ if (can && typeof can.redo === "function") {
84427
+ return !!can.redo();
83844
84428
  }
84429
+ } catch (error) {
84430
+ console.warn("[SlashMenu] Unable to determine redo availability via editor.can():", error);
83845
84431
  }
83846
84432
  }
83847
- const markType = state2.schema.marks[name];
83848
- if (markType) {
83849
- const { from: from2, to, empty: empty2 } = state2.selection;
83850
- if (requireEnds) {
83851
- const fromMarks = markType.isInSet($from.marks());
83852
- const toMarks = markType.isInSet($to.marks());
83853
- if (fromMarks || toMarks) {
83854
- return true;
83855
- }
83856
- if (empty2 && markType.isInSet(state2.storedMarks || $from.marks())) {
83857
- return true;
83858
- }
83859
- } else {
83860
- if (empty2) {
83861
- if (markType.isInSet(state2.storedMarks || $from.marks())) {
83862
- return true;
83863
- }
83864
- } else {
83865
- let hasMark = false;
83866
- state2.doc.nodesBetween(from2, to, (node) => {
83867
- if (markType.isInSet(node.marks)) {
83868
- hasMark = true;
83869
- return false;
83870
- }
83871
- });
83872
- if (hasMark) return true;
83873
- }
84433
+ if (isCollaborationEnabled(editor)) {
84434
+ try {
84435
+ const undoManager = yUndoPluginKey.getState(state2)?.undoManager;
84436
+ return !!undoManager && undoManager.redoStack.length > 0;
84437
+ } catch (error) {
84438
+ console.warn("[SlashMenu] Unable to determine redo availability via y-prosemirror:", error);
83874
84439
  }
83875
84440
  }
83876
- return false;
84441
+ try {
84442
+ return redoDepth(state2) > 0;
84443
+ } catch (error) {
84444
+ console.warn("[SlashMenu] Unable to determine redo availability via history plugin:", error);
84445
+ return false;
84446
+ }
83877
84447
  }
83878
- function moveCursorToMouseEvent(event, editor) {
83879
- const { view } = editor;
83880
- const coords = { left: event.clientX, top: event.clientY };
83881
- const pos = view.posAtCoords(coords)?.pos;
83882
- if (typeof pos === "number") {
83883
- const tr = view.state.tr.setSelection(TextSelection$1.create(view.state.doc, pos));
83884
- view.dispatch(tr);
83885
- view.focus();
84448
+ function isCollaborationEnabled(editor) {
84449
+ return Boolean(editor?.options?.collaborationProvider && editor?.options?.ydoc);
84450
+ }
84451
+ function getStructureFromResolvedPos(state2, pos) {
84452
+ try {
84453
+ const $pos = state2.doc.resolve(pos);
84454
+ const ancestors = /* @__PURE__ */ new Set();
84455
+ for (let depth = $pos.depth; depth > 0; depth--) {
84456
+ ancestors.add($pos.node(depth).type.name);
84457
+ }
84458
+ const isInList = ancestors.has("bulletList") || ancestors.has("orderedList");
84459
+ const isInTable2 = ancestors.has("table") || ancestors.has("tableRow") || ancestors.has("tableCell") || ancestors.has("tableHeader");
84460
+ const isInSectionNode = ancestors.has("documentSection");
84461
+ return {
84462
+ isInTable: isInTable2,
84463
+ isInList,
84464
+ isInSectionNode
84465
+ };
84466
+ } catch (error) {
84467
+ console.warn("[SlashMenu] Unable to resolve position for structural context:", error);
84468
+ return null;
83886
84469
  }
83887
84470
  }
83888
84471
  const isModuleEnabled = (editorOptions, moduleName) => {
@@ -83896,8 +84479,52 @@ const isModuleEnabled = (editorOptions, moduleName) => {
83896
84479
  return true;
83897
84480
  }
83898
84481
  };
84482
+ function applyCustomMenuConfiguration(defaultSections, context) {
84483
+ const { editor } = context;
84484
+ const slashMenuConfig = editor.options?.slashMenuConfig;
84485
+ if (!slashMenuConfig) {
84486
+ return defaultSections;
84487
+ }
84488
+ let sections = [];
84489
+ if (slashMenuConfig.includeDefaultItems !== false) {
84490
+ sections = [...defaultSections];
84491
+ }
84492
+ if (slashMenuConfig.customItems && Array.isArray(slashMenuConfig.customItems)) {
84493
+ sections = [...sections, ...slashMenuConfig.customItems];
84494
+ }
84495
+ if (typeof slashMenuConfig.menuProvider === "function") {
84496
+ try {
84497
+ sections = slashMenuConfig.menuProvider(context, sections) || sections;
84498
+ } catch (error) {
84499
+ console.warn("[SlashMenu] Error in custom menuProvider:", error);
84500
+ }
84501
+ }
84502
+ return sections;
84503
+ }
84504
+ function filterCustomItems(sections, context) {
84505
+ return sections.map((section) => {
84506
+ const filteredItems = section.items.filter((item) => {
84507
+ if (typeof item.showWhen === "function") {
84508
+ try {
84509
+ return item.showWhen(context);
84510
+ } catch (error) {
84511
+ console.warn(`[SlashMenu] Error in showWhen for item ${item.id}:`, error);
84512
+ return false;
84513
+ }
84514
+ }
84515
+ return true;
84516
+ });
84517
+ return {
84518
+ ...section,
84519
+ items: filteredItems
84520
+ };
84521
+ }).filter((section) => section.items.length > 0);
84522
+ }
83899
84523
  function getItems(context) {
83900
84524
  const { editor, selectedText, trigger: trigger2, clipboardContent } = context;
84525
+ const clipboardHasContent = Boolean(
84526
+ 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
84527
+ );
83901
84528
  const isInTable2 = selectionHasNodeOrMark(editor.view.state, "table", { requireEnds: true });
83902
84529
  const isInSectionNode = selectionHasNodeOrMark(editor.view.state, "documentSection", { requireEnds: true });
83903
84530
  const sections = [
@@ -84034,12 +84661,13 @@ function getItems(context) {
84034
84661
  ]
84035
84662
  }
84036
84663
  ];
84037
- const filteredSections = sections.map((section) => {
84664
+ let allSections = applyCustomMenuConfiguration(sections, context);
84665
+ const filteredSections = allSections.map((section) => {
84038
84666
  const filteredItems = section.items.filter((item) => {
84039
84667
  if (item.requiresModule && !isModuleEnabled(editor?.options, item.requiresModule)) return false;
84040
84668
  if (item.requiresSelection && !selectedText) return false;
84041
84669
  if (!item.allowedTriggers.includes(trigger2)) return false;
84042
- if (item.requiresClipboard && !clipboardContent) return false;
84670
+ if (item.requiresClipboard && !clipboardHasContent) return false;
84043
84671
  if (item.requiresTableParent && !isInTable2 || item.id === "insert-table" && isInTable2) return false;
84044
84672
  if (item.requiresSectionParent && !isInSectionNode) return false;
84045
84673
  return true;
@@ -84049,7 +84677,8 @@ function getItems(context) {
84049
84677
  items: filteredItems
84050
84678
  };
84051
84679
  }).filter((section) => section.items.length > 0);
84052
- return filteredSections;
84680
+ const finalSections = filterCustomItems(filteredSections, context);
84681
+ return finalSections;
84053
84682
  }
84054
84683
  const _hoisted_1$3 = { class: "slash-menu-items" };
84055
84684
  const _hoisted_2$1 = {
@@ -84084,6 +84713,7 @@ const _sfc_main$4 = {
84084
84713
  const menuRef = ref$1(null);
84085
84714
  const sections = ref$1([]);
84086
84715
  const selectedId = ref$1(null);
84716
+ const currentContext = ref$1(null);
84087
84717
  const handleEditorUpdate = () => {
84088
84718
  if (!props.editor?.isEditable && isOpen.value) {
84089
84719
  closeMenu({ restoreCursor: false });
@@ -84129,6 +84759,44 @@ const _sfc_main$4 = {
84129
84759
  selectedId.value = newItems[0].id;
84130
84760
  }
84131
84761
  });
84762
+ const customItemRefs = /* @__PURE__ */ new Map();
84763
+ const setCustomItemRef = (el, item) => {
84764
+ if (el && item.render) {
84765
+ customItemRefs.set(item.id, { element: el, item });
84766
+ nextTick(() => {
84767
+ renderCustomItem(item.id);
84768
+ });
84769
+ }
84770
+ };
84771
+ const renderCustomItem = async (itemId) => {
84772
+ const refData = customItemRefs.get(itemId);
84773
+ if (!refData || refData.element.hasCustomContent) return;
84774
+ const { element, item } = refData;
84775
+ try {
84776
+ if (!currentContext.value) {
84777
+ currentContext.value = await getEditorContext(props.editor);
84778
+ }
84779
+ const context = currentContext.value;
84780
+ const customElement = item.render(context);
84781
+ if (customElement instanceof HTMLElement) {
84782
+ element.innerHTML = "";
84783
+ element.appendChild(customElement);
84784
+ element.hasCustomContent = true;
84785
+ }
84786
+ } catch (error) {
84787
+ console.warn(`[SlashMenu] Error rendering custom item ${itemId}:`, error);
84788
+ element.innerHTML = `<span>${item.label || "Custom Item"}</span>`;
84789
+ element.hasCustomContent = true;
84790
+ }
84791
+ };
84792
+ const cleanupCustomItems = () => {
84793
+ customItemRefs.forEach((refData) => {
84794
+ if (refData.element) {
84795
+ refData.element.hasCustomContent = false;
84796
+ }
84797
+ });
84798
+ customItemRefs.clear();
84799
+ };
84132
84800
  const handleGlobalKeyDown = (event) => {
84133
84801
  if (event.key === "Escape") {
84134
84802
  event.preventDefault();
@@ -84174,27 +84842,27 @@ const _sfc_main$4 = {
84174
84842
  };
84175
84843
  const handleRightClick = async (event) => {
84176
84844
  const readOnly = !props.editor?.isEditable;
84177
- const isHoldingCtrl = event.ctrlKey;
84178
- if (readOnly || isHoldingCtrl) {
84845
+ if (readOnly || shouldBypassContextMenu(event)) {
84179
84846
  return;
84180
84847
  }
84181
84848
  event.preventDefault();
84849
+ const context = await getEditorContext(props.editor, event);
84850
+ currentContext.value = context;
84851
+ sections.value = getItems({ ...context, trigger: "click" });
84852
+ selectedId.value = flattenedItems.value[0]?.id || null;
84853
+ searchQuery.value = "";
84182
84854
  props.editor.view.dispatch(
84183
84855
  props.editor.view.state.tr.setMeta(SlashMenuPluginKey, {
84184
84856
  type: "open",
84185
- pos: props.editor.view.state.selection.from,
84857
+ pos: context?.pos ?? props.editor.view.state.selection.from,
84186
84858
  clientX: event.clientX,
84187
84859
  clientY: event.clientY
84188
84860
  })
84189
84861
  );
84190
- searchQuery.value = "";
84191
- const context = await getEditorContext(props.editor, event);
84192
- sections.value = getItems({ ...context, trigger: "click" });
84193
- selectedId.value = flattenedItems.value[0]?.id || null;
84194
84862
  };
84195
84863
  const executeCommand = async (item) => {
84196
84864
  if (props.editor) {
84197
- item.action ? await item.action(props.editor) : null;
84865
+ item.action ? await item.action(props.editor, currentContext.value) : null;
84198
84866
  if (item.component) {
84199
84867
  menuRef.value;
84200
84868
  const componentProps = getPropsByItemId(item.id, props);
@@ -84212,7 +84880,7 @@ const _sfc_main$4 = {
84212
84880
  const closeMenu = (options = { restoreCursor: true }) => {
84213
84881
  if (props.editor?.view) {
84214
84882
  const pluginState = SlashMenuPluginKey.getState(props.editor.view.state);
84215
- const { anchorPos } = pluginState;
84883
+ const anchorPos = pluginState?.anchorPos;
84216
84884
  props.editor.view.dispatch(
84217
84885
  props.editor.view.state.tr.setMeta(SlashMenuPluginKey, {
84218
84886
  type: "close"
@@ -84225,6 +84893,8 @@ const _sfc_main$4 = {
84225
84893
  props.editor.view.dispatch(tr);
84226
84894
  props.editor.view.focus();
84227
84895
  }
84896
+ cleanupCustomItems();
84897
+ currentContext.value = null;
84228
84898
  isOpen.value = false;
84229
84899
  searchQuery.value = "";
84230
84900
  sections.value = [];
@@ -84241,19 +84911,29 @@ const _sfc_main$4 = {
84241
84911
  isOpen.value = true;
84242
84912
  menuPosition.value = event.menuPosition;
84243
84913
  searchQuery.value = "";
84244
- const context = await getEditorContext(props.editor);
84245
- sections.value = getItems({ ...context, trigger: "slash" });
84246
- selectedId.value = flattenedItems.value[0]?.id || null;
84914
+ if (!currentContext.value) {
84915
+ const context = await getEditorContext(props.editor);
84916
+ currentContext.value = context;
84917
+ sections.value = getItems({ ...context, trigger: "slash" });
84918
+ selectedId.value = flattenedItems.value[0]?.id || null;
84919
+ } else if (sections.value.length === 0) {
84920
+ const trigger2 = currentContext.value.event?.type === "contextmenu" ? "click" : "slash";
84921
+ sections.value = getItems({ ...currentContext.value, trigger: trigger2 });
84922
+ selectedId.value = flattenedItems.value[0]?.id || null;
84923
+ }
84247
84924
  });
84248
84925
  props.editor.view.dom.addEventListener("contextmenu", handleRightClick);
84249
84926
  props.editor.on("slashMenu:close", () => {
84927
+ cleanupCustomItems();
84250
84928
  isOpen.value = false;
84251
84929
  searchQuery.value = "";
84930
+ currentContext.value = null;
84252
84931
  });
84253
84932
  });
84254
84933
  onBeforeUnmount(() => {
84255
84934
  document.removeEventListener("keydown", handleGlobalKeyDown);
84256
84935
  document.removeEventListener("mousedown", handleGlobalOutsideClick);
84936
+ cleanupCustomItems();
84257
84937
  if (props.editor) {
84258
84938
  try {
84259
84939
  props.editor.off("slashMenu:open");
@@ -84300,12 +84980,19 @@ const _sfc_main$4 = {
84300
84980
  class: normalizeClass(["slash-menu-item", { "is-selected": item.id === selectedId.value }]),
84301
84981
  onClick: ($event) => executeCommand(item)
84302
84982
  }, [
84303
- item.icon ? (openBlock(), createElementBlock("span", {
84983
+ item.render ? (openBlock(), createElementBlock("div", {
84304
84984
  key: 0,
84305
- class: "slash-menu-item-icon",
84306
- innerHTML: item.icon
84307
- }, null, 8, _hoisted_4)) : createCommentVNode("", true),
84308
- createBaseVNode("span", null, toDisplayString(item.label), 1)
84985
+ ref_for: true,
84986
+ ref: (el) => setCustomItemRef(el, item),
84987
+ class: "slash-menu-custom-item"
84988
+ }, null, 512)) : (openBlock(), createElementBlock(Fragment$1, { key: 1 }, [
84989
+ item.icon ? (openBlock(), createElementBlock("span", {
84990
+ key: 0,
84991
+ class: "slash-menu-item-icon",
84992
+ innerHTML: item.icon
84993
+ }, null, 8, _hoisted_4)) : createCommentVNode("", true),
84994
+ createBaseVNode("span", null, toDisplayString(item.label), 1)
84995
+ ], 64))
84309
84996
  ], 10, _hoisted_3$1);
84310
84997
  }), 128))
84311
84998
  ], 64);
@@ -85000,34 +85687,76 @@ const _sfc_main = {
85000
85687
  }
85001
85688
  };
85002
85689
  const SuperInput = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-4d5cff52"]]);
85690
+ const additionalHandlers = Object.freeze({
85691
+ "mc:AlternateContent": translator,
85692
+ "w:b": translator$12,
85693
+ "w:bidiVisual": translator$F,
85694
+ "w:bookmarkEnd": translator$1,
85695
+ "w:bookmarkStart": translator$2,
85696
+ "w:bottom": translator$s,
85697
+ "w:br": translator$16,
85698
+ "w:cantSplit": translator$T,
85699
+ "w:cnfStyle": translator$S,
85700
+ "w:color": translator$_,
85701
+ "w:divId": translator$R,
85702
+ "w:drawing": translator$4,
85703
+ "w:end": translator$q,
85704
+ "w:gridAfter": translator$Q,
85705
+ "w:gridBefore": translator$P,
85706
+ "w:gridCol": translator$b,
85707
+ "w:hidden": translator$O,
85708
+ "w:highlight": translator$15,
85709
+ "w:hyperlink": translator$7,
85710
+ "w:i": translator$11,
85711
+ "w:insideH": translator$o,
85712
+ "w:insideV": translator$n,
85713
+ "w:jc": translator$N,
85714
+ "w:left": translator$m,
85715
+ "w:p": translator$13,
85716
+ "w:r": translator$U,
85717
+ "w:rFonts": translator$Z,
85718
+ "w:rPr": translator$V,
85719
+ "w:rStyle": translator$Y,
85720
+ "w:right": translator$k,
85721
+ "w:sdt": translator$3,
85722
+ "w:shd": translator$E,
85723
+ "w:start": translator$i,
85724
+ "w:strike": translator$$,
85725
+ "w:sz": translator$X,
85726
+ "w:szCs": translator$W,
85727
+ "w:tab": translator$14,
85728
+ "w:tbl": translator$9,
85729
+ "w:tblBorders": translator$e,
85730
+ "w:tblCaption": translator$D,
85731
+ "w:tblCellMar": translator$d,
85732
+ "w:tblCellSpacing": translator$M,
85733
+ "w:tblDescription": translator$C,
85734
+ "w:tblGrid": translator$a,
85735
+ "w:tblHeader": translator$L,
85736
+ "w:tblInd": translator$B,
85737
+ "w:tblLayout": translator$A,
85738
+ "w:tblLook": translator$z,
85739
+ "w:tblOverlap": translator$y,
85740
+ "w:tblPr": translator$c,
85741
+ "w:tblStyle": translator$x,
85742
+ "w:tblStyleColBandSize": translator$w,
85743
+ "w:tblStyleRowBandSize": translator$v,
85744
+ "w:tblW": translator$u,
85745
+ "w:tblpPr": translator$t,
85746
+ "w:tc": translator$8,
85747
+ "w:top": translator$g,
85748
+ "w:tr": translator$G,
85749
+ "w:trHeight": translator$K,
85750
+ "w:trPr": translator$H,
85751
+ "w:u": translator$10,
85752
+ "w:wAfter": translator$J,
85753
+ "w:wBefore": translator$I,
85754
+ "wp:anchor": translator$6,
85755
+ "wp:inline": translator$5
85756
+ });
85003
85757
  const baseHandlers = {
85004
85758
  ...runPropertyTranslators,
85005
- "w:br": translator$15,
85006
- "w:cantSplit": translator$S,
85007
- "w:cnfStyle": translator$R,
85008
- "w:divId": translator$Q,
85009
- "w:gridAfter": translator$P,
85010
- "w:gridBefore": translator$O,
85011
- "w:hidden": translator$N,
85012
- "w:hyperlink": translator$6,
85013
- "w:jc": translator$M,
85014
- "w:p": translator$12,
85015
- "w:r": translator$T,
85016
- "w:rPr": translator$U,
85017
- "w:sdt": translator$2,
85018
- "w:tab": translator$13,
85019
- "w:tblCellSpacing": translator$L,
85020
- "w:tblHeader": translator$K,
85021
- "w:tc": translator$7,
85022
- "w:tr": translator$F,
85023
- "w:trHeight": translator$J,
85024
- "w:trPr": translator$G,
85025
- "w:wAfter": translator$I,
85026
- "w:wBefore": translator$H,
85027
- "wp:anchor": translator$5,
85028
- "wp:inline": translator$4,
85029
- "w:bookmarkStart": translator$1,
85030
- "w:bookmarkEnd": translator
85759
+ ...additionalHandlers
85031
85760
  };
85032
85761
  const registeredHandlers = Object.freeze(baseHandlers);
85033
85762
  const Extensions = {