@harbour-enterprises/superdoc 0.20.1 → 0.21.0-RC1

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 (95) hide show
  1. package/dist/chunks/{PdfViewer-BLwxuMWh.cjs → PdfViewer-BdrjIRpr.cjs} +1 -1
  2. package/dist/chunks/{PdfViewer-t_JS3Mbo.es.js → PdfViewer-DK1etjvu.es.js} +1 -1
  3. package/dist/chunks/{index-CBTSdULo.cjs → index-C_zTr1ZR.cjs} +14 -33
  4. package/dist/chunks/{index-Vp2WxlNm.es.js → index-ucP9WQ5I.es.js} +14 -33
  5. package/dist/chunks/{super-editor.es-DGV2_J23.es.js → super-editor.es-KKA9G1l1.es.js} +1846 -404
  6. package/dist/chunks/{super-editor.es-Cten5oWF.cjs → super-editor.es-XC168Mlw.cjs} +1846 -404
  7. package/dist/core/SuperDoc.d.ts.map +1 -1
  8. package/dist/stores/comments-store.d.ts.map +1 -1
  9. package/dist/super-editor/ai-writer.es.js +2 -2
  10. package/dist/super-editor/chunks/{converter-Dq0PLazx.js → converter-B61ZUb-V.js} +1401 -310
  11. package/dist/super-editor/chunks/{docx-zipper-jT0gaoep.js → docx-zipper-B8nhsVFW.js} +1 -1
  12. package/dist/super-editor/chunks/{editor-BEtv1kuN.js → editor-CQ0o4v54.js} +420 -65
  13. package/dist/super-editor/chunks/{toolbar-CJfSHfLU.js → toolbar-DWzoslZk.js} +11 -21
  14. package/dist/super-editor/converter.es.js +1 -1
  15. package/dist/super-editor/docx-zipper.es.js +2 -2
  16. package/dist/super-editor/editor.es.js +3 -3
  17. package/dist/super-editor/file-zipper.es.js +1 -1
  18. package/dist/super-editor/src/core/commands/index.d.ts +1 -0
  19. package/dist/super-editor/src/core/commands/toggleMarkCascade.d.ts +41 -0
  20. package/dist/super-editor/src/core/super-converter/SuperConverter.d.ts +5 -0
  21. package/dist/super-editor/src/core/super-converter/helpers.d.ts +2 -0
  22. package/dist/super-editor/src/core/super-converter/v2/importer/markImporter.d.ts +12 -0
  23. package/dist/super-editor/src/core/super-converter/v2/importer/runNodeImporter.d.ts +6 -6
  24. package/dist/super-editor/src/core/super-converter/v3/handlers/index.d.ts +20 -4
  25. package/dist/super-editor/src/core/super-converter/v3/handlers/w/b/attributes/index.d.ts +3 -0
  26. package/dist/super-editor/src/core/super-converter/v3/handlers/w/b/attributes/w-val.d.ts +4 -0
  27. package/dist/super-editor/src/core/super-converter/v3/handlers/w/b/b-translator.d.ts +7 -0
  28. package/dist/super-editor/src/core/super-converter/v3/handlers/w/b/index.d.ts +1 -0
  29. package/dist/super-editor/src/core/super-converter/v3/handlers/w/color/attributes/index.d.ts +2 -0
  30. package/dist/super-editor/src/core/super-converter/v3/handlers/w/color/attributes/w-theme-color.d.ts +4 -0
  31. package/dist/super-editor/src/core/super-converter/v3/handlers/w/color/attributes/w-theme-shade.d.ts +4 -0
  32. package/dist/super-editor/src/core/super-converter/v3/handlers/w/color/attributes/w-theme-tint.d.ts +4 -0
  33. package/dist/super-editor/src/core/super-converter/v3/handlers/w/color/attributes/w-val.d.ts +4 -0
  34. package/dist/super-editor/src/core/super-converter/v3/handlers/w/color/color-translator.d.ts +7 -0
  35. package/dist/super-editor/src/core/super-converter/v3/handlers/w/highlight/attributes/index.d.ts +2 -0
  36. package/dist/super-editor/src/core/super-converter/v3/handlers/w/highlight/attributes/w-val.d.ts +4 -0
  37. package/dist/super-editor/src/core/super-converter/v3/handlers/w/highlight/highlight-translator.d.ts +4 -0
  38. package/dist/super-editor/src/core/super-converter/v3/handlers/w/i/attributes/index.d.ts +2 -0
  39. package/dist/super-editor/src/core/super-converter/v3/handlers/w/i/attributes/w-val.d.ts +4 -0
  40. package/dist/super-editor/src/core/super-converter/v3/handlers/w/i/i-translator.d.ts +7 -0
  41. package/dist/super-editor/src/core/super-converter/v3/handlers/w/r/attributes/index.d.ts +2 -0
  42. package/dist/super-editor/src/core/super-converter/v3/handlers/w/r/attributes/w-rsid-del.d.ts +4 -0
  43. package/dist/super-editor/src/core/super-converter/v3/handlers/w/r/attributes/w-rsid-r-pr.d.ts +4 -0
  44. package/dist/super-editor/src/core/super-converter/v3/handlers/w/r/attributes/w-rsid-r.d.ts +4 -0
  45. package/dist/super-editor/src/core/super-converter/v3/handlers/w/r/helpers/helpers.d.ts +40 -0
  46. package/dist/super-editor/src/core/super-converter/v3/handlers/w/r/helpers/index.d.ts +2 -0
  47. package/dist/super-editor/src/core/super-converter/v3/handlers/w/r/helpers/split-run-properties.d.ts +9 -0
  48. package/dist/super-editor/src/core/super-converter/v3/handlers/w/r/index.d.ts +1 -0
  49. package/dist/super-editor/src/core/super-converter/v3/handlers/w/r/r-translator.d.ts +4 -0
  50. package/dist/super-editor/src/core/super-converter/v3/handlers/w/rFonts/attributes/index.d.ts +2 -0
  51. package/dist/super-editor/src/core/super-converter/v3/handlers/w/rFonts/attributes/w-ascii.d.ts +4 -0
  52. package/dist/super-editor/src/core/super-converter/v3/handlers/w/rFonts/attributes/w-cs.d.ts +4 -0
  53. package/dist/super-editor/src/core/super-converter/v3/handlers/w/rFonts/attributes/w-east-asia.d.ts +4 -0
  54. package/dist/super-editor/src/core/super-converter/v3/handlers/w/rFonts/attributes/w-hansi.d.ts +4 -0
  55. package/dist/super-editor/src/core/super-converter/v3/handlers/w/rFonts/attributes/w-val.d.ts +4 -0
  56. package/dist/super-editor/src/core/super-converter/v3/handlers/w/rFonts/index.d.ts +1 -0
  57. package/dist/super-editor/src/core/super-converter/v3/handlers/w/rFonts/rFonts-translator.d.ts +5 -0
  58. package/dist/super-editor/src/core/super-converter/v3/handlers/w/rStyle/attributes/index.d.ts +2 -0
  59. package/dist/super-editor/src/core/super-converter/v3/handlers/w/rStyle/attributes/w-val.d.ts +4 -0
  60. package/dist/super-editor/src/core/super-converter/v3/handlers/w/rStyle/index.d.ts +1 -0
  61. package/dist/super-editor/src/core/super-converter/v3/handlers/w/rStyle/rstyle-translator.d.ts +7 -0
  62. package/dist/super-editor/src/core/super-converter/v3/handlers/w/rpr/index.d.ts +1 -0
  63. package/dist/super-editor/src/core/super-converter/v3/handlers/w/rpr/rpr-translator.d.ts +5 -0
  64. package/dist/super-editor/src/core/super-converter/v3/handlers/w/rpr/run-property-translators.d.ts +11 -0
  65. package/dist/super-editor/src/core/super-converter/v3/handlers/w/strike/attributes/index.d.ts +2 -0
  66. package/dist/super-editor/src/core/super-converter/v3/handlers/w/strike/attributes/w-val.d.ts +4 -0
  67. package/dist/super-editor/src/core/super-converter/v3/handlers/w/strike/strike-translator.d.ts +7 -0
  68. package/dist/super-editor/src/core/super-converter/v3/handlers/w/sz/attributes/index.d.ts +2 -0
  69. package/dist/super-editor/src/core/super-converter/v3/handlers/w/sz/attributes/w-val.d.ts +4 -0
  70. package/dist/super-editor/src/core/super-converter/v3/handlers/w/sz/sz-translator.d.ts +4 -0
  71. package/dist/super-editor/src/core/super-converter/v3/handlers/w/szcs/attributes/index.d.ts +2 -0
  72. package/dist/super-editor/src/core/super-converter/v3/handlers/w/szcs/attributes/w-val.d.ts +4 -0
  73. package/dist/super-editor/src/core/super-converter/v3/handlers/w/szcs/szcs-translator.d.ts +4 -0
  74. package/dist/super-editor/src/core/super-converter/v3/handlers/w/u/attributes/index.d.ts +2 -0
  75. package/dist/super-editor/src/core/super-converter/v3/handlers/w/u/attributes/w-color.d.ts +4 -0
  76. package/dist/super-editor/src/core/super-converter/v3/handlers/w/u/attributes/w-theme-color.d.ts +4 -0
  77. package/dist/super-editor/src/core/super-converter/v3/handlers/w/u/attributes/w-theme-shade.d.ts +4 -0
  78. package/dist/super-editor/src/core/super-converter/v3/handlers/w/u/attributes/w-theme-tint.d.ts +4 -0
  79. package/dist/super-editor/src/core/super-converter/v3/handlers/w/u/attributes/w-val.d.ts +4 -0
  80. package/dist/super-editor/src/core/super-converter/v3/handlers/w/u/u-translator.d.ts +7 -0
  81. package/dist/super-editor/src/extensions/index.d.ts +2 -2
  82. package/dist/super-editor/src/extensions/linked-styles/index.d.ts +1 -0
  83. package/dist/super-editor/src/extensions/linked-styles/underline-css.d.ts +17 -0
  84. package/dist/super-editor/src/extensions/run/index.d.ts +1 -0
  85. package/dist/super-editor/src/extensions/run/run.d.ts +6 -0
  86. package/dist/super-editor/src/extensions/shared/cascade-toggle.d.ts +8 -0
  87. package/dist/super-editor/super-editor.es.js +49 -23
  88. package/dist/super-editor/toolbar.es.js +2 -2
  89. package/dist/super-editor.cjs +1 -1
  90. package/dist/super-editor.es.js +1 -1
  91. package/dist/superdoc.cjs +2 -2
  92. package/dist/superdoc.es.js +2 -2
  93. package/dist/superdoc.umd.js +1860 -437
  94. package/dist/superdoc.umd.js.map +1 -1
  95. package/package.json +1 -1
@@ -14877,25 +14877,47 @@ const getContentTypesFromXml = (contentTypesXml) => {
14877
14877
  const defaults = xmlDoc.querySelectorAll("Default");
14878
14878
  return Array.from(defaults).map((item) => item.getAttribute("Extension"));
14879
14879
  };
14880
+ const DOCX_HIGHLIGHT_KEYWORD_MAP = /* @__PURE__ */ new Map([
14881
+ ["yellow", "FFFF00"],
14882
+ ["green", "00FF00"],
14883
+ ["blue", "0000FF"],
14884
+ ["cyan", "00FFFF"],
14885
+ ["magenta", "FF00FF"],
14886
+ ["red", "FF0000"],
14887
+ ["darkYellow", "808000"],
14888
+ ["darkGreen", "008000"],
14889
+ ["darkBlue", "000080"],
14890
+ ["darkCyan", "008080"],
14891
+ ["darkMagenta", "800080"],
14892
+ ["darkGray", "808080"],
14893
+ ["darkRed", "800000"],
14894
+ ["lightGray", "C0C0C0"],
14895
+ ["black", "000000"],
14896
+ ["white", "FFFFFF"]
14897
+ ]);
14898
+ const normalizeHexColor = (hex2) => {
14899
+ if (!hex2) return null;
14900
+ let value = hex2.replace("#", "").trim();
14901
+ if (!value) return null;
14902
+ value = value.toUpperCase();
14903
+ if (value.length === 3)
14904
+ value = value.split("").map((c2) => c2 + c2).join("");
14905
+ if (value.length === 8) value = value.slice(0, 6);
14906
+ return value;
14907
+ };
14880
14908
  const getHexColorFromDocxSystem = (docxColor) => {
14881
- const colorMap = /* @__PURE__ */ new Map([
14882
- ["yellow", "#ffff00"],
14883
- ["green", "#00ff00"],
14884
- ["blue", "#0000FFFF"],
14885
- ["cyan", "#00ffff"],
14886
- ["magenta", "#ff00ff"],
14887
- ["red", "#ff0000"],
14888
- ["darkYellow", "#808000FF"],
14889
- ["darkGreen", "#008000FF"],
14890
- ["darkBlue", "#000080"],
14891
- ["darkCyan", "#008080FF"],
14892
- ["darkMagenta", "#800080FF"],
14893
- ["darkGray", "#808080FF"],
14894
- ["darkRed", "#800000FF"],
14895
- ["lightGray", "#C0C0C0FF"],
14896
- ["black", "#000"]
14897
- ]);
14898
- return colorMap.get(docxColor) || null;
14909
+ const hex2 = DOCX_HIGHLIGHT_KEYWORD_MAP.get(docxColor);
14910
+ return hex2 ? `#${hex2}` : null;
14911
+ };
14912
+ const getDocxHighlightKeywordFromHex = (hexColor) => {
14913
+ if (!hexColor) return null;
14914
+ if (DOCX_HIGHLIGHT_KEYWORD_MAP.has(hexColor)) return hexColor;
14915
+ const normalized = normalizeHexColor(hexColor);
14916
+ if (!normalized) return null;
14917
+ for (const [keyword, hex2] of DOCX_HIGHLIGHT_KEYWORD_MAP.entries()) {
14918
+ if (hex2 === normalized) return keyword;
14919
+ }
14920
+ return null;
14899
14921
  };
14900
14922
  function isValidHexColor(color) {
14901
14923
  if (!color || typeof color !== "string") return false;
@@ -24296,37 +24318,37 @@ const _NodeTranslator = class _NodeTranslator2 {
24296
24318
  };
24297
24319
  __publicField$2(_NodeTranslator, "translatorTypes", TranslatorTypes);
24298
24320
  let NodeTranslator = _NodeTranslator;
24299
- const encode$j = (attributes) => {
24321
+ const encode$T = (attributes) => {
24300
24322
  return attributes["w:type"];
24301
24323
  };
24302
- const decode$j = (attrs) => {
24324
+ const decode$K = (attrs) => {
24303
24325
  const { lineBreakType } = attrs;
24304
24326
  return lineBreakType;
24305
24327
  };
24306
- const attrConfig$b = Object.freeze({
24328
+ const attrConfig$z = Object.freeze({
24307
24329
  xmlName: "w:type",
24308
24330
  sdName: "lineBreakType",
24309
- encode: encode$j,
24310
- decode: decode$j
24331
+ encode: encode$T,
24332
+ decode: decode$K
24311
24333
  });
24312
- const encode$i = (attributes) => {
24334
+ const encode$S = (attributes) => {
24313
24335
  const xmlAttrValue = attributes["w:clear"];
24314
24336
  return xmlAttrValue;
24315
24337
  };
24316
- const decode$i = (attrs) => {
24338
+ const decode$J = (attrs) => {
24317
24339
  const { clear } = attrs;
24318
24340
  return clear;
24319
24341
  };
24320
- const attrConfig$a = Object.freeze({
24342
+ const attrConfig$y = Object.freeze({
24321
24343
  xmlName: "w:clear",
24322
24344
  sdName: "clear",
24323
- encode: encode$i,
24324
- decode: decode$i
24345
+ encode: encode$S,
24346
+ decode: decode$J
24325
24347
  });
24326
- const validXmlAttributes$6 = [attrConfig$b, attrConfig$a];
24327
- const XML_NODE_NAME$7 = "w:br";
24348
+ const validXmlAttributes$h = [attrConfig$z, attrConfig$y];
24349
+ const XML_NODE_NAME$j = "w:br";
24328
24350
  const SD_NODE_NAME$6 = "lineBreak";
24329
- const encode$h = (_2, encodedAttrs) => {
24351
+ const encode$R = (_2, encodedAttrs) => {
24330
24352
  const isPageBreak = encodedAttrs?.lineBreakType === "page";
24331
24353
  const translated = {
24332
24354
  type: isPageBreak ? "hardBreak" : "lineBreak"
@@ -24336,7 +24358,7 @@ const encode$h = (_2, encodedAttrs) => {
24336
24358
  }
24337
24359
  return translated;
24338
24360
  };
24339
- const decode$h = (params2, decodedAttrs) => {
24361
+ const decode$I = (params2, decodedAttrs) => {
24340
24362
  const { node } = params2;
24341
24363
  if (!node) return;
24342
24364
  const wBreak = { name: "w:br" };
@@ -24353,63 +24375,120 @@ const decode$h = (params2, decodedAttrs) => {
24353
24375
  };
24354
24376
  return translated;
24355
24377
  };
24356
- const config$7 = {
24357
- xmlName: XML_NODE_NAME$7,
24378
+ const config$j = {
24379
+ xmlName: XML_NODE_NAME$j,
24358
24380
  sdNodeOrKeyName: SD_NODE_NAME$6,
24359
24381
  type: NodeTranslator.translatorTypes.NODE,
24360
- encode: encode$h,
24361
- decode: decode$h,
24362
- attributes: validXmlAttributes$6
24382
+ encode: encode$R,
24383
+ decode: decode$I,
24384
+ attributes: validXmlAttributes$h
24385
+ };
24386
+ const translator$v = NodeTranslator.from(config$j);
24387
+ const encode$Q = (attributes) => attributes?.["w:val"];
24388
+ const decode$H = (attrs) => attrs?.highlight;
24389
+ const attrConfig$x = Object.freeze({
24390
+ xmlName: "w:val",
24391
+ sdName: "highlight",
24392
+ encode: encode$Q,
24393
+ decode: decode$H
24394
+ });
24395
+ const validXmlAttributes$g = [attrConfig$x];
24396
+ const XML_NODE_NAME$i = "w:highlight";
24397
+ const SD_ATTR_KEY$b = "highlight";
24398
+ const encode$P = (params2, encodedAttrs = {}) => {
24399
+ const { nodes } = params2;
24400
+ const node = nodes?.[0];
24401
+ const value = encodedAttrs.highlight ?? node?.attributes?.["w:val"];
24402
+ return {
24403
+ type: "attr",
24404
+ xmlName: XML_NODE_NAME$i,
24405
+ sdNodeOrKeyName: SD_ATTR_KEY$b,
24406
+ attributes: { "w:val": value ?? null }
24407
+ };
24408
+ };
24409
+ const decode$G = (params2) => {
24410
+ const attrs = params2?.node?.attrs || {};
24411
+ const highlightValue = attrs.highlight ?? attrs.color ?? null;
24412
+ if (!highlightValue) return void 0;
24413
+ const normalizedValue = String(highlightValue).trim().toLowerCase();
24414
+ if (!normalizedValue || normalizedValue === "transparent" || normalizedValue === "none") {
24415
+ return void 0;
24416
+ }
24417
+ const keyword = getDocxHighlightKeywordFromHex(highlightValue);
24418
+ if (keyword) {
24419
+ return {
24420
+ name: XML_NODE_NAME$i,
24421
+ attributes: { "w:val": keyword }
24422
+ };
24423
+ }
24424
+ const fill = normalizeHexColor(highlightValue);
24425
+ if (!fill) return void 0;
24426
+ return {
24427
+ name: "w:shd",
24428
+ attributes: {
24429
+ "w:color": "auto",
24430
+ "w:val": "clear",
24431
+ "w:fill": fill
24432
+ }
24433
+ };
24363
24434
  };
24364
- const translator$j = NodeTranslator.from(config$7);
24365
- const encode$g = (attributes) => {
24435
+ const config$i = {
24436
+ xmlName: XML_NODE_NAME$i,
24437
+ sdNodeOrKeyName: SD_ATTR_KEY$b,
24438
+ type: NodeTranslator.translatorTypes.ATTRIBUTE,
24439
+ encode: encode$P,
24440
+ decode: decode$G,
24441
+ attributes: validXmlAttributes$g
24442
+ };
24443
+ const translator$u = NodeTranslator.from(config$i);
24444
+ const encode$O = (attributes) => {
24366
24445
  return attributes["w:val"];
24367
24446
  };
24368
- const decode$g = (attrs) => {
24447
+ const decode$F = (attrs) => {
24369
24448
  const { tabSize } = attrs || {};
24370
24449
  return tabSize;
24371
24450
  };
24372
- const attrConfig$9 = Object.freeze({
24451
+ const attrConfig$w = Object.freeze({
24373
24452
  xmlName: "w:val",
24374
24453
  sdName: "tabSize",
24375
- encode: encode$g,
24376
- decode: decode$g
24454
+ encode: encode$O,
24455
+ decode: decode$F
24377
24456
  });
24378
- const encode$f = (attributes) => {
24457
+ const encode$N = (attributes) => {
24379
24458
  return attributes["w:leader"];
24380
24459
  };
24381
- const decode$f = (attrs) => {
24460
+ const decode$E = (attrs) => {
24382
24461
  const { leader } = attrs || {};
24383
24462
  return leader;
24384
24463
  };
24385
- const attrConfig$8 = Object.freeze({
24464
+ const attrConfig$v = Object.freeze({
24386
24465
  xmlName: "w:leader",
24387
24466
  sdName: "leader",
24388
- encode: encode$f,
24389
- decode: decode$f
24467
+ encode: encode$N,
24468
+ decode: decode$E
24390
24469
  });
24391
- const encode$e = (attributes) => {
24470
+ const encode$M = (attributes) => {
24392
24471
  return attributes["w:pos"];
24393
24472
  };
24394
- const decode$e = (attrs) => {
24473
+ const decode$D = (attrs) => {
24395
24474
  const { pos } = attrs || {};
24396
24475
  return pos;
24397
24476
  };
24398
- const attrConfig$7 = Object.freeze({
24477
+ const attrConfig$u = Object.freeze({
24399
24478
  xmlName: "w:pos",
24400
24479
  sdName: "pos",
24401
- encode: encode$e,
24402
- decode: decode$e
24480
+ encode: encode$M,
24481
+ decode: decode$D
24403
24482
  });
24404
- const validXmlAttributes$5 = [attrConfig$9, attrConfig$7, attrConfig$8];
24405
- const XML_NODE_NAME$6 = "w:tab";
24483
+ const validXmlAttributes$f = [attrConfig$w, attrConfig$u, attrConfig$v];
24484
+ const XML_NODE_NAME$h = "w:tab";
24406
24485
  const SD_NODE_NAME$5 = "tab";
24407
- const encode$d = (_2, encodedAttrs = {}) => {
24486
+ const encode$L = (_2, encodedAttrs = {}) => {
24408
24487
  const translated = { type: "tab" };
24409
24488
  if (encodedAttrs) translated.attrs = { ...encodedAttrs };
24410
24489
  return translated;
24411
24490
  };
24412
- const decode$d = (params2, decodedAttrs = {}) => {
24491
+ const decode$C = (params2, decodedAttrs = {}) => {
24413
24492
  const { node } = params2 || {};
24414
24493
  if (!node) return;
24415
24494
  const wTab = { name: "w:tab" };
@@ -24425,15 +24504,15 @@ const decode$d = (params2, decodedAttrs = {}) => {
24425
24504
  }
24426
24505
  return translated;
24427
24506
  };
24428
- const config$6 = {
24429
- xmlName: XML_NODE_NAME$6,
24507
+ const config$h = {
24508
+ xmlName: XML_NODE_NAME$h,
24430
24509
  sdNodeOrKeyName: SD_NODE_NAME$5,
24431
24510
  type: NodeTranslator.translatorTypes.NODE,
24432
- encode: encode$d,
24433
- decode: decode$d,
24434
- attributes: validXmlAttributes$5
24511
+ encode: encode$L,
24512
+ decode: decode$C,
24513
+ attributes: validXmlAttributes$f
24435
24514
  };
24436
- const translator$i = NodeTranslator.from(config$6);
24515
+ const translator$t = NodeTranslator.from(config$h);
24437
24516
  const mergeTextNodes = (nodes) => {
24438
24517
  if (!nodes || !Array.isArray(nodes)) {
24439
24518
  return nodes;
@@ -24608,17 +24687,21 @@ function getMarkValue(markType, attributes, docx) {
24608
24687
  function getFontFamilyValue(attributes, docx) {
24609
24688
  const ascii = attributes["w:ascii"];
24610
24689
  const themeAscii = attributes["w:asciiTheme"];
24611
- if (!docx || !themeAscii) return ascii;
24612
- const theme = docx["word/theme/theme1.xml"];
24613
- if (!theme) return ascii;
24614
- const { elements: topElements } = theme;
24615
- const { elements } = topElements[0];
24616
- const themeElements = elements.find((el) => el.name === "a:themeElements");
24617
- const fontScheme = themeElements.elements.find((el) => el.name === "a:fontScheme");
24618
- const majorFont = fontScheme.elements.find((el) => el.name === "a:majorFont");
24619
- const latin = majorFont.elements.find((el) => el.name === "a:latin");
24620
- const typeface = latin.attributes["typeface"];
24621
- return typeface;
24690
+ let resolved = ascii;
24691
+ if (docx && themeAscii) {
24692
+ const theme = docx["word/theme/theme1.xml"];
24693
+ if (theme?.elements?.length) {
24694
+ const { elements: topElements } = theme;
24695
+ const { elements } = topElements[0] || {};
24696
+ const themeElements = elements?.find((el) => el.name === "a:themeElements");
24697
+ const fontScheme = themeElements?.elements?.find((el) => el.name === "a:fontScheme");
24698
+ const majorFont = fontScheme?.elements?.find((el) => el.name === "a:majorFont");
24699
+ const latin = majorFont?.elements?.find((el) => el.name === "a:latin");
24700
+ resolved = latin?.attributes?.typeface || resolved;
24701
+ }
24702
+ }
24703
+ if (!resolved) return null;
24704
+ return SuperConverter.toCssFontFamily(resolved, docx);
24622
24705
  }
24623
24706
  function getIndentValue(attributes) {
24624
24707
  let value = attributes["w:left"];
@@ -24639,7 +24722,11 @@ function getHighLightValue(attributes) {
24639
24722
  return getHexColorFromDocxSystem(attributes?.["w:val"]) || null;
24640
24723
  }
24641
24724
  function getStrikeValue(attributes) {
24642
- return attributes?.["w:val"] === "1" ? attributes["w:val"] : null;
24725
+ const raw = attributes?.["w:val"];
24726
+ if (raw === void 0 || raw === null) return "1";
24727
+ const value = String(raw).trim().toLowerCase();
24728
+ if (value === "1" || value === "true" || value === "on") return "1";
24729
+ return null;
24643
24730
  }
24644
24731
  const parseParagraphBorders = (pBdr) => {
24645
24732
  if (!pBdr || !pBdr.elements) return {};
@@ -25003,102 +25090,102 @@ const handleParagraphNode$1 = (params2) => {
25003
25090
  }
25004
25091
  return schemaNode;
25005
25092
  };
25006
- const encode$c = (attributes) => {
25093
+ const encode$K = (attributes) => {
25007
25094
  return attributes["w:rsidDel"];
25008
25095
  };
25009
- const decode$c = (attrs) => {
25096
+ const decode$B = (attrs) => {
25010
25097
  return attrs.rsidDel;
25011
25098
  };
25012
- const attrConfig$6 = Object.freeze({
25099
+ const attrConfig$t = Object.freeze({
25013
25100
  xmlName: "w:rsidDel",
25014
25101
  sdName: "rsidDel",
25015
- encode: encode$c,
25016
- decode: decode$c
25102
+ encode: encode$K,
25103
+ decode: decode$B
25017
25104
  });
25018
- const encode$b = (attributes) => {
25105
+ const encode$J = (attributes) => {
25019
25106
  return attributes["w:rsidP"];
25020
25107
  };
25021
- const decode$b = (attrs) => {
25108
+ const decode$A = (attrs) => {
25022
25109
  return attrs.rsidP;
25023
25110
  };
25024
- const attrConfig$5 = Object.freeze({
25111
+ const attrConfig$s = Object.freeze({
25025
25112
  xmlName: "w:rsidP",
25026
25113
  sdName: "rsidP",
25027
- encode: encode$b,
25028
- decode: decode$b
25114
+ encode: encode$J,
25115
+ decode: decode$A
25029
25116
  });
25030
- const encode$a = (attributes) => {
25117
+ const encode$I = (attributes) => {
25031
25118
  return attributes["w:rsidR"];
25032
25119
  };
25033
- const decode$a = (attrs) => {
25120
+ const decode$z = (attrs) => {
25034
25121
  return attrs.rsidR;
25035
25122
  };
25036
- const attrConfig$4 = Object.freeze({
25123
+ const attrConfig$r = Object.freeze({
25037
25124
  xmlName: "w:rsidR",
25038
25125
  sdName: "rsidR",
25039
- encode: encode$a,
25040
- decode: decode$a
25126
+ encode: encode$I,
25127
+ decode: decode$z
25041
25128
  });
25042
- const encode$9 = (attributes) => {
25129
+ const encode$H = (attributes) => {
25043
25130
  return attributes["w:rsidRPr"];
25044
25131
  };
25045
- const decode$9 = (attrs) => {
25132
+ const decode$y = (attrs) => {
25046
25133
  return attrs.rsidRPr;
25047
25134
  };
25048
- const attrConfig$3 = Object.freeze({
25135
+ const attrConfig$q = Object.freeze({
25049
25136
  xmlName: "w:rsidRPr",
25050
25137
  sdName: "rsidRPr",
25051
- encode: encode$9,
25052
- decode: decode$9
25138
+ encode: encode$H,
25139
+ decode: decode$y
25053
25140
  });
25054
- const encode$8 = (attributes) => {
25141
+ const encode$G = (attributes) => {
25055
25142
  return attributes["w:rsidRDefault"];
25056
25143
  };
25057
- const decode$8 = (attrs) => {
25144
+ const decode$x = (attrs) => {
25058
25145
  return attrs.rsidRDefault;
25059
25146
  };
25060
- const attrConfig$2 = Object.freeze({
25147
+ const attrConfig$p = Object.freeze({
25061
25148
  xmlName: "w:rsidRDefault",
25062
25149
  sdName: "rsidRDefault",
25063
- encode: encode$8,
25064
- decode: decode$8
25150
+ encode: encode$G,
25151
+ decode: decode$x
25065
25152
  });
25066
- const encode$7 = (attributes) => {
25153
+ const encode$F = (attributes) => {
25067
25154
  return attributes["w14:paraId"];
25068
25155
  };
25069
- const decode$7 = (attrs) => {
25156
+ const decode$w = (attrs) => {
25070
25157
  return attrs.paraId;
25071
25158
  };
25072
- const attrConfig$1 = Object.freeze({
25159
+ const attrConfig$o = Object.freeze({
25073
25160
  xmlName: "w14:paraId",
25074
25161
  sdName: "paraId",
25075
- encode: encode$7,
25076
- decode: decode$7
25162
+ encode: encode$F,
25163
+ decode: decode$w
25077
25164
  });
25078
- const encode$6 = (attributes) => {
25165
+ const encode$E = (attributes) => {
25079
25166
  return attributes["w14:textId"];
25080
25167
  };
25081
- const decode$6 = (attrs) => {
25168
+ const decode$v = (attrs) => {
25082
25169
  return attrs.textId;
25083
25170
  };
25084
- const attrConfig = Object.freeze({
25171
+ const attrConfig$n = Object.freeze({
25085
25172
  xmlName: "w14:textId",
25086
25173
  sdName: "textId",
25087
- encode: encode$6,
25088
- decode: decode$6
25174
+ encode: encode$E,
25175
+ decode: decode$v
25089
25176
  });
25090
- const validXmlAttributes$4 = [
25091
- attrConfig$1,
25092
- attrConfig,
25093
- attrConfig$4,
25094
- attrConfig$2,
25095
- attrConfig$5,
25096
- attrConfig$3,
25097
- attrConfig$6
25177
+ const validXmlAttributes$e = [
25178
+ attrConfig$o,
25179
+ attrConfig$n,
25180
+ attrConfig$r,
25181
+ attrConfig$p,
25182
+ attrConfig$s,
25183
+ attrConfig$q,
25184
+ attrConfig$t
25098
25185
  ];
25099
- const XML_NODE_NAME$5 = "w:p";
25186
+ const XML_NODE_NAME$g = "w:p";
25100
25187
  const SD_NODE_NAME$4 = "paragraph";
25101
- const encode$5 = (params2, encodedAttrs = {}) => {
25188
+ const encode$D = (params2, encodedAttrs = {}) => {
25102
25189
  const node = handleParagraphNode$1(params2);
25103
25190
  if (!node) return void 0;
25104
25191
  if (encodedAttrs && Object.keys(encodedAttrs).length) {
@@ -25106,7 +25193,7 @@ const encode$5 = (params2, encodedAttrs = {}) => {
25106
25193
  }
25107
25194
  return node;
25108
25195
  };
25109
- const decode$5 = (params2, decodedAttrs = {}) => {
25196
+ const decode$u = (params2, decodedAttrs = {}) => {
25110
25197
  const translated = translateParagraphNode(params2);
25111
25198
  if (!translated) return void 0;
25112
25199
  if (decodedAttrs && Object.keys(decodedAttrs).length) {
@@ -25114,15 +25201,15 @@ const decode$5 = (params2, decodedAttrs = {}) => {
25114
25201
  }
25115
25202
  return translated;
25116
25203
  };
25117
- const config$5 = {
25118
- xmlName: XML_NODE_NAME$5,
25204
+ const config$g = {
25205
+ xmlName: XML_NODE_NAME$g,
25119
25206
  sdNodeOrKeyName: SD_NODE_NAME$4,
25120
25207
  type: NodeTranslator.translatorTypes.NODE,
25121
- encode: encode$5,
25122
- decode: decode$5,
25123
- attributes: validXmlAttributes$4
25208
+ encode: encode$D,
25209
+ decode: decode$u,
25210
+ attributes: validXmlAttributes$e
25124
25211
  };
25125
- const translator$h = NodeTranslator.from(config$5);
25212
+ const translator$s = NodeTranslator.from(config$g);
25126
25213
  const generateV2HandlerEntity = (handlerName, translator2) => ({
25127
25214
  handlerName,
25128
25215
  handler: (params2) => {
@@ -25229,13 +25316,13 @@ const integerToString = (value) => {
25229
25316
  const intValue = parseInteger(value);
25230
25317
  return intValue != void 0 ? String(intValue) : void 0;
25231
25318
  };
25232
- const translator$g = NodeTranslator.from({
25319
+ const translator$r = NodeTranslator.from({
25233
25320
  xmlName: "w:cantSplit",
25234
25321
  sdNodeOrKeyName: "cantSplit",
25235
25322
  encode: ({ nodes }) => ["1", "true"].includes(nodes[0].attributes?.["w:val"] ?? "1"),
25236
25323
  decode: ({ node }) => node.attrs?.cantSplit ? {} : void 0
25237
25324
  });
25238
- const translator$f = NodeTranslator.from({
25325
+ const translator$q = NodeTranslator.from({
25239
25326
  xmlName: "w:cnfStyle",
25240
25327
  sdNodeOrKeyName: "cnfStyle",
25241
25328
  attributes: [
@@ -25268,8 +25355,8 @@ const translator$f = NodeTranslator.from({
25268
25355
  return Object.keys(cnfStyleAttrs).length > 0 ? cnfStyleAttrs : void 0;
25269
25356
  }
25270
25357
  });
25271
- const translator$e = NodeTranslator.from(createSingleAttrPropertyHandler("w:divId"));
25272
- const translator$d = NodeTranslator.from(
25358
+ const translator$p = NodeTranslator.from(createSingleAttrPropertyHandler("w:divId"));
25359
+ const translator$o = NodeTranslator.from(
25273
25360
  createSingleAttrPropertyHandler(
25274
25361
  "w:gridAfter",
25275
25362
  null,
@@ -25278,7 +25365,7 @@ const translator$d = NodeTranslator.from(
25278
25365
  (v2) => integerToString(v2)
25279
25366
  )
25280
25367
  );
25281
- const translator$c = NodeTranslator.from(
25368
+ const translator$n = NodeTranslator.from(
25282
25369
  createSingleAttrPropertyHandler(
25283
25370
  "w:gridBefore",
25284
25371
  null,
@@ -25287,21 +25374,21 @@ const translator$c = NodeTranslator.from(
25287
25374
  (v2) => integerToString(v2)
25288
25375
  )
25289
25376
  );
25290
- const translator$b = NodeTranslator.from({
25377
+ const translator$m = NodeTranslator.from({
25291
25378
  xmlName: "w:hidden",
25292
25379
  sdNodeOrKeyName: "hidden",
25293
25380
  encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
25294
25381
  decode: ({ node }) => node.attrs.hidden ? {} : void 0
25295
25382
  });
25296
- const translator$a = NodeTranslator.from(createSingleAttrPropertyHandler("w:jc"));
25297
- const translator$9 = NodeTranslator.from(createMeasurementPropertyHandler("w:tblCellSpacing", "cellSpacing"));
25298
- const translator$8 = NodeTranslator.from({
25383
+ const translator$l = NodeTranslator.from(createSingleAttrPropertyHandler("w:jc"));
25384
+ const translator$k = NodeTranslator.from(createMeasurementPropertyHandler("w:tblCellSpacing", "cellSpacing"));
25385
+ const translator$j = NodeTranslator.from({
25299
25386
  xmlName: "w:tblHeader",
25300
25387
  sdNodeOrKeyName: "repeatHeader",
25301
25388
  encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
25302
25389
  decode: ({ node }) => node.attrs.repeatHeader ? {} : void 0
25303
25390
  });
25304
- const translator$7 = NodeTranslator.from({
25391
+ const translator$i = NodeTranslator.from({
25305
25392
  xmlName: "w:trHeight",
25306
25393
  sdNodeOrKeyName: "rowHeight",
25307
25394
  encode: ({ nodes }) => {
@@ -25328,11 +25415,11 @@ const translator$7 = NodeTranslator.from({
25328
25415
  return Object.keys(heightAttrs).length > 0 ? heightAttrs : void 0;
25329
25416
  }
25330
25417
  });
25331
- const translator$6 = NodeTranslator.from(createMeasurementPropertyHandler("w:wAfter"));
25332
- const translator$5 = NodeTranslator.from(createMeasurementPropertyHandler("w:wBefore"));
25333
- const XML_NODE_NAME$4 = "w:trPr";
25334
- const SD_ATTR_KEY = "tableRowProperties";
25335
- const encode$4 = (params2) => {
25418
+ const translator$h = NodeTranslator.from(createMeasurementPropertyHandler("w:wAfter"));
25419
+ const translator$g = NodeTranslator.from(createMeasurementPropertyHandler("w:wBefore"));
25420
+ const XML_NODE_NAME$f = "w:trPr";
25421
+ const SD_ATTR_KEY$a = "tableRowProperties";
25422
+ const encode$C = (params2) => {
25336
25423
  const { nodes } = params2;
25337
25424
  const node = nodes[0];
25338
25425
  let attributes = {
@@ -25346,12 +25433,12 @@ const encode$4 = (params2) => {
25346
25433
  };
25347
25434
  return {
25348
25435
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25349
- xmlName: XML_NODE_NAME$4,
25350
- sdNodeOrKeyName: SD_ATTR_KEY,
25436
+ xmlName: XML_NODE_NAME$f,
25437
+ sdNodeOrKeyName: SD_ATTR_KEY$a,
25351
25438
  attributes
25352
25439
  };
25353
25440
  };
25354
- const decode$4 = (params2) => {
25441
+ const decode$t = (params2) => {
25355
25442
  const { tableRowProperties = {} } = params2.node.attrs || {};
25356
25443
  const elements = decodeProperties(propertyTranslatorsBySdName, tableRowProperties);
25357
25444
  const newNode = {
@@ -25363,18 +25450,18 @@ const decode$4 = (params2) => {
25363
25450
  return newNode;
25364
25451
  };
25365
25452
  const propertyTranslators = [
25366
- translator$g,
25367
- translator$f,
25368
- translator$e,
25369
- translator$d,
25370
- translator$c,
25371
- translator$b,
25372
- translator$a,
25373
- translator$9,
25374
- translator$8,
25375
- translator$7,
25376
- translator$6,
25377
- translator$5
25453
+ translator$r,
25454
+ translator$q,
25455
+ translator$p,
25456
+ translator$o,
25457
+ translator$n,
25458
+ translator$m,
25459
+ translator$l,
25460
+ translator$k,
25461
+ translator$j,
25462
+ translator$i,
25463
+ translator$h,
25464
+ translator$g
25378
25465
  ];
25379
25466
  const propertyTranslatorsByXmlName = {};
25380
25467
  propertyTranslators.forEach((translator2) => {
@@ -25384,25 +25471,25 @@ const propertyTranslatorsBySdName = {};
25384
25471
  propertyTranslators.forEach((translator2) => {
25385
25472
  propertyTranslatorsBySdName[translator2.sdNodeOrKeyName] = translator2;
25386
25473
  });
25387
- const config$4 = {
25388
- xmlName: XML_NODE_NAME$4,
25389
- sdNodeOrKeyName: SD_ATTR_KEY,
25474
+ const config$f = {
25475
+ xmlName: XML_NODE_NAME$f,
25476
+ sdNodeOrKeyName: SD_ATTR_KEY$a,
25390
25477
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25391
- encode: encode$4,
25392
- decode: decode$4
25478
+ encode: encode$C,
25479
+ decode: decode$t
25393
25480
  };
25394
- const translator$4 = NodeTranslator.from(config$4);
25395
- const XML_NODE_NAME$3 = "w:tr";
25481
+ const translator$f = NodeTranslator.from(config$f);
25482
+ const XML_NODE_NAME$e = "w:tr";
25396
25483
  const SD_NODE_NAME$3 = "tableRow";
25397
- const validXmlAttributes$3 = ["w:rsidDel", "w:rsidR", "w:rsidRPr", "w:rsidTr", "w14:paraId", "w14:textId"].map(
25484
+ const validXmlAttributes$d = ["w:rsidDel", "w:rsidR", "w:rsidRPr", "w:rsidTr", "w14:paraId", "w14:textId"].map(
25398
25485
  (xmlName) => createAttributeHandler(xmlName)
25399
25486
  );
25400
- const encode$3 = (params2, encodedAttrs) => {
25487
+ const encode$B = (params2, encodedAttrs) => {
25401
25488
  const { row, table } = params2.extraParams;
25402
25489
  let tableRowProperties = {};
25403
25490
  const tPr = row.elements.find((el) => el.name === "w:trPr");
25404
25491
  if (tPr) {
25405
- ({ attributes: tableRowProperties } = translator$4.encode({
25492
+ ({ attributes: tableRowProperties } = translator$f.encode({
25406
25493
  ...params2,
25407
25494
  nodes: [tPr]
25408
25495
  }));
@@ -25415,7 +25502,7 @@ const encode$3 = (params2, encodedAttrs) => {
25415
25502
  let currentColumnIndex = 0;
25416
25503
  const content = cellNodes?.map((n) => {
25417
25504
  let columnWidth = gridColumnWidths?.[currentColumnIndex] || null;
25418
- const result = translator$2.encode({
25505
+ const result = translator$d.encode({
25419
25506
  ...params2,
25420
25507
  extraParams: {
25421
25508
  ...params2.extraParams,
@@ -25446,7 +25533,7 @@ const _getGridColumnWidths = (tableNode) => {
25446
25533
  }) || [];
25447
25534
  return columnWidths;
25448
25535
  };
25449
- const decode$3 = (params2, decodedAttrs) => {
25536
+ const decode$s = (params2, decodedAttrs) => {
25450
25537
  const { node } = params2;
25451
25538
  const elements = translateChildNodes(params2);
25452
25539
  if (node.attrs?.tableRowProperties) {
@@ -25458,7 +25545,7 @@ const decode$3 = (params2, decodedAttrs) => {
25458
25545
  }
25459
25546
  }
25460
25547
  tableRowProperties["cantSplit"] = node.attrs["cantSplit"];
25461
- const trPr = translator$4.decode({
25548
+ const trPr = translator$f.decode({
25462
25549
  ...params2,
25463
25550
  node: { ...node, attrs: { ...node.attrs, tableRowProperties } }
25464
25551
  });
@@ -25470,15 +25557,15 @@ const decode$3 = (params2, decodedAttrs) => {
25470
25557
  elements
25471
25558
  };
25472
25559
  };
25473
- const config$3 = {
25474
- xmlName: XML_NODE_NAME$3,
25560
+ const config$e = {
25561
+ xmlName: XML_NODE_NAME$e,
25475
25562
  sdNodeOrKeyName: SD_NODE_NAME$3,
25476
25563
  type: NodeTranslator.translatorTypes.NODE,
25477
- encode: encode$3,
25478
- decode: decode$3,
25479
- attributes: validXmlAttributes$3
25564
+ encode: encode$B,
25565
+ decode: decode$s,
25566
+ attributes: validXmlAttributes$d
25480
25567
  };
25481
- const translator$3 = NodeTranslator.from(config$3);
25568
+ const translator$e = NodeTranslator.from(config$e);
25482
25569
  const handleAllTableNodes = (params2) => {
25483
25570
  const { nodes } = params2;
25484
25571
  if (nodes.length === 0) {
@@ -25542,7 +25629,7 @@ function handleTableNode(node, params2) {
25542
25629
  attrs["borders"] = borderData;
25543
25630
  const content = [];
25544
25631
  rows.forEach((row) => {
25545
- const result = translator$3.encode({
25632
+ const result = translator$e.encode({
25546
25633
  ...params2,
25547
25634
  nodes: [row],
25548
25635
  extraParams: {
@@ -25923,10 +26010,10 @@ function generateCellMargins(cellMargins) {
25923
26010
  if (left2 != null) elements.push({ name: "w:left", attributes: { "w:w": pixelsToTwips(left2) } });
25924
26011
  return elements;
25925
26012
  }
25926
- const XML_NODE_NAME$2 = "w:tc";
26013
+ const XML_NODE_NAME$d = "w:tc";
25927
26014
  const SD_NODE_NAME$2 = "tableCell";
25928
- const validXmlAttributes$2 = [];
25929
- function encode$2(params2, encodedAttrs) {
26015
+ const validXmlAttributes$c = [];
26016
+ function encode$A(params2, encodedAttrs) {
25930
26017
  const { node, table, row, rowBorders, styleTag, columnIndex, columnWidth } = params2.extraParams;
25931
26018
  const schemaNode = handleTableCellNode({
25932
26019
  params: params2,
@@ -25943,23 +26030,23 @@ function encode$2(params2, encodedAttrs) {
25943
26030
  }
25944
26031
  return schemaNode;
25945
26032
  }
25946
- function decode$2(params2, decodedAttrs) {
26033
+ function decode$r(params2, decodedAttrs) {
25947
26034
  const translated = translateTableCell(params2);
25948
26035
  if (decodedAttrs && Object.keys(decodedAttrs).length) {
25949
26036
  translated.attributes = { ...translated.attributes || {}, ...decodedAttrs };
25950
26037
  }
25951
26038
  return translated;
25952
26039
  }
25953
- const config$2 = {
25954
- xmlName: XML_NODE_NAME$2,
26040
+ const config$d = {
26041
+ xmlName: XML_NODE_NAME$d,
25955
26042
  sdNodeOrKeyName: SD_NODE_NAME$2,
25956
26043
  type: NodeTranslator.translatorTypes.NODE,
25957
- encode: encode$2,
25958
- decode: decode$2,
25959
- attributes: validXmlAttributes$2
26044
+ encode: encode$A,
26045
+ decode: decode$r,
26046
+ attributes: validXmlAttributes$c
25960
26047
  };
25961
- const translator$2 = NodeTranslator.from(config$2);
25962
- const XML_NODE_NAME$1 = "w:hyperlink";
26048
+ const translator$d = NodeTranslator.from(config$d);
26049
+ const XML_NODE_NAME$c = "w:hyperlink";
25963
26050
  const SD_NODE_NAME$1 = "link";
25964
26051
  const _createAttributeHandler = (xmlName, sdName) => ({
25965
26052
  xmlName,
@@ -25967,7 +26054,7 @@ const _createAttributeHandler = (xmlName, sdName) => ({
25967
26054
  encode: (attributes) => attributes[xmlName],
25968
26055
  decode: (attributes) => attributes[sdName]
25969
26056
  });
25970
- const validXmlAttributes$1 = [
26057
+ const validXmlAttributes$b = [
25971
26058
  _createAttributeHandler("w:anchor", "anchor"),
25972
26059
  _createAttributeHandler("w:docLocation", "docLocation"),
25973
26060
  {
@@ -25980,7 +26067,7 @@ const validXmlAttributes$1 = [
25980
26067
  _createAttributeHandler("r:id", "rId"),
25981
26068
  _createAttributeHandler("w:tgtFrame", "target")
25982
26069
  ];
25983
- const encode$1 = (params2, encodedAttrs) => {
26070
+ const encode$z = (params2, encodedAttrs) => {
25984
26071
  const { nodes, docx, nodeListHandler } = params2;
25985
26072
  const node = nodes[0];
25986
26073
  let href = _resolveHref(docx, encodedAttrs);
@@ -25994,7 +26081,16 @@ const encode$1 = (params2, encodedAttrs) => {
25994
26081
  nodes: runNodes,
25995
26082
  path: [...params2.path || [], node]
25996
26083
  });
25997
- return updatedNode;
26084
+ const ensureLinkMark = (child) => {
26085
+ if (!child || typeof child !== "object") return child;
26086
+ const existingMarks = Array.isArray(child.marks) ? child.marks : [];
26087
+ const hasLink = existingMarks.some((mark) => mark?.type === "link");
26088
+ if (hasLink) return child;
26089
+ const linkClone = { type: "link", attrs: { ...linkMark.attrs } };
26090
+ return { ...child, marks: [...existingMarks, linkClone] };
26091
+ };
26092
+ if (!Array.isArray(updatedNode)) return updatedNode;
26093
+ return updatedNode.map((child) => ensureLinkMark(child));
25998
26094
  };
25999
26095
  const _resolveHref = (docx, encodedAttrs) => {
26000
26096
  const rels = docx["word/_rels/document.xml.rels"];
@@ -26011,7 +26107,7 @@ const _resolveHref = (docx, encodedAttrs) => {
26011
26107
  }
26012
26108
  return href;
26013
26109
  };
26014
- function decode$1(params2) {
26110
+ function decode$q(params2) {
26015
26111
  const { node } = params2;
26016
26112
  const linkMark = node.marks.find((m2) => m2.type === "link");
26017
26113
  const linkAttrs = this.decodeAttributes({ ...params2, node: linkMark });
@@ -26055,15 +26151,15 @@ function _addNewLinkRelationship(params2, link, rId) {
26055
26151
  });
26056
26152
  return rId;
26057
26153
  }
26058
- const config$1 = {
26059
- xmlName: XML_NODE_NAME$1,
26154
+ const config$c = {
26155
+ xmlName: XML_NODE_NAME$c,
26060
26156
  sdNodeOrKeyName: SD_NODE_NAME$1,
26061
26157
  type: NodeTranslator.translatorTypes.NODE,
26062
- encode: encode$1,
26063
- decode: decode$1,
26064
- attributes: validXmlAttributes$1
26158
+ encode: encode$z,
26159
+ decode: decode$q,
26160
+ attributes: validXmlAttributes$b
26065
26161
  };
26066
- const translator$1 = NodeTranslator.from(config$1);
26162
+ const translator$c = NodeTranslator.from(config$c);
26067
26163
  function parseTagValueJSON(json) {
26068
26164
  if (typeof json !== "string") {
26069
26165
  return {};
@@ -26074,7 +26170,7 @@ function parseTagValueJSON(json) {
26074
26170
  }
26075
26171
  try {
26076
26172
  return JSON.parse(trimmed);
26077
- } catch (err) {
26173
+ } catch {
26078
26174
  return {};
26079
26175
  }
26080
26176
  }
@@ -27876,10 +27972,10 @@ function translateStructuredContent(params2) {
27876
27972
  };
27877
27973
  return result;
27878
27974
  }
27879
- const XML_NODE_NAME = "w:sdt";
27975
+ const XML_NODE_NAME$b = "w:sdt";
27880
27976
  const SD_NODE_NAME = ["fieldAnnotation", "structuredContent", "structuredContentBlock", "documentSection"];
27881
- const validXmlAttributes = [];
27882
- function encode$k(params2, encodedAttrs) {
27977
+ const validXmlAttributes$a = [];
27978
+ function encode$y(params2) {
27883
27979
  const nodes = params2.nodes;
27884
27980
  const node = nodes[0];
27885
27981
  const { type: sdtType, handler: handler2 } = sdtNodeTypeStrategy(node);
@@ -27889,7 +27985,7 @@ function encode$k(params2, encodedAttrs) {
27889
27985
  const result = handler2(params2);
27890
27986
  return result;
27891
27987
  }
27892
- function decode(params2, decodedAttrs) {
27988
+ function decode$p(params2) {
27893
27989
  const { node } = params2;
27894
27990
  if (!node || !node.type) {
27895
27991
  return null;
@@ -27905,43 +28001,138 @@ function decode(params2, decodedAttrs) {
27905
28001
  const result = decoder();
27906
28002
  return result;
27907
28003
  }
27908
- const config = {
27909
- xmlName: XML_NODE_NAME,
28004
+ const config$b = {
28005
+ xmlName: XML_NODE_NAME$b,
27910
28006
  sdNodeOrKeyName: SD_NODE_NAME,
27911
28007
  type: NodeTranslator.translatorTypes.NODE,
27912
- encode: encode$k,
27913
- decode,
27914
- attributes: validXmlAttributes
28008
+ encode: encode$y,
28009
+ decode: decode$p,
28010
+ attributes: validXmlAttributes$a
28011
+ };
28012
+ const translator$b = NodeTranslator.from(config$b);
28013
+ const encode$x = (attributes) => attributes?.["w:val"];
28014
+ const decode$o = (attrs) => attrs?.underline;
28015
+ const attrConfig$m = Object.freeze({
28016
+ xmlName: "w:val",
28017
+ sdName: "underline",
28018
+ encode: encode$x,
28019
+ decode: decode$o
28020
+ });
28021
+ const encode$w = (attributes) => attributes?.["w:color"];
28022
+ const decode$n = (attrs) => attrs?.color;
28023
+ const attrConfig$l = Object.freeze({
28024
+ xmlName: "w:color",
28025
+ sdName: "color",
28026
+ encode: encode$w,
28027
+ decode: decode$n
28028
+ });
28029
+ const encode$v = (attributes) => attributes?.["w:themeColor"];
28030
+ const decode$m = (attrs) => attrs?.themeColor;
28031
+ const attrConfig$k = Object.freeze({
28032
+ xmlName: "w:themeColor",
28033
+ sdName: "themeColor",
28034
+ encode: encode$v,
28035
+ decode: decode$m
28036
+ });
28037
+ const encode$u = (attributes) => attributes?.["w:themeTint"];
28038
+ const decode$l = (attrs) => attrs?.themeTint;
28039
+ const attrConfig$j = Object.freeze({
28040
+ xmlName: "w:themeTint",
28041
+ sdName: "themeTint",
28042
+ encode: encode$u,
28043
+ decode: decode$l
28044
+ });
28045
+ const encode$t = (attributes) => attributes?.["w:themeShade"];
28046
+ const decode$k = (attrs) => attrs?.themeShade;
28047
+ const attrConfig$i = Object.freeze({
28048
+ xmlName: "w:themeShade",
28049
+ sdName: "themeShade",
28050
+ encode: encode$t,
28051
+ decode: decode$k
28052
+ });
28053
+ const validXmlAttributes$9 = [attrConfig$m, attrConfig$l, attrConfig$k, attrConfig$j, attrConfig$i];
28054
+ const XML_NODE_NAME$a = "w:u";
28055
+ const SD_ATTR_KEY$9 = "underline";
28056
+ const encode$s = (params2, encodedAttrs = {}) => {
28057
+ const { nodes } = params2;
28058
+ const node = nodes?.[0];
28059
+ const sourceAttrs = node?.attributes || {};
28060
+ const underlineType = encodedAttrs.underline ?? sourceAttrs["w:val"];
28061
+ const color = encodedAttrs.color ?? sourceAttrs["w:color"];
28062
+ const themeColor = encodedAttrs.themeColor ?? sourceAttrs["w:themeColor"];
28063
+ const themeTint = encodedAttrs.themeTint ?? sourceAttrs["w:themeTint"];
28064
+ const themeShade = encodedAttrs.themeShade ?? sourceAttrs["w:themeShade"];
28065
+ const attributes = { "w:val": underlineType ?? null };
28066
+ if (color !== void 0 && color !== null) attributes["w:color"] = color;
28067
+ if (themeColor !== void 0 && themeColor !== null) attributes["w:themeColor"] = themeColor;
28068
+ if (themeTint !== void 0 && themeTint !== null) attributes["w:themeTint"] = themeTint;
28069
+ if (themeShade !== void 0 && themeShade !== null) attributes["w:themeShade"] = themeShade;
28070
+ return {
28071
+ type: "attr",
28072
+ xmlName: XML_NODE_NAME$a,
28073
+ sdNodeOrKeyName: SD_ATTR_KEY$9,
28074
+ attributes
28075
+ };
27915
28076
  };
27916
- const translator = NodeTranslator.from(config);
28077
+ const decode$j = (params2) => {
28078
+ const attrs = params2?.node?.attrs || {};
28079
+ const underlineType = attrs.underlineType ?? attrs.underline ?? null;
28080
+ const color = attrs.underlineColor ?? attrs.color ?? null;
28081
+ const themeColor = attrs.underlineThemeColor ?? attrs.themeColor ?? null;
28082
+ const themeTint = attrs.underlineThemeTint ?? attrs.themeTint ?? null;
28083
+ const themeShade = attrs.underlineThemeShade ?? attrs.themeShade ?? null;
28084
+ if (!underlineType && !color && !themeColor && !themeTint && !themeShade) return void 0;
28085
+ const attributes = {};
28086
+ if (underlineType) attributes["w:val"] = underlineType;
28087
+ if (color) {
28088
+ const normalized = normalizeHexColor(color);
28089
+ if (normalized) attributes["w:color"] = normalized;
28090
+ }
28091
+ if (themeColor) attributes["w:themeColor"] = themeColor;
28092
+ if (themeTint) attributes["w:themeTint"] = themeTint;
28093
+ if (themeShade) attributes["w:themeShade"] = themeShade;
28094
+ return {
28095
+ name: XML_NODE_NAME$a,
28096
+ attributes
28097
+ };
28098
+ };
28099
+ const config$a = {
28100
+ xmlName: XML_NODE_NAME$a,
28101
+ sdNodeOrKeyName: SD_ATTR_KEY$9,
28102
+ type: NodeTranslator.translatorTypes.ATTRIBUTE,
28103
+ encode: encode$s,
28104
+ decode: decode$j,
28105
+ attributes: validXmlAttributes$9
28106
+ };
28107
+ const translator$a = NodeTranslator.from(config$a);
27917
28108
  function exportSchemaToJson(params2) {
27918
28109
  const { type: type2 } = params2.node || {};
27919
28110
  const router = {
27920
28111
  doc: translateDocumentNode,
27921
28112
  body: translateBodyNode,
27922
28113
  heading: translateHeadingNode,
27923
- paragraph: translator$h,
28114
+ paragraph: translator$s,
27924
28115
  text: translateTextNode,
27925
28116
  bulletList: translateList,
27926
28117
  orderedList: translateList,
27927
- lineBreak: translator$j,
28118
+ lineBreak: translator$v,
27928
28119
  table: translateTable,
27929
- tableRow: translator$3,
27930
- tableCell: translator$2,
28120
+ tableRow: translator$e,
28121
+ tableCell: translator$d,
27931
28122
  bookmarkStart: translateBookmarkStart,
27932
- fieldAnnotation: translator,
27933
- tab: translator$i,
28123
+ fieldAnnotation: translator$b,
28124
+ tab: translator$t,
27934
28125
  image: translateImageNode,
27935
- hardBreak: translator$j,
28126
+ hardBreak: translator$v,
27936
28127
  commentRangeStart: () => translateCommentNode(params2, "Start"),
27937
28128
  commentRangeEnd: () => translateCommentNode(params2, "End"),
27938
28129
  commentReference: () => null,
27939
28130
  shapeContainer: translateShapeContainer,
27940
28131
  shapeTextbox: translateShapeTextbox,
27941
28132
  contentBlock: translateContentBlock,
27942
- structuredContent: translator,
27943
- structuredContentBlock: translator,
27944
- documentSection: translator,
28133
+ structuredContent: translator$b,
28134
+ structuredContentBlock: translator$b,
28135
+ documentSection: translator$b,
27945
28136
  "page-number": translatePageNumberNode,
27946
28137
  "total-page-number": translateTotalPageNumberNode
27947
28138
  };
@@ -28264,7 +28455,7 @@ function translateTextNode(params2) {
28264
28455
  const isTrackedNode = node.marks?.some((m2) => trackedMarks.includes(m2.type));
28265
28456
  if (isTrackedNode) return translateTrackedNode(params2);
28266
28457
  const isLinkNode = node.marks?.some((m2) => m2.type === "link");
28267
- if (isLinkNode) return translator$1.decode(params2);
28458
+ if (isLinkNode) return translator$c.decode(params2);
28268
28459
  const { text, marks = [] } = node;
28269
28460
  return getTextNodeForExport(text, marks, params2);
28270
28461
  }
@@ -28749,10 +28940,20 @@ function translateMark(mark) {
28749
28940
  delete markElement.attributes;
28750
28941
  markElement.type = "element";
28751
28942
  break;
28752
- case "underline":
28753
- markElement.type = "element";
28754
- markElement.attributes["w:val"] = attrs.underlineType;
28755
- break;
28943
+ case "underline": {
28944
+ const translated = translator$a.decode({
28945
+ node: {
28946
+ attrs: {
28947
+ underlineType: attrs.underlineType ?? attrs.underline ?? null,
28948
+ underlineColor: attrs.underlineColor ?? attrs.color ?? null,
28949
+ underlineThemeColor: attrs.underlineThemeColor ?? attrs.themeColor ?? null,
28950
+ underlineThemeTint: attrs.underlineThemeTint ?? attrs.themeTint ?? null,
28951
+ underlineThemeShade: attrs.underlineThemeShade ?? attrs.themeShade ?? null
28952
+ }
28953
+ }
28954
+ });
28955
+ return translated || {};
28956
+ }
28756
28957
  // Text style cases
28757
28958
  case "fontSize":
28758
28959
  value = attrs.fontSize;
@@ -28794,12 +28995,11 @@ function translateMark(mark) {
28794
28995
  case "lineHeight":
28795
28996
  markElement.attributes["w:line"] = linesToTwips(attrs.lineHeight);
28796
28997
  break;
28797
- case "highlight":
28798
- markElement.attributes["w:fill"] = attrs.color?.substring(1);
28799
- markElement.attributes["w:color"] = "auto";
28800
- markElement.attributes["w:val"] = "clear";
28801
- markElement.name = "w:shd";
28802
- break;
28998
+ case "highlight": {
28999
+ const highlightValue = attrs.color ?? attrs.highlight ?? null;
29000
+ const translated = translator$u.decode({ node: { attrs: { highlight: highlightValue } } });
29001
+ return translated || {};
29002
+ }
28803
29003
  }
28804
29004
  return markElement;
28805
29005
  }
@@ -29667,82 +29867,912 @@ const trackChangeNodeHandlerEntity = {
29667
29867
  handlerName: "trackChangeNodeHandler",
29668
29868
  handler: handleTrackChangeNode
29669
29869
  };
29670
- const hyperlinkNodeHandlerEntity = generateV2HandlerEntity("hyperlinkNodeHandler", translator$1);
29671
- const handleRunNode = (params2) => {
29672
- const { nodes, nodeListHandler, parentStyleId, docx } = params2;
29673
- if (nodes.length === 0 || nodes[0].name !== "w:r") {
29674
- return { nodes: [], consumed: 0 };
29675
- }
29870
+ const hyperlinkNodeHandlerEntity = generateV2HandlerEntity("hyperlinkNodeHandler", translator$c);
29871
+ const encode$r = (attributes) => {
29872
+ const raw = attributes?.["w:val"];
29873
+ if (raw === void 0 || raw === null) return void 0;
29874
+ if (typeof raw === "boolean") return raw;
29875
+ if (typeof raw === "number") return raw !== 0;
29876
+ const val = String(raw).trim().toLowerCase();
29877
+ if (val === "0" || val === "false" || val === "off") return false;
29878
+ if (val === "1" || val === "true" || val === "on") return true;
29879
+ return void 0;
29880
+ };
29881
+ const decode$i = (runProps) => {
29882
+ if (runProps?.bold === false) return "0";
29883
+ return void 0;
29884
+ };
29885
+ const attrConfig$h = Object.freeze({
29886
+ xmlName: "w:val",
29887
+ sdName: "bold",
29888
+ encode: encode$r,
29889
+ decode: decode$i
29890
+ });
29891
+ const validXmlAttributes$8 = [attrConfig$h];
29892
+ const XML_NODE_NAME$9 = "w:b";
29893
+ const SD_ATTR_KEY$8 = "bold";
29894
+ const encode$q = (params2, encodedAttrs = {}) => {
29895
+ const { nodes } = params2;
29676
29896
  const node = nodes[0];
29677
- const childParams = { ...params2, nodes: node.elements, path: [...params2.path || [], node] };
29678
- let processedRun = nodeListHandler.handler(childParams)?.filter((n) => n) || [];
29679
- const hasRunProperties = node.elements?.some((el) => el.name === "w:rPr");
29680
- const defaultNodeStyles = getMarksFromStyles(docx, parentStyleId);
29681
- if (hasRunProperties) {
29682
- const { marks = [] } = parseProperties(node);
29683
- let runStyleAttributes = [];
29684
- const runStyleElement = node.elements?.find((el) => el.name === "w:rPr")?.elements?.find((el) => el.name === "w:rStyle");
29685
- let runStyleId;
29686
- if (runStyleElement && runStyleElement.attributes?.["w:val"] && docx) {
29687
- runStyleId = runStyleElement.attributes["w:val"];
29688
- const runStyleDefinition = getMarksFromStyles(docx, runStyleId);
29689
- if (runStyleDefinition.marks && runStyleDefinition.marks.length > 0) {
29690
- runStyleAttributes = runStyleDefinition.marks;
29691
- }
29692
- }
29693
- let paragraphStyleAttributes = [];
29694
- if (defaultNodeStyles.marks) {
29695
- paragraphStyleAttributes = defaultNodeStyles.marks.filter((mark) => {
29696
- if (["bold"].includes(mark.type) && marks.find((m2) => m2.type === "bold")?.attrs?.value === "0") {
29697
- return false;
29698
- }
29699
- return true;
29700
- });
29701
- }
29702
- const combinedMarks = [...paragraphStyleAttributes];
29703
- runStyleAttributes.forEach((runStyle) => {
29704
- const exists2 = combinedMarks.some(
29705
- (mark) => mark.type === runStyle.type && JSON.stringify(mark.attrs || {}) === JSON.stringify(runStyle.attrs || {})
29706
- );
29707
- if (!exists2) {
29708
- combinedMarks.push(runStyle);
29897
+ if (!node) return void 0;
29898
+ const val = encodedAttrs?.[SD_ATTR_KEY$8];
29899
+ let attributes;
29900
+ if (val === false) attributes = { "w:val": "0" };
29901
+ else if (val === true)
29902
+ attributes = {};
29903
+ else attributes = node.attributes || {};
29904
+ return {
29905
+ type: "attr",
29906
+ xmlName: XML_NODE_NAME$9,
29907
+ sdNodeOrKeyName: SD_ATTR_KEY$8,
29908
+ attributes
29909
+ };
29910
+ };
29911
+ const config$9 = {
29912
+ xmlName: XML_NODE_NAME$9,
29913
+ sdNodeOrKeyName: SD_ATTR_KEY$8,
29914
+ type: NodeTranslator.translatorTypes.ATTRIBUTE,
29915
+ encode: encode$q,
29916
+ attributes: validXmlAttributes$8
29917
+ };
29918
+ const translator$9 = NodeTranslator.from(config$9);
29919
+ const encode$p = (attributes) => {
29920
+ const raw = attributes?.["w:val"];
29921
+ if (raw === void 0 || raw === null) return void 0;
29922
+ if (typeof raw === "boolean") return raw;
29923
+ if (typeof raw === "number") return raw !== 0;
29924
+ const val = String(raw).trim().toLowerCase();
29925
+ if (val === "0" || val === "false" || val === "off") return false;
29926
+ if (val === "1" || val === "true" || val === "on") return true;
29927
+ return void 0;
29928
+ };
29929
+ const decode$h = (attrs) => {
29930
+ if (attrs?.italic === false) return "0";
29931
+ return void 0;
29932
+ };
29933
+ const attrConfig$g = Object.freeze({
29934
+ xmlName: "w:val",
29935
+ sdName: "italic",
29936
+ encode: encode$p,
29937
+ decode: decode$h
29938
+ });
29939
+ const validXmlAttributes$7 = [attrConfig$g];
29940
+ const XML_NODE_NAME$8 = "w:i";
29941
+ const SD_ATTR_KEY$7 = "italic";
29942
+ const encode$o = (params2, encodedAttrs = {}) => {
29943
+ const { nodes } = params2;
29944
+ const node = nodes?.[0];
29945
+ if (!node) return void 0;
29946
+ const val = encodedAttrs?.[SD_ATTR_KEY$7];
29947
+ let attributes;
29948
+ if (val === false) attributes = { "w:val": "0" };
29949
+ else if (val === true) attributes = {};
29950
+ else attributes = { ...node.attributes || {} };
29951
+ if (attributes["w:val"] === void 0 && val !== true) attributes["w:val"] = null;
29952
+ else if (val === true && attributes["w:val"] === void 0) delete attributes["w:val"];
29953
+ return {
29954
+ type: "attr",
29955
+ xmlName: XML_NODE_NAME$8,
29956
+ sdNodeOrKeyName: SD_ATTR_KEY$7,
29957
+ attributes
29958
+ };
29959
+ };
29960
+ const config$8 = {
29961
+ xmlName: XML_NODE_NAME$8,
29962
+ sdNodeOrKeyName: SD_ATTR_KEY$7,
29963
+ type: NodeTranslator.translatorTypes.ATTRIBUTE,
29964
+ encode: encode$o,
29965
+ attributes: validXmlAttributes$7
29966
+ };
29967
+ const translator$8 = NodeTranslator.from(config$8);
29968
+ const encode$n = (attributes) => {
29969
+ const raw = attributes?.["w:val"];
29970
+ if (raw === void 0 || raw === null) return void 0;
29971
+ if (typeof raw === "boolean") return raw;
29972
+ if (typeof raw === "number") return raw !== 0;
29973
+ const val = String(raw).trim().toLowerCase();
29974
+ if (val === "0" || val === "false" || val === "off") return false;
29975
+ if (val === "1" || val === "true" || val === "on") return true;
29976
+ return void 0;
29977
+ };
29978
+ const decode$g = (attrs) => {
29979
+ if (attrs?.strike === false) return "0";
29980
+ return void 0;
29981
+ };
29982
+ const attrConfig$f = Object.freeze({
29983
+ xmlName: "w:val",
29984
+ sdName: "strike",
29985
+ encode: encode$n,
29986
+ decode: decode$g
29987
+ });
29988
+ const validXmlAttributes$6 = [attrConfig$f];
29989
+ const XML_NODE_NAME$7 = "w:strike";
29990
+ const SD_ATTR_KEY$6 = "strike";
29991
+ const encode$m = (params2, encodedAttrs = {}) => {
29992
+ const { nodes } = params2;
29993
+ const node = nodes?.[0];
29994
+ if (!node) return void 0;
29995
+ const val = encodedAttrs?.[SD_ATTR_KEY$6];
29996
+ let attributes;
29997
+ if (val === false) attributes = { "w:val": "0" };
29998
+ else if (val === true) attributes = {};
29999
+ else attributes = { ...node.attributes || {} };
30000
+ if (attributes["w:val"] === void 0 && val !== true) attributes["w:val"] = null;
30001
+ else if (val === true && attributes["w:val"] === void 0) delete attributes["w:val"];
30002
+ return {
30003
+ type: "attr",
30004
+ xmlName: XML_NODE_NAME$7,
30005
+ sdNodeOrKeyName: SD_ATTR_KEY$6,
30006
+ attributes
30007
+ };
30008
+ };
30009
+ const config$7 = {
30010
+ xmlName: XML_NODE_NAME$7,
30011
+ sdNodeOrKeyName: SD_ATTR_KEY$6,
30012
+ type: NodeTranslator.translatorTypes.ATTRIBUTE,
30013
+ encode: encode$m,
30014
+ attributes: validXmlAttributes$6
30015
+ };
30016
+ const translator$7 = NodeTranslator.from(config$7);
30017
+ const encode$l = (attributes) => attributes?.["w:val"];
30018
+ const decode$f = (attrs) => attrs?.color;
30019
+ const attrConfig$e = Object.freeze({
30020
+ xmlName: "w:val",
30021
+ sdName: "color",
30022
+ encode: encode$l,
30023
+ decode: decode$f
30024
+ });
30025
+ const encode$k = (attributes) => attributes?.["w:themeColor"];
30026
+ const decode$e = (attrs) => attrs?.themeColor;
30027
+ const attrConfig$d = Object.freeze({
30028
+ xmlName: "w:themeColor",
30029
+ sdName: "themeColor",
30030
+ encode: encode$k,
30031
+ decode: decode$e
30032
+ });
30033
+ const encode$j = (attributes) => attributes?.["w:themeTint"];
30034
+ const decode$d = (attrs) => attrs?.themeTint;
30035
+ const attrConfig$c = Object.freeze({
30036
+ xmlName: "w:themeTint",
30037
+ sdName: "themeTint",
30038
+ encode: encode$j,
30039
+ decode: decode$d
30040
+ });
30041
+ const encode$i = (attributes) => attributes?.["w:themeShade"];
30042
+ const decode$c = (attrs) => attrs?.themeShade;
30043
+ const attrConfig$b = Object.freeze({
30044
+ xmlName: "w:themeShade",
30045
+ sdName: "themeShade",
30046
+ encode: encode$i,
30047
+ decode: decode$c
30048
+ });
30049
+ const validXmlAttributes$5 = [attrConfig$e, attrConfig$d, attrConfig$c, attrConfig$b];
30050
+ const XML_NODE_NAME$6 = "w:color";
30051
+ const SD_ATTR_KEY$5 = "color";
30052
+ const encode$h = (params2, encodedAttrs = {}) => {
30053
+ const { nodes } = params2;
30054
+ const node = nodes?.[0];
30055
+ const sourceAttrs = node?.attributes || {};
30056
+ const value = encodedAttrs.color ?? sourceAttrs["w:val"];
30057
+ const themeColor = encodedAttrs.themeColor ?? sourceAttrs["w:themeColor"];
30058
+ const themeTint = encodedAttrs.themeTint ?? sourceAttrs["w:themeTint"];
30059
+ const themeShade = encodedAttrs.themeShade ?? sourceAttrs["w:themeShade"];
30060
+ const attributes = {};
30061
+ attributes["w:val"] = value ?? null;
30062
+ if (themeColor !== void 0 && themeColor !== null) attributes["w:themeColor"] = themeColor;
30063
+ if (themeTint !== void 0 && themeTint !== null) attributes["w:themeTint"] = themeTint;
30064
+ if (themeShade !== void 0 && themeShade !== null) attributes["w:themeShade"] = themeShade;
30065
+ return {
30066
+ type: "attr",
30067
+ xmlName: XML_NODE_NAME$6,
30068
+ sdNodeOrKeyName: SD_ATTR_KEY$5,
30069
+ attributes
30070
+ };
30071
+ };
30072
+ const config$6 = {
30073
+ xmlName: XML_NODE_NAME$6,
30074
+ sdNodeOrKeyName: SD_ATTR_KEY$5,
30075
+ type: NodeTranslator.translatorTypes.ATTRIBUTE,
30076
+ encode: encode$h,
30077
+ attributes: validXmlAttributes$5
30078
+ };
30079
+ const translator$6 = NodeTranslator.from(config$6);
30080
+ const encode$g = (attributes) => attributes?.["w:eastAsia"];
30081
+ const decode$b = (attrs) => attrs?.eastAsia;
30082
+ const attrConfig$a = Object.freeze({
30083
+ xmlName: "w:eastAsia",
30084
+ sdName: "eastAsia",
30085
+ encode: encode$g,
30086
+ decode: decode$b
30087
+ });
30088
+ const encode$f = (attributes) => attributes?.["w:ascii"];
30089
+ const decode$a = (attrs) => attrs?.ascii;
30090
+ const attrConfig$9 = Object.freeze({
30091
+ xmlName: "w:ascii",
30092
+ sdName: "ascii",
30093
+ encode: encode$f,
30094
+ decode: decode$a
30095
+ });
30096
+ const encode$e = (attributes) => attributes?.["w:hAnsi"];
30097
+ const decode$9 = (attrs) => attrs?.hAnsi;
30098
+ const attrConfig$8 = Object.freeze({
30099
+ xmlName: "w:hAnsi",
30100
+ sdName: "hAnsi",
30101
+ encode: encode$e,
30102
+ decode: decode$9
30103
+ });
30104
+ const encode$d = (attributes) => attributes?.["w:cs"];
30105
+ const decode$8 = (attrs) => attrs?.cs;
30106
+ const attrConfig$7 = Object.freeze({
30107
+ xmlName: "w:cs",
30108
+ sdName: "cs",
30109
+ encode: encode$d,
30110
+ decode: decode$8
30111
+ });
30112
+ const encode$c = (attributes) => attributes?.["w:val"];
30113
+ const decode$7 = (attrs) => attrs?.value;
30114
+ const attrConfig$6 = Object.freeze({
30115
+ xmlName: "w:val",
30116
+ sdName: "value",
30117
+ encode: encode$c,
30118
+ decode: decode$7
30119
+ });
30120
+ const validXmlAttributes$4 = [attrConfig$a, attrConfig$9, attrConfig$8, attrConfig$7, attrConfig$6];
30121
+ const XML_NODE_NAME$5 = "w:rFonts";
30122
+ const SD_ATTR_KEY$4 = "fontFamily";
30123
+ const encode$b = (params2, encodedAttrs = {}) => {
30124
+ const { nodes } = params2;
30125
+ const node = nodes?.[0];
30126
+ const sourceAttrs = node?.attributes || {};
30127
+ const attributes = {};
30128
+ const setAttr = (xmlName, sdName) => {
30129
+ if (encodedAttrs[sdName] !== void 0 && encodedAttrs[sdName] !== null) {
30130
+ attributes[xmlName] = encodedAttrs[sdName];
30131
+ } else if (sourceAttrs[xmlName] !== void 0) {
30132
+ attributes[xmlName] = sourceAttrs[xmlName];
30133
+ }
30134
+ };
30135
+ setAttr("w:eastAsia", "eastAsia");
30136
+ setAttr("w:ascii", "ascii");
30137
+ setAttr("w:hAnsi", "hAnsi");
30138
+ setAttr("w:cs", "cs");
30139
+ setAttr("w:val", "value");
30140
+ Object.keys(sourceAttrs).forEach((key) => {
30141
+ if (attributes[key] === void 0) attributes[key] = sourceAttrs[key];
30142
+ });
30143
+ if (attributes["w:val"] === void 0 && attributes["w:eastAsia"]) {
30144
+ attributes["w:val"] = attributes["w:eastAsia"];
30145
+ }
30146
+ if (attributes["w:val"] === void 0) delete attributes["w:val"];
30147
+ return {
30148
+ type: "attr",
30149
+ xmlName: XML_NODE_NAME$5,
30150
+ sdNodeOrKeyName: SD_ATTR_KEY$4,
30151
+ attributes
30152
+ };
30153
+ };
30154
+ const config$5 = {
30155
+ xmlName: XML_NODE_NAME$5,
30156
+ sdNodeOrKeyName: SD_ATTR_KEY$4,
30157
+ type: NodeTranslator.translatorTypes.ATTRIBUTE,
30158
+ encode: encode$b,
30159
+ attributes: validXmlAttributes$4
30160
+ };
30161
+ const translator$5 = NodeTranslator.from(config$5);
30162
+ const encode$a = (attributes) => attributes?.["w:val"];
30163
+ const decode$6 = (attrs) => attrs?.styleId;
30164
+ const attrConfig$5 = Object.freeze({
30165
+ xmlName: "w:val",
30166
+ sdName: "styleId",
30167
+ encode: encode$a,
30168
+ decode: decode$6
30169
+ });
30170
+ const validXmlAttributes$3 = [attrConfig$5];
30171
+ const XML_NODE_NAME$4 = "w:rStyle";
30172
+ const SD_ATTR_KEY$3 = "styleId";
30173
+ const encode$9 = (params2, encodedAttrs = {}) => {
30174
+ const { nodes } = params2;
30175
+ const node = nodes?.[0];
30176
+ const value = encodedAttrs.styleId ?? node?.attributes?.["w:val"];
30177
+ return {
30178
+ type: "attr",
30179
+ xmlName: XML_NODE_NAME$4,
30180
+ sdNodeOrKeyName: SD_ATTR_KEY$3,
30181
+ attributes: { "w:val": value ?? null }
30182
+ };
30183
+ };
30184
+ const config$4 = {
30185
+ xmlName: XML_NODE_NAME$4,
30186
+ sdNodeOrKeyName: SD_ATTR_KEY$3,
30187
+ type: NodeTranslator.translatorTypes.ATTRIBUTE,
30188
+ encode: encode$9,
30189
+ attributes: validXmlAttributes$3
30190
+ };
30191
+ const translator$4 = NodeTranslator.from(config$4);
30192
+ const encode$8 = (attributes) => attributes?.["w:val"];
30193
+ const decode$5 = (attrs) => attrs?.fontSize;
30194
+ const attrConfig$4 = Object.freeze({
30195
+ xmlName: "w:val",
30196
+ sdName: "fontSize",
30197
+ encode: encode$8,
30198
+ decode: decode$5
30199
+ });
30200
+ const validXmlAttributes$2 = [attrConfig$4];
30201
+ const XML_NODE_NAME$3 = "w:sz";
30202
+ const SD_ATTR_KEY$2 = "fontSize";
30203
+ const encode$7 = (params2, encodedAttrs = {}) => {
30204
+ const { nodes } = params2;
30205
+ const node = nodes?.[0];
30206
+ const value = encodedAttrs.fontSize ?? node?.attributes?.["w:val"];
30207
+ return {
30208
+ type: "attr",
30209
+ xmlName: XML_NODE_NAME$3,
30210
+ sdNodeOrKeyName: SD_ATTR_KEY$2,
30211
+ attributes: { "w:val": value ?? null }
30212
+ };
30213
+ };
30214
+ const config$3 = {
30215
+ xmlName: XML_NODE_NAME$3,
30216
+ sdNodeOrKeyName: SD_ATTR_KEY$2,
30217
+ type: NodeTranslator.translatorTypes.ATTRIBUTE,
30218
+ encode: encode$7,
30219
+ attributes: validXmlAttributes$2
30220
+ };
30221
+ const translator$3 = NodeTranslator.from(config$3);
30222
+ const encode$6 = (attributes) => attributes?.["w:val"];
30223
+ const decode$4 = (attrs) => attrs?.fontSizeCs;
30224
+ const attrConfig$3 = Object.freeze({
30225
+ xmlName: "w:val",
30226
+ sdName: "fontSizeCs",
30227
+ encode: encode$6,
30228
+ decode: decode$4
30229
+ });
30230
+ const validXmlAttributes$1 = [attrConfig$3];
30231
+ const XML_NODE_NAME$2 = "w:szCs";
30232
+ const SD_ATTR_KEY$1 = "fontSizeCs";
30233
+ const encode$5 = (params2, encodedAttrs = {}) => {
30234
+ const { nodes } = params2;
30235
+ const node = nodes?.[0];
30236
+ const value = encodedAttrs.fontSizeCs ?? node?.attributes?.["w:val"];
30237
+ return {
30238
+ type: "attr",
30239
+ xmlName: XML_NODE_NAME$2,
30240
+ sdNodeOrKeyName: SD_ATTR_KEY$1,
30241
+ attributes: { "w:val": value ?? null }
30242
+ };
30243
+ };
30244
+ const config$2 = {
30245
+ xmlName: XML_NODE_NAME$2,
30246
+ sdNodeOrKeyName: SD_ATTR_KEY$1,
30247
+ type: NodeTranslator.translatorTypes.ATTRIBUTE,
30248
+ encode: encode$5,
30249
+ attributes: validXmlAttributes$1
30250
+ };
30251
+ const translator$2 = NodeTranslator.from(config$2);
30252
+ const runPropertyTranslators = Object.freeze({
30253
+ "w:b": translator$9,
30254
+ "w:i": translator$8,
30255
+ "w:u": translator$a,
30256
+ "w:strike": translator$7,
30257
+ "w:color": translator$6,
30258
+ "w:highlight": translator$u,
30259
+ "w:rFonts": translator$5,
30260
+ "w:rStyle": translator$4,
30261
+ "w:sz": translator$3,
30262
+ "w:szCs": translator$2
30263
+ });
30264
+ const rawRunPropertyXmlNames = Object.freeze(["w:lang", "w:shd"]);
30265
+ const RAW_CHILD_NAME_SET = new Set(rawRunPropertyXmlNames);
30266
+ const KNOWN_CHILD_XML_NAMES = /* @__PURE__ */ new Set([...Object.keys(runPropertyTranslators), ...RAW_CHILD_NAME_SET]);
30267
+ const toRunPropertyEntry = (candidate) => {
30268
+ if (!candidate || candidate.type !== "attr") return null;
30269
+ const xmlName = candidate.xmlName || candidate.name;
30270
+ if (!xmlName) return null;
30271
+ return {
30272
+ xmlName,
30273
+ attributes: { ...candidate.attributes || {} }
30274
+ };
30275
+ };
30276
+ const XML_NODE_NAME$1 = "w:rPr";
30277
+ const SD_ATTR_KEY = "runProperties";
30278
+ const encode$4 = (params2) => {
30279
+ const { nodes } = params2;
30280
+ const node = nodes?.[0] || {};
30281
+ const contents = Array.isArray(node.elements) ? node.elements : [];
30282
+ const runPropsArray = contents.reduce(
30283
+ (acc, child) => {
30284
+ if (!child || typeof child !== "object") return acc;
30285
+ const xmlName = child.name;
30286
+ if (!KNOWN_CHILD_XML_NAMES.has(xmlName)) return acc;
30287
+ const translator2 = runPropertyTranslators[xmlName];
30288
+ let entry = null;
30289
+ if (translator2) {
30290
+ const encoded = translator2.encode({ ...params2, nodes: [child] }) || null;
30291
+ entry = toRunPropertyEntry(encoded);
30292
+ } else if (RAW_CHILD_NAME_SET.has(xmlName)) {
30293
+ entry = toRunPropertyEntry({
30294
+ type: "attr",
30295
+ xmlName,
30296
+ attributes: { ...child.attributes || {} }
30297
+ });
29709
30298
  }
30299
+ if (entry) acc.push(entry);
30300
+ return acc;
30301
+ },
30302
+ /** @type {{ xmlName: string, attributes: Record<string, any> }[]} */
30303
+ []
30304
+ );
30305
+ return {
30306
+ type: "attr",
30307
+ xmlName: "w:rPr",
30308
+ sdNodeOrKeyName: "runProperties",
30309
+ attributes: runPropsArray
30310
+ };
30311
+ };
30312
+ const config$1 = {
30313
+ xmlName: XML_NODE_NAME$1,
30314
+ sdNodeOrKeyName: SD_ATTR_KEY,
30315
+ type: NodeTranslator.translatorTypes.ATTRIBUTE,
30316
+ encode: encode$4
30317
+ };
30318
+ const translator$1 = NodeTranslator.from(config$1);
30319
+ const collectRunProperties = (params2, rPrNode, translator2 = translator$1) => {
30320
+ if (!rPrNode) return { entries: [], hadRPr: false, styleChangeMarks: [] };
30321
+ const result = translator2.encode({ ...params2, nodes: [rPrNode] }) || {};
30322
+ let entries = [];
30323
+ if (Array.isArray(result.attributes) && result.attributes.length) {
30324
+ entries = result.attributes.map((attr) => ({
30325
+ xmlName: attr?.xmlName,
30326
+ attributes: { ...attr?.attributes || {} }
30327
+ }));
30328
+ } else if (Array.isArray(rPrNode.elements) && rPrNode.elements.length) {
30329
+ entries = rPrNode.elements.filter((el) => el && typeof el === "object").map((el) => ({
30330
+ xmlName: el.name,
30331
+ attributes: { ...el.attributes || {} }
30332
+ }));
30333
+ }
30334
+ const legacyMarks = parseMarks(rPrNode, [], params2?.docx) || [];
30335
+ const styleChangeMarks = handleStyleChangeMarks(rPrNode, legacyMarks) || [];
30336
+ return { entries, hadRPr: true, styleChangeMarks };
30337
+ };
30338
+ const buildRunAttrs = (encodedAttrs = {}, hadRPr, runProps) => {
30339
+ const base2 = { ...encodedAttrs || {} };
30340
+ if (hadRPr) {
30341
+ base2.runProperties = runProps.length ? runProps : null;
30342
+ }
30343
+ return base2;
30344
+ };
30345
+ const ensureRunMark = (marks, runAttrs) => {
30346
+ if (!runAttrs) return;
30347
+ const runMark = createRunMark(runAttrs);
30348
+ const runMarkIndex = marks.findIndex((mark) => mark?.type === "run");
30349
+ if (runMarkIndex >= 0) {
30350
+ const existing = marks[runMarkIndex];
30351
+ if (runMark.attrs) {
30352
+ marks[runMarkIndex] = { ...existing, attrs: mergeRunAttrs(existing?.attrs, runMark.attrs) };
30353
+ }
30354
+ return;
30355
+ }
30356
+ marks.push(runMark);
30357
+ };
30358
+ const ensureInlineMarks = (marks, inlineMarks = []) => {
30359
+ inlineMarks.forEach(({ type: type2, attrs }) => {
30360
+ if (!type2) return;
30361
+ if (marks.some((mark) => mark?.type === type2)) return;
30362
+ marks.push(attrs ? { type: type2, attrs: { ...attrs } } : { type: type2 });
30363
+ });
30364
+ };
30365
+ const ensureTextStyleMark = (marks, textStyleAttrs) => {
30366
+ if (!textStyleAttrs) return;
30367
+ const existingTextStyle = marks.find((mark) => mark?.type === "textStyle");
30368
+ if (existingTextStyle) {
30369
+ existingTextStyle.attrs = { ...existingTextStyle.attrs || {}, ...textStyleAttrs };
30370
+ return;
30371
+ }
30372
+ marks.push({ type: "textStyle", attrs: { ...textStyleAttrs } });
30373
+ };
30374
+ const applyRunMarks = (node, runAttrs, inlineMarks, textStyleAttrs) => {
30375
+ if (!node || typeof node !== "object") return node;
30376
+ const baseMarks = Array.isArray(node.marks) ? node.marks : [];
30377
+ const marks = baseMarks.map((mark) => cloneMark(mark));
30378
+ ensureRunMark(marks, runAttrs);
30379
+ ensureInlineMarks(marks, inlineMarks);
30380
+ if (node.type === "text") {
30381
+ ensureTextStyleMark(marks, textStyleAttrs);
30382
+ }
30383
+ return { ...node, marks };
30384
+ };
30385
+ const createRunMark = (attrs = {}) => {
30386
+ const hasAttrs = attrs && Object.keys(attrs).length > 0;
30387
+ return hasAttrs ? { type: "run", attrs: cloneRunAttrs(attrs) } : { type: "run" };
30388
+ };
30389
+ const deriveStyleMarks = ({ docx, paragraphStyleId, runStyleId }) => {
30390
+ const paragraphStyleMarks = collectStyleMarks(paragraphStyleId, docx);
30391
+ const runStyleMarks = collectStyleMarks(runStyleId, docx);
30392
+ const inlineMarks = mergeInlineMarkSets(paragraphStyleMarks.inlineMarks, runStyleMarks.inlineMarks);
30393
+ const textStyleAttrs = mergeTextStyleAttrs(paragraphStyleMarks.textStyleAttrs, runStyleMarks.textStyleAttrs);
30394
+ return { inlineMarks, textStyleAttrs };
30395
+ };
30396
+ const collectStyleMarks = (styleId, docx, seen = /* @__PURE__ */ new Set()) => {
30397
+ if (!styleId || !docx || seen.has(styleId)) return { inlineMarks: [], textStyleAttrs: null };
30398
+ seen.add(styleId);
30399
+ const chain = collectStyleChain(styleId, docx, seen);
30400
+ if (!chain.length) return { inlineMarks: [], textStyleAttrs: null };
30401
+ const inlineMap = /* @__PURE__ */ new Map();
30402
+ let textStyleAttrs = {};
30403
+ chain.forEach((styleTag) => {
30404
+ const marks = extractMarksFromStyle(styleTag, docx);
30405
+ marks.inlineMarks.forEach((mark) => {
30406
+ inlineMap.set(mark.type, mark.attrs ? { type: mark.type, attrs: { ...mark.attrs } } : { type: mark.type });
29710
30407
  });
30408
+ if (marks.textStyleAttrs) textStyleAttrs = { ...textStyleAttrs, ...marks.textStyleAttrs };
30409
+ });
30410
+ return {
30411
+ inlineMarks: Array.from(inlineMap.values()),
30412
+ textStyleAttrs: Object.keys(textStyleAttrs).length ? textStyleAttrs : null
30413
+ };
30414
+ };
30415
+ const collectStyleChain = (styleId, docx, seen) => {
30416
+ if (!styleId || !docx) return [];
30417
+ const styleTag = findStyleTag(docx, styleId);
30418
+ if (!styleTag || !styleTag.elements) return [];
30419
+ const basedOn = styleTag.elements?.find((el) => el.name === "w:basedOn")?.attributes?.["w:val"];
30420
+ let chain = [];
30421
+ if (basedOn && !seen.has(basedOn)) {
30422
+ seen.add(basedOn);
30423
+ chain = collectStyleChain(basedOn, docx, seen);
30424
+ }
30425
+ chain.push(styleTag);
30426
+ return chain;
30427
+ };
30428
+ const findStyleTag = (docx, styleId) => {
30429
+ const stylesFile = docx?.["word/styles.xml"];
30430
+ if (!stylesFile?.elements?.length) return null;
30431
+ const candidates = [];
30432
+ stylesFile.elements.forEach((el) => {
30433
+ if (!el) return;
30434
+ if (el.name === "w:styles" && Array.isArray(el.elements)) {
30435
+ el.elements.forEach((child) => {
30436
+ if (child?.name === "w:style") candidates.push(child);
30437
+ });
30438
+ return;
30439
+ }
30440
+ if (el.name === "w:style") {
30441
+ candidates.push(el);
30442
+ return;
30443
+ }
30444
+ if (Array.isArray(el.elements)) {
30445
+ el.elements.forEach((child) => {
30446
+ if (child?.name === "w:style") candidates.push(child);
30447
+ });
30448
+ }
30449
+ });
30450
+ return candidates.find((tag) => tag?.attributes?.["w:styleId"] === styleId) || null;
30451
+ };
30452
+ const extractMarksFromStyle = (styleTag, docx) => {
30453
+ const rPr = styleTag?.elements?.find((el) => el.name === "w:rPr");
30454
+ if (!rPr) return { inlineMarks: [], textStyleAttrs: null };
30455
+ const marks = parseMarks(rPr, [], docx) || [];
30456
+ const inlineMarks = [];
30457
+ let textStyleAttrs = {};
30458
+ marks.forEach((mark) => {
30459
+ if (!mark) return;
30460
+ if (mark.type === "textStyle") {
30461
+ const attrs = mark.attrs || {};
30462
+ if (Object.keys(attrs).length) textStyleAttrs = { ...textStyleAttrs, ...attrs };
30463
+ return;
30464
+ }
30465
+ if (mark.type) inlineMarks.push(mark.attrs ? { type: mark.type, attrs: { ...mark.attrs } } : { type: mark.type });
30466
+ });
30467
+ return {
30468
+ inlineMarks,
30469
+ textStyleAttrs: Object.keys(textStyleAttrs).length ? textStyleAttrs : null
30470
+ };
30471
+ };
30472
+ const mergeInlineMarkSets = (...markSets) => {
30473
+ const map3 = /* @__PURE__ */ new Map();
30474
+ markSets.filter(Boolean).forEach((marks) => {
29711
30475
  marks.forEach((mark) => {
29712
- const exists2 = combinedMarks.some(
29713
- (existing) => existing.type === mark.type && JSON.stringify(existing.attrs || {}) === JSON.stringify(mark.attrs || {})
29714
- );
29715
- if (!exists2) {
29716
- combinedMarks.push(mark);
29717
- }
30476
+ if (!mark || !mark.type) return;
30477
+ map3.set(mark.type, mark.attrs ? { type: mark.type, attrs: { ...mark.attrs } } : { type: mark.type });
29718
30478
  });
29719
- if (runStyleId) combinedMarks.push({ type: "textStyle", attrs: { styleId: runStyleId } });
29720
- if (node.marks) combinedMarks.push(...node.marks);
29721
- const newMarks = createImportMarks(combinedMarks);
29722
- processedRun = processedRun.map((n) => {
29723
- const existingMarks = n.marks || [];
29724
- return {
29725
- ...n,
29726
- marks: [...newMarks, ...existingMarks]
29727
- };
30479
+ });
30480
+ return Array.from(map3.values());
30481
+ };
30482
+ const mergeTextStyleAttrs = (...attrsList) => {
30483
+ const merged = attrsList.filter((attrs) => attrs && Object.keys(attrs).length).reduce((acc, attrs) => ({ ...acc, ...attrs }), {});
30484
+ return Object.keys(merged).length ? merged : null;
30485
+ };
30486
+ const cloneRunAttrs = (attrs) => {
30487
+ const clone = { ...attrs };
30488
+ if (Array.isArray(attrs?.runProperties)) {
30489
+ clone.runProperties = attrs.runProperties.map((entry) => ({
30490
+ xmlName: entry?.xmlName,
30491
+ attributes: { ...entry?.attributes || {} }
30492
+ }));
30493
+ }
30494
+ return clone;
30495
+ };
30496
+ const cloneMark = (mark) => {
30497
+ if (!mark || typeof mark !== "object") return mark;
30498
+ const cloned = { ...mark };
30499
+ if (mark.attrs && typeof mark.attrs === "object") {
30500
+ cloned.attrs = { ...mark.attrs };
30501
+ if (Array.isArray(mark.attrs.runProperties)) {
30502
+ cloned.attrs.runProperties = mark.attrs.runProperties.map((entry) => ({
30503
+ xmlName: entry?.xmlName,
30504
+ attributes: { ...entry?.attributes || {} }
30505
+ }));
30506
+ }
30507
+ }
30508
+ return cloned;
30509
+ };
30510
+ const mergeRunAttrs = (existing = {}, incoming = {}) => {
30511
+ const merged = { ...existing, ...cloneRunAttrs(incoming) };
30512
+ if (Array.isArray(existing?.runProperties) && Array.isArray(incoming?.runProperties)) {
30513
+ const seen = /* @__PURE__ */ new Set();
30514
+ const combined = [...existing.runProperties, ...incoming.runProperties];
30515
+ merged.runProperties = combined.filter((entry) => {
30516
+ const key = entry?.xmlName;
30517
+ if (!key || seen.has(key)) return false;
30518
+ seen.add(key);
30519
+ return true;
29728
30520
  });
29729
30521
  }
29730
- return { nodes: processedRun, consumed: 1 };
30522
+ return merged;
29731
30523
  };
29732
- const getMarksFromStyles = (docx, styleId) => {
29733
- const styles = docx?.["word/styles.xml"];
29734
- if (!styles) {
29735
- return {};
30524
+ const normalizeBool = (value) => {
30525
+ if (value === void 0 || value === null) return true;
30526
+ if (typeof value === "boolean") return value;
30527
+ if (typeof value === "number") return value !== 0;
30528
+ const normalized = String(value).trim().toLowerCase();
30529
+ if (normalized === "0" || normalized === "false" || normalized === "off") return false;
30530
+ if (normalized === "1" || normalized === "true" || normalized === "on") return true;
30531
+ return true;
30532
+ };
30533
+ const resolveRunElement = (node) => {
30534
+ if (!node) return null;
30535
+ if (node.name === "w:r") return node;
30536
+ return (node.elements || []).find((el) => el.name === "w:r") || null;
30537
+ };
30538
+ const ensureRunPropertiesContainer = (runElement) => {
30539
+ if (!Array.isArray(runElement.elements)) runElement.elements = [];
30540
+ let rPr = runElement.elements.find((el) => el.name === "w:rPr");
30541
+ if (!rPr) {
30542
+ rPr = { name: "w:rPr", elements: [] };
30543
+ runElement.elements.unshift(rPr);
30544
+ }
30545
+ if (!Array.isArray(rPr.elements)) rPr.elements = [];
30546
+ return rPr;
30547
+ };
30548
+ const splitRunProperties = (entries = [], docx = null) => {
30549
+ const remainingProps = [];
30550
+ const inlineMarks = [];
30551
+ const textStyleAttrs = {};
30552
+ let hasTextStyle = false;
30553
+ let highlightColor = null;
30554
+ let runStyleId = null;
30555
+ entries.forEach((entry) => {
30556
+ if (!entry || !entry.xmlName) return;
30557
+ const attributes = entry.attributes || {};
30558
+ switch (entry.xmlName) {
30559
+ case "w:b": {
30560
+ const val = normalizeBool(attributes["w:val"]);
30561
+ inlineMarks.push(val ? { type: "bold" } : { type: "bold", attrs: { value: "0" } });
30562
+ break;
30563
+ }
30564
+ case "w:i": {
30565
+ const val = normalizeBool(attributes["w:val"]);
30566
+ inlineMarks.push(val ? { type: "italic" } : { type: "italic", attrs: { value: "0" } });
30567
+ break;
30568
+ }
30569
+ case "w:u": {
30570
+ const rawVal = attributes["w:val"];
30571
+ const underlineType = rawVal == null || rawVal === "" ? "single" : String(rawVal);
30572
+ const attrs = {};
30573
+ if (underlineType.toLowerCase() === "none" || underlineType === "0") {
30574
+ attrs.underlineType = "none";
30575
+ } else {
30576
+ attrs.underlineType = underlineType;
30577
+ const colorRaw = attributes["w:color"];
30578
+ if (typeof colorRaw === "string" && colorRaw.toLowerCase() !== "auto") {
30579
+ const normalizedColor = normalizeHexColor(colorRaw);
30580
+ if (normalizedColor) attrs.underlineColor = `#${normalizedColor}`;
30581
+ }
30582
+ }
30583
+ if (attributes["w:themeColor"]) attrs.underlineThemeColor = attributes["w:themeColor"];
30584
+ if (attributes["w:themeTint"]) attrs.underlineThemeTint = attributes["w:themeTint"];
30585
+ if (attributes["w:themeShade"]) attrs.underlineThemeShade = attributes["w:themeShade"];
30586
+ inlineMarks.push({ type: "underline", attrs });
30587
+ break;
30588
+ }
30589
+ case "w:color": {
30590
+ const raw = attributes["w:val"];
30591
+ if (typeof raw === "string" && raw) {
30592
+ hasTextStyle = true;
30593
+ textStyleAttrs.color = `#${raw.replace("#", "").toUpperCase()}`;
30594
+ }
30595
+ break;
30596
+ }
30597
+ case "w:rFonts": {
30598
+ const family = attributes["w:ascii"] || attributes["w:eastAsia"] || attributes["w:hAnsi"] || attributes["w:val"];
30599
+ if (family) {
30600
+ hasTextStyle = true;
30601
+ textStyleAttrs.fontFamily = SuperConverter.toCssFontFamily(family, docx);
30602
+ }
30603
+ break;
30604
+ }
30605
+ case "w:sz":
30606
+ case "w:szCs": {
30607
+ const rawSize = Number(attributes["w:val"]);
30608
+ if (Number.isFinite(rawSize) && rawSize > 0) {
30609
+ hasTextStyle = true;
30610
+ textStyleAttrs.fontSize = `${rawSize / 2}pt`;
30611
+ }
30612
+ break;
30613
+ }
30614
+ case "w:strike": {
30615
+ const val = normalizeBool(attributes["w:val"]);
30616
+ inlineMarks.push(val ? { type: "strike" } : { type: "strike", attrs: { value: "0" } });
30617
+ break;
30618
+ }
30619
+ case "w:highlight": {
30620
+ const color = attributes["w:val"];
30621
+ if (typeof color === "string" && color) {
30622
+ highlightColor = color.toLowerCase() === "none" ? "transparent" : color;
30623
+ }
30624
+ break;
30625
+ }
30626
+ case "w:shd": {
30627
+ const fill = attributes["w:fill"];
30628
+ const shdVal = attributes["w:val"];
30629
+ if (fill && String(fill).toLowerCase() !== "auto") {
30630
+ highlightColor = `#${String(fill).replace("#", "")}`;
30631
+ } else if (typeof shdVal === "string") {
30632
+ const normalized = shdVal.toLowerCase();
30633
+ if (normalized === "clear" || normalized === "nil" || normalized === "none") {
30634
+ highlightColor = "transparent";
30635
+ }
30636
+ }
30637
+ break;
30638
+ }
30639
+ case "w:rStyle": {
30640
+ if (typeof attributes["w:val"] === "string") runStyleId = attributes["w:val"];
30641
+ remainingProps.push({ xmlName: entry.xmlName, attributes: { ...attributes } });
30642
+ break;
30643
+ }
30644
+ default: {
30645
+ remainingProps.push({ xmlName: entry.xmlName, attributes: { ...attributes } });
30646
+ }
30647
+ }
30648
+ });
30649
+ if (highlightColor) inlineMarks.push({ type: "highlight", attrs: { color: highlightColor } });
30650
+ return {
30651
+ remainingProps,
30652
+ inlineMarks,
30653
+ textStyleAttrs: hasTextStyle ? textStyleAttrs : null,
30654
+ runStyleId
30655
+ };
30656
+ };
30657
+ const encode$3 = (attributes) => {
30658
+ return attributes["w:rsidR"];
30659
+ };
30660
+ const decode$3 = (attrs) => {
30661
+ return attrs.rsidR;
30662
+ };
30663
+ const attrConfig$2 = Object.freeze({
30664
+ xmlName: "w:rsidR",
30665
+ sdName: "rsidR",
30666
+ encode: encode$3,
30667
+ decode: decode$3
30668
+ });
30669
+ const encode$2 = (attributes) => {
30670
+ return attributes["w:rsidRPr"];
30671
+ };
30672
+ const decode$2 = (attrs) => {
30673
+ return attrs.rsidRPr;
30674
+ };
30675
+ const attrConfig$1 = Object.freeze({
30676
+ xmlName: "w:rsidRPr",
30677
+ sdName: "rsidRPr",
30678
+ encode: encode$2,
30679
+ decode: decode$2
30680
+ });
30681
+ const encode$1 = (attributes) => {
30682
+ return attributes["w:rsidDel"];
30683
+ };
30684
+ const decode$1 = (attrs) => {
30685
+ return attrs.rsidDel;
30686
+ };
30687
+ const attrConfig = Object.freeze({
30688
+ xmlName: "w:rsidDel",
30689
+ sdName: "rsidDel",
30690
+ encode: encode$1,
30691
+ decode: decode$1
30692
+ });
30693
+ const validXmlAttributes = [attrConfig$2, attrConfig$1, attrConfig];
30694
+ const XML_NODE_NAME = "w:r";
30695
+ const SD_KEY_NAME = "run";
30696
+ const encode$U = (params2, encodedAttrs = {}) => {
30697
+ const { nodes = [], nodeListHandler } = params2 || {};
30698
+ const runNode = nodes[0];
30699
+ if (!runNode) return void 0;
30700
+ const elements = Array.isArray(runNode.elements) ? runNode.elements : [];
30701
+ const rPrNode = elements.find((child) => child?.name === "w:rPr");
30702
+ const contentElements = rPrNode ? elements.filter((el) => el !== rPrNode) : elements;
30703
+ const { entries: runPropEntries, hadRPr, styleChangeMarks } = collectRunProperties(params2, rPrNode);
30704
+ const { remainingProps, inlineMarks, textStyleAttrs, runStyleId } = splitRunProperties(runPropEntries, params2?.docx);
30705
+ const styleMarks = deriveStyleMarks({
30706
+ docx: params2?.docx,
30707
+ paragraphStyleId: params2?.parentStyleId,
30708
+ runStyleId
30709
+ });
30710
+ const mergedInlineMarks = mergeInlineMarkSets(styleMarks.inlineMarks, inlineMarks);
30711
+ let mergedTextStyleAttrs = mergeTextStyleAttrs(styleMarks.textStyleAttrs, textStyleAttrs);
30712
+ if (runStyleId) {
30713
+ mergedTextStyleAttrs = mergedTextStyleAttrs ? { ...mergedTextStyleAttrs, styleId: runStyleId } : { styleId: runStyleId };
30714
+ }
30715
+ const runAttrs = buildRunAttrs(encodedAttrs, hadRPr, remainingProps);
30716
+ let runLevelMarks = Array.isArray(runNode.marks) ? runNode.marks.map((mark) => cloneMark(mark)) : [];
30717
+ if (styleChangeMarks?.length) {
30718
+ runLevelMarks = [...runLevelMarks, ...styleChangeMarks.map((mark) => cloneMark(mark))];
30719
+ }
30720
+ const childParams = { ...params2, nodes: contentElements };
30721
+ const content = nodeListHandler?.handler(childParams) || [];
30722
+ const contentWithRunMarks = content.map((child) => {
30723
+ if (!child || typeof child !== "object") return child;
30724
+ const baseMarks = Array.isArray(child.marks) ? child.marks.map((mark) => cloneMark(mark)) : [];
30725
+ if (!runLevelMarks.length) return child;
30726
+ return { ...child, marks: [...baseMarks, ...runLevelMarks.map((mark) => cloneMark(mark))] };
30727
+ });
30728
+ const marked = contentWithRunMarks.map(
30729
+ (child) => applyRunMarks(child, runAttrs, mergedInlineMarks, mergedTextStyleAttrs)
30730
+ );
30731
+ const filtered = marked.filter(Boolean);
30732
+ if (!filtered.length) return [];
30733
+ if (filtered.length === 1) return filtered[0];
30734
+ return filtered;
30735
+ };
30736
+ const decode = (params2, decodedAttrs = {}) => {
30737
+ const { node } = params2 || {};
30738
+ if (!node) return void 0;
30739
+ const marks = Array.isArray(node.marks) ? node.marks : [];
30740
+ const runMarkIndex = marks.findIndex((mark) => mark?.type === SD_KEY_NAME);
30741
+ const runMark = runMarkIndex >= 0 ? marks[runMarkIndex] : void 0;
30742
+ const strippedMarks = marks.filter((_2, idx) => idx !== runMarkIndex);
30743
+ const exportNode = { ...node, marks: strippedMarks };
30744
+ const exportParams = { ...params2, node: exportNode };
30745
+ if (!exportParams.editor) {
30746
+ exportParams.editor = { extensionService: { extensions: [] } };
30747
+ }
30748
+ const translated = exportSchemaToJson(exportParams);
30749
+ if (!translated) return void 0;
30750
+ const runElement = resolveRunElement(translated);
30751
+ if (!runElement) return translated;
30752
+ runElement.attributes = { ...runElement.attributes || {}, ...decodedAttrs };
30753
+ const runProperties = Array.isArray(runMark?.attrs?.runProperties) ? runMark.attrs.runProperties : null;
30754
+ if (runProperties && runProperties.length) {
30755
+ const rPr = ensureRunPropertiesContainer(runElement);
30756
+ const existingNames = new Set((rPr.elements || []).map((el) => el.name));
30757
+ runProperties.forEach((entry) => {
30758
+ if (!entry || !entry.xmlName || entry.xmlName === "w:b") return;
30759
+ if (existingNames.has(entry.xmlName)) return;
30760
+ rPr.elements.push({ name: entry.xmlName, attributes: { ...entry.attributes || {} } });
30761
+ existingNames.add(entry.xmlName);
30762
+ });
29736
30763
  }
29737
- const styleTags = styles.elements[0].elements.filter((style22) => style22.name === "w:style");
29738
- const style2 = styleTags.find((tag) => tag.attributes["w:styleId"] === styleId) || {};
29739
- if (!style2) return {};
29740
- return parseProperties(style2);
30764
+ return translated;
29741
30765
  };
29742
- const runNodeHandlerEntity = {
29743
- handlerName: "runNodeHandler",
29744
- handler: handleRunNode
30766
+ const config = {
30767
+ xmlName: XML_NODE_NAME,
30768
+ sdNodeOrKeyName: SD_KEY_NAME,
30769
+ type: NodeTranslator.translatorTypes.NODE,
30770
+ encode: encode$U,
30771
+ decode,
30772
+ attributes: validXmlAttributes
29745
30773
  };
30774
+ const translator = NodeTranslator.from(config);
30775
+ const runNodeHandlerEntity = generateV2HandlerEntity("runNodeHandler", translator);
29746
30776
  const handleTextNode = (params2) => {
29747
30777
  const { nodes, insideTrackChange } = params2;
29748
30778
  if (nodes.length === 0 || !(nodes[0].name === "w:t" || insideTrackChange && nodes[0].name === "w:delText")) {
@@ -29779,7 +30809,7 @@ const handleParagraphNode = (params2) => {
29779
30809
  if (nodes.length === 0 || nodes[0].name !== "w:p") {
29780
30810
  return { nodes: [], consumed: 0 };
29781
30811
  }
29782
- const schemaNode = translator$h.encode(params2);
30812
+ const schemaNode = translator$s.encode(params2);
29783
30813
  const newNodes = schemaNode ? [schemaNode] : [];
29784
30814
  return { nodes: newNodes, consumed: 1 };
29785
30815
  };
@@ -29792,7 +30822,7 @@ const handleSdtNode = (params2) => {
29792
30822
  if (nodes.length === 0 || nodes[0].name !== "w:sdt") {
29793
30823
  return { nodes: [], consumed: 0 };
29794
30824
  }
29795
- const result = translator.encode(params2);
30825
+ const result = translator$b.encode(params2);
29796
30826
  if (!result) {
29797
30827
  return { nodes: [], consumed: 0 };
29798
30828
  }
@@ -29882,7 +30912,7 @@ const handler = (params2) => {
29882
30912
  if (nodes.length === 0 || nodes[0].name !== "w:br") {
29883
30913
  return { nodes: [], consumed: 0 };
29884
30914
  }
29885
- const result = translator$j.encode(params2);
30915
+ const result = translator$v.encode(params2);
29886
30916
  if (!result) return { nodes: [], consumed: 0 };
29887
30917
  return {
29888
30918
  nodes: [result],
@@ -30578,7 +31608,7 @@ const handleTabNode = (params2) => {
30578
31608
  if (!nodes.length || nodes[0].name !== "w:tab") {
30579
31609
  return { nodes: [], consumed: 0 };
30580
31610
  }
30581
- const node = translator$i.encode(params2);
31611
+ const node = translator$t.encode(params2);
30582
31612
  return { nodes: [node], consumed: 1 };
30583
31613
  };
30584
31614
  const tabNodeEntityHandler = {
@@ -31025,6 +32055,16 @@ const isAlternatingHeadersOddEven = (docx) => {
31025
32055
  };
31026
32056
  const HYPERLINK_RELATIONSHIP_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink";
31027
32057
  const HEADER_RELATIONSHIP_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/header";
32058
+ const FONT_FAMILY_FALLBACKS = Object.freeze({
32059
+ swiss: "Arial, sans-serif",
32060
+ roman: "Times New Roman, serif",
32061
+ modern: "Courier New, monospace",
32062
+ script: "cursive",
32063
+ decorative: "fantasy",
32064
+ system: "system-ui",
32065
+ auto: "sans-serif"
32066
+ });
32067
+ const DEFAULT_GENERIC_FALLBACK = "sans-serif";
31028
32068
  const _SuperConverter = class _SuperConverter2 {
31029
32069
  constructor(params2 = null) {
31030
32070
  __privateAdd$2(this, _SuperConverter_instances);
@@ -31060,6 +32100,31 @@ const _SuperConverter = class _SuperConverter2 {
31060
32100
  this.documentId = params2?.documentId || null;
31061
32101
  if (this.docx.length || this.xml) this.parseFromXml();
31062
32102
  }
32103
+ static getFontTableEntry(docx, fontName) {
32104
+ if (!docx || !fontName) return null;
32105
+ const fontTable = docx["word/fontTable.xml"];
32106
+ if (!fontTable?.elements?.length) return null;
32107
+ const fontsNode = fontTable.elements.find((el) => el.name === "w:fonts");
32108
+ if (!fontsNode?.elements?.length) return null;
32109
+ return fontsNode.elements.find((el) => el?.attributes?.["w:name"] === fontName) || null;
32110
+ }
32111
+ static getFallbackFromFontTable(docx, fontName) {
32112
+ const fontEntry = _SuperConverter2.getFontTableEntry(docx, fontName);
32113
+ const family = fontEntry?.elements?.find((child) => child.name === "w:family")?.attributes?.["w:val"];
32114
+ if (!family) return null;
32115
+ const mapped = FONT_FAMILY_FALLBACKS[family.toLowerCase()];
32116
+ return mapped || DEFAULT_GENERIC_FALLBACK;
32117
+ }
32118
+ static toCssFontFamily(fontName, docx) {
32119
+ if (!fontName) return fontName;
32120
+ if (fontName.includes(",")) return fontName;
32121
+ const fallback = _SuperConverter2.getFallbackFromFontTable(docx, fontName) || DEFAULT_GENERIC_FALLBACK;
32122
+ const normalizedFallbackParts = fallback.split(",").map((part) => part.trim().toLowerCase()).filter(Boolean);
32123
+ if (normalizedFallbackParts.includes(fontName.trim().toLowerCase())) {
32124
+ return fallback;
32125
+ }
32126
+ return `${fontName}, ${fallback}`;
32127
+ }
31063
32128
  /**
31064
32129
  * Get the DocxHelpers object that contains utility functions for working with docx files.
31065
32130
  * @returns {import('./docx-helpers/docx-helpers.js').DocxHelpers} The DocxHelpers object.
@@ -31105,7 +32170,7 @@ const _SuperConverter = class _SuperConverter2 {
31105
32170
  return;
31106
32171
  }
31107
32172
  }
31108
- static updateDocumentVersion(docx = this.convertedXml, version2 = "0.20.0") {
32173
+ static updateDocumentVersion(docx = this.convertedXml, version2 = "0.21.0-RC1") {
31109
32174
  const customLocation = "docProps/custom.xml";
31110
32175
  if (!docx[customLocation]) {
31111
32176
  docx[customLocation] = generateCustomXml();
@@ -31156,13 +32221,19 @@ const _SuperConverter = class _SuperConverter2 {
31156
32221
  if (rPrDefaults) {
31157
32222
  const rPr = rPrDefaults.elements?.find((el) => el.name === "w:rPr");
31158
32223
  const fonts = rPr?.elements?.find((el) => el.name === "w:rFonts");
31159
- typeface = fonts?.attributes["w:ascii"];
31160
- const fontSize2 = typeface ?? rPr?.elements?.find((el) => el.name === "w:sz")?.attributes["w:val"];
31161
- fontSizeNormal = !fontSizeNormal && fontSize2 ? Number(fontSize2) / 2 : null;
32224
+ if (fonts?.attributes?.["w:ascii"]) {
32225
+ typeface = fonts.attributes["w:ascii"];
32226
+ }
32227
+ const fontSizeRaw = rPr?.elements?.find((el) => el.name === "w:sz")?.attributes?.["w:val"];
32228
+ if (!fontSizeNormal && fontSizeRaw) {
32229
+ fontSizeNormal = Number(fontSizeRaw) / 2;
32230
+ }
31162
32231
  }
31163
- const fontSizePt = fontSizeNormal || Number(rElements.find((el) => el.name === "w:sz")?.attributes["w:val"]) / 2 || 10;
32232
+ const fallbackSz = Number(rElements.find((el) => el.name === "w:sz")?.attributes?.["w:val"]);
32233
+ const fontSizePt = fontSizeNormal ?? (Number.isFinite(fallbackSz) ? fallbackSz / 2 : void 0) ?? 10;
31164
32234
  const kern = rElements.find((el) => el.name === "w:kern")?.attributes["w:val"];
31165
- return { fontSizePt, kern, typeface, panose };
32235
+ const fontFamilyCss = _SuperConverter2.toCssFontFamily(typeface, this.convertedXml);
32236
+ return { fontSizePt, kern, typeface, panose, fontFamilyCss };
31166
32237
  }
31167
32238
  }
31168
32239
  getDocumentFonts() {
@@ -31592,7 +32663,7 @@ function storeSuperdocVersion(docx) {
31592
32663
  function generateCustomXml() {
31593
32664
  return DEFAULT_CUSTOM_XML;
31594
32665
  }
31595
- function generateSuperdocVersion(pid = 2, version2 = "0.20.0") {
32666
+ function generateSuperdocVersion(pid = 2, version2 = "0.21.0-RC1") {
31596
32667
  return {
31597
32668
  type: "element",
31598
32669
  name: "property",
@@ -43006,6 +44077,95 @@ const toggleMark = (typeOrName, attrs = {}, options = {}) => ({ state: state2, c
43006
44077
  if (isActive2) return commands2.unsetMark(type2, { extendEmptyMarkRange });
43007
44078
  return commands2.setMark(type2, attrs);
43008
44079
  };
44080
+ const toggleMarkCascade = (markName, options = {}) => ({ state: state2, chain, editor }) => {
44081
+ const {
44082
+ negationAttrs = { value: "0" },
44083
+ isNegation = (attrs) => attrs?.value === "0",
44084
+ styleDetector = defaultStyleDetector,
44085
+ extendEmptyMarkRange = true
44086
+ } = options;
44087
+ const selectionMarks = getMarksFromSelection(state2) || [];
44088
+ const inlineMarks = selectionMarks.filter((m2) => m2.type?.name === markName);
44089
+ const hasNegation = inlineMarks.some((m2) => isNegation(m2.attrs || {}));
44090
+ const hasInline = inlineMarks.some((m2) => !isNegation(m2.attrs || {}));
44091
+ const styleOn = styleDetector({ state: state2, selectionMarks, markName, editor });
44092
+ const cmdChain = chain();
44093
+ if (hasNegation) return cmdChain.unsetMark(markName, { extendEmptyMarkRange }).run();
44094
+ if (hasInline && styleOn) {
44095
+ return cmdChain.unsetMark(markName, { extendEmptyMarkRange }).setMark(markName, negationAttrs, { extendEmptyMarkRange }).run();
44096
+ }
44097
+ if (hasInline) return cmdChain.unsetMark(markName, { extendEmptyMarkRange }).run();
44098
+ if (styleOn) return cmdChain.setMark(markName, negationAttrs, { extendEmptyMarkRange }).run();
44099
+ return cmdChain.setMark(markName, {}, { extendEmptyMarkRange }).run();
44100
+ };
44101
+ function defaultStyleDetector({ state: state2, selectionMarks, markName, editor }) {
44102
+ try {
44103
+ const styleId = getEffectiveStyleId(state2, selectionMarks);
44104
+ if (!styleId || !editor?.converter?.linkedStyles) return false;
44105
+ const styles = editor.converter.linkedStyles;
44106
+ const seen = /* @__PURE__ */ new Set();
44107
+ let current = styleId;
44108
+ const key = mapMarkToStyleKey(markName);
44109
+ while (current && !seen.has(current)) {
44110
+ seen.add(current);
44111
+ const style2 = styles.find((s) => s.id === current);
44112
+ const def = style2?.definition?.styles || {};
44113
+ if (key in def) {
44114
+ const raw = def[key];
44115
+ if (raw === void 0) return true;
44116
+ const val = raw?.value ?? raw;
44117
+ if (val === "0" || val === false) return false;
44118
+ return !!val;
44119
+ }
44120
+ current = style2?.definition?.attrs?.basedOn || null;
44121
+ }
44122
+ return false;
44123
+ } catch {
44124
+ return false;
44125
+ }
44126
+ }
44127
+ function getEffectiveStyleId(state2, selectionMarks) {
44128
+ const sidFromMarks = getStyleIdFromMarks(selectionMarks);
44129
+ if (sidFromMarks) return sidFromMarks;
44130
+ const $from = state2.selection.$from;
44131
+ const before = $from.nodeBefore;
44132
+ const after = $from.nodeAfter;
44133
+ if (before && before.marks) {
44134
+ const sid = getStyleIdFromMarks(before.marks);
44135
+ if (sid) return sid;
44136
+ }
44137
+ if (after && after.marks) {
44138
+ const sid = getStyleIdFromMarks(after.marks);
44139
+ if (sid) return sid;
44140
+ }
44141
+ const ts = selectionMarks.find((m2) => m2.type?.name === "textStyle" && m2.attrs?.styleId);
44142
+ if (ts) return ts.attrs.styleId;
44143
+ const pos = state2.selection.$from.pos;
44144
+ const $pos = state2.doc.resolve(pos);
44145
+ for (let d2 = $pos.depth; d2 >= 0; d2--) {
44146
+ const n = $pos.node(d2);
44147
+ if (n?.type?.name === "paragraph") return n.attrs?.styleId || null;
44148
+ }
44149
+ return null;
44150
+ }
44151
+ function getStyleIdFromMarks(marks) {
44152
+ const run2 = marks.find((m2) => m2.type?.name === "run");
44153
+ const runProperties = run2?.attrs?.runProperties;
44154
+ if (!runProperties) return null;
44155
+ if (runProperties && typeof runProperties === "object" && !Array.isArray(runProperties) && runProperties.styleId) {
44156
+ return runProperties.styleId;
44157
+ }
44158
+ if (Array.isArray(runProperties)) {
44159
+ const rStyleEntry = runProperties.find((e) => e?.xmlName === "w:rStyle");
44160
+ const sid = rStyleEntry?.attributes?.["w:val"];
44161
+ if (sid) return sid;
44162
+ }
44163
+ return null;
44164
+ }
44165
+ function mapMarkToStyleKey(markName) {
44166
+ if (markName === "textStyle" || markName === "color") return "color";
44167
+ return markName;
44168
+ }
43009
44169
  const clearNodes = () => ({ state: state2, tr, dispatch }) => {
43010
44170
  const { selection } = tr;
43011
44171
  const { ranges } = selection;
@@ -44351,11 +45511,14 @@ const commands$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePr
44351
45511
  command,
44352
45512
  createParagraphNear,
44353
45513
  decreaseListIndent,
45514
+ defaultStyleDetector,
44354
45515
  deleteListItem,
44355
45516
  deleteSelection,
44356
45517
  exitCode,
44357
45518
  first,
45519
+ getEffectiveStyleId,
44358
45520
  getParaCtx,
45521
+ getStyleIdFromMarks,
44359
45522
  handleBackspaceNextToList,
44360
45523
  handleDeleteNextToList,
44361
45524
  increaseListIndent,
@@ -44370,6 +45533,7 @@ const commands$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePr
44370
45533
  joinUp,
44371
45534
  liftEmptyBlock,
44372
45535
  liftListItem,
45536
+ mapMarkToStyleKey,
44373
45537
  nearestListAt,
44374
45538
  newlineInCode,
44375
45539
  rebuildListNodeWithNewNum,
@@ -44389,6 +45553,7 @@ const commands$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePr
44389
45553
  splitListItem,
44390
45554
  toggleList,
44391
45555
  toggleMark,
45556
+ toggleMarkCascade,
44392
45557
  toggleNode,
44393
45558
  undoInputRule,
44394
45559
  unsetAllMarks,
@@ -45592,7 +46757,7 @@ const createHeaderFooterEditor = ({
45592
46757
  currentPageNumber
45593
46758
  }) => {
45594
46759
  const parentStyles = editor.converter.getDocumentDefaultStyles();
45595
- const { fontSizePt, typeface } = parentStyles;
46760
+ const { fontSizePt, typeface, fontFamilyCss } = parentStyles;
45596
46761
  const fontSizeInPixles = fontSizePt * 1.3333;
45597
46762
  const lineHeight2 = fontSizeInPixles * 1.2;
45598
46763
  Object.assign(editorContainer.style, {
@@ -45605,7 +46770,7 @@ const createHeaderFooterEditor = ({
45605
46770
  left: "0",
45606
46771
  width: "auto",
45607
46772
  maxWidth: "none",
45608
- fontFamily: typeface,
46773
+ fontFamily: fontFamilyCss || typeface,
45609
46774
  fontSize: `${fontSizeInPixles}px`,
45610
46775
  lineHeight: `${lineHeight2}px`
45611
46776
  });
@@ -46435,7 +47600,6 @@ const trackedTransaction = ({ tr, state: state2, user }) => {
46435
47600
  originalStep,
46436
47601
  originalStepIndex
46437
47602
  });
46438
- console.debug("[track-changes]: replaceStep");
46439
47603
  } else if (step instanceof AddMarkStep) {
46440
47604
  addMarkStep({
46441
47605
  state: state2,
@@ -46445,7 +47609,6 @@ const trackedTransaction = ({ tr, state: state2, user }) => {
46445
47609
  user,
46446
47610
  date
46447
47611
  });
46448
- console.debug("[track-changes]: addMarkStep");
46449
47612
  } else if (step instanceof RemoveMarkStep) {
46450
47613
  removeMarkStep({
46451
47614
  state: state2,
@@ -46455,10 +47618,8 @@ const trackedTransaction = ({ tr, state: state2, user }) => {
46455
47618
  user,
46456
47619
  date
46457
47620
  });
46458
- console.debug("[track-changes]: removeMarkStep");
46459
47621
  } else {
46460
47622
  newTr.step(step);
46461
- console.log("[track-changes]: otherStep");
46462
47623
  }
46463
47624
  });
46464
47625
  if (tr.getMeta("inputType")) {
@@ -48528,9 +49689,10 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
48528
49689
  element.style.isolation = "isolate";
48529
49690
  proseMirror.style.outline = "none";
48530
49691
  proseMirror.style.border = "none";
48531
- const { typeface, fontSizePt } = this.converter.getDocumentDefaultStyles() ?? {};
48532
- if (typeface) {
48533
- element.style.fontFamily = typeface;
49692
+ const { typeface, fontSizePt, fontFamilyCss } = this.converter.getDocumentDefaultStyles() ?? {};
49693
+ const resolvedFontFamily = fontFamilyCss || typeface;
49694
+ if (resolvedFontFamily) {
49695
+ element.style.fontFamily = resolvedFontFamily;
48534
49696
  }
48535
49697
  if (fontSizePt) {
48536
49698
  element.style.fontSize = `${fontSizePt}pt`;
@@ -48844,7 +50006,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
48844
50006
  * @returns {Object | void} Migration results
48845
50007
  */
48846
50008
  processCollaborationMigrations() {
48847
- console.debug("[checkVersionMigrations] Current editor version", "0.20.0");
50009
+ console.debug("[checkVersionMigrations] Current editor version", "0.21.0-RC1");
48848
50010
  if (!this.options.ydoc) return;
48849
50011
  const metaMap = this.options.ydoc.getMap("meta");
48850
50012
  let docVersion = metaMap.get("version");
@@ -49953,6 +51115,7 @@ const FormatCommands = Extension.create({
49953
51115
  },
49954
51116
  addCommands() {
49955
51117
  return {
51118
+ toggleMarkCascade,
49956
51119
  /**
49957
51120
  * Clear all formatting (nodes and marks)
49958
51121
  * @category Command
@@ -50937,24 +52100,32 @@ const Text = Node$1.create({
50937
52100
  group: "inline",
50938
52101
  inline: true
50939
52102
  });
50940
- const RunItem = Node$1.create({
52103
+ const Run = Mark2.create({
50941
52104
  name: "run",
50942
- group: "inline",
50943
- content: "text*",
50944
- inline: true,
50945
- parseDOM() {
50946
- return [{ tag: "run" }];
50947
- },
50948
- renderDOM() {
50949
- return ["run", 0];
52105
+ inclusive: false,
52106
+ addOptions() {
52107
+ return {
52108
+ htmlAttributes: {}
52109
+ };
50950
52110
  },
50951
52111
  addAttributes() {
50952
52112
  return {
50953
- attributes: {
50954
- rendered: false,
50955
- "aria-label": "Run node"
52113
+ runProperties: {
52114
+ default: null,
52115
+ rendered: false
50956
52116
  }
50957
52117
  };
52118
+ },
52119
+ parseDOM() {
52120
+ return [
52121
+ {
52122
+ tag: "span[data-run]"
52123
+ }
52124
+ ];
52125
+ },
52126
+ renderDOM({ htmlAttributes }) {
52127
+ const base2 = Attribute2.mergeAttributes({ "data-run": "1" }, this.options.htmlAttributes, htmlAttributes);
52128
+ return ["span", base2, 0];
50958
52129
  }
50959
52130
  });
50960
52131
  const inputRegex$1 = /^\s*([-+*])\s$/;
@@ -51518,6 +52689,7 @@ const getMarksStyle = (attrs) => {
51518
52689
  case "textStyle":
51519
52690
  const { fontFamily: fontFamily2, fontSize: fontSize2 } = attr.attrs;
51520
52691
  styles += `${fontFamily2 ? `font-family: ${fontFamily2};` : ""} ${fontSize2 ? `font-size: ${fontSize2};` : ""}`;
52692
+ break;
51521
52693
  }
51522
52694
  }
51523
52695
  return styles.trim();
@@ -51536,12 +52708,22 @@ const generateLinkedStyleString = (linkedStyle, basedOnStyle, node, parent, incl
51536
52708
  const linkedDefinitionStyles = { ...linkedStyle.definition.styles };
51537
52709
  const basedOnDefinitionStyles = { ...basedOnStyle?.definition?.styles };
51538
52710
  const resultStyles = { ...linkedDefinitionStyles };
51539
- if (!linkedDefinitionStyles["font-size"] && basedOnDefinitionStyles["font-size"]) {
51540
- resultStyles["font-size"] = basedOnDefinitionStyles["font-size"];
51541
- }
51542
- if (!linkedDefinitionStyles["text-transform"] && basedOnDefinitionStyles["text-transform"]) {
51543
- resultStyles["text-transform"] = basedOnDefinitionStyles["text-transform"];
51544
- }
52711
+ const inheritKeys = [
52712
+ "font-size",
52713
+ "font-family",
52714
+ "text-transform",
52715
+ "bold",
52716
+ "italic",
52717
+ "underline",
52718
+ "strike",
52719
+ "color",
52720
+ "highlight"
52721
+ ];
52722
+ inheritKeys.forEach((k) => {
52723
+ if (!linkedDefinitionStyles[k] && basedOnDefinitionStyles[k]) {
52724
+ resultStyles[k] = basedOnDefinitionStyles[k];
52725
+ }
52726
+ });
51545
52727
  Object.entries(resultStyles).forEach(([k, value]) => {
51546
52728
  const key = kebabCase$1(k);
51547
52729
  const flattenedMarks = [];
@@ -51556,6 +52738,10 @@ const generateLinkedStyleString = (linkedStyle, basedOnStyle, node, parent, incl
51556
52738
  }
51557
52739
  flattenedMarks.push({ key: n.type.name, value: n.attrs[key] });
51558
52740
  });
52741
+ const underlineNone = node?.marks?.some((m2) => m2.type?.name === "underline" && m2.attrs?.underlineType === "none");
52742
+ if (underlineNone) {
52743
+ markValue["text-decoration"] = "none";
52744
+ }
51559
52745
  const mark = flattenedMarks.find((n) => n.key === key);
51560
52746
  const hasParentIndent = Object.keys(parent?.attrs?.indent || {});
51561
52747
  const hasParentSpacing = Object.keys(parent?.attrs?.spacing || {});
@@ -51572,10 +52758,28 @@ const generateLinkedStyleString = (linkedStyle, basedOnStyle, node, parent, incl
51572
52758
  if (rightIndent) markValue["margin-right"] = rightIndent + "px";
51573
52759
  if (firstLine) markValue["text-indent"] = firstLine + "px";
51574
52760
  } else if (key === "bold" && node) {
51575
- const val = value?.value;
51576
- if (!listTypes.includes(node.type.name) && val !== "0") {
52761
+ const boldValue = typeof value === "object" && value !== null ? value.value : value;
52762
+ const hasInlineBoldOff = node.marks?.some((m2) => m2.type?.name === "bold" && m2.attrs?.value === "0");
52763
+ const hasInlineBoldOn = node.marks?.some((m2) => m2.type?.name === "bold" && m2.attrs?.value !== "0");
52764
+ if (!listTypes.includes(node.type.name) && !hasInlineBoldOff && !hasInlineBoldOn && boldValue !== "0" && boldValue !== false) {
51577
52765
  markValue["font-weight"] = "bold";
51578
52766
  }
52767
+ } else if (key === "italic" && node) {
52768
+ const italicValue = typeof value === "object" && value !== null ? value.value : value;
52769
+ const hasInlineItalicOff = node.marks?.some((m2) => m2.type?.name === "italic" && m2.attrs?.value === "0");
52770
+ const hasInlineItalicOn = node.marks?.some((m2) => m2.type?.name === "italic" && m2.attrs?.value !== "0");
52771
+ if (!listTypes.includes(node.type.name) && !hasInlineItalicOff && !hasInlineItalicOn && italicValue !== "0" && italicValue !== false) {
52772
+ markValue["font-style"] = "italic";
52773
+ }
52774
+ } else if (key === "strike" && node) {
52775
+ const strikeValue = typeof value === "object" && value !== null ? value.value : value;
52776
+ const hasInlineStrikeOff = node.marks?.some((m2) => m2.type?.name === "strike" && m2.attrs?.value === "0");
52777
+ const hasInlineStrikeOn = node.marks?.some(
52778
+ (m2) => m2.type?.name === "strike" && (m2.attrs?.value === void 0 || m2.attrs?.value !== "0")
52779
+ );
52780
+ if (!listTypes.includes(node.type.name) && !hasInlineStrikeOff && !hasInlineStrikeOn && strikeValue !== "0" && strikeValue !== false) {
52781
+ markValue["text-decoration"] = "line-through";
52782
+ }
51579
52783
  } else if (key === "text-transform" && node) {
51580
52784
  if (!listTypes.includes(node.type.name)) {
51581
52785
  markValue[key] = value;
@@ -51584,10 +52788,44 @@ const generateLinkedStyleString = (linkedStyle, basedOnStyle, node, parent, incl
51584
52788
  if (!listTypes.includes(node.type.name)) {
51585
52789
  markValue[key] = value;
51586
52790
  }
52791
+ } else if (key === "font-family" && node) {
52792
+ if (!listTypes.includes(node.type.name)) {
52793
+ markValue[key] = value;
52794
+ }
51587
52795
  } else if (key === "color" && node) {
51588
52796
  if (!listTypes.includes(node.type.name)) {
51589
52797
  markValue[key] = value;
51590
52798
  }
52799
+ } else if (key === "highlight" && node) {
52800
+ const hasInlineHighlight = node.marks?.some((m2) => m2.type?.name === "highlight");
52801
+ if (!listTypes.includes(node.type.name) && !hasInlineHighlight) {
52802
+ const color = typeof value === "string" ? value : value?.color;
52803
+ if (color) markValue["background-color"] = color;
52804
+ }
52805
+ } else if (key === "underline" && node) {
52806
+ const styleValRaw = value?.value ?? value ?? "";
52807
+ const styleVal = styleValRaw.toString().toLowerCase();
52808
+ const hasInlineUnderlineOff = node.marks?.some(
52809
+ (m2) => m2.type?.name === "underline" && m2.attrs?.underlineType === "none"
52810
+ );
52811
+ const hasInlineUnderlineOn = node.marks?.some(
52812
+ (m2) => m2.type?.name === "underline" && m2.attrs?.underlineType && m2.attrs.underlineType !== "none"
52813
+ );
52814
+ if (!listTypes.includes(node.type.name) && !hasInlineUnderlineOff && !hasInlineUnderlineOn) {
52815
+ if (styleVal && styleVal !== "none" && styleVal !== "0") {
52816
+ const colorVal = value && typeof value === "object" ? value.color || value.underlineColor || null : null;
52817
+ const css = getUnderlineCssString({ type: styleVal, color: colorVal });
52818
+ css.split(";").forEach((decl) => {
52819
+ const d2 = decl.trim();
52820
+ if (!d2) return;
52821
+ const idx = d2.indexOf(":");
52822
+ if (idx === -1) return;
52823
+ const k2 = d2.slice(0, idx).trim();
52824
+ const v2 = d2.slice(idx + 1).trim();
52825
+ markValue[k2] = v2;
52826
+ });
52827
+ }
52828
+ }
51591
52829
  } else if (typeof value === "string") {
51592
52830
  markValue[key] = value;
51593
52831
  }
@@ -51720,23 +52958,51 @@ const createLinkedStylesPlugin = (editor) => {
51720
52958
  };
51721
52959
  const generateDecorations = (state2, styles) => {
51722
52960
  const decorations = [];
51723
- let lastStyleId = null;
51724
52961
  const doc2 = state2?.doc;
52962
+ const getParagraphStyleId = (pos) => {
52963
+ const $pos = state2.doc.resolve(pos);
52964
+ for (let d2 = $pos.depth; d2 >= 0; d2--) {
52965
+ const n = $pos.node(d2);
52966
+ if (n?.type?.name === "paragraph") return n.attrs?.styleId || null;
52967
+ }
52968
+ return null;
52969
+ };
51725
52970
  doc2.descendants((node, pos) => {
51726
52971
  const { name } = node.type;
51727
- if (node?.attrs?.styleId) lastStyleId = node.attrs.styleId;
51728
- if (name === "paragraph" && !node.attrs?.styleId) lastStyleId = null;
51729
- if (name !== "text" && name !== "listItem" && name !== "orderedList") return;
52972
+ if (name !== "text") return;
52973
+ const paragraphStyleId = getParagraphStyleId(pos);
52974
+ let runStyleId = null;
52975
+ let inlineTextStyleId = null;
51730
52976
  for (const mark of node.marks) {
51731
- if (mark.type.name === "textStyle" && mark.attrs.styleId) {
51732
- lastStyleId = mark.attrs.styleId;
51733
- }
51734
- }
51735
- const { linkedStyle, basedOnStyle } = getLinkedStyle(lastStyleId, styles);
51736
- if (!linkedStyle) return;
52977
+ if (mark.type.name === "run") {
52978
+ const rp = mark.attrs?.runProperties;
52979
+ if (rp && typeof rp === "object" && !Array.isArray(rp) && rp.styleId) runStyleId = rp.styleId;
52980
+ else if (Array.isArray(rp)) {
52981
+ const ent = rp.find((e) => e?.xmlName === "w:rStyle");
52982
+ const sid = ent?.attributes?.["w:val"];
52983
+ if (sid) runStyleId = sid;
52984
+ }
52985
+ } else if (mark.type.name === "textStyle" && mark.attrs?.styleId) {
52986
+ inlineTextStyleId = mark.attrs.styleId;
52987
+ }
52988
+ }
52989
+ const buildStyleMap = (sid) => {
52990
+ if (!sid) return {};
52991
+ const { linkedStyle, basedOnStyle: basedOnStyle2 } = getLinkedStyle(sid, styles);
52992
+ if (!linkedStyle) return {};
52993
+ const base2 = { ...basedOnStyle2?.definition?.styles || {} };
52994
+ return { ...base2, ...linkedStyle.definition?.styles || {} };
52995
+ };
52996
+ const pMap = buildStyleMap(paragraphStyleId);
52997
+ const tMap = buildStyleMap(inlineTextStyleId);
52998
+ const rMap = buildStyleMap(runStyleId);
52999
+ const finalStyles = { ...pMap, ...tMap, ...rMap };
53000
+ if (Object.keys(finalStyles).length === 0) return;
53001
+ const mergedLinkedStyle = { definition: { styles: finalStyles, attrs: {} } };
53002
+ const basedOnStyle = null;
51737
53003
  const $pos = state2.doc.resolve(pos);
51738
53004
  const parent = $pos.parent;
51739
- const styleString = generateLinkedStyleString(linkedStyle, basedOnStyle, node, parent);
53005
+ const styleString = generateLinkedStyleString(mergedLinkedStyle, basedOnStyle, node, parent);
51740
53006
  if (!styleString) return;
51741
53007
  const decoration = Decoration.inline(pos, pos + node.nodeSize, { style: styleString });
51742
53008
  decorations.push(decoration);
@@ -51871,6 +53137,70 @@ const LinkedStyles = Extension.create({
51871
53137
  };
51872
53138
  }
51873
53139
  });
53140
+ function getUnderlineCssString({ type: type2 = "single", color = null, thickness = null, approximate = true } = {}) {
53141
+ const parts = [];
53142
+ const add = (k, v2) => {
53143
+ if (!v2) return;
53144
+ parts.push(`${k}: ${v2}`);
53145
+ };
53146
+ const lower = String(type2 || "single").toLowerCase();
53147
+ if (lower === "none" || lower === "0") {
53148
+ add("text-decoration", "none");
53149
+ return parts.join("; ");
53150
+ }
53151
+ add("text-decoration-line", "underline");
53152
+ const HEAVY = thickness || "0.2em";
53153
+ const THICK = thickness || "0.15em";
53154
+ switch (lower) {
53155
+ case "single":
53156
+ break;
53157
+ case "double":
53158
+ add("text-decoration-style", "double");
53159
+ break;
53160
+ case "thick":
53161
+ add("text-decoration-thickness", THICK);
53162
+ break;
53163
+ case "dotted":
53164
+ add("text-decoration-style", "dotted");
53165
+ break;
53166
+ case "dash":
53167
+ case "dashed":
53168
+ add("text-decoration-style", "dashed");
53169
+ break;
53170
+ case "dotdash":
53171
+ case "dotdotdash":
53172
+ case "dashlong":
53173
+ case "dashlongheavy":
53174
+ if (approximate) {
53175
+ add("text-decoration-style", "dashed");
53176
+ if (lower.includes("heavy")) add("text-decoration-thickness", HEAVY);
53177
+ }
53178
+ break;
53179
+ case "dottedheavy":
53180
+ add("text-decoration-style", "dotted");
53181
+ add("text-decoration-thickness", HEAVY);
53182
+ break;
53183
+ case "dashedheavy":
53184
+ add("text-decoration-style", "dashed");
53185
+ add("text-decoration-thickness", HEAVY);
53186
+ break;
53187
+ case "wavy":
53188
+ add("text-decoration-style", "wavy");
53189
+ break;
53190
+ case "wavyheavy":
53191
+ add("text-decoration-style", "wavy");
53192
+ add("text-decoration-thickness", HEAVY);
53193
+ break;
53194
+ case "wavydouble":
53195
+ if (approximate) {
53196
+ add("text-decoration-style", "wavy");
53197
+ add("text-decoration-thickness", HEAVY);
53198
+ }
53199
+ break;
53200
+ }
53201
+ if (color) add("text-decoration-color", color);
53202
+ return parts.join("; ");
53203
+ }
51874
53204
  const generateOrderedListIndex = ({ listLevel, lvlText, listNumberingType, customFormat }) => {
51875
53205
  const handler2 = listIndexMap[listNumberingType];
51876
53206
  return handler2 ? handler2(listLevel, lvlText, customFormat) : null;
@@ -60156,6 +61486,30 @@ const TextStyle = Mark2.create({
60156
61486
  };
60157
61487
  }
60158
61488
  });
61489
+ function createCascadeToggleCommands({
61490
+ markName,
61491
+ setCommand,
61492
+ unsetCommand,
61493
+ toggleCommand,
61494
+ negationAttrs,
61495
+ isNegation,
61496
+ extendEmptyMarkRange
61497
+ } = {}) {
61498
+ if (!markName) throw new Error("createCascadeToggleCommands requires a markName");
61499
+ const capitalized = markName.charAt(0).toUpperCase() + markName.slice(1);
61500
+ const setName = setCommand ?? `set${capitalized}`;
61501
+ const unsetName = unsetCommand ?? `unset${capitalized}`;
61502
+ const toggleName = toggleCommand ?? `toggle${capitalized}`;
61503
+ const cascadeOptions = {};
61504
+ if (negationAttrs) cascadeOptions.negationAttrs = negationAttrs;
61505
+ if (typeof isNegation === "function") cascadeOptions.isNegation = isNegation;
61506
+ if (extendEmptyMarkRange !== void 0) cascadeOptions.extendEmptyMarkRange = extendEmptyMarkRange;
61507
+ return {
61508
+ [setName]: () => ({ commands: commands2 }) => commands2.setMark(markName),
61509
+ [unsetName]: () => ({ commands: commands2 }) => commands2.unsetMark(markName),
61510
+ [toggleName]: () => ({ commands: commands2 }) => commands2.toggleMarkCascade(markName, cascadeOptions)
61511
+ };
61512
+ }
60159
61513
  const Bold = Mark2.create({
60160
61514
  name: "bold",
60161
61515
  addOptions() {
@@ -60190,9 +61544,18 @@ const Bold = Mark2.create({
60190
61544
  ];
60191
61545
  },
60192
61546
  renderDOM({ htmlAttributes }) {
60193
- return ["strong", Attribute2.mergeAttributes(this.options.htmlAttributes, htmlAttributes), 0];
61547
+ const merged = Attribute2.mergeAttributes(this.options.htmlAttributes, htmlAttributes);
61548
+ const { value, ...rest } = merged || {};
61549
+ if (value === "0") {
61550
+ return ["span", rest, 0];
61551
+ }
61552
+ return ["strong", rest, 0];
60194
61553
  },
60195
61554
  addCommands() {
61555
+ const { setBold, unsetBold, toggleBold } = createCascadeToggleCommands({
61556
+ markName: this.name,
61557
+ negationAttrs: { value: "0" }
61558
+ });
60196
61559
  return {
60197
61560
  /**
60198
61561
  * Apply bold formatting
@@ -60202,7 +61565,7 @@ const Bold = Mark2.create({
60202
61565
  * setBold()
60203
61566
  * @note '0' renders as normal weight
60204
61567
  */
60205
- setBold: () => ({ commands: commands2 }) => commands2.setMark(this.name),
61568
+ setBold,
60206
61569
  /**
60207
61570
  * Remove bold formatting
60208
61571
  * @category Command
@@ -60210,7 +61573,7 @@ const Bold = Mark2.create({
60210
61573
  * @example
60211
61574
  * unsetBold()
60212
61575
  */
60213
- unsetBold: () => ({ commands: commands2 }) => commands2.unsetMark(this.name),
61576
+ unsetBold,
60214
61577
  /**
60215
61578
  * Toggle bold formatting
60216
61579
  * @category Command
@@ -60218,7 +61581,7 @@ const Bold = Mark2.create({
60218
61581
  * @example
60219
61582
  * toggleBold()
60220
61583
  */
60221
- toggleBold: () => ({ commands: commands2 }) => commands2.toggleMark(this.name)
61584
+ toggleBold
60222
61585
  };
60223
61586
  },
60224
61587
  addShortcuts() {
@@ -60235,6 +61598,22 @@ const Italic = Mark2.create({
60235
61598
  htmlAttributes: {}
60236
61599
  };
60237
61600
  },
61601
+ addAttributes() {
61602
+ return {
61603
+ /**
61604
+ * @category Attribute
61605
+ * @param {string} [value] - Italic toggle value ('0' renders as normal)
61606
+ */
61607
+ value: {
61608
+ default: null,
61609
+ renderDOM: (attrs) => {
61610
+ if (!attrs.value) return {};
61611
+ if (attrs.value === "0") return { style: "font-style: normal" };
61612
+ return {};
61613
+ }
61614
+ }
61615
+ };
61616
+ },
60238
61617
  parseDOM() {
60239
61618
  return [
60240
61619
  { tag: "i" },
@@ -60244,9 +61623,18 @@ const Italic = Mark2.create({
60244
61623
  ];
60245
61624
  },
60246
61625
  renderDOM({ htmlAttributes }) {
60247
- return ["em", Attribute2.mergeAttributes(this.options.htmlAttributes, htmlAttributes), 0];
61626
+ const merged = Attribute2.mergeAttributes(this.options.htmlAttributes, htmlAttributes);
61627
+ const { value, ...rest } = merged || {};
61628
+ if (value === "0") {
61629
+ return ["span", rest, 0];
61630
+ }
61631
+ return ["em", rest, 0];
60248
61632
  },
60249
61633
  addCommands() {
61634
+ const { setItalic, unsetItalic, toggleItalic } = createCascadeToggleCommands({
61635
+ markName: this.name,
61636
+ negationAttrs: { value: "0" }
61637
+ });
60250
61638
  return {
60251
61639
  /**
60252
61640
  * Apply italic formatting
@@ -60255,7 +61643,7 @@ const Italic = Mark2.create({
60255
61643
  * @example
60256
61644
  * setItalic()
60257
61645
  */
60258
- setItalic: () => ({ commands: commands2 }) => commands2.setMark(this.name),
61646
+ setItalic,
60259
61647
  /**
60260
61648
  * Remove italic formatting
60261
61649
  * @category Command
@@ -60263,7 +61651,7 @@ const Italic = Mark2.create({
60263
61651
  * @example
60264
61652
  * unsetItalic()
60265
61653
  */
60266
- unsetItalic: () => ({ commands: commands2 }) => commands2.unsetMark(this.name),
61654
+ unsetItalic,
60267
61655
  /**
60268
61656
  * Toggle italic formatting
60269
61657
  * @category Command
@@ -60271,7 +61659,7 @@ const Italic = Mark2.create({
60271
61659
  * @example
60272
61660
  * toggleItalic()
60273
61661
  */
60274
- toggleItalic: () => ({ commands: commands2 }) => commands2.toggleMark(this.name)
61662
+ toggleItalic
60275
61663
  };
60276
61664
  },
60277
61665
  addShortcuts() {
@@ -60296,7 +61684,16 @@ const Underline = Mark2.create({
60296
61684
  ];
60297
61685
  },
60298
61686
  renderDOM({ htmlAttributes }) {
60299
- return ["u", Attribute2.mergeAttributes(this.options.htmlAttributes, htmlAttributes), 0];
61687
+ const merged = Attribute2.mergeAttributes(this.options.htmlAttributes, htmlAttributes);
61688
+ const type2 = merged?.underlineType;
61689
+ const color = merged?.underlineColor;
61690
+ const css = getUnderlineCssString({ type: type2, color });
61691
+ const { style: style2, ...rest } = merged || {};
61692
+ const styleString = [style2, css].filter(Boolean).join("; ");
61693
+ if (type2 === "none") {
61694
+ return ["span", { ...rest, ...styleString ? { style: styleString } : {} }, 0];
61695
+ }
61696
+ return ["u", { ...rest, ...styleString ? { style: styleString } : {} }, 0];
60300
61697
  },
60301
61698
  addAttributes() {
60302
61699
  return {
@@ -60306,10 +61703,18 @@ const Underline = Mark2.create({
60306
61703
  */
60307
61704
  underlineType: {
60308
61705
  default: "single"
61706
+ },
61707
+ underlineColor: {
61708
+ default: null
60309
61709
  }
60310
61710
  };
60311
61711
  },
60312
61712
  addCommands() {
61713
+ const { setUnderline, unsetUnderline, toggleUnderline } = createCascadeToggleCommands({
61714
+ markName: this.name,
61715
+ negationAttrs: { underlineType: "none" },
61716
+ isNegation: (attrs) => attrs?.underlineType === "none"
61717
+ });
60313
61718
  return {
60314
61719
  /**
60315
61720
  * Apply underline formatting
@@ -60318,7 +61723,7 @@ const Underline = Mark2.create({
60318
61723
  * @example
60319
61724
  * setUnderline()
60320
61725
  */
60321
- setUnderline: () => ({ commands: commands2 }) => commands2.setMark(this.name),
61726
+ setUnderline,
60322
61727
  /**
60323
61728
  * Remove underline formatting
60324
61729
  * @category Command
@@ -60326,7 +61731,7 @@ const Underline = Mark2.create({
60326
61731
  * @example
60327
61732
  * unsetUnderline()
60328
61733
  */
60329
- unsetUnderline: () => ({ commands: commands2 }) => commands2.unsetMark(this.name),
61734
+ unsetUnderline,
60330
61735
  /**
60331
61736
  * Toggle underline formatting
60332
61737
  * @category Command
@@ -60334,7 +61739,7 @@ const Underline = Mark2.create({
60334
61739
  * @example
60335
61740
  * toggleUnderline()
60336
61741
  */
60337
- toggleUnderline: () => ({ commands: commands2 }) => commands2.toggleMark(this.name)
61742
+ toggleUnderline
60338
61743
  };
60339
61744
  },
60340
61745
  addShortcuts() {
@@ -60429,9 +61834,18 @@ const Strike = Mark2.create({
60429
61834
  ];
60430
61835
  },
60431
61836
  renderDOM({ htmlAttributes }) {
60432
- return ["s", Attribute2.mergeAttributes(this.options.htmlAttributes, htmlAttributes), 0];
61837
+ const merged = Attribute2.mergeAttributes(this.options.htmlAttributes, htmlAttributes);
61838
+ const { value, ...rest } = merged || {};
61839
+ if (value === "0") {
61840
+ return ["span", rest, 0];
61841
+ }
61842
+ return ["s", rest, 0];
60433
61843
  },
60434
61844
  addCommands() {
61845
+ const { setStrike, unsetStrike, toggleStrike } = createCascadeToggleCommands({
61846
+ markName: this.name,
61847
+ negationAttrs: { value: "0" }
61848
+ });
60435
61849
  return {
60436
61850
  /**
60437
61851
  * Apply strikethrough formatting
@@ -60440,9 +61854,7 @@ const Strike = Mark2.create({
60440
61854
  * @example
60441
61855
  * setStrike()
60442
61856
  */
60443
- setStrike: () => ({ commands: commands2 }) => {
60444
- return commands2.setMark(this.name);
60445
- },
61857
+ setStrike,
60446
61858
  /**
60447
61859
  * Remove strikethrough formatting
60448
61860
  * @category Command
@@ -60450,9 +61862,7 @@ const Strike = Mark2.create({
60450
61862
  * @example
60451
61863
  * unsetStrike()
60452
61864
  */
60453
- unsetStrike: () => ({ commands: commands2 }) => {
60454
- return commands2.unsetMark(this.name);
60455
- },
61865
+ unsetStrike,
60456
61866
  /**
60457
61867
  * Toggle strikethrough formatting
60458
61868
  * @category Command
@@ -60460,8 +61870,24 @@ const Strike = Mark2.create({
60460
61870
  * @example
60461
61871
  * toggleStrike()
60462
61872
  */
60463
- toggleStrike: () => ({ commands: commands2 }) => {
60464
- return commands2.toggleMark(this.name);
61873
+ toggleStrike
61874
+ };
61875
+ },
61876
+ addAttributes() {
61877
+ return {
61878
+ /**
61879
+ * @category Attribute
61880
+ * @param {string} [value] - Strike toggle value ('0' renders as normal)
61881
+ */
61882
+ value: {
61883
+ default: null,
61884
+ renderDOM: (attrs) => {
61885
+ if (!attrs.value) return {};
61886
+ if (attrs.value === "0") {
61887
+ return { style: "text-decoration: none" };
61888
+ }
61889
+ return {};
61890
+ }
60465
61891
  }
60466
61892
  };
60467
61893
  },
@@ -66616,7 +68042,7 @@ const getStarterExtensions = () => {
66616
68042
  Paragraph,
66617
68043
  LineBreak,
66618
68044
  HardBreak,
66619
- RunItem,
68045
+ Run,
66620
68046
  SlashMenu,
66621
68047
  Strike,
66622
68048
  TabNode,
@@ -69147,7 +70573,7 @@ function resolveTo(selector) {
69147
70573
  if (typeof selector === "string") {
69148
70574
  return document.querySelector(selector);
69149
70575
  }
69150
- return selector() || null;
70576
+ return selector();
69151
70577
  }
69152
70578
  const LazyTeleport = defineComponent({
69153
70579
  name: "LazyTeleport",
@@ -69235,11 +70661,8 @@ const oppositeAlignCssPositionProps = {
69235
70661
  };
69236
70662
  const keepOffsetDirection = {
69237
70663
  top: true,
69238
- // top++
69239
70664
  bottom: false,
69240
- // top--
69241
70665
  left: true,
69242
- // left++
69243
70666
  right: false
69244
70667
  // left--
69245
70668
  };
@@ -70356,6 +71779,7 @@ function isFocusable(element) {
70356
71779
  return !!element.href && element.rel !== "ignore";
70357
71780
  case "INPUT":
70358
71781
  return element.type !== "hidden" && element.type !== "file";
71782
+ case "BUTTON":
70359
71783
  case "SELECT":
70360
71784
  case "TEXTAREA":
70361
71785
  return true;
@@ -70374,8 +71798,8 @@ const FocusTrap = defineComponent({
70374
71798
  default: true
70375
71799
  },
70376
71800
  onEsc: Function,
70377
- initialFocusTo: [String, Function],
70378
- finalFocusTo: [String, Function],
71801
+ initialFocusTo: String,
71802
+ finalFocusTo: String,
70379
71803
  returnFocusOnDeactivated: {
70380
71804
  type: Boolean,
70381
71805
  default: true
@@ -72473,7 +73897,6 @@ function self$6(vars) {
72473
73897
  });
72474
73898
  }
72475
73899
  const scrollbarLight = {
72476
- name: "Scrollbar",
72477
73900
  common: derived,
72478
73901
  self: self$6
72479
73902
  };
@@ -73989,14 +75412,11 @@ function self$5(vars) {
73989
75412
  boxShadow: boxShadow2
73990
75413
  });
73991
75414
  }
73992
- const popoverLight = createTheme({
75415
+ const popoverLight = {
73993
75416
  name: "Popover",
73994
75417
  common: derived,
73995
- peers: {
73996
- Scrollbar: scrollbarLight
73997
- },
73998
75418
  self: self$5
73999
- });
75419
+ };
74000
75420
  const oppositePlacement = {
74001
75421
  top: "bottom",
74002
75422
  bottom: "top",
@@ -74216,11 +75636,9 @@ const NPopoverBody = defineComponent({
74216
75636
  const {
74217
75637
  namespaceRef,
74218
75638
  mergedClsPrefixRef,
74219
- inlineThemeDisabled,
74220
- mergedRtlRef
75639
+ inlineThemeDisabled
74221
75640
  } = useConfig(props);
74222
75641
  const themeRef = useTheme("Popover", "-popover", style$3, popoverLight, props, mergedClsPrefixRef);
74223
- const rtlEnabledRef = useRtl("Popover", mergedRtlRef, mergedClsPrefixRef);
74224
75642
  const followerRef = ref$1(null);
74225
75643
  const NPopover2 = inject("NPopover");
74226
75644
  const bodyRef = ref$1(null);
@@ -74418,8 +75836,6 @@ const NPopoverBody = defineComponent({
74418
75836
  style: props.contentStyle
74419
75837
  }, slots);
74420
75838
  const maybeScrollableBody = props.scrollable ? h$1(XScrollbar, {
74421
- themeOverrides: themeRef.value.peerOverrides.Scrollbar,
74422
- theme: themeRef.value.peers.Scrollbar,
74423
75839
  contentClass: hasHeaderOrFooter ? void 0 : `${mergedClsPrefix}-popover__content ${(_b = props.contentClass) !== null && _b !== void 0 ? _b : ""}`,
74424
75840
  contentStyle: hasHeaderOrFooter ? void 0 : props.contentStyle
74425
75841
  }, {
@@ -74435,7 +75851,7 @@ const NPopoverBody = defineComponent({
74435
75851
  return [maybeScrollableBody, arrow2];
74436
75852
  };
74437
75853
  contentNode = h$1("div", mergeProps({
74438
- class: [`${mergedClsPrefix}-popover`, `${mergedClsPrefix}-popover-shared`, (rtlEnabledRef === null || rtlEnabledRef === void 0 ? void 0 : rtlEnabledRef.value) && `${mergedClsPrefix}-popover--rtl`, themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.themeClass.value, extraClass.map((v2) => `${mergedClsPrefix}-${v2}`), {
75854
+ class: [`${mergedClsPrefix}-popover`, `${mergedClsPrefix}-popover-shared`, themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.themeClass.value, extraClass.map((v2) => `${mergedClsPrefix}-${v2}`), {
74439
75855
  [`${mergedClsPrefix}-popover--scrollable`]: props.scrollable,
74440
75856
  [`${mergedClsPrefix}-popover--show-header-or-footer`]: hasHeaderOrFooter,
74441
75857
  [`${mergedClsPrefix}-popover--raw`]: props.raw,
@@ -74459,7 +75875,7 @@ const NPopoverBody = defineComponent({
74459
75875
  // The popover class and overlap class must exists, they will be used
74460
75876
  // to place the body & transition animation.
74461
75877
  // Shadow class exists for reuse box-shadow.
74462
- [`${mergedClsPrefix}-popover-shared`, (rtlEnabledRef === null || rtlEnabledRef === void 0 ? void 0 : rtlEnabledRef.value) && `${mergedClsPrefix}-popover--rtl`, themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.themeClass.value, props.overlap && `${mergedClsPrefix}-popover-shared--overlap`, props.showArrow && `${mergedClsPrefix}-popover-shared--show-arrow`, props.arrowPointToCenter && `${mergedClsPrefix}-popover-shared--center-arrow`],
75878
+ [`${mergedClsPrefix}-popover-shared`, themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.themeClass.value, props.overlap && `${mergedClsPrefix}-popover-shared--overlap`, props.showArrow && `${mergedClsPrefix}-popover-shared--show-arrow`, props.arrowPointToCenter && `${mergedClsPrefix}-popover-shared--center-arrow`],
74463
75879
  bodyRef,
74464
75880
  styleRef.value,
74465
75881
  handleMouseEnter,
@@ -79936,10 +81352,14 @@ class SuperToolbar extends EventEmitter2 {
79936
81352
  * @param {string} params.argument - The color to set
79937
81353
  * @returns {void}
79938
81354
  */
79939
- setColor: ({ item, argument }) => {
79940
- __privateMethod(this, _SuperToolbar_instances, runCommandWithArgumentOnly_fn).call(this, { item, argument }, () => {
79941
- this.activeEditor?.commands.setFieldAnnotationsTextColor(argument, true);
79942
- });
81355
+ setColor: ({ argument }) => {
81356
+ if (!argument || !this.activeEditor) return;
81357
+ const isNone = argument === "none";
81358
+ const value = isNone ? "inherit" : argument;
81359
+ if (this.activeEditor?.commands?.setColor) this.activeEditor.commands.setColor(value);
81360
+ const argValue = isNone ? null : argument;
81361
+ this.activeEditor?.commands.setFieldAnnotationsTextColor(argValue, true);
81362
+ this.updateToolbarState();
79943
81363
  },
79944
81364
  /**
79945
81365
  * Sets the highlight color for text
@@ -79948,12 +81368,14 @@ class SuperToolbar extends EventEmitter2 {
79948
81368
  * @param {string} params.argument - The highlight color to set
79949
81369
  * @returns {void}
79950
81370
  */
79951
- setHighlight: ({ item, argument }) => {
79952
- __privateMethod(this, _SuperToolbar_instances, runCommandWithArgumentOnly_fn).call(this, { item, argument, noArgumentCallback: true }, () => {
79953
- let arg = argument !== "none" ? argument : null;
79954
- this.activeEditor?.commands.setFieldAnnotationsTextHighlight(arg, true);
79955
- this.activeEditor?.commands.setCellBackground(arg);
79956
- });
81371
+ setHighlight: ({ argument }) => {
81372
+ if (!argument || !this.activeEditor) return;
81373
+ const inlineColor = argument !== "none" ? argument : "transparent";
81374
+ if (this.activeEditor?.commands?.setHighlight) this.activeEditor.commands.setHighlight(inlineColor);
81375
+ const argValue = argument !== "none" ? argument : null;
81376
+ this.activeEditor?.commands.setFieldAnnotationsTextHighlight(argValue, true);
81377
+ this.activeEditor?.commands.setCellBackground(argValue);
81378
+ this.updateToolbarState();
79957
81379
  },
79958
81380
  /**
79959
81381
  * Toggles the ruler visibility
@@ -80320,7 +81742,6 @@ class SuperToolbar extends EventEmitter2 {
80320
81742
  if (!command2) {
80321
81743
  return;
80322
81744
  }
80323
- this.log("(emmitCommand) Command:", command2, "\n item:", item, "\n argument:", argument, "\n option:", option);
80324
81745
  if (command2 in __privateGet(this, _interceptedCommands)) {
80325
81746
  return __privateGet(this, _interceptedCommands)[command2]({ item, argument });
80326
81747
  }
@@ -81883,11 +83304,32 @@ const _sfc_main = {
81883
83304
  }
81884
83305
  };
81885
83306
  const SuperInput = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-4d5cff52"]]);
81886
- const registeredHandlers = Object.freeze({
81887
- "w:br": translator$j,
81888
- "w:tab": translator$i,
81889
- "w:p": translator$h
81890
- });
83307
+ const baseHandlers = {
83308
+ ...runPropertyTranslators,
83309
+ "w:br": translator$v,
83310
+ "w:cantSplit": translator$r,
83311
+ "w:cnfStyle": translator$q,
83312
+ "w:divId": translator$p,
83313
+ "w:gridAfter": translator$o,
83314
+ "w:gridBefore": translator$n,
83315
+ "w:hidden": translator$m,
83316
+ "w:hyperlink": translator$c,
83317
+ "w:jc": translator$l,
83318
+ "w:p": translator$s,
83319
+ "w:r": translator,
83320
+ "w:rPr": translator$1,
83321
+ "w:sdt": translator$b,
83322
+ "w:tab": translator$t,
83323
+ "w:tblCellSpacing": translator$k,
83324
+ "w:tblHeader": translator$j,
83325
+ "w:tc": translator$d,
83326
+ "w:tr": translator$e,
83327
+ "w:trHeight": translator$i,
83328
+ "w:trPr": translator$f,
83329
+ "w:wAfter": translator$h,
83330
+ "w:wBefore": translator$g
83331
+ };
83332
+ const registeredHandlers = Object.freeze(baseHandlers);
81891
83333
  const Extensions = {
81892
83334
  Node: Node$1,
81893
83335
  Attribute: Attribute2,