@harbour-enterprises/superdoc 0.20.2 → 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 (96) hide show
  1. package/dist/chunks/{PdfViewer-BhwyCIho.cjs → PdfViewer-BdrjIRpr.cjs} +1 -1
  2. package/dist/chunks/{PdfViewer-BceCsygM.es.js → PdfViewer-DK1etjvu.es.js} +1 -1
  3. package/dist/chunks/{index-B6tAKGVb.cjs → index-C_zTr1ZR.cjs} +14 -33
  4. package/dist/chunks/{index-C0kV6dM8.es.js → index-ucP9WQ5I.es.js} +14 -33
  5. package/dist/chunks/{super-editor.es-BollA_Sr.es.js → super-editor.es-KKA9G1l1.es.js} +1851 -434
  6. package/dist/chunks/{super-editor.es-Dzt_HBkR.cjs → super-editor.es-XC168Mlw.cjs} +1851 -434
  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-DyzbfydS.js → converter-B61ZUb-V.js} +1405 -339
  11. package/dist/super-editor/chunks/{docx-zipper-Bk9SAmal.js → docx-zipper-B8nhsVFW.js} +2 -2
  12. package/dist/super-editor/chunks/{editor-BWE7oMgS.js → editor-CQ0o4v54.js} +420 -65
  13. package/dist/super-editor/chunks/{toolbar-BmHEsvA1.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 +1865 -467
  94. package/dist/superdoc.umd.js.map +1 -1
  95. package/package.json +1 -1
  96. package/dist/super-editor/src/core/super-converter/helpers/mediaHelpers.d.ts +0 -2
@@ -1385,7 +1385,7 @@
1385
1385
  shallowReadonlyMap
1386
1386
  );
1387
1387
  }
1388
- function createReactiveObject(target, isReadonly2, baseHandlers, collectionHandlers, proxyMap) {
1388
+ function createReactiveObject(target, isReadonly2, baseHandlers2, collectionHandlers, proxyMap) {
1389
1389
  if (!isObject$3(target)) {
1390
1390
  return target;
1391
1391
  }
@@ -1402,7 +1402,7 @@
1402
1402
  }
1403
1403
  const proxy = new Proxy(
1404
1404
  target,
1405
- targetType === 2 ? collectionHandlers : baseHandlers
1405
+ targetType === 2 ? collectionHandlers : baseHandlers2
1406
1406
  );
1407
1407
  proxyMap.set(target, proxy);
1408
1408
  return proxy;
@@ -22619,25 +22619,47 @@
22619
22619
  const defaults = xmlDoc.querySelectorAll("Default");
22620
22620
  return Array.from(defaults).map((item) => item.getAttribute("Extension"));
22621
22621
  };
22622
+ const DOCX_HIGHLIGHT_KEYWORD_MAP = /* @__PURE__ */ new Map([
22623
+ ["yellow", "FFFF00"],
22624
+ ["green", "00FF00"],
22625
+ ["blue", "0000FF"],
22626
+ ["cyan", "00FFFF"],
22627
+ ["magenta", "FF00FF"],
22628
+ ["red", "FF0000"],
22629
+ ["darkYellow", "808000"],
22630
+ ["darkGreen", "008000"],
22631
+ ["darkBlue", "000080"],
22632
+ ["darkCyan", "008080"],
22633
+ ["darkMagenta", "800080"],
22634
+ ["darkGray", "808080"],
22635
+ ["darkRed", "800000"],
22636
+ ["lightGray", "C0C0C0"],
22637
+ ["black", "000000"],
22638
+ ["white", "FFFFFF"]
22639
+ ]);
22640
+ const normalizeHexColor = (hex2) => {
22641
+ if (!hex2) return null;
22642
+ let value = hex2.replace("#", "").trim();
22643
+ if (!value) return null;
22644
+ value = value.toUpperCase();
22645
+ if (value.length === 3)
22646
+ value = value.split("").map((c2) => c2 + c2).join("");
22647
+ if (value.length === 8) value = value.slice(0, 6);
22648
+ return value;
22649
+ };
22622
22650
  const getHexColorFromDocxSystem = (docxColor) => {
22623
- const colorMap = /* @__PURE__ */ new Map([
22624
- ["yellow", "#ffff00"],
22625
- ["green", "#00ff00"],
22626
- ["blue", "#0000FFFF"],
22627
- ["cyan", "#00ffff"],
22628
- ["magenta", "#ff00ff"],
22629
- ["red", "#ff0000"],
22630
- ["darkYellow", "#808000FF"],
22631
- ["darkGreen", "#008000FF"],
22632
- ["darkBlue", "#000080"],
22633
- ["darkCyan", "#008080FF"],
22634
- ["darkMagenta", "#800080FF"],
22635
- ["darkGray", "#808080FF"],
22636
- ["darkRed", "#800000FF"],
22637
- ["lightGray", "#C0C0C0FF"],
22638
- ["black", "#000"]
22639
- ]);
22640
- return colorMap.get(docxColor) || null;
22651
+ const hex2 = DOCX_HIGHLIGHT_KEYWORD_MAP.get(docxColor);
22652
+ return hex2 ? `#${hex2}` : null;
22653
+ };
22654
+ const getDocxHighlightKeywordFromHex = (hexColor) => {
22655
+ if (!hexColor) return null;
22656
+ if (DOCX_HIGHLIGHT_KEYWORD_MAP.has(hexColor)) return hexColor;
22657
+ const normalized = normalizeHexColor(hexColor);
22658
+ if (!normalized) return null;
22659
+ for (const [keyword, hex2] of DOCX_HIGHLIGHT_KEYWORD_MAP.entries()) {
22660
+ if (hex2 === normalized) return keyword;
22661
+ }
22662
+ return null;
22641
22663
  };
22642
22664
  function isValidHexColor(color) {
22643
22665
  if (!color || typeof color !== "string") return false;
@@ -31918,18 +31940,6 @@ Please report this to https://github.com/markedjs/marked.`, e) {
31918
31940
  }
31919
31941
  ]
31920
31942
  };
31921
- const sanitizeDocxMediaName = (value, fallback = "image") => {
31922
- if (!value) return fallback;
31923
- const sanitized = value.replace(/[^a-zA-Z0-9_-]/g, "_");
31924
- return sanitized || fallback;
31925
- };
31926
- const getFallbackImageNameFromDataUri = (src = "", fallback = "image") => {
31927
- if (!src || typeof src !== "string") return fallback;
31928
- const [prefix2] = src.split(";");
31929
- const [, maybeType] = prefix2.split("/");
31930
- const extension = maybeType?.toLowerCase();
31931
- return extension ? `${fallback}.${extension}` : fallback;
31932
- };
31933
31943
  const TranslatorTypes = Object.freeze({
31934
31944
  NODE: "node",
31935
31945
  ATTRIBUTE: "attribute"
@@ -32050,37 +32060,37 @@ Please report this to https://github.com/markedjs/marked.`, e) {
32050
32060
  };
32051
32061
  __publicField$2(_NodeTranslator, "translatorTypes", TranslatorTypes);
32052
32062
  let NodeTranslator = _NodeTranslator;
32053
- const encode$j = (attributes) => {
32063
+ const encode$T = (attributes) => {
32054
32064
  return attributes["w:type"];
32055
32065
  };
32056
- const decode$j = (attrs) => {
32066
+ const decode$K = (attrs) => {
32057
32067
  const { lineBreakType } = attrs;
32058
32068
  return lineBreakType;
32059
32069
  };
32060
- const attrConfig$b = Object.freeze({
32070
+ const attrConfig$z = Object.freeze({
32061
32071
  xmlName: "w:type",
32062
32072
  sdName: "lineBreakType",
32063
- encode: encode$j,
32064
- decode: decode$j
32073
+ encode: encode$T,
32074
+ decode: decode$K
32065
32075
  });
32066
- const encode$i = (attributes) => {
32076
+ const encode$S = (attributes) => {
32067
32077
  const xmlAttrValue = attributes["w:clear"];
32068
32078
  return xmlAttrValue;
32069
32079
  };
32070
- const decode$i = (attrs) => {
32080
+ const decode$J = (attrs) => {
32071
32081
  const { clear } = attrs;
32072
32082
  return clear;
32073
32083
  };
32074
- const attrConfig$a = Object.freeze({
32084
+ const attrConfig$y = Object.freeze({
32075
32085
  xmlName: "w:clear",
32076
32086
  sdName: "clear",
32077
- encode: encode$i,
32078
- decode: decode$i
32087
+ encode: encode$S,
32088
+ decode: decode$J
32079
32089
  });
32080
- const validXmlAttributes$6 = [attrConfig$b, attrConfig$a];
32081
- const XML_NODE_NAME$7 = "w:br";
32090
+ const validXmlAttributes$h = [attrConfig$z, attrConfig$y];
32091
+ const XML_NODE_NAME$j = "w:br";
32082
32092
  const SD_NODE_NAME$6 = "lineBreak";
32083
- const encode$h = (_2, encodedAttrs) => {
32093
+ const encode$R = (_2, encodedAttrs) => {
32084
32094
  const isPageBreak = encodedAttrs?.lineBreakType === "page";
32085
32095
  const translated = {
32086
32096
  type: isPageBreak ? "hardBreak" : "lineBreak"
@@ -32090,7 +32100,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
32090
32100
  }
32091
32101
  return translated;
32092
32102
  };
32093
- const decode$h = (params2, decodedAttrs) => {
32103
+ const decode$I = (params2, decodedAttrs) => {
32094
32104
  const { node } = params2;
32095
32105
  if (!node) return;
32096
32106
  const wBreak = { name: "w:br" };
@@ -32107,63 +32117,120 @@ Please report this to https://github.com/markedjs/marked.`, e) {
32107
32117
  };
32108
32118
  return translated;
32109
32119
  };
32110
- const config$7 = {
32111
- xmlName: XML_NODE_NAME$7,
32120
+ const config$j = {
32121
+ xmlName: XML_NODE_NAME$j,
32112
32122
  sdNodeOrKeyName: SD_NODE_NAME$6,
32113
32123
  type: NodeTranslator.translatorTypes.NODE,
32114
- encode: encode$h,
32115
- decode: decode$h,
32116
- attributes: validXmlAttributes$6
32124
+ encode: encode$R,
32125
+ decode: decode$I,
32126
+ attributes: validXmlAttributes$h
32127
+ };
32128
+ const translator$v = NodeTranslator.from(config$j);
32129
+ const encode$Q = (attributes) => attributes?.["w:val"];
32130
+ const decode$H = (attrs) => attrs?.highlight;
32131
+ const attrConfig$x = Object.freeze({
32132
+ xmlName: "w:val",
32133
+ sdName: "highlight",
32134
+ encode: encode$Q,
32135
+ decode: decode$H
32136
+ });
32137
+ const validXmlAttributes$g = [attrConfig$x];
32138
+ const XML_NODE_NAME$i = "w:highlight";
32139
+ const SD_ATTR_KEY$b = "highlight";
32140
+ const encode$P = (params2, encodedAttrs = {}) => {
32141
+ const { nodes } = params2;
32142
+ const node = nodes?.[0];
32143
+ const value = encodedAttrs.highlight ?? node?.attributes?.["w:val"];
32144
+ return {
32145
+ type: "attr",
32146
+ xmlName: XML_NODE_NAME$i,
32147
+ sdNodeOrKeyName: SD_ATTR_KEY$b,
32148
+ attributes: { "w:val": value ?? null }
32149
+ };
32150
+ };
32151
+ const decode$G = (params2) => {
32152
+ const attrs = params2?.node?.attrs || {};
32153
+ const highlightValue = attrs.highlight ?? attrs.color ?? null;
32154
+ if (!highlightValue) return void 0;
32155
+ const normalizedValue = String(highlightValue).trim().toLowerCase();
32156
+ if (!normalizedValue || normalizedValue === "transparent" || normalizedValue === "none") {
32157
+ return void 0;
32158
+ }
32159
+ const keyword = getDocxHighlightKeywordFromHex(highlightValue);
32160
+ if (keyword) {
32161
+ return {
32162
+ name: XML_NODE_NAME$i,
32163
+ attributes: { "w:val": keyword }
32164
+ };
32165
+ }
32166
+ const fill = normalizeHexColor(highlightValue);
32167
+ if (!fill) return void 0;
32168
+ return {
32169
+ name: "w:shd",
32170
+ attributes: {
32171
+ "w:color": "auto",
32172
+ "w:val": "clear",
32173
+ "w:fill": fill
32174
+ }
32175
+ };
32117
32176
  };
32118
- const translator$j = NodeTranslator.from(config$7);
32119
- const encode$g = (attributes) => {
32177
+ const config$i = {
32178
+ xmlName: XML_NODE_NAME$i,
32179
+ sdNodeOrKeyName: SD_ATTR_KEY$b,
32180
+ type: NodeTranslator.translatorTypes.ATTRIBUTE,
32181
+ encode: encode$P,
32182
+ decode: decode$G,
32183
+ attributes: validXmlAttributes$g
32184
+ };
32185
+ const translator$u = NodeTranslator.from(config$i);
32186
+ const encode$O = (attributes) => {
32120
32187
  return attributes["w:val"];
32121
32188
  };
32122
- const decode$g = (attrs) => {
32189
+ const decode$F = (attrs) => {
32123
32190
  const { tabSize } = attrs || {};
32124
32191
  return tabSize;
32125
32192
  };
32126
- const attrConfig$9 = Object.freeze({
32193
+ const attrConfig$w = Object.freeze({
32127
32194
  xmlName: "w:val",
32128
32195
  sdName: "tabSize",
32129
- encode: encode$g,
32130
- decode: decode$g
32196
+ encode: encode$O,
32197
+ decode: decode$F
32131
32198
  });
32132
- const encode$f = (attributes) => {
32199
+ const encode$N = (attributes) => {
32133
32200
  return attributes["w:leader"];
32134
32201
  };
32135
- const decode$f = (attrs) => {
32202
+ const decode$E = (attrs) => {
32136
32203
  const { leader } = attrs || {};
32137
32204
  return leader;
32138
32205
  };
32139
- const attrConfig$8 = Object.freeze({
32206
+ const attrConfig$v = Object.freeze({
32140
32207
  xmlName: "w:leader",
32141
32208
  sdName: "leader",
32142
- encode: encode$f,
32143
- decode: decode$f
32209
+ encode: encode$N,
32210
+ decode: decode$E
32144
32211
  });
32145
- const encode$e = (attributes) => {
32212
+ const encode$M = (attributes) => {
32146
32213
  return attributes["w:pos"];
32147
32214
  };
32148
- const decode$e = (attrs) => {
32215
+ const decode$D = (attrs) => {
32149
32216
  const { pos } = attrs || {};
32150
32217
  return pos;
32151
32218
  };
32152
- const attrConfig$7 = Object.freeze({
32219
+ const attrConfig$u = Object.freeze({
32153
32220
  xmlName: "w:pos",
32154
32221
  sdName: "pos",
32155
- encode: encode$e,
32156
- decode: decode$e
32222
+ encode: encode$M,
32223
+ decode: decode$D
32157
32224
  });
32158
- const validXmlAttributes$5 = [attrConfig$9, attrConfig$7, attrConfig$8];
32159
- const XML_NODE_NAME$6 = "w:tab";
32225
+ const validXmlAttributes$f = [attrConfig$w, attrConfig$u, attrConfig$v];
32226
+ const XML_NODE_NAME$h = "w:tab";
32160
32227
  const SD_NODE_NAME$5 = "tab";
32161
- const encode$d = (_2, encodedAttrs = {}) => {
32228
+ const encode$L = (_2, encodedAttrs = {}) => {
32162
32229
  const translated = { type: "tab" };
32163
32230
  if (encodedAttrs) translated.attrs = { ...encodedAttrs };
32164
32231
  return translated;
32165
32232
  };
32166
- const decode$d = (params2, decodedAttrs = {}) => {
32233
+ const decode$C = (params2, decodedAttrs = {}) => {
32167
32234
  const { node } = params2 || {};
32168
32235
  if (!node) return;
32169
32236
  const wTab = { name: "w:tab" };
@@ -32179,15 +32246,15 @@ Please report this to https://github.com/markedjs/marked.`, e) {
32179
32246
  }
32180
32247
  return translated;
32181
32248
  };
32182
- const config$6 = {
32183
- xmlName: XML_NODE_NAME$6,
32249
+ const config$h = {
32250
+ xmlName: XML_NODE_NAME$h,
32184
32251
  sdNodeOrKeyName: SD_NODE_NAME$5,
32185
32252
  type: NodeTranslator.translatorTypes.NODE,
32186
- encode: encode$d,
32187
- decode: decode$d,
32188
- attributes: validXmlAttributes$5
32253
+ encode: encode$L,
32254
+ decode: decode$C,
32255
+ attributes: validXmlAttributes$f
32189
32256
  };
32190
- const translator$i = NodeTranslator.from(config$6);
32257
+ const translator$t = NodeTranslator.from(config$h);
32191
32258
  const mergeTextNodes = (nodes) => {
32192
32259
  if (!nodes || !Array.isArray(nodes)) {
32193
32260
  return nodes;
@@ -32362,17 +32429,21 @@ Please report this to https://github.com/markedjs/marked.`, e) {
32362
32429
  function getFontFamilyValue(attributes, docx) {
32363
32430
  const ascii = attributes["w:ascii"];
32364
32431
  const themeAscii = attributes["w:asciiTheme"];
32365
- if (!docx || !themeAscii) return ascii;
32366
- const theme = docx["word/theme/theme1.xml"];
32367
- if (!theme) return ascii;
32368
- const { elements: topElements } = theme;
32369
- const { elements } = topElements[0];
32370
- const themeElements = elements.find((el) => el.name === "a:themeElements");
32371
- const fontScheme = themeElements.elements.find((el) => el.name === "a:fontScheme");
32372
- const majorFont = fontScheme.elements.find((el) => el.name === "a:majorFont");
32373
- const latin = majorFont.elements.find((el) => el.name === "a:latin");
32374
- const typeface = latin.attributes["typeface"];
32375
- return typeface;
32432
+ let resolved = ascii;
32433
+ if (docx && themeAscii) {
32434
+ const theme = docx["word/theme/theme1.xml"];
32435
+ if (theme?.elements?.length) {
32436
+ const { elements: topElements } = theme;
32437
+ const { elements } = topElements[0] || {};
32438
+ const themeElements = elements?.find((el) => el.name === "a:themeElements");
32439
+ const fontScheme = themeElements?.elements?.find((el) => el.name === "a:fontScheme");
32440
+ const majorFont = fontScheme?.elements?.find((el) => el.name === "a:majorFont");
32441
+ const latin = majorFont?.elements?.find((el) => el.name === "a:latin");
32442
+ resolved = latin?.attributes?.typeface || resolved;
32443
+ }
32444
+ }
32445
+ if (!resolved) return null;
32446
+ return SuperConverter.toCssFontFamily(resolved, docx);
32376
32447
  }
32377
32448
  function getIndentValue(attributes) {
32378
32449
  let value = attributes["w:left"];
@@ -32393,7 +32464,11 @@ Please report this to https://github.com/markedjs/marked.`, e) {
32393
32464
  return getHexColorFromDocxSystem(attributes?.["w:val"]) || null;
32394
32465
  }
32395
32466
  function getStrikeValue(attributes) {
32396
- return attributes?.["w:val"] === "1" ? attributes["w:val"] : null;
32467
+ const raw = attributes?.["w:val"];
32468
+ if (raw === void 0 || raw === null) return "1";
32469
+ const value = String(raw).trim().toLowerCase();
32470
+ if (value === "1" || value === "true" || value === "on") return "1";
32471
+ return null;
32397
32472
  }
32398
32473
  const parseParagraphBorders = (pBdr) => {
32399
32474
  if (!pBdr || !pBdr.elements) return {};
@@ -32757,102 +32832,102 @@ Please report this to https://github.com/markedjs/marked.`, e) {
32757
32832
  }
32758
32833
  return schemaNode;
32759
32834
  };
32760
- const encode$c = (attributes) => {
32835
+ const encode$K = (attributes) => {
32761
32836
  return attributes["w:rsidDel"];
32762
32837
  };
32763
- const decode$c = (attrs) => {
32838
+ const decode$B = (attrs) => {
32764
32839
  return attrs.rsidDel;
32765
32840
  };
32766
- const attrConfig$6 = Object.freeze({
32841
+ const attrConfig$t = Object.freeze({
32767
32842
  xmlName: "w:rsidDel",
32768
32843
  sdName: "rsidDel",
32769
- encode: encode$c,
32770
- decode: decode$c
32844
+ encode: encode$K,
32845
+ decode: decode$B
32771
32846
  });
32772
- const encode$b = (attributes) => {
32847
+ const encode$J = (attributes) => {
32773
32848
  return attributes["w:rsidP"];
32774
32849
  };
32775
- const decode$b = (attrs) => {
32850
+ const decode$A = (attrs) => {
32776
32851
  return attrs.rsidP;
32777
32852
  };
32778
- const attrConfig$5 = Object.freeze({
32853
+ const attrConfig$s = Object.freeze({
32779
32854
  xmlName: "w:rsidP",
32780
32855
  sdName: "rsidP",
32781
- encode: encode$b,
32782
- decode: decode$b
32856
+ encode: encode$J,
32857
+ decode: decode$A
32783
32858
  });
32784
- const encode$a = (attributes) => {
32859
+ const encode$I = (attributes) => {
32785
32860
  return attributes["w:rsidR"];
32786
32861
  };
32787
- const decode$a = (attrs) => {
32862
+ const decode$z = (attrs) => {
32788
32863
  return attrs.rsidR;
32789
32864
  };
32790
- const attrConfig$4 = Object.freeze({
32865
+ const attrConfig$r = Object.freeze({
32791
32866
  xmlName: "w:rsidR",
32792
32867
  sdName: "rsidR",
32793
- encode: encode$a,
32794
- decode: decode$a
32868
+ encode: encode$I,
32869
+ decode: decode$z
32795
32870
  });
32796
- const encode$9 = (attributes) => {
32871
+ const encode$H = (attributes) => {
32797
32872
  return attributes["w:rsidRPr"];
32798
32873
  };
32799
- const decode$9 = (attrs) => {
32874
+ const decode$y = (attrs) => {
32800
32875
  return attrs.rsidRPr;
32801
32876
  };
32802
- const attrConfig$3 = Object.freeze({
32877
+ const attrConfig$q = Object.freeze({
32803
32878
  xmlName: "w:rsidRPr",
32804
32879
  sdName: "rsidRPr",
32805
- encode: encode$9,
32806
- decode: decode$9
32880
+ encode: encode$H,
32881
+ decode: decode$y
32807
32882
  });
32808
- const encode$8 = (attributes) => {
32883
+ const encode$G = (attributes) => {
32809
32884
  return attributes["w:rsidRDefault"];
32810
32885
  };
32811
- const decode$8 = (attrs) => {
32886
+ const decode$x = (attrs) => {
32812
32887
  return attrs.rsidRDefault;
32813
32888
  };
32814
- const attrConfig$2 = Object.freeze({
32889
+ const attrConfig$p = Object.freeze({
32815
32890
  xmlName: "w:rsidRDefault",
32816
32891
  sdName: "rsidRDefault",
32817
- encode: encode$8,
32818
- decode: decode$8
32892
+ encode: encode$G,
32893
+ decode: decode$x
32819
32894
  });
32820
- const encode$7 = (attributes) => {
32895
+ const encode$F = (attributes) => {
32821
32896
  return attributes["w14:paraId"];
32822
32897
  };
32823
- const decode$7 = (attrs) => {
32898
+ const decode$w = (attrs) => {
32824
32899
  return attrs.paraId;
32825
32900
  };
32826
- const attrConfig$1 = Object.freeze({
32901
+ const attrConfig$o = Object.freeze({
32827
32902
  xmlName: "w14:paraId",
32828
32903
  sdName: "paraId",
32829
- encode: encode$7,
32830
- decode: decode$7
32904
+ encode: encode$F,
32905
+ decode: decode$w
32831
32906
  });
32832
- const encode$6 = (attributes) => {
32907
+ const encode$E = (attributes) => {
32833
32908
  return attributes["w14:textId"];
32834
32909
  };
32835
- const decode$6 = (attrs) => {
32910
+ const decode$v = (attrs) => {
32836
32911
  return attrs.textId;
32837
32912
  };
32838
- const attrConfig = Object.freeze({
32913
+ const attrConfig$n = Object.freeze({
32839
32914
  xmlName: "w14:textId",
32840
32915
  sdName: "textId",
32841
- encode: encode$6,
32842
- decode: decode$6
32916
+ encode: encode$E,
32917
+ decode: decode$v
32843
32918
  });
32844
- const validXmlAttributes$4 = [
32845
- attrConfig$1,
32846
- attrConfig,
32847
- attrConfig$4,
32848
- attrConfig$2,
32849
- attrConfig$5,
32850
- attrConfig$3,
32851
- attrConfig$6
32919
+ const validXmlAttributes$e = [
32920
+ attrConfig$o,
32921
+ attrConfig$n,
32922
+ attrConfig$r,
32923
+ attrConfig$p,
32924
+ attrConfig$s,
32925
+ attrConfig$q,
32926
+ attrConfig$t
32852
32927
  ];
32853
- const XML_NODE_NAME$5 = "w:p";
32928
+ const XML_NODE_NAME$g = "w:p";
32854
32929
  const SD_NODE_NAME$4 = "paragraph";
32855
- const encode$5 = (params2, encodedAttrs = {}) => {
32930
+ const encode$D = (params2, encodedAttrs = {}) => {
32856
32931
  const node = handleParagraphNode$1(params2);
32857
32932
  if (!node) return void 0;
32858
32933
  if (encodedAttrs && Object.keys(encodedAttrs).length) {
@@ -32860,7 +32935,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
32860
32935
  }
32861
32936
  return node;
32862
32937
  };
32863
- const decode$5 = (params2, decodedAttrs = {}) => {
32938
+ const decode$u = (params2, decodedAttrs = {}) => {
32864
32939
  const translated = translateParagraphNode(params2);
32865
32940
  if (!translated) return void 0;
32866
32941
  if (decodedAttrs && Object.keys(decodedAttrs).length) {
@@ -32868,15 +32943,15 @@ Please report this to https://github.com/markedjs/marked.`, e) {
32868
32943
  }
32869
32944
  return translated;
32870
32945
  };
32871
- const config$5 = {
32872
- xmlName: XML_NODE_NAME$5,
32946
+ const config$g = {
32947
+ xmlName: XML_NODE_NAME$g,
32873
32948
  sdNodeOrKeyName: SD_NODE_NAME$4,
32874
32949
  type: NodeTranslator.translatorTypes.NODE,
32875
- encode: encode$5,
32876
- decode: decode$5,
32877
- attributes: validXmlAttributes$4
32950
+ encode: encode$D,
32951
+ decode: decode$u,
32952
+ attributes: validXmlAttributes$e
32878
32953
  };
32879
- const translator$h = NodeTranslator.from(config$5);
32954
+ const translator$s = NodeTranslator.from(config$g);
32880
32955
  const generateV2HandlerEntity = (handlerName, translator2) => ({
32881
32956
  handlerName,
32882
32957
  handler: (params2) => {
@@ -32983,13 +33058,13 @@ Please report this to https://github.com/markedjs/marked.`, e) {
32983
33058
  const intValue = parseInteger(value);
32984
33059
  return intValue != void 0 ? String(intValue) : void 0;
32985
33060
  };
32986
- const translator$g = NodeTranslator.from({
33061
+ const translator$r = NodeTranslator.from({
32987
33062
  xmlName: "w:cantSplit",
32988
33063
  sdNodeOrKeyName: "cantSplit",
32989
33064
  encode: ({ nodes }) => ["1", "true"].includes(nodes[0].attributes?.["w:val"] ?? "1"),
32990
33065
  decode: ({ node }) => node.attrs?.cantSplit ? {} : void 0
32991
33066
  });
32992
- const translator$f = NodeTranslator.from({
33067
+ const translator$q = NodeTranslator.from({
32993
33068
  xmlName: "w:cnfStyle",
32994
33069
  sdNodeOrKeyName: "cnfStyle",
32995
33070
  attributes: [
@@ -33022,8 +33097,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
33022
33097
  return Object.keys(cnfStyleAttrs).length > 0 ? cnfStyleAttrs : void 0;
33023
33098
  }
33024
33099
  });
33025
- const translator$e = NodeTranslator.from(createSingleAttrPropertyHandler("w:divId"));
33026
- const translator$d = NodeTranslator.from(
33100
+ const translator$p = NodeTranslator.from(createSingleAttrPropertyHandler("w:divId"));
33101
+ const translator$o = NodeTranslator.from(
33027
33102
  createSingleAttrPropertyHandler(
33028
33103
  "w:gridAfter",
33029
33104
  null,
@@ -33032,7 +33107,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
33032
33107
  (v2) => integerToString(v2)
33033
33108
  )
33034
33109
  );
33035
- const translator$c = NodeTranslator.from(
33110
+ const translator$n = NodeTranslator.from(
33036
33111
  createSingleAttrPropertyHandler(
33037
33112
  "w:gridBefore",
33038
33113
  null,
@@ -33041,21 +33116,21 @@ Please report this to https://github.com/markedjs/marked.`, e) {
33041
33116
  (v2) => integerToString(v2)
33042
33117
  )
33043
33118
  );
33044
- const translator$b = NodeTranslator.from({
33119
+ const translator$m = NodeTranslator.from({
33045
33120
  xmlName: "w:hidden",
33046
33121
  sdNodeOrKeyName: "hidden",
33047
33122
  encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
33048
33123
  decode: ({ node }) => node.attrs.hidden ? {} : void 0
33049
33124
  });
33050
- const translator$a = NodeTranslator.from(createSingleAttrPropertyHandler("w:jc"));
33051
- const translator$9 = NodeTranslator.from(createMeasurementPropertyHandler("w:tblCellSpacing", "cellSpacing"));
33052
- const translator$8 = NodeTranslator.from({
33125
+ const translator$l = NodeTranslator.from(createSingleAttrPropertyHandler("w:jc"));
33126
+ const translator$k = NodeTranslator.from(createMeasurementPropertyHandler("w:tblCellSpacing", "cellSpacing"));
33127
+ const translator$j = NodeTranslator.from({
33053
33128
  xmlName: "w:tblHeader",
33054
33129
  sdNodeOrKeyName: "repeatHeader",
33055
33130
  encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
33056
33131
  decode: ({ node }) => node.attrs.repeatHeader ? {} : void 0
33057
33132
  });
33058
- const translator$7 = NodeTranslator.from({
33133
+ const translator$i = NodeTranslator.from({
33059
33134
  xmlName: "w:trHeight",
33060
33135
  sdNodeOrKeyName: "rowHeight",
33061
33136
  encode: ({ nodes }) => {
@@ -33082,11 +33157,11 @@ Please report this to https://github.com/markedjs/marked.`, e) {
33082
33157
  return Object.keys(heightAttrs).length > 0 ? heightAttrs : void 0;
33083
33158
  }
33084
33159
  });
33085
- const translator$6 = NodeTranslator.from(createMeasurementPropertyHandler("w:wAfter"));
33086
- const translator$5 = NodeTranslator.from(createMeasurementPropertyHandler("w:wBefore"));
33087
- const XML_NODE_NAME$4 = "w:trPr";
33088
- const SD_ATTR_KEY = "tableRowProperties";
33089
- const encode$4 = (params2) => {
33160
+ const translator$h = NodeTranslator.from(createMeasurementPropertyHandler("w:wAfter"));
33161
+ const translator$g = NodeTranslator.from(createMeasurementPropertyHandler("w:wBefore"));
33162
+ const XML_NODE_NAME$f = "w:trPr";
33163
+ const SD_ATTR_KEY$a = "tableRowProperties";
33164
+ const encode$C = (params2) => {
33090
33165
  const { nodes } = params2;
33091
33166
  const node = nodes[0];
33092
33167
  let attributes = {
@@ -33100,12 +33175,12 @@ Please report this to https://github.com/markedjs/marked.`, e) {
33100
33175
  };
33101
33176
  return {
33102
33177
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
33103
- xmlName: XML_NODE_NAME$4,
33104
- sdNodeOrKeyName: SD_ATTR_KEY,
33178
+ xmlName: XML_NODE_NAME$f,
33179
+ sdNodeOrKeyName: SD_ATTR_KEY$a,
33105
33180
  attributes
33106
33181
  };
33107
33182
  };
33108
- const decode$4 = (params2) => {
33183
+ const decode$t = (params2) => {
33109
33184
  const { tableRowProperties = {} } = params2.node.attrs || {};
33110
33185
  const elements = decodeProperties(propertyTranslatorsBySdName, tableRowProperties);
33111
33186
  const newNode = {
@@ -33117,18 +33192,18 @@ Please report this to https://github.com/markedjs/marked.`, e) {
33117
33192
  return newNode;
33118
33193
  };
33119
33194
  const propertyTranslators = [
33120
- translator$g,
33121
- translator$f,
33122
- translator$e,
33123
- translator$d,
33124
- translator$c,
33125
- translator$b,
33126
- translator$a,
33127
- translator$9,
33128
- translator$8,
33129
- translator$7,
33130
- translator$6,
33131
- translator$5
33195
+ translator$r,
33196
+ translator$q,
33197
+ translator$p,
33198
+ translator$o,
33199
+ translator$n,
33200
+ translator$m,
33201
+ translator$l,
33202
+ translator$k,
33203
+ translator$j,
33204
+ translator$i,
33205
+ translator$h,
33206
+ translator$g
33132
33207
  ];
33133
33208
  const propertyTranslatorsByXmlName = {};
33134
33209
  propertyTranslators.forEach((translator2) => {
@@ -33138,25 +33213,25 @@ Please report this to https://github.com/markedjs/marked.`, e) {
33138
33213
  propertyTranslators.forEach((translator2) => {
33139
33214
  propertyTranslatorsBySdName[translator2.sdNodeOrKeyName] = translator2;
33140
33215
  });
33141
- const config$4 = {
33142
- xmlName: XML_NODE_NAME$4,
33143
- sdNodeOrKeyName: SD_ATTR_KEY,
33216
+ const config$f = {
33217
+ xmlName: XML_NODE_NAME$f,
33218
+ sdNodeOrKeyName: SD_ATTR_KEY$a,
33144
33219
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
33145
- encode: encode$4,
33146
- decode: decode$4
33220
+ encode: encode$C,
33221
+ decode: decode$t
33147
33222
  };
33148
- const translator$4 = NodeTranslator.from(config$4);
33149
- const XML_NODE_NAME$3 = "w:tr";
33223
+ const translator$f = NodeTranslator.from(config$f);
33224
+ const XML_NODE_NAME$e = "w:tr";
33150
33225
  const SD_NODE_NAME$3 = "tableRow";
33151
- const validXmlAttributes$3 = ["w:rsidDel", "w:rsidR", "w:rsidRPr", "w:rsidTr", "w14:paraId", "w14:textId"].map(
33226
+ const validXmlAttributes$d = ["w:rsidDel", "w:rsidR", "w:rsidRPr", "w:rsidTr", "w14:paraId", "w14:textId"].map(
33152
33227
  (xmlName) => createAttributeHandler(xmlName)
33153
33228
  );
33154
- const encode$3 = (params2, encodedAttrs) => {
33229
+ const encode$B = (params2, encodedAttrs) => {
33155
33230
  const { row, table } = params2.extraParams;
33156
33231
  let tableRowProperties = {};
33157
33232
  const tPr = row.elements.find((el) => el.name === "w:trPr");
33158
33233
  if (tPr) {
33159
- ({ attributes: tableRowProperties } = translator$4.encode({
33234
+ ({ attributes: tableRowProperties } = translator$f.encode({
33160
33235
  ...params2,
33161
33236
  nodes: [tPr]
33162
33237
  }));
@@ -33169,7 +33244,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
33169
33244
  let currentColumnIndex = 0;
33170
33245
  const content = cellNodes?.map((n) => {
33171
33246
  let columnWidth = gridColumnWidths?.[currentColumnIndex] || null;
33172
- const result = translator$2.encode({
33247
+ const result = translator$d.encode({
33173
33248
  ...params2,
33174
33249
  extraParams: {
33175
33250
  ...params2.extraParams,
@@ -33200,7 +33275,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
33200
33275
  }) || [];
33201
33276
  return columnWidths;
33202
33277
  };
33203
- const decode$3 = (params2, decodedAttrs) => {
33278
+ const decode$s = (params2, decodedAttrs) => {
33204
33279
  const { node } = params2;
33205
33280
  const elements = translateChildNodes(params2);
33206
33281
  if (node.attrs?.tableRowProperties) {
@@ -33212,7 +33287,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
33212
33287
  }
33213
33288
  }
33214
33289
  tableRowProperties["cantSplit"] = node.attrs["cantSplit"];
33215
- const trPr = translator$4.decode({
33290
+ const trPr = translator$f.decode({
33216
33291
  ...params2,
33217
33292
  node: { ...node, attrs: { ...node.attrs, tableRowProperties } }
33218
33293
  });
@@ -33224,15 +33299,15 @@ Please report this to https://github.com/markedjs/marked.`, e) {
33224
33299
  elements
33225
33300
  };
33226
33301
  };
33227
- const config$3 = {
33228
- xmlName: XML_NODE_NAME$3,
33302
+ const config$e = {
33303
+ xmlName: XML_NODE_NAME$e,
33229
33304
  sdNodeOrKeyName: SD_NODE_NAME$3,
33230
33305
  type: NodeTranslator.translatorTypes.NODE,
33231
- encode: encode$3,
33232
- decode: decode$3,
33233
- attributes: validXmlAttributes$3
33306
+ encode: encode$B,
33307
+ decode: decode$s,
33308
+ attributes: validXmlAttributes$d
33234
33309
  };
33235
- const translator$3 = NodeTranslator.from(config$3);
33310
+ const translator$e = NodeTranslator.from(config$e);
33236
33311
  const handleAllTableNodes = (params2) => {
33237
33312
  const { nodes } = params2;
33238
33313
  if (nodes.length === 0) {
@@ -33296,7 +33371,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
33296
33371
  attrs["borders"] = borderData;
33297
33372
  const content = [];
33298
33373
  rows.forEach((row) => {
33299
- const result = translator$3.encode({
33374
+ const result = translator$e.encode({
33300
33375
  ...params2,
33301
33376
  nodes: [row],
33302
33377
  extraParams: {
@@ -33677,10 +33752,10 @@ Please report this to https://github.com/markedjs/marked.`, e) {
33677
33752
  if (left2 != null) elements.push({ name: "w:left", attributes: { "w:w": pixelsToTwips(left2) } });
33678
33753
  return elements;
33679
33754
  }
33680
- const XML_NODE_NAME$2 = "w:tc";
33755
+ const XML_NODE_NAME$d = "w:tc";
33681
33756
  const SD_NODE_NAME$2 = "tableCell";
33682
- const validXmlAttributes$2 = [];
33683
- function encode$2(params2, encodedAttrs) {
33757
+ const validXmlAttributes$c = [];
33758
+ function encode$A(params2, encodedAttrs) {
33684
33759
  const { node, table, row, rowBorders, styleTag, columnIndex, columnWidth } = params2.extraParams;
33685
33760
  const schemaNode = handleTableCellNode({
33686
33761
  params: params2,
@@ -33697,23 +33772,23 @@ Please report this to https://github.com/markedjs/marked.`, e) {
33697
33772
  }
33698
33773
  return schemaNode;
33699
33774
  }
33700
- function decode$2(params2, decodedAttrs) {
33775
+ function decode$r(params2, decodedAttrs) {
33701
33776
  const translated = translateTableCell(params2);
33702
33777
  if (decodedAttrs && Object.keys(decodedAttrs).length) {
33703
33778
  translated.attributes = { ...translated.attributes || {}, ...decodedAttrs };
33704
33779
  }
33705
33780
  return translated;
33706
33781
  }
33707
- const config$2 = {
33708
- xmlName: XML_NODE_NAME$2,
33782
+ const config$d = {
33783
+ xmlName: XML_NODE_NAME$d,
33709
33784
  sdNodeOrKeyName: SD_NODE_NAME$2,
33710
33785
  type: NodeTranslator.translatorTypes.NODE,
33711
- encode: encode$2,
33712
- decode: decode$2,
33713
- attributes: validXmlAttributes$2
33786
+ encode: encode$A,
33787
+ decode: decode$r,
33788
+ attributes: validXmlAttributes$c
33714
33789
  };
33715
- const translator$2 = NodeTranslator.from(config$2);
33716
- const XML_NODE_NAME$1 = "w:hyperlink";
33790
+ const translator$d = NodeTranslator.from(config$d);
33791
+ const XML_NODE_NAME$c = "w:hyperlink";
33717
33792
  const SD_NODE_NAME$1 = "link";
33718
33793
  const _createAttributeHandler = (xmlName, sdName) => ({
33719
33794
  xmlName,
@@ -33721,7 +33796,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
33721
33796
  encode: (attributes) => attributes[xmlName],
33722
33797
  decode: (attributes) => attributes[sdName]
33723
33798
  });
33724
- const validXmlAttributes$1 = [
33799
+ const validXmlAttributes$b = [
33725
33800
  _createAttributeHandler("w:anchor", "anchor"),
33726
33801
  _createAttributeHandler("w:docLocation", "docLocation"),
33727
33802
  {
@@ -33734,7 +33809,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
33734
33809
  _createAttributeHandler("r:id", "rId"),
33735
33810
  _createAttributeHandler("w:tgtFrame", "target")
33736
33811
  ];
33737
- const encode$1 = (params2, encodedAttrs) => {
33812
+ const encode$z = (params2, encodedAttrs) => {
33738
33813
  const { nodes, docx, nodeListHandler } = params2;
33739
33814
  const node = nodes[0];
33740
33815
  let href = _resolveHref(docx, encodedAttrs);
@@ -33748,7 +33823,16 @@ Please report this to https://github.com/markedjs/marked.`, e) {
33748
33823
  nodes: runNodes,
33749
33824
  path: [...params2.path || [], node]
33750
33825
  });
33751
- return updatedNode;
33826
+ const ensureLinkMark = (child) => {
33827
+ if (!child || typeof child !== "object") return child;
33828
+ const existingMarks = Array.isArray(child.marks) ? child.marks : [];
33829
+ const hasLink = existingMarks.some((mark) => mark?.type === "link");
33830
+ if (hasLink) return child;
33831
+ const linkClone = { type: "link", attrs: { ...linkMark.attrs } };
33832
+ return { ...child, marks: [...existingMarks, linkClone] };
33833
+ };
33834
+ if (!Array.isArray(updatedNode)) return updatedNode;
33835
+ return updatedNode.map((child) => ensureLinkMark(child));
33752
33836
  };
33753
33837
  const _resolveHref = (docx, encodedAttrs) => {
33754
33838
  const rels = docx["word/_rels/document.xml.rels"];
@@ -33765,7 +33849,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
33765
33849
  }
33766
33850
  return href;
33767
33851
  };
33768
- function decode$1(params2) {
33852
+ function decode$q(params2) {
33769
33853
  const { node } = params2;
33770
33854
  const linkMark = node.marks.find((m2) => m2.type === "link");
33771
33855
  const linkAttrs = this.decodeAttributes({ ...params2, node: linkMark });
@@ -33809,15 +33893,15 @@ Please report this to https://github.com/markedjs/marked.`, e) {
33809
33893
  });
33810
33894
  return rId;
33811
33895
  }
33812
- const config$1 = {
33813
- xmlName: XML_NODE_NAME$1,
33896
+ const config$c = {
33897
+ xmlName: XML_NODE_NAME$c,
33814
33898
  sdNodeOrKeyName: SD_NODE_NAME$1,
33815
33899
  type: NodeTranslator.translatorTypes.NODE,
33816
- encode: encode$1,
33817
- decode: decode$1,
33818
- attributes: validXmlAttributes$1
33900
+ encode: encode$z,
33901
+ decode: decode$q,
33902
+ attributes: validXmlAttributes$b
33819
33903
  };
33820
- const translator$1 = NodeTranslator.from(config$1);
33904
+ const translator$c = NodeTranslator.from(config$c);
33821
33905
  function parseTagValueJSON(json) {
33822
33906
  if (typeof json !== "string") {
33823
33907
  return {};
@@ -33828,7 +33912,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
33828
33912
  }
33829
33913
  try {
33830
33914
  return JSON.parse(trimmed);
33831
- } catch (err) {
33915
+ } catch {
33832
33916
  return {};
33833
33917
  }
33834
33918
  }
@@ -35630,10 +35714,10 @@ Please report this to https://github.com/markedjs/marked.`, e) {
35630
35714
  };
35631
35715
  return result;
35632
35716
  }
35633
- const XML_NODE_NAME = "w:sdt";
35717
+ const XML_NODE_NAME$b = "w:sdt";
35634
35718
  const SD_NODE_NAME = ["fieldAnnotation", "structuredContent", "structuredContentBlock", "documentSection"];
35635
- const validXmlAttributes = [];
35636
- function encode$k(params2, encodedAttrs) {
35719
+ const validXmlAttributes$a = [];
35720
+ function encode$y(params2) {
35637
35721
  const nodes = params2.nodes;
35638
35722
  const node = nodes[0];
35639
35723
  const { type: sdtType, handler: handler2 } = sdtNodeTypeStrategy(node);
@@ -35643,7 +35727,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
35643
35727
  const result = handler2(params2);
35644
35728
  return result;
35645
35729
  }
35646
- function decode(params2, decodedAttrs) {
35730
+ function decode$p(params2) {
35647
35731
  const { node } = params2;
35648
35732
  if (!node || !node.type) {
35649
35733
  return null;
@@ -35659,43 +35743,138 @@ Please report this to https://github.com/markedjs/marked.`, e) {
35659
35743
  const result = decoder();
35660
35744
  return result;
35661
35745
  }
35662
- const config = {
35663
- xmlName: XML_NODE_NAME,
35746
+ const config$b = {
35747
+ xmlName: XML_NODE_NAME$b,
35664
35748
  sdNodeOrKeyName: SD_NODE_NAME,
35665
35749
  type: NodeTranslator.translatorTypes.NODE,
35666
- encode: encode$k,
35667
- decode,
35668
- attributes: validXmlAttributes
35750
+ encode: encode$y,
35751
+ decode: decode$p,
35752
+ attributes: validXmlAttributes$a
35753
+ };
35754
+ const translator$b = NodeTranslator.from(config$b);
35755
+ const encode$x = (attributes) => attributes?.["w:val"];
35756
+ const decode$o = (attrs) => attrs?.underline;
35757
+ const attrConfig$m = Object.freeze({
35758
+ xmlName: "w:val",
35759
+ sdName: "underline",
35760
+ encode: encode$x,
35761
+ decode: decode$o
35762
+ });
35763
+ const encode$w = (attributes) => attributes?.["w:color"];
35764
+ const decode$n = (attrs) => attrs?.color;
35765
+ const attrConfig$l = Object.freeze({
35766
+ xmlName: "w:color",
35767
+ sdName: "color",
35768
+ encode: encode$w,
35769
+ decode: decode$n
35770
+ });
35771
+ const encode$v = (attributes) => attributes?.["w:themeColor"];
35772
+ const decode$m = (attrs) => attrs?.themeColor;
35773
+ const attrConfig$k = Object.freeze({
35774
+ xmlName: "w:themeColor",
35775
+ sdName: "themeColor",
35776
+ encode: encode$v,
35777
+ decode: decode$m
35778
+ });
35779
+ const encode$u = (attributes) => attributes?.["w:themeTint"];
35780
+ const decode$l = (attrs) => attrs?.themeTint;
35781
+ const attrConfig$j = Object.freeze({
35782
+ xmlName: "w:themeTint",
35783
+ sdName: "themeTint",
35784
+ encode: encode$u,
35785
+ decode: decode$l
35786
+ });
35787
+ const encode$t = (attributes) => attributes?.["w:themeShade"];
35788
+ const decode$k = (attrs) => attrs?.themeShade;
35789
+ const attrConfig$i = Object.freeze({
35790
+ xmlName: "w:themeShade",
35791
+ sdName: "themeShade",
35792
+ encode: encode$t,
35793
+ decode: decode$k
35794
+ });
35795
+ const validXmlAttributes$9 = [attrConfig$m, attrConfig$l, attrConfig$k, attrConfig$j, attrConfig$i];
35796
+ const XML_NODE_NAME$a = "w:u";
35797
+ const SD_ATTR_KEY$9 = "underline";
35798
+ const encode$s = (params2, encodedAttrs = {}) => {
35799
+ const { nodes } = params2;
35800
+ const node = nodes?.[0];
35801
+ const sourceAttrs = node?.attributes || {};
35802
+ const underlineType = encodedAttrs.underline ?? sourceAttrs["w:val"];
35803
+ const color = encodedAttrs.color ?? sourceAttrs["w:color"];
35804
+ const themeColor = encodedAttrs.themeColor ?? sourceAttrs["w:themeColor"];
35805
+ const themeTint = encodedAttrs.themeTint ?? sourceAttrs["w:themeTint"];
35806
+ const themeShade = encodedAttrs.themeShade ?? sourceAttrs["w:themeShade"];
35807
+ const attributes = { "w:val": underlineType ?? null };
35808
+ if (color !== void 0 && color !== null) attributes["w:color"] = color;
35809
+ if (themeColor !== void 0 && themeColor !== null) attributes["w:themeColor"] = themeColor;
35810
+ if (themeTint !== void 0 && themeTint !== null) attributes["w:themeTint"] = themeTint;
35811
+ if (themeShade !== void 0 && themeShade !== null) attributes["w:themeShade"] = themeShade;
35812
+ return {
35813
+ type: "attr",
35814
+ xmlName: XML_NODE_NAME$a,
35815
+ sdNodeOrKeyName: SD_ATTR_KEY$9,
35816
+ attributes
35817
+ };
35669
35818
  };
35670
- const translator = NodeTranslator.from(config);
35819
+ const decode$j = (params2) => {
35820
+ const attrs = params2?.node?.attrs || {};
35821
+ const underlineType = attrs.underlineType ?? attrs.underline ?? null;
35822
+ const color = attrs.underlineColor ?? attrs.color ?? null;
35823
+ const themeColor = attrs.underlineThemeColor ?? attrs.themeColor ?? null;
35824
+ const themeTint = attrs.underlineThemeTint ?? attrs.themeTint ?? null;
35825
+ const themeShade = attrs.underlineThemeShade ?? attrs.themeShade ?? null;
35826
+ if (!underlineType && !color && !themeColor && !themeTint && !themeShade) return void 0;
35827
+ const attributes = {};
35828
+ if (underlineType) attributes["w:val"] = underlineType;
35829
+ if (color) {
35830
+ const normalized = normalizeHexColor(color);
35831
+ if (normalized) attributes["w:color"] = normalized;
35832
+ }
35833
+ if (themeColor) attributes["w:themeColor"] = themeColor;
35834
+ if (themeTint) attributes["w:themeTint"] = themeTint;
35835
+ if (themeShade) attributes["w:themeShade"] = themeShade;
35836
+ return {
35837
+ name: XML_NODE_NAME$a,
35838
+ attributes
35839
+ };
35840
+ };
35841
+ const config$a = {
35842
+ xmlName: XML_NODE_NAME$a,
35843
+ sdNodeOrKeyName: SD_ATTR_KEY$9,
35844
+ type: NodeTranslator.translatorTypes.ATTRIBUTE,
35845
+ encode: encode$s,
35846
+ decode: decode$j,
35847
+ attributes: validXmlAttributes$9
35848
+ };
35849
+ const translator$a = NodeTranslator.from(config$a);
35671
35850
  function exportSchemaToJson(params2) {
35672
35851
  const { type: type2 } = params2.node || {};
35673
35852
  const router = {
35674
35853
  doc: translateDocumentNode,
35675
35854
  body: translateBodyNode,
35676
35855
  heading: translateHeadingNode,
35677
- paragraph: translator$h,
35856
+ paragraph: translator$s,
35678
35857
  text: translateTextNode,
35679
35858
  bulletList: translateList,
35680
35859
  orderedList: translateList,
35681
- lineBreak: translator$j,
35860
+ lineBreak: translator$v,
35682
35861
  table: translateTable,
35683
- tableRow: translator$3,
35684
- tableCell: translator$2,
35862
+ tableRow: translator$e,
35863
+ tableCell: translator$d,
35685
35864
  bookmarkStart: translateBookmarkStart,
35686
- fieldAnnotation: translator,
35687
- tab: translator$i,
35865
+ fieldAnnotation: translator$b,
35866
+ tab: translator$t,
35688
35867
  image: translateImageNode,
35689
- hardBreak: translator$j,
35868
+ hardBreak: translator$v,
35690
35869
  commentRangeStart: () => translateCommentNode(params2, "Start"),
35691
35870
  commentRangeEnd: () => translateCommentNode(params2, "End"),
35692
35871
  commentReference: () => null,
35693
35872
  shapeContainer: translateShapeContainer,
35694
35873
  shapeTextbox: translateShapeTextbox,
35695
35874
  contentBlock: translateContentBlock,
35696
- structuredContent: translator,
35697
- structuredContentBlock: translator,
35698
- documentSection: translator,
35875
+ structuredContent: translator$b,
35876
+ structuredContentBlock: translator$b,
35877
+ documentSection: translator$b,
35699
35878
  "page-number": translatePageNumberNode,
35700
35879
  "total-page-number": translateTotalPageNumberNode
35701
35880
  };
@@ -36018,7 +36197,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
36018
36197
  const isTrackedNode = node.marks?.some((m2) => trackedMarks.includes(m2.type));
36019
36198
  if (isTrackedNode) return translateTrackedNode(params2);
36020
36199
  const isLinkNode = node.marks?.some((m2) => m2.type === "link");
36021
- if (isLinkNode) return translator$1.decode(params2);
36200
+ if (isLinkNode) return translator$c.decode(params2);
36022
36201
  const { text, marks = [] } = node;
36023
36202
  return getTextNodeForExport(text, marks, params2);
36024
36203
  }
@@ -36503,10 +36682,20 @@ Please report this to https://github.com/markedjs/marked.`, e) {
36503
36682
  delete markElement.attributes;
36504
36683
  markElement.type = "element";
36505
36684
  break;
36506
- case "underline":
36507
- markElement.type = "element";
36508
- markElement.attributes["w:val"] = attrs.underlineType;
36509
- break;
36685
+ case "underline": {
36686
+ const translated = translator$a.decode({
36687
+ node: {
36688
+ attrs: {
36689
+ underlineType: attrs.underlineType ?? attrs.underline ?? null,
36690
+ underlineColor: attrs.underlineColor ?? attrs.color ?? null,
36691
+ underlineThemeColor: attrs.underlineThemeColor ?? attrs.themeColor ?? null,
36692
+ underlineThemeTint: attrs.underlineThemeTint ?? attrs.themeTint ?? null,
36693
+ underlineThemeShade: attrs.underlineThemeShade ?? attrs.themeShade ?? null
36694
+ }
36695
+ }
36696
+ });
36697
+ return translated || {};
36698
+ }
36510
36699
  // Text style cases
36511
36700
  case "fontSize":
36512
36701
  value = attrs.fontSize;
@@ -36548,12 +36737,11 @@ Please report this to https://github.com/markedjs/marked.`, e) {
36548
36737
  case "lineHeight":
36549
36738
  markElement.attributes["w:line"] = linesToTwips(attrs.lineHeight);
36550
36739
  break;
36551
- case "highlight":
36552
- markElement.attributes["w:fill"] = attrs.color?.substring(1);
36553
- markElement.attributes["w:color"] = "auto";
36554
- markElement.attributes["w:val"] = "clear";
36555
- markElement.name = "w:shd";
36556
- break;
36740
+ case "highlight": {
36741
+ const highlightValue = attrs.color ?? attrs.highlight ?? null;
36742
+ const translated = translator$u.decode({ node: { attrs: { highlight: highlightValue } } });
36743
+ return translated || {};
36744
+ }
36557
36745
  }
36558
36746
  return markElement;
36559
36747
  }
@@ -36590,17 +36778,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
36590
36778
  let imageId = attrs.rId;
36591
36779
  const src = attrs.src || attrs.imageSrc;
36592
36780
  const { originalWidth, originalHeight } = getPngDimensions(src);
36593
- let imageName;
36594
- if (params2.node.type === "image") {
36595
- if (src?.startsWith("data:")) {
36596
- imageName = getFallbackImageNameFromDataUri(src);
36597
- } else {
36598
- imageName = src?.split("/").pop();
36599
- }
36600
- } else {
36601
- imageName = attrs.fieldId;
36602
- }
36603
- imageName = sanitizeDocxMediaName(imageName);
36781
+ const imageName = params2.node.type === "image" ? src.split("/").pop() : attrs.fieldId?.replace("-", "_");
36604
36782
  let size2 = attrs.size ? {
36605
36783
  w: pixelsToEmu(attrs.size.width),
36606
36784
  h: pixelsToEmu(attrs.size.height)
@@ -36630,12 +36808,9 @@ Please report this to https://github.com/markedjs/marked.`, e) {
36630
36808
  if (!type2) {
36631
36809
  return prepareTextAnnotation(params2);
36632
36810
  }
36633
- const sanitizedHash = sanitizeDocxMediaName(attrs.hash, generateDocxRandomId(4));
36634
- const fileName = `${imageName}_${sanitizedHash}.${type2}`;
36635
- const relationshipTarget = `media/${fileName}`;
36636
- const packagePath = `word/${relationshipTarget}`;
36637
- imageId = addNewImageRelationship(params2, relationshipTarget);
36638
- params2.media[packagePath] = src;
36811
+ const imageUrl = `media/${imageName}_${attrs.hash}.${type2}`;
36812
+ imageId = addNewImageRelationship(params2, imageUrl);
36813
+ params2.media[`${imageName}_${attrs.hash}.${type2}`] = src;
36639
36814
  }
36640
36815
  let inlineAttrs = attrs.originalPadding || {
36641
36816
  distT: 0,
@@ -37434,82 +37609,912 @@ Please report this to https://github.com/markedjs/marked.`, e) {
37434
37609
  handlerName: "trackChangeNodeHandler",
37435
37610
  handler: handleTrackChangeNode
37436
37611
  };
37437
- const hyperlinkNodeHandlerEntity = generateV2HandlerEntity("hyperlinkNodeHandler", translator$1);
37438
- const handleRunNode = (params2) => {
37439
- const { nodes, nodeListHandler, parentStyleId, docx } = params2;
37440
- if (nodes.length === 0 || nodes[0].name !== "w:r") {
37441
- return { nodes: [], consumed: 0 };
37442
- }
37612
+ const hyperlinkNodeHandlerEntity = generateV2HandlerEntity("hyperlinkNodeHandler", translator$c);
37613
+ const encode$r = (attributes) => {
37614
+ const raw = attributes?.["w:val"];
37615
+ if (raw === void 0 || raw === null) return void 0;
37616
+ if (typeof raw === "boolean") return raw;
37617
+ if (typeof raw === "number") return raw !== 0;
37618
+ const val = String(raw).trim().toLowerCase();
37619
+ if (val === "0" || val === "false" || val === "off") return false;
37620
+ if (val === "1" || val === "true" || val === "on") return true;
37621
+ return void 0;
37622
+ };
37623
+ const decode$i = (runProps) => {
37624
+ if (runProps?.bold === false) return "0";
37625
+ return void 0;
37626
+ };
37627
+ const attrConfig$h = Object.freeze({
37628
+ xmlName: "w:val",
37629
+ sdName: "bold",
37630
+ encode: encode$r,
37631
+ decode: decode$i
37632
+ });
37633
+ const validXmlAttributes$8 = [attrConfig$h];
37634
+ const XML_NODE_NAME$9 = "w:b";
37635
+ const SD_ATTR_KEY$8 = "bold";
37636
+ const encode$q = (params2, encodedAttrs = {}) => {
37637
+ const { nodes } = params2;
37443
37638
  const node = nodes[0];
37444
- const childParams = { ...params2, nodes: node.elements, path: [...params2.path || [], node] };
37445
- let processedRun = nodeListHandler.handler(childParams)?.filter((n) => n) || [];
37446
- const hasRunProperties = node.elements?.some((el) => el.name === "w:rPr");
37447
- const defaultNodeStyles = getMarksFromStyles(docx, parentStyleId);
37448
- if (hasRunProperties) {
37449
- const { marks = [] } = parseProperties(node);
37450
- let runStyleAttributes = [];
37451
- const runStyleElement = node.elements?.find((el) => el.name === "w:rPr")?.elements?.find((el) => el.name === "w:rStyle");
37452
- let runStyleId;
37453
- if (runStyleElement && runStyleElement.attributes?.["w:val"] && docx) {
37454
- runStyleId = runStyleElement.attributes["w:val"];
37455
- const runStyleDefinition = getMarksFromStyles(docx, runStyleId);
37456
- if (runStyleDefinition.marks && runStyleDefinition.marks.length > 0) {
37457
- runStyleAttributes = runStyleDefinition.marks;
37458
- }
37459
- }
37460
- let paragraphStyleAttributes = [];
37461
- if (defaultNodeStyles.marks) {
37462
- paragraphStyleAttributes = defaultNodeStyles.marks.filter((mark) => {
37463
- if (["bold"].includes(mark.type) && marks.find((m2) => m2.type === "bold")?.attrs?.value === "0") {
37464
- return false;
37465
- }
37466
- return true;
37467
- });
37639
+ if (!node) return void 0;
37640
+ const val = encodedAttrs?.[SD_ATTR_KEY$8];
37641
+ let attributes;
37642
+ if (val === false) attributes = { "w:val": "0" };
37643
+ else if (val === true)
37644
+ attributes = {};
37645
+ else attributes = node.attributes || {};
37646
+ return {
37647
+ type: "attr",
37648
+ xmlName: XML_NODE_NAME$9,
37649
+ sdNodeOrKeyName: SD_ATTR_KEY$8,
37650
+ attributes
37651
+ };
37652
+ };
37653
+ const config$9 = {
37654
+ xmlName: XML_NODE_NAME$9,
37655
+ sdNodeOrKeyName: SD_ATTR_KEY$8,
37656
+ type: NodeTranslator.translatorTypes.ATTRIBUTE,
37657
+ encode: encode$q,
37658
+ attributes: validXmlAttributes$8
37659
+ };
37660
+ const translator$9 = NodeTranslator.from(config$9);
37661
+ const encode$p = (attributes) => {
37662
+ const raw = attributes?.["w:val"];
37663
+ if (raw === void 0 || raw === null) return void 0;
37664
+ if (typeof raw === "boolean") return raw;
37665
+ if (typeof raw === "number") return raw !== 0;
37666
+ const val = String(raw).trim().toLowerCase();
37667
+ if (val === "0" || val === "false" || val === "off") return false;
37668
+ if (val === "1" || val === "true" || val === "on") return true;
37669
+ return void 0;
37670
+ };
37671
+ const decode$h = (attrs) => {
37672
+ if (attrs?.italic === false) return "0";
37673
+ return void 0;
37674
+ };
37675
+ const attrConfig$g = Object.freeze({
37676
+ xmlName: "w:val",
37677
+ sdName: "italic",
37678
+ encode: encode$p,
37679
+ decode: decode$h
37680
+ });
37681
+ const validXmlAttributes$7 = [attrConfig$g];
37682
+ const XML_NODE_NAME$8 = "w:i";
37683
+ const SD_ATTR_KEY$7 = "italic";
37684
+ const encode$o = (params2, encodedAttrs = {}) => {
37685
+ const { nodes } = params2;
37686
+ const node = nodes?.[0];
37687
+ if (!node) return void 0;
37688
+ const val = encodedAttrs?.[SD_ATTR_KEY$7];
37689
+ let attributes;
37690
+ if (val === false) attributes = { "w:val": "0" };
37691
+ else if (val === true) attributes = {};
37692
+ else attributes = { ...node.attributes || {} };
37693
+ if (attributes["w:val"] === void 0 && val !== true) attributes["w:val"] = null;
37694
+ else if (val === true && attributes["w:val"] === void 0) delete attributes["w:val"];
37695
+ return {
37696
+ type: "attr",
37697
+ xmlName: XML_NODE_NAME$8,
37698
+ sdNodeOrKeyName: SD_ATTR_KEY$7,
37699
+ attributes
37700
+ };
37701
+ };
37702
+ const config$8 = {
37703
+ xmlName: XML_NODE_NAME$8,
37704
+ sdNodeOrKeyName: SD_ATTR_KEY$7,
37705
+ type: NodeTranslator.translatorTypes.ATTRIBUTE,
37706
+ encode: encode$o,
37707
+ attributes: validXmlAttributes$7
37708
+ };
37709
+ const translator$8 = NodeTranslator.from(config$8);
37710
+ const encode$n = (attributes) => {
37711
+ const raw = attributes?.["w:val"];
37712
+ if (raw === void 0 || raw === null) return void 0;
37713
+ if (typeof raw === "boolean") return raw;
37714
+ if (typeof raw === "number") return raw !== 0;
37715
+ const val = String(raw).trim().toLowerCase();
37716
+ if (val === "0" || val === "false" || val === "off") return false;
37717
+ if (val === "1" || val === "true" || val === "on") return true;
37718
+ return void 0;
37719
+ };
37720
+ const decode$g = (attrs) => {
37721
+ if (attrs?.strike === false) return "0";
37722
+ return void 0;
37723
+ };
37724
+ const attrConfig$f = Object.freeze({
37725
+ xmlName: "w:val",
37726
+ sdName: "strike",
37727
+ encode: encode$n,
37728
+ decode: decode$g
37729
+ });
37730
+ const validXmlAttributes$6 = [attrConfig$f];
37731
+ const XML_NODE_NAME$7 = "w:strike";
37732
+ const SD_ATTR_KEY$6 = "strike";
37733
+ const encode$m = (params2, encodedAttrs = {}) => {
37734
+ const { nodes } = params2;
37735
+ const node = nodes?.[0];
37736
+ if (!node) return void 0;
37737
+ const val = encodedAttrs?.[SD_ATTR_KEY$6];
37738
+ let attributes;
37739
+ if (val === false) attributes = { "w:val": "0" };
37740
+ else if (val === true) attributes = {};
37741
+ else attributes = { ...node.attributes || {} };
37742
+ if (attributes["w:val"] === void 0 && val !== true) attributes["w:val"] = null;
37743
+ else if (val === true && attributes["w:val"] === void 0) delete attributes["w:val"];
37744
+ return {
37745
+ type: "attr",
37746
+ xmlName: XML_NODE_NAME$7,
37747
+ sdNodeOrKeyName: SD_ATTR_KEY$6,
37748
+ attributes
37749
+ };
37750
+ };
37751
+ const config$7 = {
37752
+ xmlName: XML_NODE_NAME$7,
37753
+ sdNodeOrKeyName: SD_ATTR_KEY$6,
37754
+ type: NodeTranslator.translatorTypes.ATTRIBUTE,
37755
+ encode: encode$m,
37756
+ attributes: validXmlAttributes$6
37757
+ };
37758
+ const translator$7 = NodeTranslator.from(config$7);
37759
+ const encode$l = (attributes) => attributes?.["w:val"];
37760
+ const decode$f = (attrs) => attrs?.color;
37761
+ const attrConfig$e = Object.freeze({
37762
+ xmlName: "w:val",
37763
+ sdName: "color",
37764
+ encode: encode$l,
37765
+ decode: decode$f
37766
+ });
37767
+ const encode$k = (attributes) => attributes?.["w:themeColor"];
37768
+ const decode$e = (attrs) => attrs?.themeColor;
37769
+ const attrConfig$d = Object.freeze({
37770
+ xmlName: "w:themeColor",
37771
+ sdName: "themeColor",
37772
+ encode: encode$k,
37773
+ decode: decode$e
37774
+ });
37775
+ const encode$j = (attributes) => attributes?.["w:themeTint"];
37776
+ const decode$d = (attrs) => attrs?.themeTint;
37777
+ const attrConfig$c = Object.freeze({
37778
+ xmlName: "w:themeTint",
37779
+ sdName: "themeTint",
37780
+ encode: encode$j,
37781
+ decode: decode$d
37782
+ });
37783
+ const encode$i = (attributes) => attributes?.["w:themeShade"];
37784
+ const decode$c = (attrs) => attrs?.themeShade;
37785
+ const attrConfig$b = Object.freeze({
37786
+ xmlName: "w:themeShade",
37787
+ sdName: "themeShade",
37788
+ encode: encode$i,
37789
+ decode: decode$c
37790
+ });
37791
+ const validXmlAttributes$5 = [attrConfig$e, attrConfig$d, attrConfig$c, attrConfig$b];
37792
+ const XML_NODE_NAME$6 = "w:color";
37793
+ const SD_ATTR_KEY$5 = "color";
37794
+ const encode$h = (params2, encodedAttrs = {}) => {
37795
+ const { nodes } = params2;
37796
+ const node = nodes?.[0];
37797
+ const sourceAttrs = node?.attributes || {};
37798
+ const value = encodedAttrs.color ?? sourceAttrs["w:val"];
37799
+ const themeColor = encodedAttrs.themeColor ?? sourceAttrs["w:themeColor"];
37800
+ const themeTint = encodedAttrs.themeTint ?? sourceAttrs["w:themeTint"];
37801
+ const themeShade = encodedAttrs.themeShade ?? sourceAttrs["w:themeShade"];
37802
+ const attributes = {};
37803
+ attributes["w:val"] = value ?? null;
37804
+ if (themeColor !== void 0 && themeColor !== null) attributes["w:themeColor"] = themeColor;
37805
+ if (themeTint !== void 0 && themeTint !== null) attributes["w:themeTint"] = themeTint;
37806
+ if (themeShade !== void 0 && themeShade !== null) attributes["w:themeShade"] = themeShade;
37807
+ return {
37808
+ type: "attr",
37809
+ xmlName: XML_NODE_NAME$6,
37810
+ sdNodeOrKeyName: SD_ATTR_KEY$5,
37811
+ attributes
37812
+ };
37813
+ };
37814
+ const config$6 = {
37815
+ xmlName: XML_NODE_NAME$6,
37816
+ sdNodeOrKeyName: SD_ATTR_KEY$5,
37817
+ type: NodeTranslator.translatorTypes.ATTRIBUTE,
37818
+ encode: encode$h,
37819
+ attributes: validXmlAttributes$5
37820
+ };
37821
+ const translator$6 = NodeTranslator.from(config$6);
37822
+ const encode$g = (attributes) => attributes?.["w:eastAsia"];
37823
+ const decode$b = (attrs) => attrs?.eastAsia;
37824
+ const attrConfig$a = Object.freeze({
37825
+ xmlName: "w:eastAsia",
37826
+ sdName: "eastAsia",
37827
+ encode: encode$g,
37828
+ decode: decode$b
37829
+ });
37830
+ const encode$f = (attributes) => attributes?.["w:ascii"];
37831
+ const decode$a = (attrs) => attrs?.ascii;
37832
+ const attrConfig$9 = Object.freeze({
37833
+ xmlName: "w:ascii",
37834
+ sdName: "ascii",
37835
+ encode: encode$f,
37836
+ decode: decode$a
37837
+ });
37838
+ const encode$e = (attributes) => attributes?.["w:hAnsi"];
37839
+ const decode$9 = (attrs) => attrs?.hAnsi;
37840
+ const attrConfig$8 = Object.freeze({
37841
+ xmlName: "w:hAnsi",
37842
+ sdName: "hAnsi",
37843
+ encode: encode$e,
37844
+ decode: decode$9
37845
+ });
37846
+ const encode$d = (attributes) => attributes?.["w:cs"];
37847
+ const decode$8 = (attrs) => attrs?.cs;
37848
+ const attrConfig$7 = Object.freeze({
37849
+ xmlName: "w:cs",
37850
+ sdName: "cs",
37851
+ encode: encode$d,
37852
+ decode: decode$8
37853
+ });
37854
+ const encode$c = (attributes) => attributes?.["w:val"];
37855
+ const decode$7 = (attrs) => attrs?.value;
37856
+ const attrConfig$6 = Object.freeze({
37857
+ xmlName: "w:val",
37858
+ sdName: "value",
37859
+ encode: encode$c,
37860
+ decode: decode$7
37861
+ });
37862
+ const validXmlAttributes$4 = [attrConfig$a, attrConfig$9, attrConfig$8, attrConfig$7, attrConfig$6];
37863
+ const XML_NODE_NAME$5 = "w:rFonts";
37864
+ const SD_ATTR_KEY$4 = "fontFamily";
37865
+ const encode$b = (params2, encodedAttrs = {}) => {
37866
+ const { nodes } = params2;
37867
+ const node = nodes?.[0];
37868
+ const sourceAttrs = node?.attributes || {};
37869
+ const attributes = {};
37870
+ const setAttr = (xmlName, sdName) => {
37871
+ if (encodedAttrs[sdName] !== void 0 && encodedAttrs[sdName] !== null) {
37872
+ attributes[xmlName] = encodedAttrs[sdName];
37873
+ } else if (sourceAttrs[xmlName] !== void 0) {
37874
+ attributes[xmlName] = sourceAttrs[xmlName];
37468
37875
  }
37469
- const combinedMarks = [...paragraphStyleAttributes];
37470
- runStyleAttributes.forEach((runStyle) => {
37471
- const exists2 = combinedMarks.some(
37472
- (mark) => mark.type === runStyle.type && JSON.stringify(mark.attrs || {}) === JSON.stringify(runStyle.attrs || {})
37473
- );
37474
- if (!exists2) {
37475
- combinedMarks.push(runStyle);
37876
+ };
37877
+ setAttr("w:eastAsia", "eastAsia");
37878
+ setAttr("w:ascii", "ascii");
37879
+ setAttr("w:hAnsi", "hAnsi");
37880
+ setAttr("w:cs", "cs");
37881
+ setAttr("w:val", "value");
37882
+ Object.keys(sourceAttrs).forEach((key) => {
37883
+ if (attributes[key] === void 0) attributes[key] = sourceAttrs[key];
37884
+ });
37885
+ if (attributes["w:val"] === void 0 && attributes["w:eastAsia"]) {
37886
+ attributes["w:val"] = attributes["w:eastAsia"];
37887
+ }
37888
+ if (attributes["w:val"] === void 0) delete attributes["w:val"];
37889
+ return {
37890
+ type: "attr",
37891
+ xmlName: XML_NODE_NAME$5,
37892
+ sdNodeOrKeyName: SD_ATTR_KEY$4,
37893
+ attributes
37894
+ };
37895
+ };
37896
+ const config$5 = {
37897
+ xmlName: XML_NODE_NAME$5,
37898
+ sdNodeOrKeyName: SD_ATTR_KEY$4,
37899
+ type: NodeTranslator.translatorTypes.ATTRIBUTE,
37900
+ encode: encode$b,
37901
+ attributes: validXmlAttributes$4
37902
+ };
37903
+ const translator$5 = NodeTranslator.from(config$5);
37904
+ const encode$a = (attributes) => attributes?.["w:val"];
37905
+ const decode$6 = (attrs) => attrs?.styleId;
37906
+ const attrConfig$5 = Object.freeze({
37907
+ xmlName: "w:val",
37908
+ sdName: "styleId",
37909
+ encode: encode$a,
37910
+ decode: decode$6
37911
+ });
37912
+ const validXmlAttributes$3 = [attrConfig$5];
37913
+ const XML_NODE_NAME$4 = "w:rStyle";
37914
+ const SD_ATTR_KEY$3 = "styleId";
37915
+ const encode$9 = (params2, encodedAttrs = {}) => {
37916
+ const { nodes } = params2;
37917
+ const node = nodes?.[0];
37918
+ const value = encodedAttrs.styleId ?? node?.attributes?.["w:val"];
37919
+ return {
37920
+ type: "attr",
37921
+ xmlName: XML_NODE_NAME$4,
37922
+ sdNodeOrKeyName: SD_ATTR_KEY$3,
37923
+ attributes: { "w:val": value ?? null }
37924
+ };
37925
+ };
37926
+ const config$4 = {
37927
+ xmlName: XML_NODE_NAME$4,
37928
+ sdNodeOrKeyName: SD_ATTR_KEY$3,
37929
+ type: NodeTranslator.translatorTypes.ATTRIBUTE,
37930
+ encode: encode$9,
37931
+ attributes: validXmlAttributes$3
37932
+ };
37933
+ const translator$4 = NodeTranslator.from(config$4);
37934
+ const encode$8 = (attributes) => attributes?.["w:val"];
37935
+ const decode$5 = (attrs) => attrs?.fontSize;
37936
+ const attrConfig$4 = Object.freeze({
37937
+ xmlName: "w:val",
37938
+ sdName: "fontSize",
37939
+ encode: encode$8,
37940
+ decode: decode$5
37941
+ });
37942
+ const validXmlAttributes$2 = [attrConfig$4];
37943
+ const XML_NODE_NAME$3 = "w:sz";
37944
+ const SD_ATTR_KEY$2 = "fontSize";
37945
+ const encode$7 = (params2, encodedAttrs = {}) => {
37946
+ const { nodes } = params2;
37947
+ const node = nodes?.[0];
37948
+ const value = encodedAttrs.fontSize ?? node?.attributes?.["w:val"];
37949
+ return {
37950
+ type: "attr",
37951
+ xmlName: XML_NODE_NAME$3,
37952
+ sdNodeOrKeyName: SD_ATTR_KEY$2,
37953
+ attributes: { "w:val": value ?? null }
37954
+ };
37955
+ };
37956
+ const config$3 = {
37957
+ xmlName: XML_NODE_NAME$3,
37958
+ sdNodeOrKeyName: SD_ATTR_KEY$2,
37959
+ type: NodeTranslator.translatorTypes.ATTRIBUTE,
37960
+ encode: encode$7,
37961
+ attributes: validXmlAttributes$2
37962
+ };
37963
+ const translator$3 = NodeTranslator.from(config$3);
37964
+ const encode$6 = (attributes) => attributes?.["w:val"];
37965
+ const decode$4 = (attrs) => attrs?.fontSizeCs;
37966
+ const attrConfig$3 = Object.freeze({
37967
+ xmlName: "w:val",
37968
+ sdName: "fontSizeCs",
37969
+ encode: encode$6,
37970
+ decode: decode$4
37971
+ });
37972
+ const validXmlAttributes$1 = [attrConfig$3];
37973
+ const XML_NODE_NAME$2 = "w:szCs";
37974
+ const SD_ATTR_KEY$1 = "fontSizeCs";
37975
+ const encode$5 = (params2, encodedAttrs = {}) => {
37976
+ const { nodes } = params2;
37977
+ const node = nodes?.[0];
37978
+ const value = encodedAttrs.fontSizeCs ?? node?.attributes?.["w:val"];
37979
+ return {
37980
+ type: "attr",
37981
+ xmlName: XML_NODE_NAME$2,
37982
+ sdNodeOrKeyName: SD_ATTR_KEY$1,
37983
+ attributes: { "w:val": value ?? null }
37984
+ };
37985
+ };
37986
+ const config$2 = {
37987
+ xmlName: XML_NODE_NAME$2,
37988
+ sdNodeOrKeyName: SD_ATTR_KEY$1,
37989
+ type: NodeTranslator.translatorTypes.ATTRIBUTE,
37990
+ encode: encode$5,
37991
+ attributes: validXmlAttributes$1
37992
+ };
37993
+ const translator$2 = NodeTranslator.from(config$2);
37994
+ const runPropertyTranslators = Object.freeze({
37995
+ "w:b": translator$9,
37996
+ "w:i": translator$8,
37997
+ "w:u": translator$a,
37998
+ "w:strike": translator$7,
37999
+ "w:color": translator$6,
38000
+ "w:highlight": translator$u,
38001
+ "w:rFonts": translator$5,
38002
+ "w:rStyle": translator$4,
38003
+ "w:sz": translator$3,
38004
+ "w:szCs": translator$2
38005
+ });
38006
+ const rawRunPropertyXmlNames = Object.freeze(["w:lang", "w:shd"]);
38007
+ const RAW_CHILD_NAME_SET = new Set(rawRunPropertyXmlNames);
38008
+ const KNOWN_CHILD_XML_NAMES = /* @__PURE__ */ new Set([...Object.keys(runPropertyTranslators), ...RAW_CHILD_NAME_SET]);
38009
+ const toRunPropertyEntry = (candidate) => {
38010
+ if (!candidate || candidate.type !== "attr") return null;
38011
+ const xmlName = candidate.xmlName || candidate.name;
38012
+ if (!xmlName) return null;
38013
+ return {
38014
+ xmlName,
38015
+ attributes: { ...candidate.attributes || {} }
38016
+ };
38017
+ };
38018
+ const XML_NODE_NAME$1 = "w:rPr";
38019
+ const SD_ATTR_KEY = "runProperties";
38020
+ const encode$4 = (params2) => {
38021
+ const { nodes } = params2;
38022
+ const node = nodes?.[0] || {};
38023
+ const contents = Array.isArray(node.elements) ? node.elements : [];
38024
+ const runPropsArray = contents.reduce(
38025
+ (acc, child) => {
38026
+ if (!child || typeof child !== "object") return acc;
38027
+ const xmlName = child.name;
38028
+ if (!KNOWN_CHILD_XML_NAMES.has(xmlName)) return acc;
38029
+ const translator2 = runPropertyTranslators[xmlName];
38030
+ let entry = null;
38031
+ if (translator2) {
38032
+ const encoded = translator2.encode({ ...params2, nodes: [child] }) || null;
38033
+ entry = toRunPropertyEntry(encoded);
38034
+ } else if (RAW_CHILD_NAME_SET.has(xmlName)) {
38035
+ entry = toRunPropertyEntry({
38036
+ type: "attr",
38037
+ xmlName,
38038
+ attributes: { ...child.attributes || {} }
38039
+ });
37476
38040
  }
37477
- });
38041
+ if (entry) acc.push(entry);
38042
+ return acc;
38043
+ },
38044
+ /** @type {{ xmlName: string, attributes: Record<string, any> }[]} */
38045
+ []
38046
+ );
38047
+ return {
38048
+ type: "attr",
38049
+ xmlName: "w:rPr",
38050
+ sdNodeOrKeyName: "runProperties",
38051
+ attributes: runPropsArray
38052
+ };
38053
+ };
38054
+ const config$1 = {
38055
+ xmlName: XML_NODE_NAME$1,
38056
+ sdNodeOrKeyName: SD_ATTR_KEY,
38057
+ type: NodeTranslator.translatorTypes.ATTRIBUTE,
38058
+ encode: encode$4
38059
+ };
38060
+ const translator$1 = NodeTranslator.from(config$1);
38061
+ const collectRunProperties = (params2, rPrNode, translator2 = translator$1) => {
38062
+ if (!rPrNode) return { entries: [], hadRPr: false, styleChangeMarks: [] };
38063
+ const result = translator2.encode({ ...params2, nodes: [rPrNode] }) || {};
38064
+ let entries = [];
38065
+ if (Array.isArray(result.attributes) && result.attributes.length) {
38066
+ entries = result.attributes.map((attr) => ({
38067
+ xmlName: attr?.xmlName,
38068
+ attributes: { ...attr?.attributes || {} }
38069
+ }));
38070
+ } else if (Array.isArray(rPrNode.elements) && rPrNode.elements.length) {
38071
+ entries = rPrNode.elements.filter((el) => el && typeof el === "object").map((el) => ({
38072
+ xmlName: el.name,
38073
+ attributes: { ...el.attributes || {} }
38074
+ }));
38075
+ }
38076
+ const legacyMarks = parseMarks(rPrNode, [], params2?.docx) || [];
38077
+ const styleChangeMarks = handleStyleChangeMarks(rPrNode, legacyMarks) || [];
38078
+ return { entries, hadRPr: true, styleChangeMarks };
38079
+ };
38080
+ const buildRunAttrs = (encodedAttrs = {}, hadRPr, runProps) => {
38081
+ const base2 = { ...encodedAttrs || {} };
38082
+ if (hadRPr) {
38083
+ base2.runProperties = runProps.length ? runProps : null;
38084
+ }
38085
+ return base2;
38086
+ };
38087
+ const ensureRunMark = (marks, runAttrs) => {
38088
+ if (!runAttrs) return;
38089
+ const runMark = createRunMark(runAttrs);
38090
+ const runMarkIndex = marks.findIndex((mark) => mark?.type === "run");
38091
+ if (runMarkIndex >= 0) {
38092
+ const existing = marks[runMarkIndex];
38093
+ if (runMark.attrs) {
38094
+ marks[runMarkIndex] = { ...existing, attrs: mergeRunAttrs(existing?.attrs, runMark.attrs) };
38095
+ }
38096
+ return;
38097
+ }
38098
+ marks.push(runMark);
38099
+ };
38100
+ const ensureInlineMarks = (marks, inlineMarks = []) => {
38101
+ inlineMarks.forEach(({ type: type2, attrs }) => {
38102
+ if (!type2) return;
38103
+ if (marks.some((mark) => mark?.type === type2)) return;
38104
+ marks.push(attrs ? { type: type2, attrs: { ...attrs } } : { type: type2 });
38105
+ });
38106
+ };
38107
+ const ensureTextStyleMark = (marks, textStyleAttrs) => {
38108
+ if (!textStyleAttrs) return;
38109
+ const existingTextStyle = marks.find((mark) => mark?.type === "textStyle");
38110
+ if (existingTextStyle) {
38111
+ existingTextStyle.attrs = { ...existingTextStyle.attrs || {}, ...textStyleAttrs };
38112
+ return;
38113
+ }
38114
+ marks.push({ type: "textStyle", attrs: { ...textStyleAttrs } });
38115
+ };
38116
+ const applyRunMarks = (node, runAttrs, inlineMarks, textStyleAttrs) => {
38117
+ if (!node || typeof node !== "object") return node;
38118
+ const baseMarks = Array.isArray(node.marks) ? node.marks : [];
38119
+ const marks = baseMarks.map((mark) => cloneMark(mark));
38120
+ ensureRunMark(marks, runAttrs);
38121
+ ensureInlineMarks(marks, inlineMarks);
38122
+ if (node.type === "text") {
38123
+ ensureTextStyleMark(marks, textStyleAttrs);
38124
+ }
38125
+ return { ...node, marks };
38126
+ };
38127
+ const createRunMark = (attrs = {}) => {
38128
+ const hasAttrs = attrs && Object.keys(attrs).length > 0;
38129
+ return hasAttrs ? { type: "run", attrs: cloneRunAttrs(attrs) } : { type: "run" };
38130
+ };
38131
+ const deriveStyleMarks = ({ docx, paragraphStyleId, runStyleId }) => {
38132
+ const paragraphStyleMarks = collectStyleMarks(paragraphStyleId, docx);
38133
+ const runStyleMarks = collectStyleMarks(runStyleId, docx);
38134
+ const inlineMarks = mergeInlineMarkSets(paragraphStyleMarks.inlineMarks, runStyleMarks.inlineMarks);
38135
+ const textStyleAttrs = mergeTextStyleAttrs(paragraphStyleMarks.textStyleAttrs, runStyleMarks.textStyleAttrs);
38136
+ return { inlineMarks, textStyleAttrs };
38137
+ };
38138
+ const collectStyleMarks = (styleId, docx, seen = /* @__PURE__ */ new Set()) => {
38139
+ if (!styleId || !docx || seen.has(styleId)) return { inlineMarks: [], textStyleAttrs: null };
38140
+ seen.add(styleId);
38141
+ const chain = collectStyleChain(styleId, docx, seen);
38142
+ if (!chain.length) return { inlineMarks: [], textStyleAttrs: null };
38143
+ const inlineMap = /* @__PURE__ */ new Map();
38144
+ let textStyleAttrs = {};
38145
+ chain.forEach((styleTag) => {
38146
+ const marks = extractMarksFromStyle(styleTag, docx);
38147
+ marks.inlineMarks.forEach((mark) => {
38148
+ inlineMap.set(mark.type, mark.attrs ? { type: mark.type, attrs: { ...mark.attrs } } : { type: mark.type });
38149
+ });
38150
+ if (marks.textStyleAttrs) textStyleAttrs = { ...textStyleAttrs, ...marks.textStyleAttrs };
38151
+ });
38152
+ return {
38153
+ inlineMarks: Array.from(inlineMap.values()),
38154
+ textStyleAttrs: Object.keys(textStyleAttrs).length ? textStyleAttrs : null
38155
+ };
38156
+ };
38157
+ const collectStyleChain = (styleId, docx, seen) => {
38158
+ if (!styleId || !docx) return [];
38159
+ const styleTag = findStyleTag(docx, styleId);
38160
+ if (!styleTag || !styleTag.elements) return [];
38161
+ const basedOn = styleTag.elements?.find((el) => el.name === "w:basedOn")?.attributes?.["w:val"];
38162
+ let chain = [];
38163
+ if (basedOn && !seen.has(basedOn)) {
38164
+ seen.add(basedOn);
38165
+ chain = collectStyleChain(basedOn, docx, seen);
38166
+ }
38167
+ chain.push(styleTag);
38168
+ return chain;
38169
+ };
38170
+ const findStyleTag = (docx, styleId) => {
38171
+ const stylesFile = docx?.["word/styles.xml"];
38172
+ if (!stylesFile?.elements?.length) return null;
38173
+ const candidates = [];
38174
+ stylesFile.elements.forEach((el) => {
38175
+ if (!el) return;
38176
+ if (el.name === "w:styles" && Array.isArray(el.elements)) {
38177
+ el.elements.forEach((child) => {
38178
+ if (child?.name === "w:style") candidates.push(child);
38179
+ });
38180
+ return;
38181
+ }
38182
+ if (el.name === "w:style") {
38183
+ candidates.push(el);
38184
+ return;
38185
+ }
38186
+ if (Array.isArray(el.elements)) {
38187
+ el.elements.forEach((child) => {
38188
+ if (child?.name === "w:style") candidates.push(child);
38189
+ });
38190
+ }
38191
+ });
38192
+ return candidates.find((tag) => tag?.attributes?.["w:styleId"] === styleId) || null;
38193
+ };
38194
+ const extractMarksFromStyle = (styleTag, docx) => {
38195
+ const rPr = styleTag?.elements?.find((el) => el.name === "w:rPr");
38196
+ if (!rPr) return { inlineMarks: [], textStyleAttrs: null };
38197
+ const marks = parseMarks(rPr, [], docx) || [];
38198
+ const inlineMarks = [];
38199
+ let textStyleAttrs = {};
38200
+ marks.forEach((mark) => {
38201
+ if (!mark) return;
38202
+ if (mark.type === "textStyle") {
38203
+ const attrs = mark.attrs || {};
38204
+ if (Object.keys(attrs).length) textStyleAttrs = { ...textStyleAttrs, ...attrs };
38205
+ return;
38206
+ }
38207
+ if (mark.type) inlineMarks.push(mark.attrs ? { type: mark.type, attrs: { ...mark.attrs } } : { type: mark.type });
38208
+ });
38209
+ return {
38210
+ inlineMarks,
38211
+ textStyleAttrs: Object.keys(textStyleAttrs).length ? textStyleAttrs : null
38212
+ };
38213
+ };
38214
+ const mergeInlineMarkSets = (...markSets) => {
38215
+ const map2 = /* @__PURE__ */ new Map();
38216
+ markSets.filter(Boolean).forEach((marks) => {
37478
38217
  marks.forEach((mark) => {
37479
- const exists2 = combinedMarks.some(
37480
- (existing) => existing.type === mark.type && JSON.stringify(existing.attrs || {}) === JSON.stringify(mark.attrs || {})
37481
- );
37482
- if (!exists2) {
37483
- combinedMarks.push(mark);
37484
- }
38218
+ if (!mark || !mark.type) return;
38219
+ map2.set(mark.type, mark.attrs ? { type: mark.type, attrs: { ...mark.attrs } } : { type: mark.type });
37485
38220
  });
37486
- if (runStyleId) combinedMarks.push({ type: "textStyle", attrs: { styleId: runStyleId } });
37487
- if (node.marks) combinedMarks.push(...node.marks);
37488
- const newMarks = createImportMarks(combinedMarks);
37489
- processedRun = processedRun.map((n) => {
37490
- const existingMarks = n.marks || [];
37491
- return {
37492
- ...n,
37493
- marks: [...newMarks, ...existingMarks]
37494
- };
38221
+ });
38222
+ return Array.from(map2.values());
38223
+ };
38224
+ const mergeTextStyleAttrs = (...attrsList) => {
38225
+ const merged = attrsList.filter((attrs) => attrs && Object.keys(attrs).length).reduce((acc, attrs) => ({ ...acc, ...attrs }), {});
38226
+ return Object.keys(merged).length ? merged : null;
38227
+ };
38228
+ const cloneRunAttrs = (attrs) => {
38229
+ const clone = { ...attrs };
38230
+ if (Array.isArray(attrs?.runProperties)) {
38231
+ clone.runProperties = attrs.runProperties.map((entry) => ({
38232
+ xmlName: entry?.xmlName,
38233
+ attributes: { ...entry?.attributes || {} }
38234
+ }));
38235
+ }
38236
+ return clone;
38237
+ };
38238
+ const cloneMark = (mark) => {
38239
+ if (!mark || typeof mark !== "object") return mark;
38240
+ const cloned = { ...mark };
38241
+ if (mark.attrs && typeof mark.attrs === "object") {
38242
+ cloned.attrs = { ...mark.attrs };
38243
+ if (Array.isArray(mark.attrs.runProperties)) {
38244
+ cloned.attrs.runProperties = mark.attrs.runProperties.map((entry) => ({
38245
+ xmlName: entry?.xmlName,
38246
+ attributes: { ...entry?.attributes || {} }
38247
+ }));
38248
+ }
38249
+ }
38250
+ return cloned;
38251
+ };
38252
+ const mergeRunAttrs = (existing = {}, incoming = {}) => {
38253
+ const merged = { ...existing, ...cloneRunAttrs(incoming) };
38254
+ if (Array.isArray(existing?.runProperties) && Array.isArray(incoming?.runProperties)) {
38255
+ const seen = /* @__PURE__ */ new Set();
38256
+ const combined = [...existing.runProperties, ...incoming.runProperties];
38257
+ merged.runProperties = combined.filter((entry) => {
38258
+ const key = entry?.xmlName;
38259
+ if (!key || seen.has(key)) return false;
38260
+ seen.add(key);
38261
+ return true;
37495
38262
  });
37496
38263
  }
37497
- return { nodes: processedRun, consumed: 1 };
38264
+ return merged;
37498
38265
  };
37499
- const getMarksFromStyles = (docx, styleId) => {
37500
- const styles = docx?.["word/styles.xml"];
37501
- if (!styles) {
37502
- return {};
38266
+ const normalizeBool = (value) => {
38267
+ if (value === void 0 || value === null) return true;
38268
+ if (typeof value === "boolean") return value;
38269
+ if (typeof value === "number") return value !== 0;
38270
+ const normalized = String(value).trim().toLowerCase();
38271
+ if (normalized === "0" || normalized === "false" || normalized === "off") return false;
38272
+ if (normalized === "1" || normalized === "true" || normalized === "on") return true;
38273
+ return true;
38274
+ };
38275
+ const resolveRunElement = (node) => {
38276
+ if (!node) return null;
38277
+ if (node.name === "w:r") return node;
38278
+ return (node.elements || []).find((el) => el.name === "w:r") || null;
38279
+ };
38280
+ const ensureRunPropertiesContainer = (runElement) => {
38281
+ if (!Array.isArray(runElement.elements)) runElement.elements = [];
38282
+ let rPr = runElement.elements.find((el) => el.name === "w:rPr");
38283
+ if (!rPr) {
38284
+ rPr = { name: "w:rPr", elements: [] };
38285
+ runElement.elements.unshift(rPr);
38286
+ }
38287
+ if (!Array.isArray(rPr.elements)) rPr.elements = [];
38288
+ return rPr;
38289
+ };
38290
+ const splitRunProperties = (entries = [], docx = null) => {
38291
+ const remainingProps = [];
38292
+ const inlineMarks = [];
38293
+ const textStyleAttrs = {};
38294
+ let hasTextStyle = false;
38295
+ let highlightColor = null;
38296
+ let runStyleId = null;
38297
+ entries.forEach((entry) => {
38298
+ if (!entry || !entry.xmlName) return;
38299
+ const attributes = entry.attributes || {};
38300
+ switch (entry.xmlName) {
38301
+ case "w:b": {
38302
+ const val = normalizeBool(attributes["w:val"]);
38303
+ inlineMarks.push(val ? { type: "bold" } : { type: "bold", attrs: { value: "0" } });
38304
+ break;
38305
+ }
38306
+ case "w:i": {
38307
+ const val = normalizeBool(attributes["w:val"]);
38308
+ inlineMarks.push(val ? { type: "italic" } : { type: "italic", attrs: { value: "0" } });
38309
+ break;
38310
+ }
38311
+ case "w:u": {
38312
+ const rawVal = attributes["w:val"];
38313
+ const underlineType = rawVal == null || rawVal === "" ? "single" : String(rawVal);
38314
+ const attrs = {};
38315
+ if (underlineType.toLowerCase() === "none" || underlineType === "0") {
38316
+ attrs.underlineType = "none";
38317
+ } else {
38318
+ attrs.underlineType = underlineType;
38319
+ const colorRaw = attributes["w:color"];
38320
+ if (typeof colorRaw === "string" && colorRaw.toLowerCase() !== "auto") {
38321
+ const normalizedColor = normalizeHexColor(colorRaw);
38322
+ if (normalizedColor) attrs.underlineColor = `#${normalizedColor}`;
38323
+ }
38324
+ }
38325
+ if (attributes["w:themeColor"]) attrs.underlineThemeColor = attributes["w:themeColor"];
38326
+ if (attributes["w:themeTint"]) attrs.underlineThemeTint = attributes["w:themeTint"];
38327
+ if (attributes["w:themeShade"]) attrs.underlineThemeShade = attributes["w:themeShade"];
38328
+ inlineMarks.push({ type: "underline", attrs });
38329
+ break;
38330
+ }
38331
+ case "w:color": {
38332
+ const raw = attributes["w:val"];
38333
+ if (typeof raw === "string" && raw) {
38334
+ hasTextStyle = true;
38335
+ textStyleAttrs.color = `#${raw.replace("#", "").toUpperCase()}`;
38336
+ }
38337
+ break;
38338
+ }
38339
+ case "w:rFonts": {
38340
+ const family = attributes["w:ascii"] || attributes["w:eastAsia"] || attributes["w:hAnsi"] || attributes["w:val"];
38341
+ if (family) {
38342
+ hasTextStyle = true;
38343
+ textStyleAttrs.fontFamily = SuperConverter.toCssFontFamily(family, docx);
38344
+ }
38345
+ break;
38346
+ }
38347
+ case "w:sz":
38348
+ case "w:szCs": {
38349
+ const rawSize = Number(attributes["w:val"]);
38350
+ if (Number.isFinite(rawSize) && rawSize > 0) {
38351
+ hasTextStyle = true;
38352
+ textStyleAttrs.fontSize = `${rawSize / 2}pt`;
38353
+ }
38354
+ break;
38355
+ }
38356
+ case "w:strike": {
38357
+ const val = normalizeBool(attributes["w:val"]);
38358
+ inlineMarks.push(val ? { type: "strike" } : { type: "strike", attrs: { value: "0" } });
38359
+ break;
38360
+ }
38361
+ case "w:highlight": {
38362
+ const color = attributes["w:val"];
38363
+ if (typeof color === "string" && color) {
38364
+ highlightColor = color.toLowerCase() === "none" ? "transparent" : color;
38365
+ }
38366
+ break;
38367
+ }
38368
+ case "w:shd": {
38369
+ const fill = attributes["w:fill"];
38370
+ const shdVal = attributes["w:val"];
38371
+ if (fill && String(fill).toLowerCase() !== "auto") {
38372
+ highlightColor = `#${String(fill).replace("#", "")}`;
38373
+ } else if (typeof shdVal === "string") {
38374
+ const normalized = shdVal.toLowerCase();
38375
+ if (normalized === "clear" || normalized === "nil" || normalized === "none") {
38376
+ highlightColor = "transparent";
38377
+ }
38378
+ }
38379
+ break;
38380
+ }
38381
+ case "w:rStyle": {
38382
+ if (typeof attributes["w:val"] === "string") runStyleId = attributes["w:val"];
38383
+ remainingProps.push({ xmlName: entry.xmlName, attributes: { ...attributes } });
38384
+ break;
38385
+ }
38386
+ default: {
38387
+ remainingProps.push({ xmlName: entry.xmlName, attributes: { ...attributes } });
38388
+ }
38389
+ }
38390
+ });
38391
+ if (highlightColor) inlineMarks.push({ type: "highlight", attrs: { color: highlightColor } });
38392
+ return {
38393
+ remainingProps,
38394
+ inlineMarks,
38395
+ textStyleAttrs: hasTextStyle ? textStyleAttrs : null,
38396
+ runStyleId
38397
+ };
38398
+ };
38399
+ const encode$3 = (attributes) => {
38400
+ return attributes["w:rsidR"];
38401
+ };
38402
+ const decode$3 = (attrs) => {
38403
+ return attrs.rsidR;
38404
+ };
38405
+ const attrConfig$2 = Object.freeze({
38406
+ xmlName: "w:rsidR",
38407
+ sdName: "rsidR",
38408
+ encode: encode$3,
38409
+ decode: decode$3
38410
+ });
38411
+ const encode$2 = (attributes) => {
38412
+ return attributes["w:rsidRPr"];
38413
+ };
38414
+ const decode$2 = (attrs) => {
38415
+ return attrs.rsidRPr;
38416
+ };
38417
+ const attrConfig$1 = Object.freeze({
38418
+ xmlName: "w:rsidRPr",
38419
+ sdName: "rsidRPr",
38420
+ encode: encode$2,
38421
+ decode: decode$2
38422
+ });
38423
+ const encode$1 = (attributes) => {
38424
+ return attributes["w:rsidDel"];
38425
+ };
38426
+ const decode$1 = (attrs) => {
38427
+ return attrs.rsidDel;
38428
+ };
38429
+ const attrConfig = Object.freeze({
38430
+ xmlName: "w:rsidDel",
38431
+ sdName: "rsidDel",
38432
+ encode: encode$1,
38433
+ decode: decode$1
38434
+ });
38435
+ const validXmlAttributes = [attrConfig$2, attrConfig$1, attrConfig];
38436
+ const XML_NODE_NAME = "w:r";
38437
+ const SD_KEY_NAME = "run";
38438
+ const encode$U = (params2, encodedAttrs = {}) => {
38439
+ const { nodes = [], nodeListHandler } = params2 || {};
38440
+ const runNode = nodes[0];
38441
+ if (!runNode) return void 0;
38442
+ const elements = Array.isArray(runNode.elements) ? runNode.elements : [];
38443
+ const rPrNode = elements.find((child) => child?.name === "w:rPr");
38444
+ const contentElements = rPrNode ? elements.filter((el) => el !== rPrNode) : elements;
38445
+ const { entries: runPropEntries, hadRPr, styleChangeMarks } = collectRunProperties(params2, rPrNode);
38446
+ const { remainingProps, inlineMarks, textStyleAttrs, runStyleId } = splitRunProperties(runPropEntries, params2?.docx);
38447
+ const styleMarks = deriveStyleMarks({
38448
+ docx: params2?.docx,
38449
+ paragraphStyleId: params2?.parentStyleId,
38450
+ runStyleId
38451
+ });
38452
+ const mergedInlineMarks = mergeInlineMarkSets(styleMarks.inlineMarks, inlineMarks);
38453
+ let mergedTextStyleAttrs = mergeTextStyleAttrs(styleMarks.textStyleAttrs, textStyleAttrs);
38454
+ if (runStyleId) {
38455
+ mergedTextStyleAttrs = mergedTextStyleAttrs ? { ...mergedTextStyleAttrs, styleId: runStyleId } : { styleId: runStyleId };
38456
+ }
38457
+ const runAttrs = buildRunAttrs(encodedAttrs, hadRPr, remainingProps);
38458
+ let runLevelMarks = Array.isArray(runNode.marks) ? runNode.marks.map((mark) => cloneMark(mark)) : [];
38459
+ if (styleChangeMarks?.length) {
38460
+ runLevelMarks = [...runLevelMarks, ...styleChangeMarks.map((mark) => cloneMark(mark))];
38461
+ }
38462
+ const childParams = { ...params2, nodes: contentElements };
38463
+ const content = nodeListHandler?.handler(childParams) || [];
38464
+ const contentWithRunMarks = content.map((child) => {
38465
+ if (!child || typeof child !== "object") return child;
38466
+ const baseMarks = Array.isArray(child.marks) ? child.marks.map((mark) => cloneMark(mark)) : [];
38467
+ if (!runLevelMarks.length) return child;
38468
+ return { ...child, marks: [...baseMarks, ...runLevelMarks.map((mark) => cloneMark(mark))] };
38469
+ });
38470
+ const marked = contentWithRunMarks.map(
38471
+ (child) => applyRunMarks(child, runAttrs, mergedInlineMarks, mergedTextStyleAttrs)
38472
+ );
38473
+ const filtered = marked.filter(Boolean);
38474
+ if (!filtered.length) return [];
38475
+ if (filtered.length === 1) return filtered[0];
38476
+ return filtered;
38477
+ };
38478
+ const decode = (params2, decodedAttrs = {}) => {
38479
+ const { node } = params2 || {};
38480
+ if (!node) return void 0;
38481
+ const marks = Array.isArray(node.marks) ? node.marks : [];
38482
+ const runMarkIndex = marks.findIndex((mark) => mark?.type === SD_KEY_NAME);
38483
+ const runMark = runMarkIndex >= 0 ? marks[runMarkIndex] : void 0;
38484
+ const strippedMarks = marks.filter((_2, idx) => idx !== runMarkIndex);
38485
+ const exportNode = { ...node, marks: strippedMarks };
38486
+ const exportParams = { ...params2, node: exportNode };
38487
+ if (!exportParams.editor) {
38488
+ exportParams.editor = { extensionService: { extensions: [] } };
38489
+ }
38490
+ const translated = exportSchemaToJson(exportParams);
38491
+ if (!translated) return void 0;
38492
+ const runElement = resolveRunElement(translated);
38493
+ if (!runElement) return translated;
38494
+ runElement.attributes = { ...runElement.attributes || {}, ...decodedAttrs };
38495
+ const runProperties = Array.isArray(runMark?.attrs?.runProperties) ? runMark.attrs.runProperties : null;
38496
+ if (runProperties && runProperties.length) {
38497
+ const rPr = ensureRunPropertiesContainer(runElement);
38498
+ const existingNames = new Set((rPr.elements || []).map((el) => el.name));
38499
+ runProperties.forEach((entry) => {
38500
+ if (!entry || !entry.xmlName || entry.xmlName === "w:b") return;
38501
+ if (existingNames.has(entry.xmlName)) return;
38502
+ rPr.elements.push({ name: entry.xmlName, attributes: { ...entry.attributes || {} } });
38503
+ existingNames.add(entry.xmlName);
38504
+ });
37503
38505
  }
37504
- const styleTags = styles.elements[0].elements.filter((style22) => style22.name === "w:style");
37505
- const style2 = styleTags.find((tag) => tag.attributes["w:styleId"] === styleId) || {};
37506
- if (!style2) return {};
37507
- return parseProperties(style2);
38506
+ return translated;
37508
38507
  };
37509
- const runNodeHandlerEntity = {
37510
- handlerName: "runNodeHandler",
37511
- handler: handleRunNode
38508
+ const config = {
38509
+ xmlName: XML_NODE_NAME,
38510
+ sdNodeOrKeyName: SD_KEY_NAME,
38511
+ type: NodeTranslator.translatorTypes.NODE,
38512
+ encode: encode$U,
38513
+ decode,
38514
+ attributes: validXmlAttributes
37512
38515
  };
38516
+ const translator = NodeTranslator.from(config);
38517
+ const runNodeHandlerEntity = generateV2HandlerEntity("runNodeHandler", translator);
37513
38518
  const handleTextNode = (params2) => {
37514
38519
  const { nodes, insideTrackChange } = params2;
37515
38520
  if (nodes.length === 0 || !(nodes[0].name === "w:t" || insideTrackChange && nodes[0].name === "w:delText")) {
@@ -37546,7 +38551,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
37546
38551
  if (nodes.length === 0 || nodes[0].name !== "w:p") {
37547
38552
  return { nodes: [], consumed: 0 };
37548
38553
  }
37549
- const schemaNode = translator$h.encode(params2);
38554
+ const schemaNode = translator$s.encode(params2);
37550
38555
  const newNodes = schemaNode ? [schemaNode] : [];
37551
38556
  return { nodes: newNodes, consumed: 1 };
37552
38557
  };
@@ -37559,7 +38564,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
37559
38564
  if (nodes.length === 0 || nodes[0].name !== "w:sdt") {
37560
38565
  return { nodes: [], consumed: 0 };
37561
38566
  }
37562
- const result = translator.encode(params2);
38567
+ const result = translator$b.encode(params2);
37563
38568
  if (!result) {
37564
38569
  return { nodes: [], consumed: 0 };
37565
38570
  }
@@ -37649,7 +38654,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
37649
38654
  if (nodes.length === 0 || nodes[0].name !== "w:br") {
37650
38655
  return { nodes: [], consumed: 0 };
37651
38656
  }
37652
- const result = translator$j.encode(params2);
38657
+ const result = translator$v.encode(params2);
37653
38658
  if (!result) return { nodes: [], consumed: 0 };
37654
38659
  return {
37655
38660
  nodes: [result],
@@ -38318,7 +39323,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
38318
39323
  if (!nodes.length || nodes[0].name !== "w:tab") {
38319
39324
  return { nodes: [], consumed: 0 };
38320
39325
  }
38321
- const node = translator$i.encode(params2);
39326
+ const node = translator$t.encode(params2);
38322
39327
  return { nodes: [node], consumed: 1 };
38323
39328
  };
38324
39329
  const tabNodeEntityHandler = {
@@ -38765,6 +39770,16 @@ Please report this to https://github.com/markedjs/marked.`, e) {
38765
39770
  };
38766
39771
  const HYPERLINK_RELATIONSHIP_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink";
38767
39772
  const HEADER_RELATIONSHIP_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/header";
39773
+ const FONT_FAMILY_FALLBACKS = Object.freeze({
39774
+ swiss: "Arial, sans-serif",
39775
+ roman: "Times New Roman, serif",
39776
+ modern: "Courier New, monospace",
39777
+ script: "cursive",
39778
+ decorative: "fantasy",
39779
+ system: "system-ui",
39780
+ auto: "sans-serif"
39781
+ });
39782
+ const DEFAULT_GENERIC_FALLBACK = "sans-serif";
38768
39783
  const _SuperConverter = class _SuperConverter2 {
38769
39784
  constructor(params2 = null) {
38770
39785
  __privateAdd$2(this, _SuperConverter_instances);
@@ -38800,6 +39815,31 @@ Please report this to https://github.com/markedjs/marked.`, e) {
38800
39815
  this.documentId = params2?.documentId || null;
38801
39816
  if (this.docx.length || this.xml) this.parseFromXml();
38802
39817
  }
39818
+ static getFontTableEntry(docx, fontName) {
39819
+ if (!docx || !fontName) return null;
39820
+ const fontTable = docx["word/fontTable.xml"];
39821
+ if (!fontTable?.elements?.length) return null;
39822
+ const fontsNode = fontTable.elements.find((el) => el.name === "w:fonts");
39823
+ if (!fontsNode?.elements?.length) return null;
39824
+ return fontsNode.elements.find((el) => el?.attributes?.["w:name"] === fontName) || null;
39825
+ }
39826
+ static getFallbackFromFontTable(docx, fontName) {
39827
+ const fontEntry = _SuperConverter2.getFontTableEntry(docx, fontName);
39828
+ const family = fontEntry?.elements?.find((child) => child.name === "w:family")?.attributes?.["w:val"];
39829
+ if (!family) return null;
39830
+ const mapped = FONT_FAMILY_FALLBACKS[family.toLowerCase()];
39831
+ return mapped || DEFAULT_GENERIC_FALLBACK;
39832
+ }
39833
+ static toCssFontFamily(fontName, docx) {
39834
+ if (!fontName) return fontName;
39835
+ if (fontName.includes(",")) return fontName;
39836
+ const fallback = _SuperConverter2.getFallbackFromFontTable(docx, fontName) || DEFAULT_GENERIC_FALLBACK;
39837
+ const normalizedFallbackParts = fallback.split(",").map((part) => part.trim().toLowerCase()).filter(Boolean);
39838
+ if (normalizedFallbackParts.includes(fontName.trim().toLowerCase())) {
39839
+ return fallback;
39840
+ }
39841
+ return `${fontName}, ${fallback}`;
39842
+ }
38803
39843
  /**
38804
39844
  * Get the DocxHelpers object that contains utility functions for working with docx files.
38805
39845
  * @returns {import('./docx-helpers/docx-helpers.js').DocxHelpers} The DocxHelpers object.
@@ -38845,7 +39885,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
38845
39885
  return;
38846
39886
  }
38847
39887
  }
38848
- static updateDocumentVersion(docx = this.convertedXml, version2 = "0.20.1") {
39888
+ static updateDocumentVersion(docx = this.convertedXml, version2 = "0.21.0-RC1") {
38849
39889
  const customLocation = "docProps/custom.xml";
38850
39890
  if (!docx[customLocation]) {
38851
39891
  docx[customLocation] = generateCustomXml();
@@ -38896,13 +39936,19 @@ Please report this to https://github.com/markedjs/marked.`, e) {
38896
39936
  if (rPrDefaults) {
38897
39937
  const rPr = rPrDefaults.elements?.find((el) => el.name === "w:rPr");
38898
39938
  const fonts = rPr?.elements?.find((el) => el.name === "w:rFonts");
38899
- typeface = fonts?.attributes["w:ascii"];
38900
- const fontSize2 = typeface ?? rPr?.elements?.find((el) => el.name === "w:sz")?.attributes["w:val"];
38901
- fontSizeNormal = !fontSizeNormal && fontSize2 ? Number(fontSize2) / 2 : null;
39939
+ if (fonts?.attributes?.["w:ascii"]) {
39940
+ typeface = fonts.attributes["w:ascii"];
39941
+ }
39942
+ const fontSizeRaw = rPr?.elements?.find((el) => el.name === "w:sz")?.attributes?.["w:val"];
39943
+ if (!fontSizeNormal && fontSizeRaw) {
39944
+ fontSizeNormal = Number(fontSizeRaw) / 2;
39945
+ }
38902
39946
  }
38903
- const fontSizePt = fontSizeNormal || Number(rElements.find((el) => el.name === "w:sz")?.attributes["w:val"]) / 2 || 10;
39947
+ const fallbackSz = Number(rElements.find((el) => el.name === "w:sz")?.attributes?.["w:val"]);
39948
+ const fontSizePt = fontSizeNormal ?? (Number.isFinite(fallbackSz) ? fallbackSz / 2 : void 0) ?? 10;
38904
39949
  const kern = rElements.find((el) => el.name === "w:kern")?.attributes["w:val"];
38905
- return { fontSizePt, kern, typeface, panose };
39950
+ const fontFamilyCss = _SuperConverter2.toCssFontFamily(typeface, this.convertedXml);
39951
+ return { fontSizePt, kern, typeface, panose, fontFamilyCss };
38906
39952
  }
38907
39953
  }
38908
39954
  getDocumentFonts() {
@@ -39332,7 +40378,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
39332
40378
  function generateCustomXml() {
39333
40379
  return DEFAULT_CUSTOM_XML;
39334
40380
  }
39335
- function generateSuperdocVersion(pid = 2, version2 = "0.20.1") {
40381
+ function generateSuperdocVersion(pid = 2, version2 = "0.21.0-RC1") {
39336
40382
  return {
39337
40383
  type: "element",
39338
40384
  name: "property",
@@ -41741,7 +42787,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
41741
42787
  const u8 = await zipEntry.async("uint8array");
41742
42788
  const content = ensureXmlString(u8);
41743
42789
  this.files.push({ name, content });
41744
- } else if (name.startsWith("word/media") && name !== "word/media/" || zipEntry.name.startsWith("media") && zipEntry.name !== "media/" || name.startsWith("media") && name !== "media/") {
42790
+ } else if (name.startsWith("word/media") && name !== "word/media/" || name.startsWith("media") && name !== "media/") {
41745
42791
  if (isNode2) {
41746
42792
  const buffer2 = await zipEntry.async("nodebuffer");
41747
42793
  const fileBase64 = buffer2.toString("base64");
@@ -50746,6 +51792,95 @@ Please report this to https://github.com/markedjs/marked.`, e) {
50746
51792
  if (isActive2) return commands2.unsetMark(type2, { extendEmptyMarkRange });
50747
51793
  return commands2.setMark(type2, attrs);
50748
51794
  };
51795
+ const toggleMarkCascade = (markName, options = {}) => ({ state: state2, chain, editor }) => {
51796
+ const {
51797
+ negationAttrs = { value: "0" },
51798
+ isNegation = (attrs) => attrs?.value === "0",
51799
+ styleDetector = defaultStyleDetector,
51800
+ extendEmptyMarkRange = true
51801
+ } = options;
51802
+ const selectionMarks = getMarksFromSelection(state2) || [];
51803
+ const inlineMarks = selectionMarks.filter((m2) => m2.type?.name === markName);
51804
+ const hasNegation = inlineMarks.some((m2) => isNegation(m2.attrs || {}));
51805
+ const hasInline = inlineMarks.some((m2) => !isNegation(m2.attrs || {}));
51806
+ const styleOn = styleDetector({ state: state2, selectionMarks, markName, editor });
51807
+ const cmdChain = chain();
51808
+ if (hasNegation) return cmdChain.unsetMark(markName, { extendEmptyMarkRange }).run();
51809
+ if (hasInline && styleOn) {
51810
+ return cmdChain.unsetMark(markName, { extendEmptyMarkRange }).setMark(markName, negationAttrs, { extendEmptyMarkRange }).run();
51811
+ }
51812
+ if (hasInline) return cmdChain.unsetMark(markName, { extendEmptyMarkRange }).run();
51813
+ if (styleOn) return cmdChain.setMark(markName, negationAttrs, { extendEmptyMarkRange }).run();
51814
+ return cmdChain.setMark(markName, {}, { extendEmptyMarkRange }).run();
51815
+ };
51816
+ function defaultStyleDetector({ state: state2, selectionMarks, markName, editor }) {
51817
+ try {
51818
+ const styleId = getEffectiveStyleId(state2, selectionMarks);
51819
+ if (!styleId || !editor?.converter?.linkedStyles) return false;
51820
+ const styles = editor.converter.linkedStyles;
51821
+ const seen = /* @__PURE__ */ new Set();
51822
+ let current = styleId;
51823
+ const key = mapMarkToStyleKey(markName);
51824
+ while (current && !seen.has(current)) {
51825
+ seen.add(current);
51826
+ const style2 = styles.find((s) => s.id === current);
51827
+ const def2 = style2?.definition?.styles || {};
51828
+ if (key in def2) {
51829
+ const raw = def2[key];
51830
+ if (raw === void 0) return true;
51831
+ const val = raw?.value ?? raw;
51832
+ if (val === "0" || val === false) return false;
51833
+ return !!val;
51834
+ }
51835
+ current = style2?.definition?.attrs?.basedOn || null;
51836
+ }
51837
+ return false;
51838
+ } catch {
51839
+ return false;
51840
+ }
51841
+ }
51842
+ function getEffectiveStyleId(state2, selectionMarks) {
51843
+ const sidFromMarks = getStyleIdFromMarks(selectionMarks);
51844
+ if (sidFromMarks) return sidFromMarks;
51845
+ const $from = state2.selection.$from;
51846
+ const before = $from.nodeBefore;
51847
+ const after = $from.nodeAfter;
51848
+ if (before && before.marks) {
51849
+ const sid = getStyleIdFromMarks(before.marks);
51850
+ if (sid) return sid;
51851
+ }
51852
+ if (after && after.marks) {
51853
+ const sid = getStyleIdFromMarks(after.marks);
51854
+ if (sid) return sid;
51855
+ }
51856
+ const ts = selectionMarks.find((m2) => m2.type?.name === "textStyle" && m2.attrs?.styleId);
51857
+ if (ts) return ts.attrs.styleId;
51858
+ const pos = state2.selection.$from.pos;
51859
+ const $pos = state2.doc.resolve(pos);
51860
+ for (let d2 = $pos.depth; d2 >= 0; d2--) {
51861
+ const n = $pos.node(d2);
51862
+ if (n?.type?.name === "paragraph") return n.attrs?.styleId || null;
51863
+ }
51864
+ return null;
51865
+ }
51866
+ function getStyleIdFromMarks(marks) {
51867
+ const run2 = marks.find((m2) => m2.type?.name === "run");
51868
+ const runProperties = run2?.attrs?.runProperties;
51869
+ if (!runProperties) return null;
51870
+ if (runProperties && typeof runProperties === "object" && !Array.isArray(runProperties) && runProperties.styleId) {
51871
+ return runProperties.styleId;
51872
+ }
51873
+ if (Array.isArray(runProperties)) {
51874
+ const rStyleEntry = runProperties.find((e) => e?.xmlName === "w:rStyle");
51875
+ const sid = rStyleEntry?.attributes?.["w:val"];
51876
+ if (sid) return sid;
51877
+ }
51878
+ return null;
51879
+ }
51880
+ function mapMarkToStyleKey(markName) {
51881
+ if (markName === "textStyle" || markName === "color") return "color";
51882
+ return markName;
51883
+ }
50749
51884
  const clearNodes = () => ({ state: state2, tr, dispatch }) => {
50750
51885
  const { selection } = tr;
50751
51886
  const { ranges } = selection;
@@ -52091,11 +53226,14 @@ Please report this to https://github.com/markedjs/marked.`, e) {
52091
53226
  command,
52092
53227
  createParagraphNear,
52093
53228
  decreaseListIndent,
53229
+ defaultStyleDetector,
52094
53230
  deleteListItem,
52095
53231
  deleteSelection,
52096
53232
  exitCode,
52097
53233
  first,
53234
+ getEffectiveStyleId,
52098
53235
  getParaCtx,
53236
+ getStyleIdFromMarks,
52099
53237
  handleBackspaceNextToList,
52100
53238
  handleDeleteNextToList,
52101
53239
  increaseListIndent,
@@ -52110,6 +53248,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
52110
53248
  joinUp,
52111
53249
  liftEmptyBlock,
52112
53250
  liftListItem,
53251
+ mapMarkToStyleKey,
52113
53252
  nearestListAt,
52114
53253
  newlineInCode,
52115
53254
  rebuildListNodeWithNewNum,
@@ -52129,6 +53268,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
52129
53268
  splitListItem,
52130
53269
  toggleList,
52131
53270
  toggleMark,
53271
+ toggleMarkCascade,
52132
53272
  toggleNode,
52133
53273
  undoInputRule,
52134
53274
  unsetAllMarks,
@@ -53332,7 +54472,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
53332
54472
  currentPageNumber
53333
54473
  }) => {
53334
54474
  const parentStyles = editor.converter.getDocumentDefaultStyles();
53335
- const { fontSizePt, typeface } = parentStyles;
54475
+ const { fontSizePt, typeface, fontFamilyCss } = parentStyles;
53336
54476
  const fontSizeInPixles = fontSizePt * 1.3333;
53337
54477
  const lineHeight2 = fontSizeInPixles * 1.2;
53338
54478
  Object.assign(editorContainer.style, {
@@ -53345,7 +54485,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
53345
54485
  left: "0",
53346
54486
  width: "auto",
53347
54487
  maxWidth: "none",
53348
- fontFamily: typeface,
54488
+ fontFamily: fontFamilyCss || typeface,
53349
54489
  fontSize: `${fontSizeInPixles}px`,
53350
54490
  lineHeight: `${lineHeight2}px`
53351
54491
  });
@@ -54175,7 +55315,6 @@ Please report this to https://github.com/markedjs/marked.`, e) {
54175
55315
  originalStep,
54176
55316
  originalStepIndex
54177
55317
  });
54178
- console.debug("[track-changes]: replaceStep");
54179
55318
  } else if (step instanceof AddMarkStep) {
54180
55319
  addMarkStep({
54181
55320
  state: state2,
@@ -54185,7 +55324,6 @@ Please report this to https://github.com/markedjs/marked.`, e) {
54185
55324
  user,
54186
55325
  date
54187
55326
  });
54188
- console.debug("[track-changes]: addMarkStep");
54189
55327
  } else if (step instanceof RemoveMarkStep) {
54190
55328
  removeMarkStep({
54191
55329
  state: state2,
@@ -54195,10 +55333,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
54195
55333
  user,
54196
55334
  date
54197
55335
  });
54198
- console.debug("[track-changes]: removeMarkStep");
54199
55336
  } else {
54200
55337
  newTr.step(step);
54201
- console.log("[track-changes]: otherStep");
54202
55338
  }
54203
55339
  });
54204
55340
  if (tr.getMeta("inputType")) {
@@ -56268,9 +57404,10 @@ Please report this to https://github.com/markedjs/marked.`, e) {
56268
57404
  element.style.isolation = "isolate";
56269
57405
  proseMirror.style.outline = "none";
56270
57406
  proseMirror.style.border = "none";
56271
- const { typeface, fontSizePt } = this.converter.getDocumentDefaultStyles() ?? {};
56272
- if (typeface) {
56273
- element.style.fontFamily = typeface;
57407
+ const { typeface, fontSizePt, fontFamilyCss } = this.converter.getDocumentDefaultStyles() ?? {};
57408
+ const resolvedFontFamily = fontFamilyCss || typeface;
57409
+ if (resolvedFontFamily) {
57410
+ element.style.fontFamily = resolvedFontFamily;
56274
57411
  }
56275
57412
  if (fontSizePt) {
56276
57413
  element.style.fontSize = `${fontSizePt}pt`;
@@ -56584,7 +57721,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
56584
57721
  * @returns {Object | void} Migration results
56585
57722
  */
56586
57723
  processCollaborationMigrations() {
56587
- console.debug("[checkVersionMigrations] Current editor version", "0.20.1");
57724
+ console.debug("[checkVersionMigrations] Current editor version", "0.21.0-RC1");
56588
57725
  if (!this.options.ydoc) return;
56589
57726
  const metaMap = this.options.ydoc.getMap("meta");
56590
57727
  let docVersion = metaMap.get("version");
@@ -57693,6 +58830,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
57693
58830
  },
57694
58831
  addCommands() {
57695
58832
  return {
58833
+ toggleMarkCascade,
57696
58834
  /**
57697
58835
  * Clear all formatting (nodes and marks)
57698
58836
  * @category Command
@@ -58677,24 +59815,32 @@ Please report this to https://github.com/markedjs/marked.`, e) {
58677
59815
  group: "inline",
58678
59816
  inline: true
58679
59817
  });
58680
- const RunItem = Node$1.create({
59818
+ const Run = Mark.create({
58681
59819
  name: "run",
58682
- group: "inline",
58683
- content: "text*",
58684
- inline: true,
58685
- parseDOM() {
58686
- return [{ tag: "run" }];
58687
- },
58688
- renderDOM() {
58689
- return ["run", 0];
59820
+ inclusive: false,
59821
+ addOptions() {
59822
+ return {
59823
+ htmlAttributes: {}
59824
+ };
58690
59825
  },
58691
59826
  addAttributes() {
58692
59827
  return {
58693
- attributes: {
58694
- rendered: false,
58695
- "aria-label": "Run node"
59828
+ runProperties: {
59829
+ default: null,
59830
+ rendered: false
58696
59831
  }
58697
59832
  };
59833
+ },
59834
+ parseDOM() {
59835
+ return [
59836
+ {
59837
+ tag: "span[data-run]"
59838
+ }
59839
+ ];
59840
+ },
59841
+ renderDOM({ htmlAttributes }) {
59842
+ const base2 = Attribute.mergeAttributes({ "data-run": "1" }, this.options.htmlAttributes, htmlAttributes);
59843
+ return ["span", base2, 0];
58698
59844
  }
58699
59845
  });
58700
59846
  const inputRegex$1 = /^\s*([-+*])\s$/;
@@ -59258,6 +60404,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
59258
60404
  case "textStyle":
59259
60405
  const { fontFamily: fontFamily2, fontSize: fontSize2 } = attr.attrs;
59260
60406
  styles += `${fontFamily2 ? `font-family: ${fontFamily2};` : ""} ${fontSize2 ? `font-size: ${fontSize2};` : ""}`;
60407
+ break;
59261
60408
  }
59262
60409
  }
59263
60410
  return styles.trim();
@@ -59276,12 +60423,22 @@ Please report this to https://github.com/markedjs/marked.`, e) {
59276
60423
  const linkedDefinitionStyles = { ...linkedStyle.definition.styles };
59277
60424
  const basedOnDefinitionStyles = { ...basedOnStyle?.definition?.styles };
59278
60425
  const resultStyles = { ...linkedDefinitionStyles };
59279
- if (!linkedDefinitionStyles["font-size"] && basedOnDefinitionStyles["font-size"]) {
59280
- resultStyles["font-size"] = basedOnDefinitionStyles["font-size"];
59281
- }
59282
- if (!linkedDefinitionStyles["text-transform"] && basedOnDefinitionStyles["text-transform"]) {
59283
- resultStyles["text-transform"] = basedOnDefinitionStyles["text-transform"];
59284
- }
60426
+ const inheritKeys = [
60427
+ "font-size",
60428
+ "font-family",
60429
+ "text-transform",
60430
+ "bold",
60431
+ "italic",
60432
+ "underline",
60433
+ "strike",
60434
+ "color",
60435
+ "highlight"
60436
+ ];
60437
+ inheritKeys.forEach((k) => {
60438
+ if (!linkedDefinitionStyles[k] && basedOnDefinitionStyles[k]) {
60439
+ resultStyles[k] = basedOnDefinitionStyles[k];
60440
+ }
60441
+ });
59285
60442
  Object.entries(resultStyles).forEach(([k, value]) => {
59286
60443
  const key = kebabCase$2(k);
59287
60444
  const flattenedMarks = [];
@@ -59296,6 +60453,10 @@ Please report this to https://github.com/markedjs/marked.`, e) {
59296
60453
  }
59297
60454
  flattenedMarks.push({ key: n.type.name, value: n.attrs[key] });
59298
60455
  });
60456
+ const underlineNone = node?.marks?.some((m2) => m2.type?.name === "underline" && m2.attrs?.underlineType === "none");
60457
+ if (underlineNone) {
60458
+ markValue["text-decoration"] = "none";
60459
+ }
59299
60460
  const mark = flattenedMarks.find((n) => n.key === key);
59300
60461
  const hasParentIndent = Object.keys(parent?.attrs?.indent || {});
59301
60462
  const hasParentSpacing = Object.keys(parent?.attrs?.spacing || {});
@@ -59312,10 +60473,28 @@ Please report this to https://github.com/markedjs/marked.`, e) {
59312
60473
  if (rightIndent) markValue["margin-right"] = rightIndent + "px";
59313
60474
  if (firstLine) markValue["text-indent"] = firstLine + "px";
59314
60475
  } else if (key === "bold" && node) {
59315
- const val = value?.value;
59316
- if (!listTypes.includes(node.type.name) && val !== "0") {
60476
+ const boldValue = typeof value === "object" && value !== null ? value.value : value;
60477
+ const hasInlineBoldOff = node.marks?.some((m2) => m2.type?.name === "bold" && m2.attrs?.value === "0");
60478
+ const hasInlineBoldOn = node.marks?.some((m2) => m2.type?.name === "bold" && m2.attrs?.value !== "0");
60479
+ if (!listTypes.includes(node.type.name) && !hasInlineBoldOff && !hasInlineBoldOn && boldValue !== "0" && boldValue !== false) {
59317
60480
  markValue["font-weight"] = "bold";
59318
60481
  }
60482
+ } else if (key === "italic" && node) {
60483
+ const italicValue = typeof value === "object" && value !== null ? value.value : value;
60484
+ const hasInlineItalicOff = node.marks?.some((m2) => m2.type?.name === "italic" && m2.attrs?.value === "0");
60485
+ const hasInlineItalicOn = node.marks?.some((m2) => m2.type?.name === "italic" && m2.attrs?.value !== "0");
60486
+ if (!listTypes.includes(node.type.name) && !hasInlineItalicOff && !hasInlineItalicOn && italicValue !== "0" && italicValue !== false) {
60487
+ markValue["font-style"] = "italic";
60488
+ }
60489
+ } else if (key === "strike" && node) {
60490
+ const strikeValue = typeof value === "object" && value !== null ? value.value : value;
60491
+ const hasInlineStrikeOff = node.marks?.some((m2) => m2.type?.name === "strike" && m2.attrs?.value === "0");
60492
+ const hasInlineStrikeOn = node.marks?.some(
60493
+ (m2) => m2.type?.name === "strike" && (m2.attrs?.value === void 0 || m2.attrs?.value !== "0")
60494
+ );
60495
+ if (!listTypes.includes(node.type.name) && !hasInlineStrikeOff && !hasInlineStrikeOn && strikeValue !== "0" && strikeValue !== false) {
60496
+ markValue["text-decoration"] = "line-through";
60497
+ }
59319
60498
  } else if (key === "text-transform" && node) {
59320
60499
  if (!listTypes.includes(node.type.name)) {
59321
60500
  markValue[key] = value;
@@ -59324,10 +60503,44 @@ Please report this to https://github.com/markedjs/marked.`, e) {
59324
60503
  if (!listTypes.includes(node.type.name)) {
59325
60504
  markValue[key] = value;
59326
60505
  }
60506
+ } else if (key === "font-family" && node) {
60507
+ if (!listTypes.includes(node.type.name)) {
60508
+ markValue[key] = value;
60509
+ }
59327
60510
  } else if (key === "color" && node) {
59328
60511
  if (!listTypes.includes(node.type.name)) {
59329
60512
  markValue[key] = value;
59330
60513
  }
60514
+ } else if (key === "highlight" && node) {
60515
+ const hasInlineHighlight = node.marks?.some((m2) => m2.type?.name === "highlight");
60516
+ if (!listTypes.includes(node.type.name) && !hasInlineHighlight) {
60517
+ const color = typeof value === "string" ? value : value?.color;
60518
+ if (color) markValue["background-color"] = color;
60519
+ }
60520
+ } else if (key === "underline" && node) {
60521
+ const styleValRaw = value?.value ?? value ?? "";
60522
+ const styleVal = styleValRaw.toString().toLowerCase();
60523
+ const hasInlineUnderlineOff = node.marks?.some(
60524
+ (m2) => m2.type?.name === "underline" && m2.attrs?.underlineType === "none"
60525
+ );
60526
+ const hasInlineUnderlineOn = node.marks?.some(
60527
+ (m2) => m2.type?.name === "underline" && m2.attrs?.underlineType && m2.attrs.underlineType !== "none"
60528
+ );
60529
+ if (!listTypes.includes(node.type.name) && !hasInlineUnderlineOff && !hasInlineUnderlineOn) {
60530
+ if (styleVal && styleVal !== "none" && styleVal !== "0") {
60531
+ const colorVal = value && typeof value === "object" ? value.color || value.underlineColor || null : null;
60532
+ const css = getUnderlineCssString({ type: styleVal, color: colorVal });
60533
+ css.split(";").forEach((decl) => {
60534
+ const d2 = decl.trim();
60535
+ if (!d2) return;
60536
+ const idx = d2.indexOf(":");
60537
+ if (idx === -1) return;
60538
+ const k2 = d2.slice(0, idx).trim();
60539
+ const v2 = d2.slice(idx + 1).trim();
60540
+ markValue[k2] = v2;
60541
+ });
60542
+ }
60543
+ }
59331
60544
  } else if (typeof value === "string") {
59332
60545
  markValue[key] = value;
59333
60546
  }
@@ -59460,23 +60673,51 @@ Please report this to https://github.com/markedjs/marked.`, e) {
59460
60673
  };
59461
60674
  const generateDecorations = (state2, styles) => {
59462
60675
  const decorations = [];
59463
- let lastStyleId = null;
59464
60676
  const doc2 = state2?.doc;
60677
+ const getParagraphStyleId = (pos) => {
60678
+ const $pos = state2.doc.resolve(pos);
60679
+ for (let d2 = $pos.depth; d2 >= 0; d2--) {
60680
+ const n = $pos.node(d2);
60681
+ if (n?.type?.name === "paragraph") return n.attrs?.styleId || null;
60682
+ }
60683
+ return null;
60684
+ };
59465
60685
  doc2.descendants((node, pos) => {
59466
60686
  const { name } = node.type;
59467
- if (node?.attrs?.styleId) lastStyleId = node.attrs.styleId;
59468
- if (name === "paragraph" && !node.attrs?.styleId) lastStyleId = null;
59469
- if (name !== "text" && name !== "listItem" && name !== "orderedList") return;
60687
+ if (name !== "text") return;
60688
+ const paragraphStyleId = getParagraphStyleId(pos);
60689
+ let runStyleId = null;
60690
+ let inlineTextStyleId = null;
59470
60691
  for (const mark of node.marks) {
59471
- if (mark.type.name === "textStyle" && mark.attrs.styleId) {
59472
- lastStyleId = mark.attrs.styleId;
59473
- }
59474
- }
59475
- const { linkedStyle, basedOnStyle } = getLinkedStyle(lastStyleId, styles);
59476
- if (!linkedStyle) return;
60692
+ if (mark.type.name === "run") {
60693
+ const rp = mark.attrs?.runProperties;
60694
+ if (rp && typeof rp === "object" && !Array.isArray(rp) && rp.styleId) runStyleId = rp.styleId;
60695
+ else if (Array.isArray(rp)) {
60696
+ const ent = rp.find((e) => e?.xmlName === "w:rStyle");
60697
+ const sid = ent?.attributes?.["w:val"];
60698
+ if (sid) runStyleId = sid;
60699
+ }
60700
+ } else if (mark.type.name === "textStyle" && mark.attrs?.styleId) {
60701
+ inlineTextStyleId = mark.attrs.styleId;
60702
+ }
60703
+ }
60704
+ const buildStyleMap = (sid) => {
60705
+ if (!sid) return {};
60706
+ const { linkedStyle, basedOnStyle: basedOnStyle2 } = getLinkedStyle(sid, styles);
60707
+ if (!linkedStyle) return {};
60708
+ const base2 = { ...basedOnStyle2?.definition?.styles || {} };
60709
+ return { ...base2, ...linkedStyle.definition?.styles || {} };
60710
+ };
60711
+ const pMap = buildStyleMap(paragraphStyleId);
60712
+ const tMap = buildStyleMap(inlineTextStyleId);
60713
+ const rMap = buildStyleMap(runStyleId);
60714
+ const finalStyles = { ...pMap, ...tMap, ...rMap };
60715
+ if (Object.keys(finalStyles).length === 0) return;
60716
+ const mergedLinkedStyle = { definition: { styles: finalStyles, attrs: {} } };
60717
+ const basedOnStyle = null;
59477
60718
  const $pos = state2.doc.resolve(pos);
59478
60719
  const parent = $pos.parent;
59479
- const styleString = generateLinkedStyleString(linkedStyle, basedOnStyle, node, parent);
60720
+ const styleString = generateLinkedStyleString(mergedLinkedStyle, basedOnStyle, node, parent);
59480
60721
  if (!styleString) return;
59481
60722
  const decoration = Decoration.inline(pos, pos + node.nodeSize, { style: styleString });
59482
60723
  decorations.push(decoration);
@@ -59611,6 +60852,70 @@ Please report this to https://github.com/markedjs/marked.`, e) {
59611
60852
  };
59612
60853
  }
59613
60854
  });
60855
+ function getUnderlineCssString({ type: type2 = "single", color = null, thickness = null, approximate = true } = {}) {
60856
+ const parts = [];
60857
+ const add = (k, v2) => {
60858
+ if (!v2) return;
60859
+ parts.push(`${k}: ${v2}`);
60860
+ };
60861
+ const lower = String(type2 || "single").toLowerCase();
60862
+ if (lower === "none" || lower === "0") {
60863
+ add("text-decoration", "none");
60864
+ return parts.join("; ");
60865
+ }
60866
+ add("text-decoration-line", "underline");
60867
+ const HEAVY = thickness || "0.2em";
60868
+ const THICK = thickness || "0.15em";
60869
+ switch (lower) {
60870
+ case "single":
60871
+ break;
60872
+ case "double":
60873
+ add("text-decoration-style", "double");
60874
+ break;
60875
+ case "thick":
60876
+ add("text-decoration-thickness", THICK);
60877
+ break;
60878
+ case "dotted":
60879
+ add("text-decoration-style", "dotted");
60880
+ break;
60881
+ case "dash":
60882
+ case "dashed":
60883
+ add("text-decoration-style", "dashed");
60884
+ break;
60885
+ case "dotdash":
60886
+ case "dotdotdash":
60887
+ case "dashlong":
60888
+ case "dashlongheavy":
60889
+ if (approximate) {
60890
+ add("text-decoration-style", "dashed");
60891
+ if (lower.includes("heavy")) add("text-decoration-thickness", HEAVY);
60892
+ }
60893
+ break;
60894
+ case "dottedheavy":
60895
+ add("text-decoration-style", "dotted");
60896
+ add("text-decoration-thickness", HEAVY);
60897
+ break;
60898
+ case "dashedheavy":
60899
+ add("text-decoration-style", "dashed");
60900
+ add("text-decoration-thickness", HEAVY);
60901
+ break;
60902
+ case "wavy":
60903
+ add("text-decoration-style", "wavy");
60904
+ break;
60905
+ case "wavyheavy":
60906
+ add("text-decoration-style", "wavy");
60907
+ add("text-decoration-thickness", HEAVY);
60908
+ break;
60909
+ case "wavydouble":
60910
+ if (approximate) {
60911
+ add("text-decoration-style", "wavy");
60912
+ add("text-decoration-thickness", HEAVY);
60913
+ }
60914
+ break;
60915
+ }
60916
+ if (color) add("text-decoration-color", color);
60917
+ return parts.join("; ");
60918
+ }
59614
60919
  const generateOrderedListIndex = ({ listLevel, lvlText, listNumberingType, customFormat }) => {
59615
60920
  const handler2 = listIndexMap[listNumberingType];
59616
60921
  return handler2 ? handler2(listLevel, lvlText, customFormat) : null;
@@ -67896,6 +69201,30 @@ Please report this to https://github.com/markedjs/marked.`, e) {
67896
69201
  };
67897
69202
  }
67898
69203
  });
69204
+ function createCascadeToggleCommands({
69205
+ markName,
69206
+ setCommand,
69207
+ unsetCommand,
69208
+ toggleCommand,
69209
+ negationAttrs,
69210
+ isNegation,
69211
+ extendEmptyMarkRange
69212
+ } = {}) {
69213
+ if (!markName) throw new Error("createCascadeToggleCommands requires a markName");
69214
+ const capitalized = markName.charAt(0).toUpperCase() + markName.slice(1);
69215
+ const setName = setCommand ?? `set${capitalized}`;
69216
+ const unsetName = unsetCommand ?? `unset${capitalized}`;
69217
+ const toggleName = toggleCommand ?? `toggle${capitalized}`;
69218
+ const cascadeOptions = {};
69219
+ if (negationAttrs) cascadeOptions.negationAttrs = negationAttrs;
69220
+ if (typeof isNegation === "function") cascadeOptions.isNegation = isNegation;
69221
+ if (extendEmptyMarkRange !== void 0) cascadeOptions.extendEmptyMarkRange = extendEmptyMarkRange;
69222
+ return {
69223
+ [setName]: () => ({ commands: commands2 }) => commands2.setMark(markName),
69224
+ [unsetName]: () => ({ commands: commands2 }) => commands2.unsetMark(markName),
69225
+ [toggleName]: () => ({ commands: commands2 }) => commands2.toggleMarkCascade(markName, cascadeOptions)
69226
+ };
69227
+ }
67899
69228
  const Bold = Mark.create({
67900
69229
  name: "bold",
67901
69230
  addOptions() {
@@ -67930,9 +69259,18 @@ Please report this to https://github.com/markedjs/marked.`, e) {
67930
69259
  ];
67931
69260
  },
67932
69261
  renderDOM({ htmlAttributes }) {
67933
- return ["strong", Attribute.mergeAttributes(this.options.htmlAttributes, htmlAttributes), 0];
69262
+ const merged = Attribute.mergeAttributes(this.options.htmlAttributes, htmlAttributes);
69263
+ const { value, ...rest } = merged || {};
69264
+ if (value === "0") {
69265
+ return ["span", rest, 0];
69266
+ }
69267
+ return ["strong", rest, 0];
67934
69268
  },
67935
69269
  addCommands() {
69270
+ const { setBold, unsetBold, toggleBold } = createCascadeToggleCommands({
69271
+ markName: this.name,
69272
+ negationAttrs: { value: "0" }
69273
+ });
67936
69274
  return {
67937
69275
  /**
67938
69276
  * Apply bold formatting
@@ -67942,7 +69280,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
67942
69280
  * setBold()
67943
69281
  * @note '0' renders as normal weight
67944
69282
  */
67945
- setBold: () => ({ commands: commands2 }) => commands2.setMark(this.name),
69283
+ setBold,
67946
69284
  /**
67947
69285
  * Remove bold formatting
67948
69286
  * @category Command
@@ -67950,7 +69288,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
67950
69288
  * @example
67951
69289
  * unsetBold()
67952
69290
  */
67953
- unsetBold: () => ({ commands: commands2 }) => commands2.unsetMark(this.name),
69291
+ unsetBold,
67954
69292
  /**
67955
69293
  * Toggle bold formatting
67956
69294
  * @category Command
@@ -67958,7 +69296,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
67958
69296
  * @example
67959
69297
  * toggleBold()
67960
69298
  */
67961
- toggleBold: () => ({ commands: commands2 }) => commands2.toggleMark(this.name)
69299
+ toggleBold
67962
69300
  };
67963
69301
  },
67964
69302
  addShortcuts() {
@@ -67975,6 +69313,22 @@ Please report this to https://github.com/markedjs/marked.`, e) {
67975
69313
  htmlAttributes: {}
67976
69314
  };
67977
69315
  },
69316
+ addAttributes() {
69317
+ return {
69318
+ /**
69319
+ * @category Attribute
69320
+ * @param {string} [value] - Italic toggle value ('0' renders as normal)
69321
+ */
69322
+ value: {
69323
+ default: null,
69324
+ renderDOM: (attrs) => {
69325
+ if (!attrs.value) return {};
69326
+ if (attrs.value === "0") return { style: "font-style: normal" };
69327
+ return {};
69328
+ }
69329
+ }
69330
+ };
69331
+ },
67978
69332
  parseDOM() {
67979
69333
  return [
67980
69334
  { tag: "i" },
@@ -67984,9 +69338,18 @@ Please report this to https://github.com/markedjs/marked.`, e) {
67984
69338
  ];
67985
69339
  },
67986
69340
  renderDOM({ htmlAttributes }) {
67987
- return ["em", Attribute.mergeAttributes(this.options.htmlAttributes, htmlAttributes), 0];
69341
+ const merged = Attribute.mergeAttributes(this.options.htmlAttributes, htmlAttributes);
69342
+ const { value, ...rest } = merged || {};
69343
+ if (value === "0") {
69344
+ return ["span", rest, 0];
69345
+ }
69346
+ return ["em", rest, 0];
67988
69347
  },
67989
69348
  addCommands() {
69349
+ const { setItalic, unsetItalic, toggleItalic } = createCascadeToggleCommands({
69350
+ markName: this.name,
69351
+ negationAttrs: { value: "0" }
69352
+ });
67990
69353
  return {
67991
69354
  /**
67992
69355
  * Apply italic formatting
@@ -67995,7 +69358,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
67995
69358
  * @example
67996
69359
  * setItalic()
67997
69360
  */
67998
- setItalic: () => ({ commands: commands2 }) => commands2.setMark(this.name),
69361
+ setItalic,
67999
69362
  /**
68000
69363
  * Remove italic formatting
68001
69364
  * @category Command
@@ -68003,7 +69366,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
68003
69366
  * @example
68004
69367
  * unsetItalic()
68005
69368
  */
68006
- unsetItalic: () => ({ commands: commands2 }) => commands2.unsetMark(this.name),
69369
+ unsetItalic,
68007
69370
  /**
68008
69371
  * Toggle italic formatting
68009
69372
  * @category Command
@@ -68011,7 +69374,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
68011
69374
  * @example
68012
69375
  * toggleItalic()
68013
69376
  */
68014
- toggleItalic: () => ({ commands: commands2 }) => commands2.toggleMark(this.name)
69377
+ toggleItalic
68015
69378
  };
68016
69379
  },
68017
69380
  addShortcuts() {
@@ -68036,7 +69399,16 @@ Please report this to https://github.com/markedjs/marked.`, e) {
68036
69399
  ];
68037
69400
  },
68038
69401
  renderDOM({ htmlAttributes }) {
68039
- return ["u", Attribute.mergeAttributes(this.options.htmlAttributes, htmlAttributes), 0];
69402
+ const merged = Attribute.mergeAttributes(this.options.htmlAttributes, htmlAttributes);
69403
+ const type2 = merged?.underlineType;
69404
+ const color = merged?.underlineColor;
69405
+ const css = getUnderlineCssString({ type: type2, color });
69406
+ const { style: style2, ...rest } = merged || {};
69407
+ const styleString = [style2, css].filter(Boolean).join("; ");
69408
+ if (type2 === "none") {
69409
+ return ["span", { ...rest, ...styleString ? { style: styleString } : {} }, 0];
69410
+ }
69411
+ return ["u", { ...rest, ...styleString ? { style: styleString } : {} }, 0];
68040
69412
  },
68041
69413
  addAttributes() {
68042
69414
  return {
@@ -68046,10 +69418,18 @@ Please report this to https://github.com/markedjs/marked.`, e) {
68046
69418
  */
68047
69419
  underlineType: {
68048
69420
  default: "single"
69421
+ },
69422
+ underlineColor: {
69423
+ default: null
68049
69424
  }
68050
69425
  };
68051
69426
  },
68052
69427
  addCommands() {
69428
+ const { setUnderline, unsetUnderline, toggleUnderline } = createCascadeToggleCommands({
69429
+ markName: this.name,
69430
+ negationAttrs: { underlineType: "none" },
69431
+ isNegation: (attrs) => attrs?.underlineType === "none"
69432
+ });
68053
69433
  return {
68054
69434
  /**
68055
69435
  * Apply underline formatting
@@ -68058,7 +69438,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
68058
69438
  * @example
68059
69439
  * setUnderline()
68060
69440
  */
68061
- setUnderline: () => ({ commands: commands2 }) => commands2.setMark(this.name),
69441
+ setUnderline,
68062
69442
  /**
68063
69443
  * Remove underline formatting
68064
69444
  * @category Command
@@ -68066,7 +69446,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
68066
69446
  * @example
68067
69447
  * unsetUnderline()
68068
69448
  */
68069
- unsetUnderline: () => ({ commands: commands2 }) => commands2.unsetMark(this.name),
69449
+ unsetUnderline,
68070
69450
  /**
68071
69451
  * Toggle underline formatting
68072
69452
  * @category Command
@@ -68074,7 +69454,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
68074
69454
  * @example
68075
69455
  * toggleUnderline()
68076
69456
  */
68077
- toggleUnderline: () => ({ commands: commands2 }) => commands2.toggleMark(this.name)
69457
+ toggleUnderline
68078
69458
  };
68079
69459
  },
68080
69460
  addShortcuts() {
@@ -68169,9 +69549,18 @@ Please report this to https://github.com/markedjs/marked.`, e) {
68169
69549
  ];
68170
69550
  },
68171
69551
  renderDOM({ htmlAttributes }) {
68172
- return ["s", Attribute.mergeAttributes(this.options.htmlAttributes, htmlAttributes), 0];
69552
+ const merged = Attribute.mergeAttributes(this.options.htmlAttributes, htmlAttributes);
69553
+ const { value, ...rest } = merged || {};
69554
+ if (value === "0") {
69555
+ return ["span", rest, 0];
69556
+ }
69557
+ return ["s", rest, 0];
68173
69558
  },
68174
69559
  addCommands() {
69560
+ const { setStrike, unsetStrike, toggleStrike } = createCascadeToggleCommands({
69561
+ markName: this.name,
69562
+ negationAttrs: { value: "0" }
69563
+ });
68175
69564
  return {
68176
69565
  /**
68177
69566
  * Apply strikethrough formatting
@@ -68180,9 +69569,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
68180
69569
  * @example
68181
69570
  * setStrike()
68182
69571
  */
68183
- setStrike: () => ({ commands: commands2 }) => {
68184
- return commands2.setMark(this.name);
68185
- },
69572
+ setStrike,
68186
69573
  /**
68187
69574
  * Remove strikethrough formatting
68188
69575
  * @category Command
@@ -68190,9 +69577,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
68190
69577
  * @example
68191
69578
  * unsetStrike()
68192
69579
  */
68193
- unsetStrike: () => ({ commands: commands2 }) => {
68194
- return commands2.unsetMark(this.name);
68195
- },
69580
+ unsetStrike,
68196
69581
  /**
68197
69582
  * Toggle strikethrough formatting
68198
69583
  * @category Command
@@ -68200,8 +69585,24 @@ Please report this to https://github.com/markedjs/marked.`, e) {
68200
69585
  * @example
68201
69586
  * toggleStrike()
68202
69587
  */
68203
- toggleStrike: () => ({ commands: commands2 }) => {
68204
- return commands2.toggleMark(this.name);
69588
+ toggleStrike
69589
+ };
69590
+ },
69591
+ addAttributes() {
69592
+ return {
69593
+ /**
69594
+ * @category Attribute
69595
+ * @param {string} [value] - Strike toggle value ('0' renders as normal)
69596
+ */
69597
+ value: {
69598
+ default: null,
69599
+ renderDOM: (attrs) => {
69600
+ if (!attrs.value) return {};
69601
+ if (attrs.value === "0") {
69602
+ return { style: "text-decoration: none" };
69603
+ }
69604
+ return {};
69605
+ }
68205
69606
  }
68206
69607
  };
68207
69608
  },
@@ -74356,7 +75757,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
74356
75757
  Paragraph,
74357
75758
  LineBreak,
74358
75759
  HardBreak,
74359
- RunItem,
75760
+ Run,
74360
75761
  SlashMenu,
74361
75762
  Strike,
74362
75763
  TabNode,
@@ -76887,7 +78288,7 @@ ${style2}
76887
78288
  if (typeof selector === "string") {
76888
78289
  return document.querySelector(selector);
76889
78290
  }
76890
- return selector() || null;
78291
+ return selector();
76891
78292
  }
76892
78293
  const LazyTeleport$1 = /* @__PURE__ */ defineComponent({
76893
78294
  name: "LazyTeleport",
@@ -76975,11 +78376,8 @@ ${style2}
76975
78376
  };
76976
78377
  const keepOffsetDirection$1 = {
76977
78378
  top: true,
76978
- // top++
76979
78379
  bottom: false,
76980
- // top--
76981
78380
  left: true,
76982
- // left++
76983
78381
  right: false
76984
78382
  // left--
76985
78383
  };
@@ -78096,6 +79494,7 @@ ${style2}
78096
79494
  return !!element.href && element.rel !== "ignore";
78097
79495
  case "INPUT":
78098
79496
  return element.type !== "hidden" && element.type !== "file";
79497
+ case "BUTTON":
78099
79498
  case "SELECT":
78100
79499
  case "TEXTAREA":
78101
79500
  return true;
@@ -78114,8 +79513,8 @@ ${style2}
78114
79513
  default: true
78115
79514
  },
78116
79515
  onEsc: Function,
78117
- initialFocusTo: [String, Function],
78118
- finalFocusTo: [String, Function],
79516
+ initialFocusTo: String,
79517
+ finalFocusTo: String,
78119
79518
  returnFocusOnDeactivated: {
78120
79519
  type: Boolean,
78121
79520
  default: true
@@ -80213,7 +81612,6 @@ ${style2}
80213
81612
  });
80214
81613
  }
80215
81614
  const scrollbarLight$1 = {
80216
- name: "Scrollbar",
80217
81615
  common: derived$1,
80218
81616
  self: self$6$1
80219
81617
  };
@@ -81729,14 +83127,11 @@ ${style2}
81729
83127
  boxShadow: boxShadow2
81730
83128
  });
81731
83129
  }
81732
- const popoverLight$1 = createTheme$1({
83130
+ const popoverLight$1 = {
81733
83131
  name: "Popover",
81734
83132
  common: derived$1,
81735
- peers: {
81736
- Scrollbar: scrollbarLight$1
81737
- },
81738
83133
  self: self$5$1
81739
- });
83134
+ };
81740
83135
  const oppositePlacement$1 = {
81741
83136
  top: "bottom",
81742
83137
  bottom: "top",
@@ -81956,11 +83351,9 @@ ${style2}
81956
83351
  const {
81957
83352
  namespaceRef,
81958
83353
  mergedClsPrefixRef,
81959
- inlineThemeDisabled,
81960
- mergedRtlRef
83354
+ inlineThemeDisabled
81961
83355
  } = useConfig$1(props);
81962
83356
  const themeRef = useTheme$1("Popover", "-popover", style$3$1, popoverLight$1, props, mergedClsPrefixRef);
81963
- const rtlEnabledRef = useRtl$1("Popover", mergedRtlRef, mergedClsPrefixRef);
81964
83357
  const followerRef = ref$1(null);
81965
83358
  const NPopover2 = inject("NPopover");
81966
83359
  const bodyRef = ref$1(null);
@@ -82158,8 +83551,6 @@ ${style2}
82158
83551
  style: props.contentStyle
82159
83552
  }, slots);
82160
83553
  const maybeScrollableBody = props.scrollable ? h$1(XScrollbar$1, {
82161
- themeOverrides: themeRef.value.peerOverrides.Scrollbar,
82162
- theme: themeRef.value.peers.Scrollbar,
82163
83554
  contentClass: hasHeaderOrFooter ? void 0 : `${mergedClsPrefix}-popover__content ${(_b = props.contentClass) !== null && _b !== void 0 ? _b : ""}`,
82164
83555
  contentStyle: hasHeaderOrFooter ? void 0 : props.contentStyle
82165
83556
  }, {
@@ -82175,7 +83566,7 @@ ${style2}
82175
83566
  return [maybeScrollableBody, arrow2];
82176
83567
  };
82177
83568
  contentNode = h$1("div", mergeProps({
82178
- 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}`), {
83569
+ class: [`${mergedClsPrefix}-popover`, `${mergedClsPrefix}-popover-shared`, themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.themeClass.value, extraClass.map((v2) => `${mergedClsPrefix}-${v2}`), {
82179
83570
  [`${mergedClsPrefix}-popover--scrollable`]: props.scrollable,
82180
83571
  [`${mergedClsPrefix}-popover--show-header-or-footer`]: hasHeaderOrFooter,
82181
83572
  [`${mergedClsPrefix}-popover--raw`]: props.raw,
@@ -82199,7 +83590,7 @@ ${style2}
82199
83590
  // The popover class and overlap class must exists, they will be used
82200
83591
  // to place the body & transition animation.
82201
83592
  // Shadow class exists for reuse box-shadow.
82202
- [`${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`],
83593
+ [`${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`],
82203
83594
  bodyRef,
82204
83595
  styleRef.value,
82205
83596
  handleMouseEnter,
@@ -87676,10 +89067,14 @@ ${style2}
87676
89067
  * @param {string} params.argument - The color to set
87677
89068
  * @returns {void}
87678
89069
  */
87679
- setColor: ({ item, argument }) => {
87680
- __privateMethod(this, _SuperToolbar_instances, runCommandWithArgumentOnly_fn).call(this, { item, argument }, () => {
87681
- this.activeEditor?.commands.setFieldAnnotationsTextColor(argument, true);
87682
- });
89070
+ setColor: ({ argument }) => {
89071
+ if (!argument || !this.activeEditor) return;
89072
+ const isNone = argument === "none";
89073
+ const value = isNone ? "inherit" : argument;
89074
+ if (this.activeEditor?.commands?.setColor) this.activeEditor.commands.setColor(value);
89075
+ const argValue = isNone ? null : argument;
89076
+ this.activeEditor?.commands.setFieldAnnotationsTextColor(argValue, true);
89077
+ this.updateToolbarState();
87683
89078
  },
87684
89079
  /**
87685
89080
  * Sets the highlight color for text
@@ -87688,12 +89083,14 @@ ${style2}
87688
89083
  * @param {string} params.argument - The highlight color to set
87689
89084
  * @returns {void}
87690
89085
  */
87691
- setHighlight: ({ item, argument }) => {
87692
- __privateMethod(this, _SuperToolbar_instances, runCommandWithArgumentOnly_fn).call(this, { item, argument, noArgumentCallback: true }, () => {
87693
- let arg = argument !== "none" ? argument : null;
87694
- this.activeEditor?.commands.setFieldAnnotationsTextHighlight(arg, true);
87695
- this.activeEditor?.commands.setCellBackground(arg);
87696
- });
89086
+ setHighlight: ({ argument }) => {
89087
+ if (!argument || !this.activeEditor) return;
89088
+ const inlineColor = argument !== "none" ? argument : "transparent";
89089
+ if (this.activeEditor?.commands?.setHighlight) this.activeEditor.commands.setHighlight(inlineColor);
89090
+ const argValue = argument !== "none" ? argument : null;
89091
+ this.activeEditor?.commands.setFieldAnnotationsTextHighlight(argValue, true);
89092
+ this.activeEditor?.commands.setCellBackground(argValue);
89093
+ this.updateToolbarState();
87697
89094
  },
87698
89095
  /**
87699
89096
  * Toggles the ruler visibility
@@ -88060,7 +89457,6 @@ ${style2}
88060
89457
  if (!command2) {
88061
89458
  return;
88062
89459
  }
88063
- this.log("(emmitCommand) Command:", command2, "\n item:", item, "\n argument:", argument, "\n option:", option);
88064
89460
  if (command2 in __privateGet(this, _interceptedCommands)) {
88065
89461
  return __privateGet(this, _interceptedCommands)[command2]({ item, argument });
88066
89462
  }
@@ -89623,11 +91019,32 @@ ${style2}
89623
91019
  }
89624
91020
  };
89625
91021
  const SuperInput = /* @__PURE__ */ _export_sfc$1(_sfc_main$i, [["__scopeId", "data-v-4d5cff52"]]);
89626
- const registeredHandlers = Object.freeze({
89627
- "w:br": translator$j,
89628
- "w:tab": translator$i,
89629
- "w:p": translator$h
89630
- });
91022
+ const baseHandlers = {
91023
+ ...runPropertyTranslators,
91024
+ "w:br": translator$v,
91025
+ "w:cantSplit": translator$r,
91026
+ "w:cnfStyle": translator$q,
91027
+ "w:divId": translator$p,
91028
+ "w:gridAfter": translator$o,
91029
+ "w:gridBefore": translator$n,
91030
+ "w:hidden": translator$m,
91031
+ "w:hyperlink": translator$c,
91032
+ "w:jc": translator$l,
91033
+ "w:p": translator$s,
91034
+ "w:r": translator,
91035
+ "w:rPr": translator$1,
91036
+ "w:sdt": translator$b,
91037
+ "w:tab": translator$t,
91038
+ "w:tblCellSpacing": translator$k,
91039
+ "w:tblHeader": translator$j,
91040
+ "w:tc": translator$d,
91041
+ "w:tr": translator$e,
91042
+ "w:trHeight": translator$i,
91043
+ "w:trPr": translator$f,
91044
+ "w:wAfter": translator$h,
91045
+ "w:wBefore": translator$g
91046
+ };
91047
+ const registeredHandlers = Object.freeze(baseHandlers);
89631
91048
  const Extensions = {
89632
91049
  Node: Node$1,
89633
91050
  Attribute,
@@ -93016,7 +94433,6 @@ ${reason}`);
93016
94433
  }
93017
94434
  debounceTimers[commentId] = setTimeout(() => {
93018
94435
  if (superdoc2) {
93019
- if (__IS_DEBUG__) console.debug("[debounceEmit] tracked change update emitting...", event);
93020
94436
  superdoc2.emit("comments-update", event);
93021
94437
  }
93022
94438
  delete debounceTimers[commentId];
@@ -93024,7 +94440,6 @@ ${reason}`);
93024
94440
  };
93025
94441
  const showAddComment = (superdoc2) => {
93026
94442
  const event = { type: COMMENT_EVENTS.PENDING };
93027
- if (__IS_DEBUG__) console.debug("[showAddComment] emitting...", event);
93028
94443
  superdoc2.emit("comments-update", event);
93029
94444
  const selection = { ...superdocStore.activeSelection };
93030
94445
  selection.selectionBounds = { ...selection.selectionBounds };
@@ -93125,7 +94540,6 @@ ${reason}`);
93125
94540
  }
93126
94541
  const event = { type: COMMENT_EVENTS.ADD, comment: newComment.getValues() };
93127
94542
  syncCommentsToClients(superdoc2, event);
93128
- if (__IS_DEBUG__) console.debug("[addComment] emitting...", event);
93129
94543
  superdoc2.emit("comments-update", event);
93130
94544
  };
93131
94545
  const deleteComment = ({ commentId: commentIdToDelete, superdoc: superdoc2 }) => {
@@ -93142,7 +94556,6 @@ ${reason}`);
93142
94556
  comment: comment.getValues(),
93143
94557
  changes: [{ key: "deleted", commentId, fileId }]
93144
94558
  };
93145
- if (__IS_DEBUG__) console.debug("[deleteComment] emitting...", event);
93146
94559
  superdoc2.emit("comments-update", event);
93147
94560
  syncCommentsToClients(superdoc2, event);
93148
94561
  };
@@ -93151,7 +94564,6 @@ ${reason}`);
93151
94564
  };
93152
94565
  const processLoadedDocxComments = async ({ superdoc: superdoc2, editor, comments, documentId }) => {
93153
94566
  const document2 = superdocStore.getDocument(documentId);
93154
- if (__IS_DEBUG__) console.debug("[processLoadedDocxComments] processing comments...", comments);
93155
94567
  comments.forEach((comment) => {
93156
94568
  const htmlContent = getHTmlFromComment(comment.textJson);
93157
94569
  if (!htmlContent && !comment.trackedChange) {
@@ -95325,7 +96737,7 @@ ${style2}
95325
96737
  if (typeof selector === "string") {
95326
96738
  return document.querySelector(selector);
95327
96739
  }
95328
- return selector() || null;
96740
+ return selector();
95329
96741
  }
95330
96742
  const LazyTeleport = /* @__PURE__ */ defineComponent({
95331
96743
  name: "LazyTeleport",
@@ -95413,11 +96825,8 @@ ${style2}
95413
96825
  };
95414
96826
  const keepOffsetDirection = {
95415
96827
  top: true,
95416
- // top++
95417
96828
  bottom: false,
95418
- // top--
95419
96829
  left: true,
95420
- // left++
95421
96830
  right: false
95422
96831
  // left--
95423
96832
  };
@@ -96534,6 +97943,7 @@ ${style2}
96534
97943
  return !!element.href && element.rel !== "ignore";
96535
97944
  case "INPUT":
96536
97945
  return element.type !== "hidden" && element.type !== "file";
97946
+ case "BUTTON":
96537
97947
  case "SELECT":
96538
97948
  case "TEXTAREA":
96539
97949
  return true;
@@ -96552,8 +97962,8 @@ ${style2}
96552
97962
  default: true
96553
97963
  },
96554
97964
  onEsc: Function,
96555
- initialFocusTo: [String, Function],
96556
- finalFocusTo: [String, Function],
97965
+ initialFocusTo: String,
97966
+ finalFocusTo: String,
96557
97967
  returnFocusOnDeactivated: {
96558
97968
  type: Boolean,
96559
97969
  default: true
@@ -99328,7 +100738,6 @@ ${style2}
99328
100738
  });
99329
100739
  }
99330
100740
  const scrollbarLight = {
99331
- name: "Scrollbar",
99332
100741
  common: derived,
99333
100742
  self: self$7
99334
100743
  };
@@ -100833,14 +102242,11 @@ ${style2}
100833
102242
  boxShadow: boxShadow2
100834
102243
  });
100835
102244
  }
100836
- const popoverLight = createTheme({
102245
+ const popoverLight = {
100837
102246
  name: "Popover",
100838
102247
  common: derived,
100839
- peers: {
100840
- Scrollbar: scrollbarLight
100841
- },
100842
102248
  self: self$6
100843
- });
102249
+ };
100844
102250
  const oppositePlacement = {
100845
102251
  top: "bottom",
100846
102252
  bottom: "top",
@@ -101060,11 +102466,9 @@ ${style2}
101060
102466
  const {
101061
102467
  namespaceRef,
101062
102468
  mergedClsPrefixRef,
101063
- inlineThemeDisabled,
101064
- mergedRtlRef
102469
+ inlineThemeDisabled
101065
102470
  } = useConfig(props);
101066
102471
  const themeRef = useTheme("Popover", "-popover", style$5, popoverLight, props, mergedClsPrefixRef);
101067
- const rtlEnabledRef = useRtl("Popover", mergedRtlRef, mergedClsPrefixRef);
101068
102472
  const followerRef = ref$1(null);
101069
102473
  const NPopover2 = inject("NPopover");
101070
102474
  const bodyRef = ref$1(null);
@@ -101262,8 +102666,6 @@ ${style2}
101262
102666
  style: props.contentStyle
101263
102667
  }, slots);
101264
102668
  const maybeScrollableBody = props.scrollable ? h$1(XScrollbar, {
101265
- themeOverrides: themeRef.value.peerOverrides.Scrollbar,
101266
- theme: themeRef.value.peers.Scrollbar,
101267
102669
  contentClass: hasHeaderOrFooter ? void 0 : `${mergedClsPrefix}-popover__content ${(_b = props.contentClass) !== null && _b !== void 0 ? _b : ""}`,
101268
102670
  contentStyle: hasHeaderOrFooter ? void 0 : props.contentStyle
101269
102671
  }, {
@@ -101279,7 +102681,7 @@ ${style2}
101279
102681
  return [maybeScrollableBody, arrow2];
101280
102682
  };
101281
102683
  contentNode = h$1("div", mergeProps({
101282
- 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}`), {
102684
+ class: [`${mergedClsPrefix}-popover`, `${mergedClsPrefix}-popover-shared`, themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.themeClass.value, extraClass.map((v2) => `${mergedClsPrefix}-${v2}`), {
101283
102685
  [`${mergedClsPrefix}-popover--scrollable`]: props.scrollable,
101284
102686
  [`${mergedClsPrefix}-popover--show-header-or-footer`]: hasHeaderOrFooter,
101285
102687
  [`${mergedClsPrefix}-popover--raw`]: props.raw,
@@ -101303,7 +102705,7 @@ ${style2}
101303
102705
  // The popover class and overlap class must exists, they will be used
101304
102706
  // to place the body & transition animation.
101305
102707
  // Shadow class exists for reuse box-shadow.
101306
- [`${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`],
102708
+ [`${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`],
101307
102709
  bodyRef,
101308
102710
  styleRef.value,
101309
102711
  handleMouseEnter,
@@ -103728,8 +105130,7 @@ ${style2}
103728
105130
  closeIconColorPressedLoading: closeIconColorPressed,
103729
105131
  loadingColor: primaryColor,
103730
105132
  lineHeight: lineHeight2,
103731
- borderRadius,
103732
- border: "0"
105133
+ borderRadius
103733
105134
  });
103734
105135
  }
103735
105136
  const messageLight = {
@@ -103780,7 +105181,6 @@ ${style2}
103780
105181
  margin-bottom .3s var(--n-bezier);
103781
105182
  padding: var(--n-padding);
103782
105183
  border-radius: var(--n-border-radius);
103783
- border: var(--n-border);
103784
105184
  flex-wrap: nowrap;
103785
105185
  overflow: hidden;
103786
105186
  max-width: var(--n-max-width);
@@ -103899,7 +105299,6 @@ ${style2}
103899
105299
  fontSize: fontSize2,
103900
105300
  lineHeight: lineHeight2,
103901
105301
  borderRadius,
103902
- border,
103903
105302
  iconColorInfo,
103904
105303
  iconColorSuccess,
103905
105304
  iconColorWarning,
@@ -103943,8 +105342,7 @@ ${style2}
103943
105342
  "--n-close-icon-color-pressed": closeIconColorPressed,
103944
105343
  "--n-close-icon-color-hover": closeIconColorHover,
103945
105344
  "--n-line-height": lineHeight2,
103946
- "--n-border-radius": borderRadius,
103947
- "--n-border": border
105345
+ "--n-border-radius": borderRadius
103948
105346
  };
103949
105347
  });
103950
105348
  const themeClassHandle = inlineThemeDisabled ? useThemeClass("message", computed(() => props.type[0]), cssVarsRef, {}) : void 0;
@@ -106905,7 +108303,7 @@ ${style2}
106905
108303
  this.config.colors = shuffleArray(this.config.colors);
106906
108304
  this.userColorMap = /* @__PURE__ */ new Map();
106907
108305
  this.colorIndex = 0;
106908
- this.version = "0.20.1";
108306
+ this.version = "0.21.0-RC1";
106909
108307
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
106910
108308
  this.superdocId = config2.superdocId || v4();
106911
108309
  this.colors = this.config.colors;