@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
@@ -14894,25 +14894,47 @@ const getContentTypesFromXml = (contentTypesXml) => {
14894
14894
  const defaults = xmlDoc.querySelectorAll("Default");
14895
14895
  return Array.from(defaults).map((item) => item.getAttribute("Extension"));
14896
14896
  };
14897
+ const DOCX_HIGHLIGHT_KEYWORD_MAP = /* @__PURE__ */ new Map([
14898
+ ["yellow", "FFFF00"],
14899
+ ["green", "00FF00"],
14900
+ ["blue", "0000FF"],
14901
+ ["cyan", "00FFFF"],
14902
+ ["magenta", "FF00FF"],
14903
+ ["red", "FF0000"],
14904
+ ["darkYellow", "808000"],
14905
+ ["darkGreen", "008000"],
14906
+ ["darkBlue", "000080"],
14907
+ ["darkCyan", "008080"],
14908
+ ["darkMagenta", "800080"],
14909
+ ["darkGray", "808080"],
14910
+ ["darkRed", "800000"],
14911
+ ["lightGray", "C0C0C0"],
14912
+ ["black", "000000"],
14913
+ ["white", "FFFFFF"]
14914
+ ]);
14915
+ const normalizeHexColor = (hex2) => {
14916
+ if (!hex2) return null;
14917
+ let value = hex2.replace("#", "").trim();
14918
+ if (!value) return null;
14919
+ value = value.toUpperCase();
14920
+ if (value.length === 3)
14921
+ value = value.split("").map((c2) => c2 + c2).join("");
14922
+ if (value.length === 8) value = value.slice(0, 6);
14923
+ return value;
14924
+ };
14897
14925
  const getHexColorFromDocxSystem = (docxColor) => {
14898
- const colorMap = /* @__PURE__ */ new Map([
14899
- ["yellow", "#ffff00"],
14900
- ["green", "#00ff00"],
14901
- ["blue", "#0000FFFF"],
14902
- ["cyan", "#00ffff"],
14903
- ["magenta", "#ff00ff"],
14904
- ["red", "#ff0000"],
14905
- ["darkYellow", "#808000FF"],
14906
- ["darkGreen", "#008000FF"],
14907
- ["darkBlue", "#000080"],
14908
- ["darkCyan", "#008080FF"],
14909
- ["darkMagenta", "#800080FF"],
14910
- ["darkGray", "#808080FF"],
14911
- ["darkRed", "#800000FF"],
14912
- ["lightGray", "#C0C0C0FF"],
14913
- ["black", "#000"]
14914
- ]);
14915
- return colorMap.get(docxColor) || null;
14926
+ const hex2 = DOCX_HIGHLIGHT_KEYWORD_MAP.get(docxColor);
14927
+ return hex2 ? `#${hex2}` : null;
14928
+ };
14929
+ const getDocxHighlightKeywordFromHex = (hexColor) => {
14930
+ if (!hexColor) return null;
14931
+ if (DOCX_HIGHLIGHT_KEYWORD_MAP.has(hexColor)) return hexColor;
14932
+ const normalized = normalizeHexColor(hexColor);
14933
+ if (!normalized) return null;
14934
+ for (const [keyword, hex2] of DOCX_HIGHLIGHT_KEYWORD_MAP.entries()) {
14935
+ if (hex2 === normalized) return keyword;
14936
+ }
14937
+ return null;
14916
14938
  };
14917
14939
  function isValidHexColor(color) {
14918
14940
  if (!color || typeof color !== "string") return false;
@@ -24193,18 +24215,6 @@ const baseNumbering = {
24193
24215
  }
24194
24216
  ]
24195
24217
  };
24196
- const sanitizeDocxMediaName = (value, fallback = "image") => {
24197
- if (!value) return fallback;
24198
- const sanitized = value.replace(/[^a-zA-Z0-9_-]/g, "_");
24199
- return sanitized || fallback;
24200
- };
24201
- const getFallbackImageNameFromDataUri = (src = "", fallback = "image") => {
24202
- if (!src || typeof src !== "string") return fallback;
24203
- const [prefix2] = src.split(";");
24204
- const [, maybeType] = prefix2.split("/");
24205
- const extension = maybeType?.toLowerCase();
24206
- return extension ? `${fallback}.${extension}` : fallback;
24207
- };
24208
24218
  const TranslatorTypes = Object.freeze({
24209
24219
  NODE: "node",
24210
24220
  ATTRIBUTE: "attribute"
@@ -24325,37 +24335,37 @@ const _NodeTranslator = class _NodeTranslator2 {
24325
24335
  };
24326
24336
  __publicField$2(_NodeTranslator, "translatorTypes", TranslatorTypes);
24327
24337
  let NodeTranslator = _NodeTranslator;
24328
- const encode$j = (attributes) => {
24338
+ const encode$T = (attributes) => {
24329
24339
  return attributes["w:type"];
24330
24340
  };
24331
- const decode$j = (attrs) => {
24341
+ const decode$K = (attrs) => {
24332
24342
  const { lineBreakType } = attrs;
24333
24343
  return lineBreakType;
24334
24344
  };
24335
- const attrConfig$b = Object.freeze({
24345
+ const attrConfig$z = Object.freeze({
24336
24346
  xmlName: "w:type",
24337
24347
  sdName: "lineBreakType",
24338
- encode: encode$j,
24339
- decode: decode$j
24348
+ encode: encode$T,
24349
+ decode: decode$K
24340
24350
  });
24341
- const encode$i = (attributes) => {
24351
+ const encode$S = (attributes) => {
24342
24352
  const xmlAttrValue = attributes["w:clear"];
24343
24353
  return xmlAttrValue;
24344
24354
  };
24345
- const decode$i = (attrs) => {
24355
+ const decode$J = (attrs) => {
24346
24356
  const { clear } = attrs;
24347
24357
  return clear;
24348
24358
  };
24349
- const attrConfig$a = Object.freeze({
24359
+ const attrConfig$y = Object.freeze({
24350
24360
  xmlName: "w:clear",
24351
24361
  sdName: "clear",
24352
- encode: encode$i,
24353
- decode: decode$i
24362
+ encode: encode$S,
24363
+ decode: decode$J
24354
24364
  });
24355
- const validXmlAttributes$6 = [attrConfig$b, attrConfig$a];
24356
- const XML_NODE_NAME$7 = "w:br";
24365
+ const validXmlAttributes$h = [attrConfig$z, attrConfig$y];
24366
+ const XML_NODE_NAME$j = "w:br";
24357
24367
  const SD_NODE_NAME$6 = "lineBreak";
24358
- const encode$h = (_2, encodedAttrs) => {
24368
+ const encode$R = (_2, encodedAttrs) => {
24359
24369
  const isPageBreak = encodedAttrs?.lineBreakType === "page";
24360
24370
  const translated = {
24361
24371
  type: isPageBreak ? "hardBreak" : "lineBreak"
@@ -24365,7 +24375,7 @@ const encode$h = (_2, encodedAttrs) => {
24365
24375
  }
24366
24376
  return translated;
24367
24377
  };
24368
- const decode$h = (params2, decodedAttrs) => {
24378
+ const decode$I = (params2, decodedAttrs) => {
24369
24379
  const { node } = params2;
24370
24380
  if (!node) return;
24371
24381
  const wBreak = { name: "w:br" };
@@ -24382,63 +24392,120 @@ const decode$h = (params2, decodedAttrs) => {
24382
24392
  };
24383
24393
  return translated;
24384
24394
  };
24385
- const config$7 = {
24386
- xmlName: XML_NODE_NAME$7,
24395
+ const config$j = {
24396
+ xmlName: XML_NODE_NAME$j,
24387
24397
  sdNodeOrKeyName: SD_NODE_NAME$6,
24388
24398
  type: NodeTranslator.translatorTypes.NODE,
24389
- encode: encode$h,
24390
- decode: decode$h,
24391
- attributes: validXmlAttributes$6
24399
+ encode: encode$R,
24400
+ decode: decode$I,
24401
+ attributes: validXmlAttributes$h
24402
+ };
24403
+ const translator$v = NodeTranslator.from(config$j);
24404
+ const encode$Q = (attributes) => attributes?.["w:val"];
24405
+ const decode$H = (attrs) => attrs?.highlight;
24406
+ const attrConfig$x = Object.freeze({
24407
+ xmlName: "w:val",
24408
+ sdName: "highlight",
24409
+ encode: encode$Q,
24410
+ decode: decode$H
24411
+ });
24412
+ const validXmlAttributes$g = [attrConfig$x];
24413
+ const XML_NODE_NAME$i = "w:highlight";
24414
+ const SD_ATTR_KEY$b = "highlight";
24415
+ const encode$P = (params2, encodedAttrs = {}) => {
24416
+ const { nodes } = params2;
24417
+ const node = nodes?.[0];
24418
+ const value = encodedAttrs.highlight ?? node?.attributes?.["w:val"];
24419
+ return {
24420
+ type: "attr",
24421
+ xmlName: XML_NODE_NAME$i,
24422
+ sdNodeOrKeyName: SD_ATTR_KEY$b,
24423
+ attributes: { "w:val": value ?? null }
24424
+ };
24425
+ };
24426
+ const decode$G = (params2) => {
24427
+ const attrs = params2?.node?.attrs || {};
24428
+ const highlightValue = attrs.highlight ?? attrs.color ?? null;
24429
+ if (!highlightValue) return void 0;
24430
+ const normalizedValue = String(highlightValue).trim().toLowerCase();
24431
+ if (!normalizedValue || normalizedValue === "transparent" || normalizedValue === "none") {
24432
+ return void 0;
24433
+ }
24434
+ const keyword = getDocxHighlightKeywordFromHex(highlightValue);
24435
+ if (keyword) {
24436
+ return {
24437
+ name: XML_NODE_NAME$i,
24438
+ attributes: { "w:val": keyword }
24439
+ };
24440
+ }
24441
+ const fill = normalizeHexColor(highlightValue);
24442
+ if (!fill) return void 0;
24443
+ return {
24444
+ name: "w:shd",
24445
+ attributes: {
24446
+ "w:color": "auto",
24447
+ "w:val": "clear",
24448
+ "w:fill": fill
24449
+ }
24450
+ };
24451
+ };
24452
+ const config$i = {
24453
+ xmlName: XML_NODE_NAME$i,
24454
+ sdNodeOrKeyName: SD_ATTR_KEY$b,
24455
+ type: NodeTranslator.translatorTypes.ATTRIBUTE,
24456
+ encode: encode$P,
24457
+ decode: decode$G,
24458
+ attributes: validXmlAttributes$g
24392
24459
  };
24393
- const translator$j = NodeTranslator.from(config$7);
24394
- const encode$g = (attributes) => {
24460
+ const translator$u = NodeTranslator.from(config$i);
24461
+ const encode$O = (attributes) => {
24395
24462
  return attributes["w:val"];
24396
24463
  };
24397
- const decode$g = (attrs) => {
24464
+ const decode$F = (attrs) => {
24398
24465
  const { tabSize } = attrs || {};
24399
24466
  return tabSize;
24400
24467
  };
24401
- const attrConfig$9 = Object.freeze({
24468
+ const attrConfig$w = Object.freeze({
24402
24469
  xmlName: "w:val",
24403
24470
  sdName: "tabSize",
24404
- encode: encode$g,
24405
- decode: decode$g
24471
+ encode: encode$O,
24472
+ decode: decode$F
24406
24473
  });
24407
- const encode$f = (attributes) => {
24474
+ const encode$N = (attributes) => {
24408
24475
  return attributes["w:leader"];
24409
24476
  };
24410
- const decode$f = (attrs) => {
24477
+ const decode$E = (attrs) => {
24411
24478
  const { leader } = attrs || {};
24412
24479
  return leader;
24413
24480
  };
24414
- const attrConfig$8 = Object.freeze({
24481
+ const attrConfig$v = Object.freeze({
24415
24482
  xmlName: "w:leader",
24416
24483
  sdName: "leader",
24417
- encode: encode$f,
24418
- decode: decode$f
24484
+ encode: encode$N,
24485
+ decode: decode$E
24419
24486
  });
24420
- const encode$e = (attributes) => {
24487
+ const encode$M = (attributes) => {
24421
24488
  return attributes["w:pos"];
24422
24489
  };
24423
- const decode$e = (attrs) => {
24490
+ const decode$D = (attrs) => {
24424
24491
  const { pos } = attrs || {};
24425
24492
  return pos;
24426
24493
  };
24427
- const attrConfig$7 = Object.freeze({
24494
+ const attrConfig$u = Object.freeze({
24428
24495
  xmlName: "w:pos",
24429
24496
  sdName: "pos",
24430
- encode: encode$e,
24431
- decode: decode$e
24497
+ encode: encode$M,
24498
+ decode: decode$D
24432
24499
  });
24433
- const validXmlAttributes$5 = [attrConfig$9, attrConfig$7, attrConfig$8];
24434
- const XML_NODE_NAME$6 = "w:tab";
24500
+ const validXmlAttributes$f = [attrConfig$w, attrConfig$u, attrConfig$v];
24501
+ const XML_NODE_NAME$h = "w:tab";
24435
24502
  const SD_NODE_NAME$5 = "tab";
24436
- const encode$d = (_2, encodedAttrs = {}) => {
24503
+ const encode$L = (_2, encodedAttrs = {}) => {
24437
24504
  const translated = { type: "tab" };
24438
24505
  if (encodedAttrs) translated.attrs = { ...encodedAttrs };
24439
24506
  return translated;
24440
24507
  };
24441
- const decode$d = (params2, decodedAttrs = {}) => {
24508
+ const decode$C = (params2, decodedAttrs = {}) => {
24442
24509
  const { node } = params2 || {};
24443
24510
  if (!node) return;
24444
24511
  const wTab = { name: "w:tab" };
@@ -24454,15 +24521,15 @@ const decode$d = (params2, decodedAttrs = {}) => {
24454
24521
  }
24455
24522
  return translated;
24456
24523
  };
24457
- const config$6 = {
24458
- xmlName: XML_NODE_NAME$6,
24524
+ const config$h = {
24525
+ xmlName: XML_NODE_NAME$h,
24459
24526
  sdNodeOrKeyName: SD_NODE_NAME$5,
24460
24527
  type: NodeTranslator.translatorTypes.NODE,
24461
- encode: encode$d,
24462
- decode: decode$d,
24463
- attributes: validXmlAttributes$5
24528
+ encode: encode$L,
24529
+ decode: decode$C,
24530
+ attributes: validXmlAttributes$f
24464
24531
  };
24465
- const translator$i = NodeTranslator.from(config$6);
24532
+ const translator$t = NodeTranslator.from(config$h);
24466
24533
  const mergeTextNodes = (nodes) => {
24467
24534
  if (!nodes || !Array.isArray(nodes)) {
24468
24535
  return nodes;
@@ -24637,17 +24704,21 @@ function getMarkValue(markType, attributes, docx) {
24637
24704
  function getFontFamilyValue(attributes, docx) {
24638
24705
  const ascii = attributes["w:ascii"];
24639
24706
  const themeAscii = attributes["w:asciiTheme"];
24640
- if (!docx || !themeAscii) return ascii;
24641
- const theme = docx["word/theme/theme1.xml"];
24642
- if (!theme) return ascii;
24643
- const { elements: topElements } = theme;
24644
- const { elements } = topElements[0];
24645
- const themeElements = elements.find((el) => el.name === "a:themeElements");
24646
- const fontScheme = themeElements.elements.find((el) => el.name === "a:fontScheme");
24647
- const majorFont = fontScheme.elements.find((el) => el.name === "a:majorFont");
24648
- const latin = majorFont.elements.find((el) => el.name === "a:latin");
24649
- const typeface = latin.attributes["typeface"];
24650
- return typeface;
24707
+ let resolved = ascii;
24708
+ if (docx && themeAscii) {
24709
+ const theme = docx["word/theme/theme1.xml"];
24710
+ if (theme?.elements?.length) {
24711
+ const { elements: topElements } = theme;
24712
+ const { elements } = topElements[0] || {};
24713
+ const themeElements = elements?.find((el) => el.name === "a:themeElements");
24714
+ const fontScheme = themeElements?.elements?.find((el) => el.name === "a:fontScheme");
24715
+ const majorFont = fontScheme?.elements?.find((el) => el.name === "a:majorFont");
24716
+ const latin = majorFont?.elements?.find((el) => el.name === "a:latin");
24717
+ resolved = latin?.attributes?.typeface || resolved;
24718
+ }
24719
+ }
24720
+ if (!resolved) return null;
24721
+ return SuperConverter.toCssFontFamily(resolved, docx);
24651
24722
  }
24652
24723
  function getIndentValue(attributes) {
24653
24724
  let value = attributes["w:left"];
@@ -24668,7 +24739,11 @@ function getHighLightValue(attributes) {
24668
24739
  return getHexColorFromDocxSystem(attributes?.["w:val"]) || null;
24669
24740
  }
24670
24741
  function getStrikeValue(attributes) {
24671
- return attributes?.["w:val"] === "1" ? attributes["w:val"] : null;
24742
+ const raw = attributes?.["w:val"];
24743
+ if (raw === void 0 || raw === null) return "1";
24744
+ const value = String(raw).trim().toLowerCase();
24745
+ if (value === "1" || value === "true" || value === "on") return "1";
24746
+ return null;
24672
24747
  }
24673
24748
  const parseParagraphBorders = (pBdr) => {
24674
24749
  if (!pBdr || !pBdr.elements) return {};
@@ -25032,102 +25107,102 @@ const handleParagraphNode$1 = (params2) => {
25032
25107
  }
25033
25108
  return schemaNode;
25034
25109
  };
25035
- const encode$c = (attributes) => {
25110
+ const encode$K = (attributes) => {
25036
25111
  return attributes["w:rsidDel"];
25037
25112
  };
25038
- const decode$c = (attrs) => {
25113
+ const decode$B = (attrs) => {
25039
25114
  return attrs.rsidDel;
25040
25115
  };
25041
- const attrConfig$6 = Object.freeze({
25116
+ const attrConfig$t = Object.freeze({
25042
25117
  xmlName: "w:rsidDel",
25043
25118
  sdName: "rsidDel",
25044
- encode: encode$c,
25045
- decode: decode$c
25119
+ encode: encode$K,
25120
+ decode: decode$B
25046
25121
  });
25047
- const encode$b = (attributes) => {
25122
+ const encode$J = (attributes) => {
25048
25123
  return attributes["w:rsidP"];
25049
25124
  };
25050
- const decode$b = (attrs) => {
25125
+ const decode$A = (attrs) => {
25051
25126
  return attrs.rsidP;
25052
25127
  };
25053
- const attrConfig$5 = Object.freeze({
25128
+ const attrConfig$s = Object.freeze({
25054
25129
  xmlName: "w:rsidP",
25055
25130
  sdName: "rsidP",
25056
- encode: encode$b,
25057
- decode: decode$b
25131
+ encode: encode$J,
25132
+ decode: decode$A
25058
25133
  });
25059
- const encode$a = (attributes) => {
25134
+ const encode$I = (attributes) => {
25060
25135
  return attributes["w:rsidR"];
25061
25136
  };
25062
- const decode$a = (attrs) => {
25137
+ const decode$z = (attrs) => {
25063
25138
  return attrs.rsidR;
25064
25139
  };
25065
- const attrConfig$4 = Object.freeze({
25140
+ const attrConfig$r = Object.freeze({
25066
25141
  xmlName: "w:rsidR",
25067
25142
  sdName: "rsidR",
25068
- encode: encode$a,
25069
- decode: decode$a
25143
+ encode: encode$I,
25144
+ decode: decode$z
25070
25145
  });
25071
- const encode$9 = (attributes) => {
25146
+ const encode$H = (attributes) => {
25072
25147
  return attributes["w:rsidRPr"];
25073
25148
  };
25074
- const decode$9 = (attrs) => {
25149
+ const decode$y = (attrs) => {
25075
25150
  return attrs.rsidRPr;
25076
25151
  };
25077
- const attrConfig$3 = Object.freeze({
25152
+ const attrConfig$q = Object.freeze({
25078
25153
  xmlName: "w:rsidRPr",
25079
25154
  sdName: "rsidRPr",
25080
- encode: encode$9,
25081
- decode: decode$9
25155
+ encode: encode$H,
25156
+ decode: decode$y
25082
25157
  });
25083
- const encode$8 = (attributes) => {
25158
+ const encode$G = (attributes) => {
25084
25159
  return attributes["w:rsidRDefault"];
25085
25160
  };
25086
- const decode$8 = (attrs) => {
25161
+ const decode$x = (attrs) => {
25087
25162
  return attrs.rsidRDefault;
25088
25163
  };
25089
- const attrConfig$2 = Object.freeze({
25164
+ const attrConfig$p = Object.freeze({
25090
25165
  xmlName: "w:rsidRDefault",
25091
25166
  sdName: "rsidRDefault",
25092
- encode: encode$8,
25093
- decode: decode$8
25167
+ encode: encode$G,
25168
+ decode: decode$x
25094
25169
  });
25095
- const encode$7 = (attributes) => {
25170
+ const encode$F = (attributes) => {
25096
25171
  return attributes["w14:paraId"];
25097
25172
  };
25098
- const decode$7 = (attrs) => {
25173
+ const decode$w = (attrs) => {
25099
25174
  return attrs.paraId;
25100
25175
  };
25101
- const attrConfig$1 = Object.freeze({
25176
+ const attrConfig$o = Object.freeze({
25102
25177
  xmlName: "w14:paraId",
25103
25178
  sdName: "paraId",
25104
- encode: encode$7,
25105
- decode: decode$7
25179
+ encode: encode$F,
25180
+ decode: decode$w
25106
25181
  });
25107
- const encode$6 = (attributes) => {
25182
+ const encode$E = (attributes) => {
25108
25183
  return attributes["w14:textId"];
25109
25184
  };
25110
- const decode$6 = (attrs) => {
25185
+ const decode$v = (attrs) => {
25111
25186
  return attrs.textId;
25112
25187
  };
25113
- const attrConfig = Object.freeze({
25188
+ const attrConfig$n = Object.freeze({
25114
25189
  xmlName: "w14:textId",
25115
25190
  sdName: "textId",
25116
- encode: encode$6,
25117
- decode: decode$6
25191
+ encode: encode$E,
25192
+ decode: decode$v
25118
25193
  });
25119
- const validXmlAttributes$4 = [
25120
- attrConfig$1,
25121
- attrConfig,
25122
- attrConfig$4,
25123
- attrConfig$2,
25124
- attrConfig$5,
25125
- attrConfig$3,
25126
- attrConfig$6
25194
+ const validXmlAttributes$e = [
25195
+ attrConfig$o,
25196
+ attrConfig$n,
25197
+ attrConfig$r,
25198
+ attrConfig$p,
25199
+ attrConfig$s,
25200
+ attrConfig$q,
25201
+ attrConfig$t
25127
25202
  ];
25128
- const XML_NODE_NAME$5 = "w:p";
25203
+ const XML_NODE_NAME$g = "w:p";
25129
25204
  const SD_NODE_NAME$4 = "paragraph";
25130
- const encode$5 = (params2, encodedAttrs = {}) => {
25205
+ const encode$D = (params2, encodedAttrs = {}) => {
25131
25206
  const node = handleParagraphNode$1(params2);
25132
25207
  if (!node) return void 0;
25133
25208
  if (encodedAttrs && Object.keys(encodedAttrs).length) {
@@ -25135,7 +25210,7 @@ const encode$5 = (params2, encodedAttrs = {}) => {
25135
25210
  }
25136
25211
  return node;
25137
25212
  };
25138
- const decode$5 = (params2, decodedAttrs = {}) => {
25213
+ const decode$u = (params2, decodedAttrs = {}) => {
25139
25214
  const translated = translateParagraphNode(params2);
25140
25215
  if (!translated) return void 0;
25141
25216
  if (decodedAttrs && Object.keys(decodedAttrs).length) {
@@ -25143,15 +25218,15 @@ const decode$5 = (params2, decodedAttrs = {}) => {
25143
25218
  }
25144
25219
  return translated;
25145
25220
  };
25146
- const config$5 = {
25147
- xmlName: XML_NODE_NAME$5,
25221
+ const config$g = {
25222
+ xmlName: XML_NODE_NAME$g,
25148
25223
  sdNodeOrKeyName: SD_NODE_NAME$4,
25149
25224
  type: NodeTranslator.translatorTypes.NODE,
25150
- encode: encode$5,
25151
- decode: decode$5,
25152
- attributes: validXmlAttributes$4
25225
+ encode: encode$D,
25226
+ decode: decode$u,
25227
+ attributes: validXmlAttributes$e
25153
25228
  };
25154
- const translator$h = NodeTranslator.from(config$5);
25229
+ const translator$s = NodeTranslator.from(config$g);
25155
25230
  const generateV2HandlerEntity = (handlerName, translator2) => ({
25156
25231
  handlerName,
25157
25232
  handler: (params2) => {
@@ -25258,13 +25333,13 @@ const integerToString = (value) => {
25258
25333
  const intValue = parseInteger(value);
25259
25334
  return intValue != void 0 ? String(intValue) : void 0;
25260
25335
  };
25261
- const translator$g = NodeTranslator.from({
25336
+ const translator$r = NodeTranslator.from({
25262
25337
  xmlName: "w:cantSplit",
25263
25338
  sdNodeOrKeyName: "cantSplit",
25264
25339
  encode: ({ nodes }) => ["1", "true"].includes(nodes[0].attributes?.["w:val"] ?? "1"),
25265
25340
  decode: ({ node }) => node.attrs?.cantSplit ? {} : void 0
25266
25341
  });
25267
- const translator$f = NodeTranslator.from({
25342
+ const translator$q = NodeTranslator.from({
25268
25343
  xmlName: "w:cnfStyle",
25269
25344
  sdNodeOrKeyName: "cnfStyle",
25270
25345
  attributes: [
@@ -25297,8 +25372,8 @@ const translator$f = NodeTranslator.from({
25297
25372
  return Object.keys(cnfStyleAttrs).length > 0 ? cnfStyleAttrs : void 0;
25298
25373
  }
25299
25374
  });
25300
- const translator$e = NodeTranslator.from(createSingleAttrPropertyHandler("w:divId"));
25301
- const translator$d = NodeTranslator.from(
25375
+ const translator$p = NodeTranslator.from(createSingleAttrPropertyHandler("w:divId"));
25376
+ const translator$o = NodeTranslator.from(
25302
25377
  createSingleAttrPropertyHandler(
25303
25378
  "w:gridAfter",
25304
25379
  null,
@@ -25307,7 +25382,7 @@ const translator$d = NodeTranslator.from(
25307
25382
  (v2) => integerToString(v2)
25308
25383
  )
25309
25384
  );
25310
- const translator$c = NodeTranslator.from(
25385
+ const translator$n = NodeTranslator.from(
25311
25386
  createSingleAttrPropertyHandler(
25312
25387
  "w:gridBefore",
25313
25388
  null,
@@ -25316,21 +25391,21 @@ const translator$c = NodeTranslator.from(
25316
25391
  (v2) => integerToString(v2)
25317
25392
  )
25318
25393
  );
25319
- const translator$b = NodeTranslator.from({
25394
+ const translator$m = NodeTranslator.from({
25320
25395
  xmlName: "w:hidden",
25321
25396
  sdNodeOrKeyName: "hidden",
25322
25397
  encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
25323
25398
  decode: ({ node }) => node.attrs.hidden ? {} : void 0
25324
25399
  });
25325
- const translator$a = NodeTranslator.from(createSingleAttrPropertyHandler("w:jc"));
25326
- const translator$9 = NodeTranslator.from(createMeasurementPropertyHandler("w:tblCellSpacing", "cellSpacing"));
25327
- const translator$8 = NodeTranslator.from({
25400
+ const translator$l = NodeTranslator.from(createSingleAttrPropertyHandler("w:jc"));
25401
+ const translator$k = NodeTranslator.from(createMeasurementPropertyHandler("w:tblCellSpacing", "cellSpacing"));
25402
+ const translator$j = NodeTranslator.from({
25328
25403
  xmlName: "w:tblHeader",
25329
25404
  sdNodeOrKeyName: "repeatHeader",
25330
25405
  encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
25331
25406
  decode: ({ node }) => node.attrs.repeatHeader ? {} : void 0
25332
25407
  });
25333
- const translator$7 = NodeTranslator.from({
25408
+ const translator$i = NodeTranslator.from({
25334
25409
  xmlName: "w:trHeight",
25335
25410
  sdNodeOrKeyName: "rowHeight",
25336
25411
  encode: ({ nodes }) => {
@@ -25357,11 +25432,11 @@ const translator$7 = NodeTranslator.from({
25357
25432
  return Object.keys(heightAttrs).length > 0 ? heightAttrs : void 0;
25358
25433
  }
25359
25434
  });
25360
- const translator$6 = NodeTranslator.from(createMeasurementPropertyHandler("w:wAfter"));
25361
- const translator$5 = NodeTranslator.from(createMeasurementPropertyHandler("w:wBefore"));
25362
- const XML_NODE_NAME$4 = "w:trPr";
25363
- const SD_ATTR_KEY = "tableRowProperties";
25364
- const encode$4 = (params2) => {
25435
+ const translator$h = NodeTranslator.from(createMeasurementPropertyHandler("w:wAfter"));
25436
+ const translator$g = NodeTranslator.from(createMeasurementPropertyHandler("w:wBefore"));
25437
+ const XML_NODE_NAME$f = "w:trPr";
25438
+ const SD_ATTR_KEY$a = "tableRowProperties";
25439
+ const encode$C = (params2) => {
25365
25440
  const { nodes } = params2;
25366
25441
  const node = nodes[0];
25367
25442
  let attributes = {
@@ -25375,12 +25450,12 @@ const encode$4 = (params2) => {
25375
25450
  };
25376
25451
  return {
25377
25452
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25378
- xmlName: XML_NODE_NAME$4,
25379
- sdNodeOrKeyName: SD_ATTR_KEY,
25453
+ xmlName: XML_NODE_NAME$f,
25454
+ sdNodeOrKeyName: SD_ATTR_KEY$a,
25380
25455
  attributes
25381
25456
  };
25382
25457
  };
25383
- const decode$4 = (params2) => {
25458
+ const decode$t = (params2) => {
25384
25459
  const { tableRowProperties = {} } = params2.node.attrs || {};
25385
25460
  const elements = decodeProperties(propertyTranslatorsBySdName, tableRowProperties);
25386
25461
  const newNode = {
@@ -25392,18 +25467,18 @@ const decode$4 = (params2) => {
25392
25467
  return newNode;
25393
25468
  };
25394
25469
  const propertyTranslators = [
25395
- translator$g,
25396
- translator$f,
25397
- translator$e,
25398
- translator$d,
25399
- translator$c,
25400
- translator$b,
25401
- translator$a,
25402
- translator$9,
25403
- translator$8,
25404
- translator$7,
25405
- translator$6,
25406
- translator$5
25470
+ translator$r,
25471
+ translator$q,
25472
+ translator$p,
25473
+ translator$o,
25474
+ translator$n,
25475
+ translator$m,
25476
+ translator$l,
25477
+ translator$k,
25478
+ translator$j,
25479
+ translator$i,
25480
+ translator$h,
25481
+ translator$g
25407
25482
  ];
25408
25483
  const propertyTranslatorsByXmlName = {};
25409
25484
  propertyTranslators.forEach((translator2) => {
@@ -25413,25 +25488,25 @@ const propertyTranslatorsBySdName = {};
25413
25488
  propertyTranslators.forEach((translator2) => {
25414
25489
  propertyTranslatorsBySdName[translator2.sdNodeOrKeyName] = translator2;
25415
25490
  });
25416
- const config$4 = {
25417
- xmlName: XML_NODE_NAME$4,
25418
- sdNodeOrKeyName: SD_ATTR_KEY,
25491
+ const config$f = {
25492
+ xmlName: XML_NODE_NAME$f,
25493
+ sdNodeOrKeyName: SD_ATTR_KEY$a,
25419
25494
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25420
- encode: encode$4,
25421
- decode: decode$4
25495
+ encode: encode$C,
25496
+ decode: decode$t
25422
25497
  };
25423
- const translator$4 = NodeTranslator.from(config$4);
25424
- const XML_NODE_NAME$3 = "w:tr";
25498
+ const translator$f = NodeTranslator.from(config$f);
25499
+ const XML_NODE_NAME$e = "w:tr";
25425
25500
  const SD_NODE_NAME$3 = "tableRow";
25426
- const validXmlAttributes$3 = ["w:rsidDel", "w:rsidR", "w:rsidRPr", "w:rsidTr", "w14:paraId", "w14:textId"].map(
25501
+ const validXmlAttributes$d = ["w:rsidDel", "w:rsidR", "w:rsidRPr", "w:rsidTr", "w14:paraId", "w14:textId"].map(
25427
25502
  (xmlName) => createAttributeHandler(xmlName)
25428
25503
  );
25429
- const encode$3 = (params2, encodedAttrs) => {
25504
+ const encode$B = (params2, encodedAttrs) => {
25430
25505
  const { row, table } = params2.extraParams;
25431
25506
  let tableRowProperties = {};
25432
25507
  const tPr = row.elements.find((el) => el.name === "w:trPr");
25433
25508
  if (tPr) {
25434
- ({ attributes: tableRowProperties } = translator$4.encode({
25509
+ ({ attributes: tableRowProperties } = translator$f.encode({
25435
25510
  ...params2,
25436
25511
  nodes: [tPr]
25437
25512
  }));
@@ -25444,7 +25519,7 @@ const encode$3 = (params2, encodedAttrs) => {
25444
25519
  let currentColumnIndex = 0;
25445
25520
  const content = cellNodes?.map((n) => {
25446
25521
  let columnWidth = gridColumnWidths?.[currentColumnIndex] || null;
25447
- const result = translator$2.encode({
25522
+ const result = translator$d.encode({
25448
25523
  ...params2,
25449
25524
  extraParams: {
25450
25525
  ...params2.extraParams,
@@ -25475,7 +25550,7 @@ const _getGridColumnWidths = (tableNode) => {
25475
25550
  }) || [];
25476
25551
  return columnWidths;
25477
25552
  };
25478
- const decode$3 = (params2, decodedAttrs) => {
25553
+ const decode$s = (params2, decodedAttrs) => {
25479
25554
  const { node } = params2;
25480
25555
  const elements = translateChildNodes(params2);
25481
25556
  if (node.attrs?.tableRowProperties) {
@@ -25487,7 +25562,7 @@ const decode$3 = (params2, decodedAttrs) => {
25487
25562
  }
25488
25563
  }
25489
25564
  tableRowProperties["cantSplit"] = node.attrs["cantSplit"];
25490
- const trPr = translator$4.decode({
25565
+ const trPr = translator$f.decode({
25491
25566
  ...params2,
25492
25567
  node: { ...node, attrs: { ...node.attrs, tableRowProperties } }
25493
25568
  });
@@ -25499,15 +25574,15 @@ const decode$3 = (params2, decodedAttrs) => {
25499
25574
  elements
25500
25575
  };
25501
25576
  };
25502
- const config$3 = {
25503
- xmlName: XML_NODE_NAME$3,
25577
+ const config$e = {
25578
+ xmlName: XML_NODE_NAME$e,
25504
25579
  sdNodeOrKeyName: SD_NODE_NAME$3,
25505
25580
  type: NodeTranslator.translatorTypes.NODE,
25506
- encode: encode$3,
25507
- decode: decode$3,
25508
- attributes: validXmlAttributes$3
25581
+ encode: encode$B,
25582
+ decode: decode$s,
25583
+ attributes: validXmlAttributes$d
25509
25584
  };
25510
- const translator$3 = NodeTranslator.from(config$3);
25585
+ const translator$e = NodeTranslator.from(config$e);
25511
25586
  const handleAllTableNodes = (params2) => {
25512
25587
  const { nodes } = params2;
25513
25588
  if (nodes.length === 0) {
@@ -25571,7 +25646,7 @@ function handleTableNode(node, params2) {
25571
25646
  attrs["borders"] = borderData;
25572
25647
  const content = [];
25573
25648
  rows.forEach((row) => {
25574
- const result = translator$3.encode({
25649
+ const result = translator$e.encode({
25575
25650
  ...params2,
25576
25651
  nodes: [row],
25577
25652
  extraParams: {
@@ -25952,10 +26027,10 @@ function generateCellMargins(cellMargins) {
25952
26027
  if (left2 != null) elements.push({ name: "w:left", attributes: { "w:w": pixelsToTwips(left2) } });
25953
26028
  return elements;
25954
26029
  }
25955
- const XML_NODE_NAME$2 = "w:tc";
26030
+ const XML_NODE_NAME$d = "w:tc";
25956
26031
  const SD_NODE_NAME$2 = "tableCell";
25957
- const validXmlAttributes$2 = [];
25958
- function encode$2(params2, encodedAttrs) {
26032
+ const validXmlAttributes$c = [];
26033
+ function encode$A(params2, encodedAttrs) {
25959
26034
  const { node, table, row, rowBorders, styleTag, columnIndex, columnWidth } = params2.extraParams;
25960
26035
  const schemaNode = handleTableCellNode({
25961
26036
  params: params2,
@@ -25972,23 +26047,23 @@ function encode$2(params2, encodedAttrs) {
25972
26047
  }
25973
26048
  return schemaNode;
25974
26049
  }
25975
- function decode$2(params2, decodedAttrs) {
26050
+ function decode$r(params2, decodedAttrs) {
25976
26051
  const translated = translateTableCell(params2);
25977
26052
  if (decodedAttrs && Object.keys(decodedAttrs).length) {
25978
26053
  translated.attributes = { ...translated.attributes || {}, ...decodedAttrs };
25979
26054
  }
25980
26055
  return translated;
25981
26056
  }
25982
- const config$2 = {
25983
- xmlName: XML_NODE_NAME$2,
26057
+ const config$d = {
26058
+ xmlName: XML_NODE_NAME$d,
25984
26059
  sdNodeOrKeyName: SD_NODE_NAME$2,
25985
26060
  type: NodeTranslator.translatorTypes.NODE,
25986
- encode: encode$2,
25987
- decode: decode$2,
25988
- attributes: validXmlAttributes$2
26061
+ encode: encode$A,
26062
+ decode: decode$r,
26063
+ attributes: validXmlAttributes$c
25989
26064
  };
25990
- const translator$2 = NodeTranslator.from(config$2);
25991
- const XML_NODE_NAME$1 = "w:hyperlink";
26065
+ const translator$d = NodeTranslator.from(config$d);
26066
+ const XML_NODE_NAME$c = "w:hyperlink";
25992
26067
  const SD_NODE_NAME$1 = "link";
25993
26068
  const _createAttributeHandler = (xmlName, sdName) => ({
25994
26069
  xmlName,
@@ -25996,7 +26071,7 @@ const _createAttributeHandler = (xmlName, sdName) => ({
25996
26071
  encode: (attributes) => attributes[xmlName],
25997
26072
  decode: (attributes) => attributes[sdName]
25998
26073
  });
25999
- const validXmlAttributes$1 = [
26074
+ const validXmlAttributes$b = [
26000
26075
  _createAttributeHandler("w:anchor", "anchor"),
26001
26076
  _createAttributeHandler("w:docLocation", "docLocation"),
26002
26077
  {
@@ -26009,7 +26084,7 @@ const validXmlAttributes$1 = [
26009
26084
  _createAttributeHandler("r:id", "rId"),
26010
26085
  _createAttributeHandler("w:tgtFrame", "target")
26011
26086
  ];
26012
- const encode$1 = (params2, encodedAttrs) => {
26087
+ const encode$z = (params2, encodedAttrs) => {
26013
26088
  const { nodes, docx, nodeListHandler } = params2;
26014
26089
  const node = nodes[0];
26015
26090
  let href = _resolveHref(docx, encodedAttrs);
@@ -26023,7 +26098,16 @@ const encode$1 = (params2, encodedAttrs) => {
26023
26098
  nodes: runNodes,
26024
26099
  path: [...params2.path || [], node]
26025
26100
  });
26026
- return updatedNode;
26101
+ const ensureLinkMark = (child) => {
26102
+ if (!child || typeof child !== "object") return child;
26103
+ const existingMarks = Array.isArray(child.marks) ? child.marks : [];
26104
+ const hasLink = existingMarks.some((mark) => mark?.type === "link");
26105
+ if (hasLink) return child;
26106
+ const linkClone = { type: "link", attrs: { ...linkMark.attrs } };
26107
+ return { ...child, marks: [...existingMarks, linkClone] };
26108
+ };
26109
+ if (!Array.isArray(updatedNode)) return updatedNode;
26110
+ return updatedNode.map((child) => ensureLinkMark(child));
26027
26111
  };
26028
26112
  const _resolveHref = (docx, encodedAttrs) => {
26029
26113
  const rels = docx["word/_rels/document.xml.rels"];
@@ -26040,7 +26124,7 @@ const _resolveHref = (docx, encodedAttrs) => {
26040
26124
  }
26041
26125
  return href;
26042
26126
  };
26043
- function decode$1(params2) {
26127
+ function decode$q(params2) {
26044
26128
  const { node } = params2;
26045
26129
  const linkMark = node.marks.find((m2) => m2.type === "link");
26046
26130
  const linkAttrs = this.decodeAttributes({ ...params2, node: linkMark });
@@ -26084,15 +26168,15 @@ function _addNewLinkRelationship(params2, link, rId) {
26084
26168
  });
26085
26169
  return rId;
26086
26170
  }
26087
- const config$1 = {
26088
- xmlName: XML_NODE_NAME$1,
26171
+ const config$c = {
26172
+ xmlName: XML_NODE_NAME$c,
26089
26173
  sdNodeOrKeyName: SD_NODE_NAME$1,
26090
26174
  type: NodeTranslator.translatorTypes.NODE,
26091
- encode: encode$1,
26092
- decode: decode$1,
26093
- attributes: validXmlAttributes$1
26175
+ encode: encode$z,
26176
+ decode: decode$q,
26177
+ attributes: validXmlAttributes$b
26094
26178
  };
26095
- const translator$1 = NodeTranslator.from(config$1);
26179
+ const translator$c = NodeTranslator.from(config$c);
26096
26180
  function parseTagValueJSON(json) {
26097
26181
  if (typeof json !== "string") {
26098
26182
  return {};
@@ -26103,7 +26187,7 @@ function parseTagValueJSON(json) {
26103
26187
  }
26104
26188
  try {
26105
26189
  return JSON.parse(trimmed);
26106
- } catch (err) {
26190
+ } catch {
26107
26191
  return {};
26108
26192
  }
26109
26193
  }
@@ -27905,10 +27989,10 @@ function translateStructuredContent(params2) {
27905
27989
  };
27906
27990
  return result;
27907
27991
  }
27908
- const XML_NODE_NAME = "w:sdt";
27992
+ const XML_NODE_NAME$b = "w:sdt";
27909
27993
  const SD_NODE_NAME = ["fieldAnnotation", "structuredContent", "structuredContentBlock", "documentSection"];
27910
- const validXmlAttributes = [];
27911
- function encode$k(params2, encodedAttrs) {
27994
+ const validXmlAttributes$a = [];
27995
+ function encode$y(params2) {
27912
27996
  const nodes = params2.nodes;
27913
27997
  const node = nodes[0];
27914
27998
  const { type: sdtType, handler: handler2 } = sdtNodeTypeStrategy(node);
@@ -27918,7 +28002,7 @@ function encode$k(params2, encodedAttrs) {
27918
28002
  const result = handler2(params2);
27919
28003
  return result;
27920
28004
  }
27921
- function decode(params2, decodedAttrs) {
28005
+ function decode$p(params2) {
27922
28006
  const { node } = params2;
27923
28007
  if (!node || !node.type) {
27924
28008
  return null;
@@ -27934,43 +28018,138 @@ function decode(params2, decodedAttrs) {
27934
28018
  const result = decoder();
27935
28019
  return result;
27936
28020
  }
27937
- const config = {
27938
- xmlName: XML_NODE_NAME,
28021
+ const config$b = {
28022
+ xmlName: XML_NODE_NAME$b,
27939
28023
  sdNodeOrKeyName: SD_NODE_NAME,
27940
28024
  type: NodeTranslator.translatorTypes.NODE,
27941
- encode: encode$k,
27942
- decode,
27943
- attributes: validXmlAttributes
28025
+ encode: encode$y,
28026
+ decode: decode$p,
28027
+ attributes: validXmlAttributes$a
28028
+ };
28029
+ const translator$b = NodeTranslator.from(config$b);
28030
+ const encode$x = (attributes) => attributes?.["w:val"];
28031
+ const decode$o = (attrs) => attrs?.underline;
28032
+ const attrConfig$m = Object.freeze({
28033
+ xmlName: "w:val",
28034
+ sdName: "underline",
28035
+ encode: encode$x,
28036
+ decode: decode$o
28037
+ });
28038
+ const encode$w = (attributes) => attributes?.["w:color"];
28039
+ const decode$n = (attrs) => attrs?.color;
28040
+ const attrConfig$l = Object.freeze({
28041
+ xmlName: "w:color",
28042
+ sdName: "color",
28043
+ encode: encode$w,
28044
+ decode: decode$n
28045
+ });
28046
+ const encode$v = (attributes) => attributes?.["w:themeColor"];
28047
+ const decode$m = (attrs) => attrs?.themeColor;
28048
+ const attrConfig$k = Object.freeze({
28049
+ xmlName: "w:themeColor",
28050
+ sdName: "themeColor",
28051
+ encode: encode$v,
28052
+ decode: decode$m
28053
+ });
28054
+ const encode$u = (attributes) => attributes?.["w:themeTint"];
28055
+ const decode$l = (attrs) => attrs?.themeTint;
28056
+ const attrConfig$j = Object.freeze({
28057
+ xmlName: "w:themeTint",
28058
+ sdName: "themeTint",
28059
+ encode: encode$u,
28060
+ decode: decode$l
28061
+ });
28062
+ const encode$t = (attributes) => attributes?.["w:themeShade"];
28063
+ const decode$k = (attrs) => attrs?.themeShade;
28064
+ const attrConfig$i = Object.freeze({
28065
+ xmlName: "w:themeShade",
28066
+ sdName: "themeShade",
28067
+ encode: encode$t,
28068
+ decode: decode$k
28069
+ });
28070
+ const validXmlAttributes$9 = [attrConfig$m, attrConfig$l, attrConfig$k, attrConfig$j, attrConfig$i];
28071
+ const XML_NODE_NAME$a = "w:u";
28072
+ const SD_ATTR_KEY$9 = "underline";
28073
+ const encode$s = (params2, encodedAttrs = {}) => {
28074
+ const { nodes } = params2;
28075
+ const node = nodes?.[0];
28076
+ const sourceAttrs = node?.attributes || {};
28077
+ const underlineType = encodedAttrs.underline ?? sourceAttrs["w:val"];
28078
+ const color = encodedAttrs.color ?? sourceAttrs["w:color"];
28079
+ const themeColor = encodedAttrs.themeColor ?? sourceAttrs["w:themeColor"];
28080
+ const themeTint = encodedAttrs.themeTint ?? sourceAttrs["w:themeTint"];
28081
+ const themeShade = encodedAttrs.themeShade ?? sourceAttrs["w:themeShade"];
28082
+ const attributes = { "w:val": underlineType ?? null };
28083
+ if (color !== void 0 && color !== null) attributes["w:color"] = color;
28084
+ if (themeColor !== void 0 && themeColor !== null) attributes["w:themeColor"] = themeColor;
28085
+ if (themeTint !== void 0 && themeTint !== null) attributes["w:themeTint"] = themeTint;
28086
+ if (themeShade !== void 0 && themeShade !== null) attributes["w:themeShade"] = themeShade;
28087
+ return {
28088
+ type: "attr",
28089
+ xmlName: XML_NODE_NAME$a,
28090
+ sdNodeOrKeyName: SD_ATTR_KEY$9,
28091
+ attributes
28092
+ };
27944
28093
  };
27945
- const translator = NodeTranslator.from(config);
28094
+ const decode$j = (params2) => {
28095
+ const attrs = params2?.node?.attrs || {};
28096
+ const underlineType = attrs.underlineType ?? attrs.underline ?? null;
28097
+ const color = attrs.underlineColor ?? attrs.color ?? null;
28098
+ const themeColor = attrs.underlineThemeColor ?? attrs.themeColor ?? null;
28099
+ const themeTint = attrs.underlineThemeTint ?? attrs.themeTint ?? null;
28100
+ const themeShade = attrs.underlineThemeShade ?? attrs.themeShade ?? null;
28101
+ if (!underlineType && !color && !themeColor && !themeTint && !themeShade) return void 0;
28102
+ const attributes = {};
28103
+ if (underlineType) attributes["w:val"] = underlineType;
28104
+ if (color) {
28105
+ const normalized = normalizeHexColor(color);
28106
+ if (normalized) attributes["w:color"] = normalized;
28107
+ }
28108
+ if (themeColor) attributes["w:themeColor"] = themeColor;
28109
+ if (themeTint) attributes["w:themeTint"] = themeTint;
28110
+ if (themeShade) attributes["w:themeShade"] = themeShade;
28111
+ return {
28112
+ name: XML_NODE_NAME$a,
28113
+ attributes
28114
+ };
28115
+ };
28116
+ const config$a = {
28117
+ xmlName: XML_NODE_NAME$a,
28118
+ sdNodeOrKeyName: SD_ATTR_KEY$9,
28119
+ type: NodeTranslator.translatorTypes.ATTRIBUTE,
28120
+ encode: encode$s,
28121
+ decode: decode$j,
28122
+ attributes: validXmlAttributes$9
28123
+ };
28124
+ const translator$a = NodeTranslator.from(config$a);
27946
28125
  function exportSchemaToJson(params2) {
27947
28126
  const { type: type2 } = params2.node || {};
27948
28127
  const router = {
27949
28128
  doc: translateDocumentNode,
27950
28129
  body: translateBodyNode,
27951
28130
  heading: translateHeadingNode,
27952
- paragraph: translator$h,
28131
+ paragraph: translator$s,
27953
28132
  text: translateTextNode,
27954
28133
  bulletList: translateList,
27955
28134
  orderedList: translateList,
27956
- lineBreak: translator$j,
28135
+ lineBreak: translator$v,
27957
28136
  table: translateTable,
27958
- tableRow: translator$3,
27959
- tableCell: translator$2,
28137
+ tableRow: translator$e,
28138
+ tableCell: translator$d,
27960
28139
  bookmarkStart: translateBookmarkStart,
27961
- fieldAnnotation: translator,
27962
- tab: translator$i,
28140
+ fieldAnnotation: translator$b,
28141
+ tab: translator$t,
27963
28142
  image: translateImageNode,
27964
- hardBreak: translator$j,
28143
+ hardBreak: translator$v,
27965
28144
  commentRangeStart: () => translateCommentNode(params2, "Start"),
27966
28145
  commentRangeEnd: () => translateCommentNode(params2, "End"),
27967
28146
  commentReference: () => null,
27968
28147
  shapeContainer: translateShapeContainer,
27969
28148
  shapeTextbox: translateShapeTextbox,
27970
28149
  contentBlock: translateContentBlock,
27971
- structuredContent: translator,
27972
- structuredContentBlock: translator,
27973
- documentSection: translator,
28150
+ structuredContent: translator$b,
28151
+ structuredContentBlock: translator$b,
28152
+ documentSection: translator$b,
27974
28153
  "page-number": translatePageNumberNode,
27975
28154
  "total-page-number": translateTotalPageNumberNode
27976
28155
  };
@@ -28293,7 +28472,7 @@ function translateTextNode(params2) {
28293
28472
  const isTrackedNode = node.marks?.some((m2) => trackedMarks.includes(m2.type));
28294
28473
  if (isTrackedNode) return translateTrackedNode(params2);
28295
28474
  const isLinkNode = node.marks?.some((m2) => m2.type === "link");
28296
- if (isLinkNode) return translator$1.decode(params2);
28475
+ if (isLinkNode) return translator$c.decode(params2);
28297
28476
  const { text, marks = [] } = node;
28298
28477
  return getTextNodeForExport(text, marks, params2);
28299
28478
  }
@@ -28778,10 +28957,20 @@ function translateMark(mark) {
28778
28957
  delete markElement.attributes;
28779
28958
  markElement.type = "element";
28780
28959
  break;
28781
- case "underline":
28782
- markElement.type = "element";
28783
- markElement.attributes["w:val"] = attrs.underlineType;
28784
- break;
28960
+ case "underline": {
28961
+ const translated = translator$a.decode({
28962
+ node: {
28963
+ attrs: {
28964
+ underlineType: attrs.underlineType ?? attrs.underline ?? null,
28965
+ underlineColor: attrs.underlineColor ?? attrs.color ?? null,
28966
+ underlineThemeColor: attrs.underlineThemeColor ?? attrs.themeColor ?? null,
28967
+ underlineThemeTint: attrs.underlineThemeTint ?? attrs.themeTint ?? null,
28968
+ underlineThemeShade: attrs.underlineThemeShade ?? attrs.themeShade ?? null
28969
+ }
28970
+ }
28971
+ });
28972
+ return translated || {};
28973
+ }
28785
28974
  // Text style cases
28786
28975
  case "fontSize":
28787
28976
  value = attrs.fontSize;
@@ -28823,12 +29012,11 @@ function translateMark(mark) {
28823
29012
  case "lineHeight":
28824
29013
  markElement.attributes["w:line"] = linesToTwips(attrs.lineHeight);
28825
29014
  break;
28826
- case "highlight":
28827
- markElement.attributes["w:fill"] = attrs.color?.substring(1);
28828
- markElement.attributes["w:color"] = "auto";
28829
- markElement.attributes["w:val"] = "clear";
28830
- markElement.name = "w:shd";
28831
- break;
29015
+ case "highlight": {
29016
+ const highlightValue = attrs.color ?? attrs.highlight ?? null;
29017
+ const translated = translator$u.decode({ node: { attrs: { highlight: highlightValue } } });
29018
+ return translated || {};
29019
+ }
28832
29020
  }
28833
29021
  return markElement;
28834
29022
  }
@@ -28865,17 +29053,7 @@ function translateImageNode(params2, imageSize) {
28865
29053
  let imageId = attrs.rId;
28866
29054
  const src = attrs.src || attrs.imageSrc;
28867
29055
  const { originalWidth, originalHeight } = getPngDimensions(src);
28868
- let imageName;
28869
- if (params2.node.type === "image") {
28870
- if (src?.startsWith("data:")) {
28871
- imageName = getFallbackImageNameFromDataUri(src);
28872
- } else {
28873
- imageName = src?.split("/").pop();
28874
- }
28875
- } else {
28876
- imageName = attrs.fieldId;
28877
- }
28878
- imageName = sanitizeDocxMediaName(imageName);
29056
+ const imageName = params2.node.type === "image" ? src.split("/").pop() : attrs.fieldId?.replace("-", "_");
28879
29057
  let size2 = attrs.size ? {
28880
29058
  w: pixelsToEmu(attrs.size.width),
28881
29059
  h: pixelsToEmu(attrs.size.height)
@@ -28905,12 +29083,9 @@ function translateImageNode(params2, imageSize) {
28905
29083
  if (!type2) {
28906
29084
  return prepareTextAnnotation(params2);
28907
29085
  }
28908
- const sanitizedHash = sanitizeDocxMediaName(attrs.hash, generateDocxRandomId(4));
28909
- const fileName = `${imageName}_${sanitizedHash}.${type2}`;
28910
- const relationshipTarget = `media/${fileName}`;
28911
- const packagePath = `word/${relationshipTarget}`;
28912
- imageId = addNewImageRelationship(params2, relationshipTarget);
28913
- params2.media[packagePath] = src;
29086
+ const imageUrl = `media/${imageName}_${attrs.hash}.${type2}`;
29087
+ imageId = addNewImageRelationship(params2, imageUrl);
29088
+ params2.media[`${imageName}_${attrs.hash}.${type2}`] = src;
28914
29089
  }
28915
29090
  let inlineAttrs = attrs.originalPadding || {
28916
29091
  distT: 0,
@@ -29709,82 +29884,912 @@ const trackChangeNodeHandlerEntity = {
29709
29884
  handlerName: "trackChangeNodeHandler",
29710
29885
  handler: handleTrackChangeNode
29711
29886
  };
29712
- const hyperlinkNodeHandlerEntity = generateV2HandlerEntity("hyperlinkNodeHandler", translator$1);
29713
- const handleRunNode = (params2) => {
29714
- const { nodes, nodeListHandler, parentStyleId, docx } = params2;
29715
- if (nodes.length === 0 || nodes[0].name !== "w:r") {
29716
- return { nodes: [], consumed: 0 };
29717
- }
29887
+ const hyperlinkNodeHandlerEntity = generateV2HandlerEntity("hyperlinkNodeHandler", translator$c);
29888
+ const encode$r = (attributes) => {
29889
+ const raw = attributes?.["w:val"];
29890
+ if (raw === void 0 || raw === null) return void 0;
29891
+ if (typeof raw === "boolean") return raw;
29892
+ if (typeof raw === "number") return raw !== 0;
29893
+ const val = String(raw).trim().toLowerCase();
29894
+ if (val === "0" || val === "false" || val === "off") return false;
29895
+ if (val === "1" || val === "true" || val === "on") return true;
29896
+ return void 0;
29897
+ };
29898
+ const decode$i = (runProps) => {
29899
+ if (runProps?.bold === false) return "0";
29900
+ return void 0;
29901
+ };
29902
+ const attrConfig$h = Object.freeze({
29903
+ xmlName: "w:val",
29904
+ sdName: "bold",
29905
+ encode: encode$r,
29906
+ decode: decode$i
29907
+ });
29908
+ const validXmlAttributes$8 = [attrConfig$h];
29909
+ const XML_NODE_NAME$9 = "w:b";
29910
+ const SD_ATTR_KEY$8 = "bold";
29911
+ const encode$q = (params2, encodedAttrs = {}) => {
29912
+ const { nodes } = params2;
29718
29913
  const node = nodes[0];
29719
- const childParams = { ...params2, nodes: node.elements, path: [...params2.path || [], node] };
29720
- let processedRun = nodeListHandler.handler(childParams)?.filter((n) => n) || [];
29721
- const hasRunProperties = node.elements?.some((el) => el.name === "w:rPr");
29722
- const defaultNodeStyles = getMarksFromStyles(docx, parentStyleId);
29723
- if (hasRunProperties) {
29724
- const { marks = [] } = parseProperties(node);
29725
- let runStyleAttributes = [];
29726
- const runStyleElement = node.elements?.find((el) => el.name === "w:rPr")?.elements?.find((el) => el.name === "w:rStyle");
29727
- let runStyleId;
29728
- if (runStyleElement && runStyleElement.attributes?.["w:val"] && docx) {
29729
- runStyleId = runStyleElement.attributes["w:val"];
29730
- const runStyleDefinition = getMarksFromStyles(docx, runStyleId);
29731
- if (runStyleDefinition.marks && runStyleDefinition.marks.length > 0) {
29732
- runStyleAttributes = runStyleDefinition.marks;
29733
- }
29734
- }
29735
- let paragraphStyleAttributes = [];
29736
- if (defaultNodeStyles.marks) {
29737
- paragraphStyleAttributes = defaultNodeStyles.marks.filter((mark) => {
29738
- if (["bold"].includes(mark.type) && marks.find((m2) => m2.type === "bold")?.attrs?.value === "0") {
29739
- return false;
29740
- }
29741
- return true;
29742
- });
29743
- }
29744
- const combinedMarks = [...paragraphStyleAttributes];
29745
- runStyleAttributes.forEach((runStyle) => {
29746
- const exists2 = combinedMarks.some(
29747
- (mark) => mark.type === runStyle.type && JSON.stringify(mark.attrs || {}) === JSON.stringify(runStyle.attrs || {})
29748
- );
29749
- if (!exists2) {
29750
- combinedMarks.push(runStyle);
29914
+ if (!node) return void 0;
29915
+ const val = encodedAttrs?.[SD_ATTR_KEY$8];
29916
+ let attributes;
29917
+ if (val === false) attributes = { "w:val": "0" };
29918
+ else if (val === true)
29919
+ attributes = {};
29920
+ else attributes = node.attributes || {};
29921
+ return {
29922
+ type: "attr",
29923
+ xmlName: XML_NODE_NAME$9,
29924
+ sdNodeOrKeyName: SD_ATTR_KEY$8,
29925
+ attributes
29926
+ };
29927
+ };
29928
+ const config$9 = {
29929
+ xmlName: XML_NODE_NAME$9,
29930
+ sdNodeOrKeyName: SD_ATTR_KEY$8,
29931
+ type: NodeTranslator.translatorTypes.ATTRIBUTE,
29932
+ encode: encode$q,
29933
+ attributes: validXmlAttributes$8
29934
+ };
29935
+ const translator$9 = NodeTranslator.from(config$9);
29936
+ const encode$p = (attributes) => {
29937
+ const raw = attributes?.["w:val"];
29938
+ if (raw === void 0 || raw === null) return void 0;
29939
+ if (typeof raw === "boolean") return raw;
29940
+ if (typeof raw === "number") return raw !== 0;
29941
+ const val = String(raw).trim().toLowerCase();
29942
+ if (val === "0" || val === "false" || val === "off") return false;
29943
+ if (val === "1" || val === "true" || val === "on") return true;
29944
+ return void 0;
29945
+ };
29946
+ const decode$h = (attrs) => {
29947
+ if (attrs?.italic === false) return "0";
29948
+ return void 0;
29949
+ };
29950
+ const attrConfig$g = Object.freeze({
29951
+ xmlName: "w:val",
29952
+ sdName: "italic",
29953
+ encode: encode$p,
29954
+ decode: decode$h
29955
+ });
29956
+ const validXmlAttributes$7 = [attrConfig$g];
29957
+ const XML_NODE_NAME$8 = "w:i";
29958
+ const SD_ATTR_KEY$7 = "italic";
29959
+ const encode$o = (params2, encodedAttrs = {}) => {
29960
+ const { nodes } = params2;
29961
+ const node = nodes?.[0];
29962
+ if (!node) return void 0;
29963
+ const val = encodedAttrs?.[SD_ATTR_KEY$7];
29964
+ let attributes;
29965
+ if (val === false) attributes = { "w:val": "0" };
29966
+ else if (val === true) attributes = {};
29967
+ else attributes = { ...node.attributes || {} };
29968
+ if (attributes["w:val"] === void 0 && val !== true) attributes["w:val"] = null;
29969
+ else if (val === true && attributes["w:val"] === void 0) delete attributes["w:val"];
29970
+ return {
29971
+ type: "attr",
29972
+ xmlName: XML_NODE_NAME$8,
29973
+ sdNodeOrKeyName: SD_ATTR_KEY$7,
29974
+ attributes
29975
+ };
29976
+ };
29977
+ const config$8 = {
29978
+ xmlName: XML_NODE_NAME$8,
29979
+ sdNodeOrKeyName: SD_ATTR_KEY$7,
29980
+ type: NodeTranslator.translatorTypes.ATTRIBUTE,
29981
+ encode: encode$o,
29982
+ attributes: validXmlAttributes$7
29983
+ };
29984
+ const translator$8 = NodeTranslator.from(config$8);
29985
+ const encode$n = (attributes) => {
29986
+ const raw = attributes?.["w:val"];
29987
+ if (raw === void 0 || raw === null) return void 0;
29988
+ if (typeof raw === "boolean") return raw;
29989
+ if (typeof raw === "number") return raw !== 0;
29990
+ const val = String(raw).trim().toLowerCase();
29991
+ if (val === "0" || val === "false" || val === "off") return false;
29992
+ if (val === "1" || val === "true" || val === "on") return true;
29993
+ return void 0;
29994
+ };
29995
+ const decode$g = (attrs) => {
29996
+ if (attrs?.strike === false) return "0";
29997
+ return void 0;
29998
+ };
29999
+ const attrConfig$f = Object.freeze({
30000
+ xmlName: "w:val",
30001
+ sdName: "strike",
30002
+ encode: encode$n,
30003
+ decode: decode$g
30004
+ });
30005
+ const validXmlAttributes$6 = [attrConfig$f];
30006
+ const XML_NODE_NAME$7 = "w:strike";
30007
+ const SD_ATTR_KEY$6 = "strike";
30008
+ const encode$m = (params2, encodedAttrs = {}) => {
30009
+ const { nodes } = params2;
30010
+ const node = nodes?.[0];
30011
+ if (!node) return void 0;
30012
+ const val = encodedAttrs?.[SD_ATTR_KEY$6];
30013
+ let attributes;
30014
+ if (val === false) attributes = { "w:val": "0" };
30015
+ else if (val === true) attributes = {};
30016
+ else attributes = { ...node.attributes || {} };
30017
+ if (attributes["w:val"] === void 0 && val !== true) attributes["w:val"] = null;
30018
+ else if (val === true && attributes["w:val"] === void 0) delete attributes["w:val"];
30019
+ return {
30020
+ type: "attr",
30021
+ xmlName: XML_NODE_NAME$7,
30022
+ sdNodeOrKeyName: SD_ATTR_KEY$6,
30023
+ attributes
30024
+ };
30025
+ };
30026
+ const config$7 = {
30027
+ xmlName: XML_NODE_NAME$7,
30028
+ sdNodeOrKeyName: SD_ATTR_KEY$6,
30029
+ type: NodeTranslator.translatorTypes.ATTRIBUTE,
30030
+ encode: encode$m,
30031
+ attributes: validXmlAttributes$6
30032
+ };
30033
+ const translator$7 = NodeTranslator.from(config$7);
30034
+ const encode$l = (attributes) => attributes?.["w:val"];
30035
+ const decode$f = (attrs) => attrs?.color;
30036
+ const attrConfig$e = Object.freeze({
30037
+ xmlName: "w:val",
30038
+ sdName: "color",
30039
+ encode: encode$l,
30040
+ decode: decode$f
30041
+ });
30042
+ const encode$k = (attributes) => attributes?.["w:themeColor"];
30043
+ const decode$e = (attrs) => attrs?.themeColor;
30044
+ const attrConfig$d = Object.freeze({
30045
+ xmlName: "w:themeColor",
30046
+ sdName: "themeColor",
30047
+ encode: encode$k,
30048
+ decode: decode$e
30049
+ });
30050
+ const encode$j = (attributes) => attributes?.["w:themeTint"];
30051
+ const decode$d = (attrs) => attrs?.themeTint;
30052
+ const attrConfig$c = Object.freeze({
30053
+ xmlName: "w:themeTint",
30054
+ sdName: "themeTint",
30055
+ encode: encode$j,
30056
+ decode: decode$d
30057
+ });
30058
+ const encode$i = (attributes) => attributes?.["w:themeShade"];
30059
+ const decode$c = (attrs) => attrs?.themeShade;
30060
+ const attrConfig$b = Object.freeze({
30061
+ xmlName: "w:themeShade",
30062
+ sdName: "themeShade",
30063
+ encode: encode$i,
30064
+ decode: decode$c
30065
+ });
30066
+ const validXmlAttributes$5 = [attrConfig$e, attrConfig$d, attrConfig$c, attrConfig$b];
30067
+ const XML_NODE_NAME$6 = "w:color";
30068
+ const SD_ATTR_KEY$5 = "color";
30069
+ const encode$h = (params2, encodedAttrs = {}) => {
30070
+ const { nodes } = params2;
30071
+ const node = nodes?.[0];
30072
+ const sourceAttrs = node?.attributes || {};
30073
+ const value = encodedAttrs.color ?? sourceAttrs["w:val"];
30074
+ const themeColor = encodedAttrs.themeColor ?? sourceAttrs["w:themeColor"];
30075
+ const themeTint = encodedAttrs.themeTint ?? sourceAttrs["w:themeTint"];
30076
+ const themeShade = encodedAttrs.themeShade ?? sourceAttrs["w:themeShade"];
30077
+ const attributes = {};
30078
+ attributes["w:val"] = value ?? null;
30079
+ if (themeColor !== void 0 && themeColor !== null) attributes["w:themeColor"] = themeColor;
30080
+ if (themeTint !== void 0 && themeTint !== null) attributes["w:themeTint"] = themeTint;
30081
+ if (themeShade !== void 0 && themeShade !== null) attributes["w:themeShade"] = themeShade;
30082
+ return {
30083
+ type: "attr",
30084
+ xmlName: XML_NODE_NAME$6,
30085
+ sdNodeOrKeyName: SD_ATTR_KEY$5,
30086
+ attributes
30087
+ };
30088
+ };
30089
+ const config$6 = {
30090
+ xmlName: XML_NODE_NAME$6,
30091
+ sdNodeOrKeyName: SD_ATTR_KEY$5,
30092
+ type: NodeTranslator.translatorTypes.ATTRIBUTE,
30093
+ encode: encode$h,
30094
+ attributes: validXmlAttributes$5
30095
+ };
30096
+ const translator$6 = NodeTranslator.from(config$6);
30097
+ const encode$g = (attributes) => attributes?.["w:eastAsia"];
30098
+ const decode$b = (attrs) => attrs?.eastAsia;
30099
+ const attrConfig$a = Object.freeze({
30100
+ xmlName: "w:eastAsia",
30101
+ sdName: "eastAsia",
30102
+ encode: encode$g,
30103
+ decode: decode$b
30104
+ });
30105
+ const encode$f = (attributes) => attributes?.["w:ascii"];
30106
+ const decode$a = (attrs) => attrs?.ascii;
30107
+ const attrConfig$9 = Object.freeze({
30108
+ xmlName: "w:ascii",
30109
+ sdName: "ascii",
30110
+ encode: encode$f,
30111
+ decode: decode$a
30112
+ });
30113
+ const encode$e = (attributes) => attributes?.["w:hAnsi"];
30114
+ const decode$9 = (attrs) => attrs?.hAnsi;
30115
+ const attrConfig$8 = Object.freeze({
30116
+ xmlName: "w:hAnsi",
30117
+ sdName: "hAnsi",
30118
+ encode: encode$e,
30119
+ decode: decode$9
30120
+ });
30121
+ const encode$d = (attributes) => attributes?.["w:cs"];
30122
+ const decode$8 = (attrs) => attrs?.cs;
30123
+ const attrConfig$7 = Object.freeze({
30124
+ xmlName: "w:cs",
30125
+ sdName: "cs",
30126
+ encode: encode$d,
30127
+ decode: decode$8
30128
+ });
30129
+ const encode$c = (attributes) => attributes?.["w:val"];
30130
+ const decode$7 = (attrs) => attrs?.value;
30131
+ const attrConfig$6 = Object.freeze({
30132
+ xmlName: "w:val",
30133
+ sdName: "value",
30134
+ encode: encode$c,
30135
+ decode: decode$7
30136
+ });
30137
+ const validXmlAttributes$4 = [attrConfig$a, attrConfig$9, attrConfig$8, attrConfig$7, attrConfig$6];
30138
+ const XML_NODE_NAME$5 = "w:rFonts";
30139
+ const SD_ATTR_KEY$4 = "fontFamily";
30140
+ const encode$b = (params2, encodedAttrs = {}) => {
30141
+ const { nodes } = params2;
30142
+ const node = nodes?.[0];
30143
+ const sourceAttrs = node?.attributes || {};
30144
+ const attributes = {};
30145
+ const setAttr = (xmlName, sdName) => {
30146
+ if (encodedAttrs[sdName] !== void 0 && encodedAttrs[sdName] !== null) {
30147
+ attributes[xmlName] = encodedAttrs[sdName];
30148
+ } else if (sourceAttrs[xmlName] !== void 0) {
30149
+ attributes[xmlName] = sourceAttrs[xmlName];
30150
+ }
30151
+ };
30152
+ setAttr("w:eastAsia", "eastAsia");
30153
+ setAttr("w:ascii", "ascii");
30154
+ setAttr("w:hAnsi", "hAnsi");
30155
+ setAttr("w:cs", "cs");
30156
+ setAttr("w:val", "value");
30157
+ Object.keys(sourceAttrs).forEach((key) => {
30158
+ if (attributes[key] === void 0) attributes[key] = sourceAttrs[key];
30159
+ });
30160
+ if (attributes["w:val"] === void 0 && attributes["w:eastAsia"]) {
30161
+ attributes["w:val"] = attributes["w:eastAsia"];
30162
+ }
30163
+ if (attributes["w:val"] === void 0) delete attributes["w:val"];
30164
+ return {
30165
+ type: "attr",
30166
+ xmlName: XML_NODE_NAME$5,
30167
+ sdNodeOrKeyName: SD_ATTR_KEY$4,
30168
+ attributes
30169
+ };
30170
+ };
30171
+ const config$5 = {
30172
+ xmlName: XML_NODE_NAME$5,
30173
+ sdNodeOrKeyName: SD_ATTR_KEY$4,
30174
+ type: NodeTranslator.translatorTypes.ATTRIBUTE,
30175
+ encode: encode$b,
30176
+ attributes: validXmlAttributes$4
30177
+ };
30178
+ const translator$5 = NodeTranslator.from(config$5);
30179
+ const encode$a = (attributes) => attributes?.["w:val"];
30180
+ const decode$6 = (attrs) => attrs?.styleId;
30181
+ const attrConfig$5 = Object.freeze({
30182
+ xmlName: "w:val",
30183
+ sdName: "styleId",
30184
+ encode: encode$a,
30185
+ decode: decode$6
30186
+ });
30187
+ const validXmlAttributes$3 = [attrConfig$5];
30188
+ const XML_NODE_NAME$4 = "w:rStyle";
30189
+ const SD_ATTR_KEY$3 = "styleId";
30190
+ const encode$9 = (params2, encodedAttrs = {}) => {
30191
+ const { nodes } = params2;
30192
+ const node = nodes?.[0];
30193
+ const value = encodedAttrs.styleId ?? node?.attributes?.["w:val"];
30194
+ return {
30195
+ type: "attr",
30196
+ xmlName: XML_NODE_NAME$4,
30197
+ sdNodeOrKeyName: SD_ATTR_KEY$3,
30198
+ attributes: { "w:val": value ?? null }
30199
+ };
30200
+ };
30201
+ const config$4 = {
30202
+ xmlName: XML_NODE_NAME$4,
30203
+ sdNodeOrKeyName: SD_ATTR_KEY$3,
30204
+ type: NodeTranslator.translatorTypes.ATTRIBUTE,
30205
+ encode: encode$9,
30206
+ attributes: validXmlAttributes$3
30207
+ };
30208
+ const translator$4 = NodeTranslator.from(config$4);
30209
+ const encode$8 = (attributes) => attributes?.["w:val"];
30210
+ const decode$5 = (attrs) => attrs?.fontSize;
30211
+ const attrConfig$4 = Object.freeze({
30212
+ xmlName: "w:val",
30213
+ sdName: "fontSize",
30214
+ encode: encode$8,
30215
+ decode: decode$5
30216
+ });
30217
+ const validXmlAttributes$2 = [attrConfig$4];
30218
+ const XML_NODE_NAME$3 = "w:sz";
30219
+ const SD_ATTR_KEY$2 = "fontSize";
30220
+ const encode$7 = (params2, encodedAttrs = {}) => {
30221
+ const { nodes } = params2;
30222
+ const node = nodes?.[0];
30223
+ const value = encodedAttrs.fontSize ?? node?.attributes?.["w:val"];
30224
+ return {
30225
+ type: "attr",
30226
+ xmlName: XML_NODE_NAME$3,
30227
+ sdNodeOrKeyName: SD_ATTR_KEY$2,
30228
+ attributes: { "w:val": value ?? null }
30229
+ };
30230
+ };
30231
+ const config$3 = {
30232
+ xmlName: XML_NODE_NAME$3,
30233
+ sdNodeOrKeyName: SD_ATTR_KEY$2,
30234
+ type: NodeTranslator.translatorTypes.ATTRIBUTE,
30235
+ encode: encode$7,
30236
+ attributes: validXmlAttributes$2
30237
+ };
30238
+ const translator$3 = NodeTranslator.from(config$3);
30239
+ const encode$6 = (attributes) => attributes?.["w:val"];
30240
+ const decode$4 = (attrs) => attrs?.fontSizeCs;
30241
+ const attrConfig$3 = Object.freeze({
30242
+ xmlName: "w:val",
30243
+ sdName: "fontSizeCs",
30244
+ encode: encode$6,
30245
+ decode: decode$4
30246
+ });
30247
+ const validXmlAttributes$1 = [attrConfig$3];
30248
+ const XML_NODE_NAME$2 = "w:szCs";
30249
+ const SD_ATTR_KEY$1 = "fontSizeCs";
30250
+ const encode$5 = (params2, encodedAttrs = {}) => {
30251
+ const { nodes } = params2;
30252
+ const node = nodes?.[0];
30253
+ const value = encodedAttrs.fontSizeCs ?? node?.attributes?.["w:val"];
30254
+ return {
30255
+ type: "attr",
30256
+ xmlName: XML_NODE_NAME$2,
30257
+ sdNodeOrKeyName: SD_ATTR_KEY$1,
30258
+ attributes: { "w:val": value ?? null }
30259
+ };
30260
+ };
30261
+ const config$2 = {
30262
+ xmlName: XML_NODE_NAME$2,
30263
+ sdNodeOrKeyName: SD_ATTR_KEY$1,
30264
+ type: NodeTranslator.translatorTypes.ATTRIBUTE,
30265
+ encode: encode$5,
30266
+ attributes: validXmlAttributes$1
30267
+ };
30268
+ const translator$2 = NodeTranslator.from(config$2);
30269
+ const runPropertyTranslators = Object.freeze({
30270
+ "w:b": translator$9,
30271
+ "w:i": translator$8,
30272
+ "w:u": translator$a,
30273
+ "w:strike": translator$7,
30274
+ "w:color": translator$6,
30275
+ "w:highlight": translator$u,
30276
+ "w:rFonts": translator$5,
30277
+ "w:rStyle": translator$4,
30278
+ "w:sz": translator$3,
30279
+ "w:szCs": translator$2
30280
+ });
30281
+ const rawRunPropertyXmlNames = Object.freeze(["w:lang", "w:shd"]);
30282
+ const RAW_CHILD_NAME_SET = new Set(rawRunPropertyXmlNames);
30283
+ const KNOWN_CHILD_XML_NAMES = /* @__PURE__ */ new Set([...Object.keys(runPropertyTranslators), ...RAW_CHILD_NAME_SET]);
30284
+ const toRunPropertyEntry = (candidate) => {
30285
+ if (!candidate || candidate.type !== "attr") return null;
30286
+ const xmlName = candidate.xmlName || candidate.name;
30287
+ if (!xmlName) return null;
30288
+ return {
30289
+ xmlName,
30290
+ attributes: { ...candidate.attributes || {} }
30291
+ };
30292
+ };
30293
+ const XML_NODE_NAME$1 = "w:rPr";
30294
+ const SD_ATTR_KEY = "runProperties";
30295
+ const encode$4 = (params2) => {
30296
+ const { nodes } = params2;
30297
+ const node = nodes?.[0] || {};
30298
+ const contents = Array.isArray(node.elements) ? node.elements : [];
30299
+ const runPropsArray = contents.reduce(
30300
+ (acc, child) => {
30301
+ if (!child || typeof child !== "object") return acc;
30302
+ const xmlName = child.name;
30303
+ if (!KNOWN_CHILD_XML_NAMES.has(xmlName)) return acc;
30304
+ const translator2 = runPropertyTranslators[xmlName];
30305
+ let entry = null;
30306
+ if (translator2) {
30307
+ const encoded = translator2.encode({ ...params2, nodes: [child] }) || null;
30308
+ entry = toRunPropertyEntry(encoded);
30309
+ } else if (RAW_CHILD_NAME_SET.has(xmlName)) {
30310
+ entry = toRunPropertyEntry({
30311
+ type: "attr",
30312
+ xmlName,
30313
+ attributes: { ...child.attributes || {} }
30314
+ });
29751
30315
  }
30316
+ if (entry) acc.push(entry);
30317
+ return acc;
30318
+ },
30319
+ /** @type {{ xmlName: string, attributes: Record<string, any> }[]} */
30320
+ []
30321
+ );
30322
+ return {
30323
+ type: "attr",
30324
+ xmlName: "w:rPr",
30325
+ sdNodeOrKeyName: "runProperties",
30326
+ attributes: runPropsArray
30327
+ };
30328
+ };
30329
+ const config$1 = {
30330
+ xmlName: XML_NODE_NAME$1,
30331
+ sdNodeOrKeyName: SD_ATTR_KEY,
30332
+ type: NodeTranslator.translatorTypes.ATTRIBUTE,
30333
+ encode: encode$4
30334
+ };
30335
+ const translator$1 = NodeTranslator.from(config$1);
30336
+ const collectRunProperties = (params2, rPrNode, translator2 = translator$1) => {
30337
+ if (!rPrNode) return { entries: [], hadRPr: false, styleChangeMarks: [] };
30338
+ const result = translator2.encode({ ...params2, nodes: [rPrNode] }) || {};
30339
+ let entries = [];
30340
+ if (Array.isArray(result.attributes) && result.attributes.length) {
30341
+ entries = result.attributes.map((attr) => ({
30342
+ xmlName: attr?.xmlName,
30343
+ attributes: { ...attr?.attributes || {} }
30344
+ }));
30345
+ } else if (Array.isArray(rPrNode.elements) && rPrNode.elements.length) {
30346
+ entries = rPrNode.elements.filter((el) => el && typeof el === "object").map((el) => ({
30347
+ xmlName: el.name,
30348
+ attributes: { ...el.attributes || {} }
30349
+ }));
30350
+ }
30351
+ const legacyMarks = parseMarks(rPrNode, [], params2?.docx) || [];
30352
+ const styleChangeMarks = handleStyleChangeMarks(rPrNode, legacyMarks) || [];
30353
+ return { entries, hadRPr: true, styleChangeMarks };
30354
+ };
30355
+ const buildRunAttrs = (encodedAttrs = {}, hadRPr, runProps) => {
30356
+ const base2 = { ...encodedAttrs || {} };
30357
+ if (hadRPr) {
30358
+ base2.runProperties = runProps.length ? runProps : null;
30359
+ }
30360
+ return base2;
30361
+ };
30362
+ const ensureRunMark = (marks, runAttrs) => {
30363
+ if (!runAttrs) return;
30364
+ const runMark = createRunMark(runAttrs);
30365
+ const runMarkIndex = marks.findIndex((mark) => mark?.type === "run");
30366
+ if (runMarkIndex >= 0) {
30367
+ const existing = marks[runMarkIndex];
30368
+ if (runMark.attrs) {
30369
+ marks[runMarkIndex] = { ...existing, attrs: mergeRunAttrs(existing?.attrs, runMark.attrs) };
30370
+ }
30371
+ return;
30372
+ }
30373
+ marks.push(runMark);
30374
+ };
30375
+ const ensureInlineMarks = (marks, inlineMarks = []) => {
30376
+ inlineMarks.forEach(({ type: type2, attrs }) => {
30377
+ if (!type2) return;
30378
+ if (marks.some((mark) => mark?.type === type2)) return;
30379
+ marks.push(attrs ? { type: type2, attrs: { ...attrs } } : { type: type2 });
30380
+ });
30381
+ };
30382
+ const ensureTextStyleMark = (marks, textStyleAttrs) => {
30383
+ if (!textStyleAttrs) return;
30384
+ const existingTextStyle = marks.find((mark) => mark?.type === "textStyle");
30385
+ if (existingTextStyle) {
30386
+ existingTextStyle.attrs = { ...existingTextStyle.attrs || {}, ...textStyleAttrs };
30387
+ return;
30388
+ }
30389
+ marks.push({ type: "textStyle", attrs: { ...textStyleAttrs } });
30390
+ };
30391
+ const applyRunMarks = (node, runAttrs, inlineMarks, textStyleAttrs) => {
30392
+ if (!node || typeof node !== "object") return node;
30393
+ const baseMarks = Array.isArray(node.marks) ? node.marks : [];
30394
+ const marks = baseMarks.map((mark) => cloneMark(mark));
30395
+ ensureRunMark(marks, runAttrs);
30396
+ ensureInlineMarks(marks, inlineMarks);
30397
+ if (node.type === "text") {
30398
+ ensureTextStyleMark(marks, textStyleAttrs);
30399
+ }
30400
+ return { ...node, marks };
30401
+ };
30402
+ const createRunMark = (attrs = {}) => {
30403
+ const hasAttrs = attrs && Object.keys(attrs).length > 0;
30404
+ return hasAttrs ? { type: "run", attrs: cloneRunAttrs(attrs) } : { type: "run" };
30405
+ };
30406
+ const deriveStyleMarks = ({ docx, paragraphStyleId, runStyleId }) => {
30407
+ const paragraphStyleMarks = collectStyleMarks(paragraphStyleId, docx);
30408
+ const runStyleMarks = collectStyleMarks(runStyleId, docx);
30409
+ const inlineMarks = mergeInlineMarkSets(paragraphStyleMarks.inlineMarks, runStyleMarks.inlineMarks);
30410
+ const textStyleAttrs = mergeTextStyleAttrs(paragraphStyleMarks.textStyleAttrs, runStyleMarks.textStyleAttrs);
30411
+ return { inlineMarks, textStyleAttrs };
30412
+ };
30413
+ const collectStyleMarks = (styleId, docx, seen = /* @__PURE__ */ new Set()) => {
30414
+ if (!styleId || !docx || seen.has(styleId)) return { inlineMarks: [], textStyleAttrs: null };
30415
+ seen.add(styleId);
30416
+ const chain = collectStyleChain(styleId, docx, seen);
30417
+ if (!chain.length) return { inlineMarks: [], textStyleAttrs: null };
30418
+ const inlineMap = /* @__PURE__ */ new Map();
30419
+ let textStyleAttrs = {};
30420
+ chain.forEach((styleTag) => {
30421
+ const marks = extractMarksFromStyle(styleTag, docx);
30422
+ marks.inlineMarks.forEach((mark) => {
30423
+ inlineMap.set(mark.type, mark.attrs ? { type: mark.type, attrs: { ...mark.attrs } } : { type: mark.type });
29752
30424
  });
30425
+ if (marks.textStyleAttrs) textStyleAttrs = { ...textStyleAttrs, ...marks.textStyleAttrs };
30426
+ });
30427
+ return {
30428
+ inlineMarks: Array.from(inlineMap.values()),
30429
+ textStyleAttrs: Object.keys(textStyleAttrs).length ? textStyleAttrs : null
30430
+ };
30431
+ };
30432
+ const collectStyleChain = (styleId, docx, seen) => {
30433
+ if (!styleId || !docx) return [];
30434
+ const styleTag = findStyleTag(docx, styleId);
30435
+ if (!styleTag || !styleTag.elements) return [];
30436
+ const basedOn = styleTag.elements?.find((el) => el.name === "w:basedOn")?.attributes?.["w:val"];
30437
+ let chain = [];
30438
+ if (basedOn && !seen.has(basedOn)) {
30439
+ seen.add(basedOn);
30440
+ chain = collectStyleChain(basedOn, docx, seen);
30441
+ }
30442
+ chain.push(styleTag);
30443
+ return chain;
30444
+ };
30445
+ const findStyleTag = (docx, styleId) => {
30446
+ const stylesFile = docx?.["word/styles.xml"];
30447
+ if (!stylesFile?.elements?.length) return null;
30448
+ const candidates = [];
30449
+ stylesFile.elements.forEach((el) => {
30450
+ if (!el) return;
30451
+ if (el.name === "w:styles" && Array.isArray(el.elements)) {
30452
+ el.elements.forEach((child) => {
30453
+ if (child?.name === "w:style") candidates.push(child);
30454
+ });
30455
+ return;
30456
+ }
30457
+ if (el.name === "w:style") {
30458
+ candidates.push(el);
30459
+ return;
30460
+ }
30461
+ if (Array.isArray(el.elements)) {
30462
+ el.elements.forEach((child) => {
30463
+ if (child?.name === "w:style") candidates.push(child);
30464
+ });
30465
+ }
30466
+ });
30467
+ return candidates.find((tag) => tag?.attributes?.["w:styleId"] === styleId) || null;
30468
+ };
30469
+ const extractMarksFromStyle = (styleTag, docx) => {
30470
+ const rPr = styleTag?.elements?.find((el) => el.name === "w:rPr");
30471
+ if (!rPr) return { inlineMarks: [], textStyleAttrs: null };
30472
+ const marks = parseMarks(rPr, [], docx) || [];
30473
+ const inlineMarks = [];
30474
+ let textStyleAttrs = {};
30475
+ marks.forEach((mark) => {
30476
+ if (!mark) return;
30477
+ if (mark.type === "textStyle") {
30478
+ const attrs = mark.attrs || {};
30479
+ if (Object.keys(attrs).length) textStyleAttrs = { ...textStyleAttrs, ...attrs };
30480
+ return;
30481
+ }
30482
+ if (mark.type) inlineMarks.push(mark.attrs ? { type: mark.type, attrs: { ...mark.attrs } } : { type: mark.type });
30483
+ });
30484
+ return {
30485
+ inlineMarks,
30486
+ textStyleAttrs: Object.keys(textStyleAttrs).length ? textStyleAttrs : null
30487
+ };
30488
+ };
30489
+ const mergeInlineMarkSets = (...markSets) => {
30490
+ const map3 = /* @__PURE__ */ new Map();
30491
+ markSets.filter(Boolean).forEach((marks) => {
29753
30492
  marks.forEach((mark) => {
29754
- const exists2 = combinedMarks.some(
29755
- (existing) => existing.type === mark.type && JSON.stringify(existing.attrs || {}) === JSON.stringify(mark.attrs || {})
29756
- );
29757
- if (!exists2) {
29758
- combinedMarks.push(mark);
29759
- }
30493
+ if (!mark || !mark.type) return;
30494
+ map3.set(mark.type, mark.attrs ? { type: mark.type, attrs: { ...mark.attrs } } : { type: mark.type });
29760
30495
  });
29761
- if (runStyleId) combinedMarks.push({ type: "textStyle", attrs: { styleId: runStyleId } });
29762
- if (node.marks) combinedMarks.push(...node.marks);
29763
- const newMarks = createImportMarks(combinedMarks);
29764
- processedRun = processedRun.map((n) => {
29765
- const existingMarks = n.marks || [];
29766
- return {
29767
- ...n,
29768
- marks: [...newMarks, ...existingMarks]
29769
- };
30496
+ });
30497
+ return Array.from(map3.values());
30498
+ };
30499
+ const mergeTextStyleAttrs = (...attrsList) => {
30500
+ const merged = attrsList.filter((attrs) => attrs && Object.keys(attrs).length).reduce((acc, attrs) => ({ ...acc, ...attrs }), {});
30501
+ return Object.keys(merged).length ? merged : null;
30502
+ };
30503
+ const cloneRunAttrs = (attrs) => {
30504
+ const clone = { ...attrs };
30505
+ if (Array.isArray(attrs?.runProperties)) {
30506
+ clone.runProperties = attrs.runProperties.map((entry) => ({
30507
+ xmlName: entry?.xmlName,
30508
+ attributes: { ...entry?.attributes || {} }
30509
+ }));
30510
+ }
30511
+ return clone;
30512
+ };
30513
+ const cloneMark = (mark) => {
30514
+ if (!mark || typeof mark !== "object") return mark;
30515
+ const cloned = { ...mark };
30516
+ if (mark.attrs && typeof mark.attrs === "object") {
30517
+ cloned.attrs = { ...mark.attrs };
30518
+ if (Array.isArray(mark.attrs.runProperties)) {
30519
+ cloned.attrs.runProperties = mark.attrs.runProperties.map((entry) => ({
30520
+ xmlName: entry?.xmlName,
30521
+ attributes: { ...entry?.attributes || {} }
30522
+ }));
30523
+ }
30524
+ }
30525
+ return cloned;
30526
+ };
30527
+ const mergeRunAttrs = (existing = {}, incoming = {}) => {
30528
+ const merged = { ...existing, ...cloneRunAttrs(incoming) };
30529
+ if (Array.isArray(existing?.runProperties) && Array.isArray(incoming?.runProperties)) {
30530
+ const seen = /* @__PURE__ */ new Set();
30531
+ const combined = [...existing.runProperties, ...incoming.runProperties];
30532
+ merged.runProperties = combined.filter((entry) => {
30533
+ const key = entry?.xmlName;
30534
+ if (!key || seen.has(key)) return false;
30535
+ seen.add(key);
30536
+ return true;
29770
30537
  });
29771
30538
  }
29772
- return { nodes: processedRun, consumed: 1 };
30539
+ return merged;
29773
30540
  };
29774
- const getMarksFromStyles = (docx, styleId) => {
29775
- const styles = docx?.["word/styles.xml"];
29776
- if (!styles) {
29777
- return {};
30541
+ const normalizeBool = (value) => {
30542
+ if (value === void 0 || value === null) return true;
30543
+ if (typeof value === "boolean") return value;
30544
+ if (typeof value === "number") return value !== 0;
30545
+ const normalized = String(value).trim().toLowerCase();
30546
+ if (normalized === "0" || normalized === "false" || normalized === "off") return false;
30547
+ if (normalized === "1" || normalized === "true" || normalized === "on") return true;
30548
+ return true;
30549
+ };
30550
+ const resolveRunElement = (node) => {
30551
+ if (!node) return null;
30552
+ if (node.name === "w:r") return node;
30553
+ return (node.elements || []).find((el) => el.name === "w:r") || null;
30554
+ };
30555
+ const ensureRunPropertiesContainer = (runElement) => {
30556
+ if (!Array.isArray(runElement.elements)) runElement.elements = [];
30557
+ let rPr = runElement.elements.find((el) => el.name === "w:rPr");
30558
+ if (!rPr) {
30559
+ rPr = { name: "w:rPr", elements: [] };
30560
+ runElement.elements.unshift(rPr);
30561
+ }
30562
+ if (!Array.isArray(rPr.elements)) rPr.elements = [];
30563
+ return rPr;
30564
+ };
30565
+ const splitRunProperties = (entries = [], docx = null) => {
30566
+ const remainingProps = [];
30567
+ const inlineMarks = [];
30568
+ const textStyleAttrs = {};
30569
+ let hasTextStyle = false;
30570
+ let highlightColor = null;
30571
+ let runStyleId = null;
30572
+ entries.forEach((entry) => {
30573
+ if (!entry || !entry.xmlName) return;
30574
+ const attributes = entry.attributes || {};
30575
+ switch (entry.xmlName) {
30576
+ case "w:b": {
30577
+ const val = normalizeBool(attributes["w:val"]);
30578
+ inlineMarks.push(val ? { type: "bold" } : { type: "bold", attrs: { value: "0" } });
30579
+ break;
30580
+ }
30581
+ case "w:i": {
30582
+ const val = normalizeBool(attributes["w:val"]);
30583
+ inlineMarks.push(val ? { type: "italic" } : { type: "italic", attrs: { value: "0" } });
30584
+ break;
30585
+ }
30586
+ case "w:u": {
30587
+ const rawVal = attributes["w:val"];
30588
+ const underlineType = rawVal == null || rawVal === "" ? "single" : String(rawVal);
30589
+ const attrs = {};
30590
+ if (underlineType.toLowerCase() === "none" || underlineType === "0") {
30591
+ attrs.underlineType = "none";
30592
+ } else {
30593
+ attrs.underlineType = underlineType;
30594
+ const colorRaw = attributes["w:color"];
30595
+ if (typeof colorRaw === "string" && colorRaw.toLowerCase() !== "auto") {
30596
+ const normalizedColor = normalizeHexColor(colorRaw);
30597
+ if (normalizedColor) attrs.underlineColor = `#${normalizedColor}`;
30598
+ }
30599
+ }
30600
+ if (attributes["w:themeColor"]) attrs.underlineThemeColor = attributes["w:themeColor"];
30601
+ if (attributes["w:themeTint"]) attrs.underlineThemeTint = attributes["w:themeTint"];
30602
+ if (attributes["w:themeShade"]) attrs.underlineThemeShade = attributes["w:themeShade"];
30603
+ inlineMarks.push({ type: "underline", attrs });
30604
+ break;
30605
+ }
30606
+ case "w:color": {
30607
+ const raw = attributes["w:val"];
30608
+ if (typeof raw === "string" && raw) {
30609
+ hasTextStyle = true;
30610
+ textStyleAttrs.color = `#${raw.replace("#", "").toUpperCase()}`;
30611
+ }
30612
+ break;
30613
+ }
30614
+ case "w:rFonts": {
30615
+ const family = attributes["w:ascii"] || attributes["w:eastAsia"] || attributes["w:hAnsi"] || attributes["w:val"];
30616
+ if (family) {
30617
+ hasTextStyle = true;
30618
+ textStyleAttrs.fontFamily = SuperConverter.toCssFontFamily(family, docx);
30619
+ }
30620
+ break;
30621
+ }
30622
+ case "w:sz":
30623
+ case "w:szCs": {
30624
+ const rawSize = Number(attributes["w:val"]);
30625
+ if (Number.isFinite(rawSize) && rawSize > 0) {
30626
+ hasTextStyle = true;
30627
+ textStyleAttrs.fontSize = `${rawSize / 2}pt`;
30628
+ }
30629
+ break;
30630
+ }
30631
+ case "w:strike": {
30632
+ const val = normalizeBool(attributes["w:val"]);
30633
+ inlineMarks.push(val ? { type: "strike" } : { type: "strike", attrs: { value: "0" } });
30634
+ break;
30635
+ }
30636
+ case "w:highlight": {
30637
+ const color = attributes["w:val"];
30638
+ if (typeof color === "string" && color) {
30639
+ highlightColor = color.toLowerCase() === "none" ? "transparent" : color;
30640
+ }
30641
+ break;
30642
+ }
30643
+ case "w:shd": {
30644
+ const fill = attributes["w:fill"];
30645
+ const shdVal = attributes["w:val"];
30646
+ if (fill && String(fill).toLowerCase() !== "auto") {
30647
+ highlightColor = `#${String(fill).replace("#", "")}`;
30648
+ } else if (typeof shdVal === "string") {
30649
+ const normalized = shdVal.toLowerCase();
30650
+ if (normalized === "clear" || normalized === "nil" || normalized === "none") {
30651
+ highlightColor = "transparent";
30652
+ }
30653
+ }
30654
+ break;
30655
+ }
30656
+ case "w:rStyle": {
30657
+ if (typeof attributes["w:val"] === "string") runStyleId = attributes["w:val"];
30658
+ remainingProps.push({ xmlName: entry.xmlName, attributes: { ...attributes } });
30659
+ break;
30660
+ }
30661
+ default: {
30662
+ remainingProps.push({ xmlName: entry.xmlName, attributes: { ...attributes } });
30663
+ }
30664
+ }
30665
+ });
30666
+ if (highlightColor) inlineMarks.push({ type: "highlight", attrs: { color: highlightColor } });
30667
+ return {
30668
+ remainingProps,
30669
+ inlineMarks,
30670
+ textStyleAttrs: hasTextStyle ? textStyleAttrs : null,
30671
+ runStyleId
30672
+ };
30673
+ };
30674
+ const encode$3 = (attributes) => {
30675
+ return attributes["w:rsidR"];
30676
+ };
30677
+ const decode$3 = (attrs) => {
30678
+ return attrs.rsidR;
30679
+ };
30680
+ const attrConfig$2 = Object.freeze({
30681
+ xmlName: "w:rsidR",
30682
+ sdName: "rsidR",
30683
+ encode: encode$3,
30684
+ decode: decode$3
30685
+ });
30686
+ const encode$2 = (attributes) => {
30687
+ return attributes["w:rsidRPr"];
30688
+ };
30689
+ const decode$2 = (attrs) => {
30690
+ return attrs.rsidRPr;
30691
+ };
30692
+ const attrConfig$1 = Object.freeze({
30693
+ xmlName: "w:rsidRPr",
30694
+ sdName: "rsidRPr",
30695
+ encode: encode$2,
30696
+ decode: decode$2
30697
+ });
30698
+ const encode$1 = (attributes) => {
30699
+ return attributes["w:rsidDel"];
30700
+ };
30701
+ const decode$1 = (attrs) => {
30702
+ return attrs.rsidDel;
30703
+ };
30704
+ const attrConfig = Object.freeze({
30705
+ xmlName: "w:rsidDel",
30706
+ sdName: "rsidDel",
30707
+ encode: encode$1,
30708
+ decode: decode$1
30709
+ });
30710
+ const validXmlAttributes = [attrConfig$2, attrConfig$1, attrConfig];
30711
+ const XML_NODE_NAME = "w:r";
30712
+ const SD_KEY_NAME = "run";
30713
+ const encode$U = (params2, encodedAttrs = {}) => {
30714
+ const { nodes = [], nodeListHandler } = params2 || {};
30715
+ const runNode = nodes[0];
30716
+ if (!runNode) return void 0;
30717
+ const elements = Array.isArray(runNode.elements) ? runNode.elements : [];
30718
+ const rPrNode = elements.find((child) => child?.name === "w:rPr");
30719
+ const contentElements = rPrNode ? elements.filter((el) => el !== rPrNode) : elements;
30720
+ const { entries: runPropEntries, hadRPr, styleChangeMarks } = collectRunProperties(params2, rPrNode);
30721
+ const { remainingProps, inlineMarks, textStyleAttrs, runStyleId } = splitRunProperties(runPropEntries, params2?.docx);
30722
+ const styleMarks = deriveStyleMarks({
30723
+ docx: params2?.docx,
30724
+ paragraphStyleId: params2?.parentStyleId,
30725
+ runStyleId
30726
+ });
30727
+ const mergedInlineMarks = mergeInlineMarkSets(styleMarks.inlineMarks, inlineMarks);
30728
+ let mergedTextStyleAttrs = mergeTextStyleAttrs(styleMarks.textStyleAttrs, textStyleAttrs);
30729
+ if (runStyleId) {
30730
+ mergedTextStyleAttrs = mergedTextStyleAttrs ? { ...mergedTextStyleAttrs, styleId: runStyleId } : { styleId: runStyleId };
30731
+ }
30732
+ const runAttrs = buildRunAttrs(encodedAttrs, hadRPr, remainingProps);
30733
+ let runLevelMarks = Array.isArray(runNode.marks) ? runNode.marks.map((mark) => cloneMark(mark)) : [];
30734
+ if (styleChangeMarks?.length) {
30735
+ runLevelMarks = [...runLevelMarks, ...styleChangeMarks.map((mark) => cloneMark(mark))];
30736
+ }
30737
+ const childParams = { ...params2, nodes: contentElements };
30738
+ const content = nodeListHandler?.handler(childParams) || [];
30739
+ const contentWithRunMarks = content.map((child) => {
30740
+ if (!child || typeof child !== "object") return child;
30741
+ const baseMarks = Array.isArray(child.marks) ? child.marks.map((mark) => cloneMark(mark)) : [];
30742
+ if (!runLevelMarks.length) return child;
30743
+ return { ...child, marks: [...baseMarks, ...runLevelMarks.map((mark) => cloneMark(mark))] };
30744
+ });
30745
+ const marked = contentWithRunMarks.map(
30746
+ (child) => applyRunMarks(child, runAttrs, mergedInlineMarks, mergedTextStyleAttrs)
30747
+ );
30748
+ const filtered = marked.filter(Boolean);
30749
+ if (!filtered.length) return [];
30750
+ if (filtered.length === 1) return filtered[0];
30751
+ return filtered;
30752
+ };
30753
+ const decode = (params2, decodedAttrs = {}) => {
30754
+ const { node } = params2 || {};
30755
+ if (!node) return void 0;
30756
+ const marks = Array.isArray(node.marks) ? node.marks : [];
30757
+ const runMarkIndex = marks.findIndex((mark) => mark?.type === SD_KEY_NAME);
30758
+ const runMark = runMarkIndex >= 0 ? marks[runMarkIndex] : void 0;
30759
+ const strippedMarks = marks.filter((_2, idx) => idx !== runMarkIndex);
30760
+ const exportNode = { ...node, marks: strippedMarks };
30761
+ const exportParams = { ...params2, node: exportNode };
30762
+ if (!exportParams.editor) {
30763
+ exportParams.editor = { extensionService: { extensions: [] } };
30764
+ }
30765
+ const translated = exportSchemaToJson(exportParams);
30766
+ if (!translated) return void 0;
30767
+ const runElement = resolveRunElement(translated);
30768
+ if (!runElement) return translated;
30769
+ runElement.attributes = { ...runElement.attributes || {}, ...decodedAttrs };
30770
+ const runProperties = Array.isArray(runMark?.attrs?.runProperties) ? runMark.attrs.runProperties : null;
30771
+ if (runProperties && runProperties.length) {
30772
+ const rPr = ensureRunPropertiesContainer(runElement);
30773
+ const existingNames = new Set((rPr.elements || []).map((el) => el.name));
30774
+ runProperties.forEach((entry) => {
30775
+ if (!entry || !entry.xmlName || entry.xmlName === "w:b") return;
30776
+ if (existingNames.has(entry.xmlName)) return;
30777
+ rPr.elements.push({ name: entry.xmlName, attributes: { ...entry.attributes || {} } });
30778
+ existingNames.add(entry.xmlName);
30779
+ });
29778
30780
  }
29779
- const styleTags = styles.elements[0].elements.filter((style22) => style22.name === "w:style");
29780
- const style2 = styleTags.find((tag) => tag.attributes["w:styleId"] === styleId) || {};
29781
- if (!style2) return {};
29782
- return parseProperties(style2);
30781
+ return translated;
29783
30782
  };
29784
- const runNodeHandlerEntity = {
29785
- handlerName: "runNodeHandler",
29786
- handler: handleRunNode
30783
+ const config = {
30784
+ xmlName: XML_NODE_NAME,
30785
+ sdNodeOrKeyName: SD_KEY_NAME,
30786
+ type: NodeTranslator.translatorTypes.NODE,
30787
+ encode: encode$U,
30788
+ decode,
30789
+ attributes: validXmlAttributes
29787
30790
  };
30791
+ const translator = NodeTranslator.from(config);
30792
+ const runNodeHandlerEntity = generateV2HandlerEntity("runNodeHandler", translator);
29788
30793
  const handleTextNode = (params2) => {
29789
30794
  const { nodes, insideTrackChange } = params2;
29790
30795
  if (nodes.length === 0 || !(nodes[0].name === "w:t" || insideTrackChange && nodes[0].name === "w:delText")) {
@@ -29821,7 +30826,7 @@ const handleParagraphNode = (params2) => {
29821
30826
  if (nodes.length === 0 || nodes[0].name !== "w:p") {
29822
30827
  return { nodes: [], consumed: 0 };
29823
30828
  }
29824
- const schemaNode = translator$h.encode(params2);
30829
+ const schemaNode = translator$s.encode(params2);
29825
30830
  const newNodes = schemaNode ? [schemaNode] : [];
29826
30831
  return { nodes: newNodes, consumed: 1 };
29827
30832
  };
@@ -29834,7 +30839,7 @@ const handleSdtNode = (params2) => {
29834
30839
  if (nodes.length === 0 || nodes[0].name !== "w:sdt") {
29835
30840
  return { nodes: [], consumed: 0 };
29836
30841
  }
29837
- const result = translator.encode(params2);
30842
+ const result = translator$b.encode(params2);
29838
30843
  if (!result) {
29839
30844
  return { nodes: [], consumed: 0 };
29840
30845
  }
@@ -29924,7 +30929,7 @@ const handler = (params2) => {
29924
30929
  if (nodes.length === 0 || nodes[0].name !== "w:br") {
29925
30930
  return { nodes: [], consumed: 0 };
29926
30931
  }
29927
- const result = translator$j.encode(params2);
30932
+ const result = translator$v.encode(params2);
29928
30933
  if (!result) return { nodes: [], consumed: 0 };
29929
30934
  return {
29930
30935
  nodes: [result],
@@ -30620,7 +31625,7 @@ const handleTabNode = (params2) => {
30620
31625
  if (!nodes.length || nodes[0].name !== "w:tab") {
30621
31626
  return { nodes: [], consumed: 0 };
30622
31627
  }
30623
- const node = translator$i.encode(params2);
31628
+ const node = translator$t.encode(params2);
30624
31629
  return { nodes: [node], consumed: 1 };
30625
31630
  };
30626
31631
  const tabNodeEntityHandler = {
@@ -31067,6 +32072,16 @@ const isAlternatingHeadersOddEven = (docx) => {
31067
32072
  };
31068
32073
  const HYPERLINK_RELATIONSHIP_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink";
31069
32074
  const HEADER_RELATIONSHIP_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/header";
32075
+ const FONT_FAMILY_FALLBACKS = Object.freeze({
32076
+ swiss: "Arial, sans-serif",
32077
+ roman: "Times New Roman, serif",
32078
+ modern: "Courier New, monospace",
32079
+ script: "cursive",
32080
+ decorative: "fantasy",
32081
+ system: "system-ui",
32082
+ auto: "sans-serif"
32083
+ });
32084
+ const DEFAULT_GENERIC_FALLBACK = "sans-serif";
31070
32085
  const _SuperConverter = class _SuperConverter2 {
31071
32086
  constructor(params2 = null) {
31072
32087
  __privateAdd$2(this, _SuperConverter_instances);
@@ -31102,6 +32117,31 @@ const _SuperConverter = class _SuperConverter2 {
31102
32117
  this.documentId = params2?.documentId || null;
31103
32118
  if (this.docx.length || this.xml) this.parseFromXml();
31104
32119
  }
32120
+ static getFontTableEntry(docx, fontName) {
32121
+ if (!docx || !fontName) return null;
32122
+ const fontTable = docx["word/fontTable.xml"];
32123
+ if (!fontTable?.elements?.length) return null;
32124
+ const fontsNode = fontTable.elements.find((el) => el.name === "w:fonts");
32125
+ if (!fontsNode?.elements?.length) return null;
32126
+ return fontsNode.elements.find((el) => el?.attributes?.["w:name"] === fontName) || null;
32127
+ }
32128
+ static getFallbackFromFontTable(docx, fontName) {
32129
+ const fontEntry = _SuperConverter2.getFontTableEntry(docx, fontName);
32130
+ const family = fontEntry?.elements?.find((child) => child.name === "w:family")?.attributes?.["w:val"];
32131
+ if (!family) return null;
32132
+ const mapped = FONT_FAMILY_FALLBACKS[family.toLowerCase()];
32133
+ return mapped || DEFAULT_GENERIC_FALLBACK;
32134
+ }
32135
+ static toCssFontFamily(fontName, docx) {
32136
+ if (!fontName) return fontName;
32137
+ if (fontName.includes(",")) return fontName;
32138
+ const fallback = _SuperConverter2.getFallbackFromFontTable(docx, fontName) || DEFAULT_GENERIC_FALLBACK;
32139
+ const normalizedFallbackParts = fallback.split(",").map((part) => part.trim().toLowerCase()).filter(Boolean);
32140
+ if (normalizedFallbackParts.includes(fontName.trim().toLowerCase())) {
32141
+ return fallback;
32142
+ }
32143
+ return `${fontName}, ${fallback}`;
32144
+ }
31105
32145
  /**
31106
32146
  * Get the DocxHelpers object that contains utility functions for working with docx files.
31107
32147
  * @returns {import('./docx-helpers/docx-helpers.js').DocxHelpers} The DocxHelpers object.
@@ -31147,7 +32187,7 @@ const _SuperConverter = class _SuperConverter2 {
31147
32187
  return;
31148
32188
  }
31149
32189
  }
31150
- static updateDocumentVersion(docx = this.convertedXml, version2 = "0.20.1") {
32190
+ static updateDocumentVersion(docx = this.convertedXml, version2 = "0.21.0-RC1") {
31151
32191
  const customLocation = "docProps/custom.xml";
31152
32192
  if (!docx[customLocation]) {
31153
32193
  docx[customLocation] = generateCustomXml();
@@ -31198,13 +32238,19 @@ const _SuperConverter = class _SuperConverter2 {
31198
32238
  if (rPrDefaults) {
31199
32239
  const rPr = rPrDefaults.elements?.find((el) => el.name === "w:rPr");
31200
32240
  const fonts = rPr?.elements?.find((el) => el.name === "w:rFonts");
31201
- typeface = fonts?.attributes["w:ascii"];
31202
- const fontSize2 = typeface ?? rPr?.elements?.find((el) => el.name === "w:sz")?.attributes["w:val"];
31203
- fontSizeNormal = !fontSizeNormal && fontSize2 ? Number(fontSize2) / 2 : null;
32241
+ if (fonts?.attributes?.["w:ascii"]) {
32242
+ typeface = fonts.attributes["w:ascii"];
32243
+ }
32244
+ const fontSizeRaw = rPr?.elements?.find((el) => el.name === "w:sz")?.attributes?.["w:val"];
32245
+ if (!fontSizeNormal && fontSizeRaw) {
32246
+ fontSizeNormal = Number(fontSizeRaw) / 2;
32247
+ }
31204
32248
  }
31205
- const fontSizePt = fontSizeNormal || Number(rElements.find((el) => el.name === "w:sz")?.attributes["w:val"]) / 2 || 10;
32249
+ const fallbackSz = Number(rElements.find((el) => el.name === "w:sz")?.attributes?.["w:val"]);
32250
+ const fontSizePt = fontSizeNormal ?? (Number.isFinite(fallbackSz) ? fallbackSz / 2 : void 0) ?? 10;
31206
32251
  const kern = rElements.find((el) => el.name === "w:kern")?.attributes["w:val"];
31207
- return { fontSizePt, kern, typeface, panose };
32252
+ const fontFamilyCss = _SuperConverter2.toCssFontFamily(typeface, this.convertedXml);
32253
+ return { fontSizePt, kern, typeface, panose, fontFamilyCss };
31208
32254
  }
31209
32255
  }
31210
32256
  getDocumentFonts() {
@@ -31634,7 +32680,7 @@ function storeSuperdocVersion(docx) {
31634
32680
  function generateCustomXml() {
31635
32681
  return DEFAULT_CUSTOM_XML;
31636
32682
  }
31637
- function generateSuperdocVersion(pid = 2, version2 = "0.20.1") {
32683
+ function generateSuperdocVersion(pid = 2, version2 = "0.21.0-RC1") {
31638
32684
  return {
31639
32685
  type: "element",
31640
32686
  name: "property",
@@ -34043,7 +35089,7 @@ class DocxZipper {
34043
35089
  const u8 = await zipEntry.async("uint8array");
34044
35090
  const content = ensureXmlString(u8);
34045
35091
  this.files.push({ name, content });
34046
- } else if (name.startsWith("word/media") && name !== "word/media/" || zipEntry.name.startsWith("media") && zipEntry.name !== "media/" || name.startsWith("media") && name !== "media/") {
35092
+ } else if (name.startsWith("word/media") && name !== "word/media/" || name.startsWith("media") && name !== "media/") {
34047
35093
  if (isNode2) {
34048
35094
  const buffer2 = await zipEntry.async("nodebuffer");
34049
35095
  const fileBase64 = buffer2.toString("base64");
@@ -43048,6 +44094,95 @@ const toggleMark = (typeOrName, attrs = {}, options = {}) => ({ state: state2, c
43048
44094
  if (isActive2) return commands2.unsetMark(type2, { extendEmptyMarkRange });
43049
44095
  return commands2.setMark(type2, attrs);
43050
44096
  };
44097
+ const toggleMarkCascade = (markName, options = {}) => ({ state: state2, chain, editor }) => {
44098
+ const {
44099
+ negationAttrs = { value: "0" },
44100
+ isNegation = (attrs) => attrs?.value === "0",
44101
+ styleDetector = defaultStyleDetector,
44102
+ extendEmptyMarkRange = true
44103
+ } = options;
44104
+ const selectionMarks = getMarksFromSelection(state2) || [];
44105
+ const inlineMarks = selectionMarks.filter((m2) => m2.type?.name === markName);
44106
+ const hasNegation = inlineMarks.some((m2) => isNegation(m2.attrs || {}));
44107
+ const hasInline = inlineMarks.some((m2) => !isNegation(m2.attrs || {}));
44108
+ const styleOn = styleDetector({ state: state2, selectionMarks, markName, editor });
44109
+ const cmdChain = chain();
44110
+ if (hasNegation) return cmdChain.unsetMark(markName, { extendEmptyMarkRange }).run();
44111
+ if (hasInline && styleOn) {
44112
+ return cmdChain.unsetMark(markName, { extendEmptyMarkRange }).setMark(markName, negationAttrs, { extendEmptyMarkRange }).run();
44113
+ }
44114
+ if (hasInline) return cmdChain.unsetMark(markName, { extendEmptyMarkRange }).run();
44115
+ if (styleOn) return cmdChain.setMark(markName, negationAttrs, { extendEmptyMarkRange }).run();
44116
+ return cmdChain.setMark(markName, {}, { extendEmptyMarkRange }).run();
44117
+ };
44118
+ function defaultStyleDetector({ state: state2, selectionMarks, markName, editor }) {
44119
+ try {
44120
+ const styleId = getEffectiveStyleId(state2, selectionMarks);
44121
+ if (!styleId || !editor?.converter?.linkedStyles) return false;
44122
+ const styles = editor.converter.linkedStyles;
44123
+ const seen = /* @__PURE__ */ new Set();
44124
+ let current = styleId;
44125
+ const key = mapMarkToStyleKey(markName);
44126
+ while (current && !seen.has(current)) {
44127
+ seen.add(current);
44128
+ const style2 = styles.find((s) => s.id === current);
44129
+ const def = style2?.definition?.styles || {};
44130
+ if (key in def) {
44131
+ const raw = def[key];
44132
+ if (raw === void 0) return true;
44133
+ const val = raw?.value ?? raw;
44134
+ if (val === "0" || val === false) return false;
44135
+ return !!val;
44136
+ }
44137
+ current = style2?.definition?.attrs?.basedOn || null;
44138
+ }
44139
+ return false;
44140
+ } catch {
44141
+ return false;
44142
+ }
44143
+ }
44144
+ function getEffectiveStyleId(state2, selectionMarks) {
44145
+ const sidFromMarks = getStyleIdFromMarks(selectionMarks);
44146
+ if (sidFromMarks) return sidFromMarks;
44147
+ const $from = state2.selection.$from;
44148
+ const before = $from.nodeBefore;
44149
+ const after = $from.nodeAfter;
44150
+ if (before && before.marks) {
44151
+ const sid = getStyleIdFromMarks(before.marks);
44152
+ if (sid) return sid;
44153
+ }
44154
+ if (after && after.marks) {
44155
+ const sid = getStyleIdFromMarks(after.marks);
44156
+ if (sid) return sid;
44157
+ }
44158
+ const ts = selectionMarks.find((m2) => m2.type?.name === "textStyle" && m2.attrs?.styleId);
44159
+ if (ts) return ts.attrs.styleId;
44160
+ const pos = state2.selection.$from.pos;
44161
+ const $pos = state2.doc.resolve(pos);
44162
+ for (let d2 = $pos.depth; d2 >= 0; d2--) {
44163
+ const n = $pos.node(d2);
44164
+ if (n?.type?.name === "paragraph") return n.attrs?.styleId || null;
44165
+ }
44166
+ return null;
44167
+ }
44168
+ function getStyleIdFromMarks(marks) {
44169
+ const run2 = marks.find((m2) => m2.type?.name === "run");
44170
+ const runProperties = run2?.attrs?.runProperties;
44171
+ if (!runProperties) return null;
44172
+ if (runProperties && typeof runProperties === "object" && !Array.isArray(runProperties) && runProperties.styleId) {
44173
+ return runProperties.styleId;
44174
+ }
44175
+ if (Array.isArray(runProperties)) {
44176
+ const rStyleEntry = runProperties.find((e) => e?.xmlName === "w:rStyle");
44177
+ const sid = rStyleEntry?.attributes?.["w:val"];
44178
+ if (sid) return sid;
44179
+ }
44180
+ return null;
44181
+ }
44182
+ function mapMarkToStyleKey(markName) {
44183
+ if (markName === "textStyle" || markName === "color") return "color";
44184
+ return markName;
44185
+ }
43051
44186
  const clearNodes = () => ({ state: state2, tr, dispatch }) => {
43052
44187
  const { selection } = tr;
43053
44188
  const { ranges } = selection;
@@ -44393,11 +45528,14 @@ const commands$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePr
44393
45528
  command,
44394
45529
  createParagraphNear,
44395
45530
  decreaseListIndent,
45531
+ defaultStyleDetector,
44396
45532
  deleteListItem,
44397
45533
  deleteSelection,
44398
45534
  exitCode,
44399
45535
  first,
45536
+ getEffectiveStyleId,
44400
45537
  getParaCtx,
45538
+ getStyleIdFromMarks,
44401
45539
  handleBackspaceNextToList,
44402
45540
  handleDeleteNextToList,
44403
45541
  increaseListIndent,
@@ -44412,6 +45550,7 @@ const commands$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePr
44412
45550
  joinUp,
44413
45551
  liftEmptyBlock,
44414
45552
  liftListItem,
45553
+ mapMarkToStyleKey,
44415
45554
  nearestListAt,
44416
45555
  newlineInCode,
44417
45556
  rebuildListNodeWithNewNum,
@@ -44431,6 +45570,7 @@ const commands$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePr
44431
45570
  splitListItem,
44432
45571
  toggleList,
44433
45572
  toggleMark,
45573
+ toggleMarkCascade,
44434
45574
  toggleNode,
44435
45575
  undoInputRule,
44436
45576
  unsetAllMarks,
@@ -45634,7 +46774,7 @@ const createHeaderFooterEditor = ({
45634
46774
  currentPageNumber
45635
46775
  }) => {
45636
46776
  const parentStyles = editor.converter.getDocumentDefaultStyles();
45637
- const { fontSizePt, typeface } = parentStyles;
46777
+ const { fontSizePt, typeface, fontFamilyCss } = parentStyles;
45638
46778
  const fontSizeInPixles = fontSizePt * 1.3333;
45639
46779
  const lineHeight2 = fontSizeInPixles * 1.2;
45640
46780
  Object.assign(editorContainer.style, {
@@ -45647,7 +46787,7 @@ const createHeaderFooterEditor = ({
45647
46787
  left: "0",
45648
46788
  width: "auto",
45649
46789
  maxWidth: "none",
45650
- fontFamily: typeface,
46790
+ fontFamily: fontFamilyCss || typeface,
45651
46791
  fontSize: `${fontSizeInPixles}px`,
45652
46792
  lineHeight: `${lineHeight2}px`
45653
46793
  });
@@ -46477,7 +47617,6 @@ const trackedTransaction = ({ tr, state: state2, user }) => {
46477
47617
  originalStep,
46478
47618
  originalStepIndex
46479
47619
  });
46480
- console.debug("[track-changes]: replaceStep");
46481
47620
  } else if (step instanceof AddMarkStep) {
46482
47621
  addMarkStep({
46483
47622
  state: state2,
@@ -46487,7 +47626,6 @@ const trackedTransaction = ({ tr, state: state2, user }) => {
46487
47626
  user,
46488
47627
  date
46489
47628
  });
46490
- console.debug("[track-changes]: addMarkStep");
46491
47629
  } else if (step instanceof RemoveMarkStep) {
46492
47630
  removeMarkStep({
46493
47631
  state: state2,
@@ -46497,10 +47635,8 @@ const trackedTransaction = ({ tr, state: state2, user }) => {
46497
47635
  user,
46498
47636
  date
46499
47637
  });
46500
- console.debug("[track-changes]: removeMarkStep");
46501
47638
  } else {
46502
47639
  newTr.step(step);
46503
- console.log("[track-changes]: otherStep");
46504
47640
  }
46505
47641
  });
46506
47642
  if (tr.getMeta("inputType")) {
@@ -48570,9 +49706,10 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
48570
49706
  element.style.isolation = "isolate";
48571
49707
  proseMirror.style.outline = "none";
48572
49708
  proseMirror.style.border = "none";
48573
- const { typeface, fontSizePt } = this.converter.getDocumentDefaultStyles() ?? {};
48574
- if (typeface) {
48575
- element.style.fontFamily = typeface;
49709
+ const { typeface, fontSizePt, fontFamilyCss } = this.converter.getDocumentDefaultStyles() ?? {};
49710
+ const resolvedFontFamily = fontFamilyCss || typeface;
49711
+ if (resolvedFontFamily) {
49712
+ element.style.fontFamily = resolvedFontFamily;
48576
49713
  }
48577
49714
  if (fontSizePt) {
48578
49715
  element.style.fontSize = `${fontSizePt}pt`;
@@ -48886,7 +50023,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
48886
50023
  * @returns {Object | void} Migration results
48887
50024
  */
48888
50025
  processCollaborationMigrations() {
48889
- console.debug("[checkVersionMigrations] Current editor version", "0.20.1");
50026
+ console.debug("[checkVersionMigrations] Current editor version", "0.21.0-RC1");
48890
50027
  if (!this.options.ydoc) return;
48891
50028
  const metaMap = this.options.ydoc.getMap("meta");
48892
50029
  let docVersion = metaMap.get("version");
@@ -49995,6 +51132,7 @@ const FormatCommands = Extension.create({
49995
51132
  },
49996
51133
  addCommands() {
49997
51134
  return {
51135
+ toggleMarkCascade,
49998
51136
  /**
49999
51137
  * Clear all formatting (nodes and marks)
50000
51138
  * @category Command
@@ -50979,24 +52117,32 @@ const Text = Node$1.create({
50979
52117
  group: "inline",
50980
52118
  inline: true
50981
52119
  });
50982
- const RunItem = Node$1.create({
52120
+ const Run = Mark2.create({
50983
52121
  name: "run",
50984
- group: "inline",
50985
- content: "text*",
50986
- inline: true,
50987
- parseDOM() {
50988
- return [{ tag: "run" }];
50989
- },
50990
- renderDOM() {
50991
- return ["run", 0];
52122
+ inclusive: false,
52123
+ addOptions() {
52124
+ return {
52125
+ htmlAttributes: {}
52126
+ };
50992
52127
  },
50993
52128
  addAttributes() {
50994
52129
  return {
50995
- attributes: {
50996
- rendered: false,
50997
- "aria-label": "Run node"
52130
+ runProperties: {
52131
+ default: null,
52132
+ rendered: false
50998
52133
  }
50999
52134
  };
52135
+ },
52136
+ parseDOM() {
52137
+ return [
52138
+ {
52139
+ tag: "span[data-run]"
52140
+ }
52141
+ ];
52142
+ },
52143
+ renderDOM({ htmlAttributes }) {
52144
+ const base2 = Attribute2.mergeAttributes({ "data-run": "1" }, this.options.htmlAttributes, htmlAttributes);
52145
+ return ["span", base2, 0];
51000
52146
  }
51001
52147
  });
51002
52148
  const inputRegex$1 = /^\s*([-+*])\s$/;
@@ -51560,6 +52706,7 @@ const getMarksStyle = (attrs) => {
51560
52706
  case "textStyle":
51561
52707
  const { fontFamily: fontFamily2, fontSize: fontSize2 } = attr.attrs;
51562
52708
  styles += `${fontFamily2 ? `font-family: ${fontFamily2};` : ""} ${fontSize2 ? `font-size: ${fontSize2};` : ""}`;
52709
+ break;
51563
52710
  }
51564
52711
  }
51565
52712
  return styles.trim();
@@ -51578,12 +52725,22 @@ const generateLinkedStyleString = (linkedStyle, basedOnStyle, node, parent, incl
51578
52725
  const linkedDefinitionStyles = { ...linkedStyle.definition.styles };
51579
52726
  const basedOnDefinitionStyles = { ...basedOnStyle?.definition?.styles };
51580
52727
  const resultStyles = { ...linkedDefinitionStyles };
51581
- if (!linkedDefinitionStyles["font-size"] && basedOnDefinitionStyles["font-size"]) {
51582
- resultStyles["font-size"] = basedOnDefinitionStyles["font-size"];
51583
- }
51584
- if (!linkedDefinitionStyles["text-transform"] && basedOnDefinitionStyles["text-transform"]) {
51585
- resultStyles["text-transform"] = basedOnDefinitionStyles["text-transform"];
51586
- }
52728
+ const inheritKeys = [
52729
+ "font-size",
52730
+ "font-family",
52731
+ "text-transform",
52732
+ "bold",
52733
+ "italic",
52734
+ "underline",
52735
+ "strike",
52736
+ "color",
52737
+ "highlight"
52738
+ ];
52739
+ inheritKeys.forEach((k) => {
52740
+ if (!linkedDefinitionStyles[k] && basedOnDefinitionStyles[k]) {
52741
+ resultStyles[k] = basedOnDefinitionStyles[k];
52742
+ }
52743
+ });
51587
52744
  Object.entries(resultStyles).forEach(([k, value]) => {
51588
52745
  const key = kebabCase$1(k);
51589
52746
  const flattenedMarks = [];
@@ -51598,6 +52755,10 @@ const generateLinkedStyleString = (linkedStyle, basedOnStyle, node, parent, incl
51598
52755
  }
51599
52756
  flattenedMarks.push({ key: n.type.name, value: n.attrs[key] });
51600
52757
  });
52758
+ const underlineNone = node?.marks?.some((m2) => m2.type?.name === "underline" && m2.attrs?.underlineType === "none");
52759
+ if (underlineNone) {
52760
+ markValue["text-decoration"] = "none";
52761
+ }
51601
52762
  const mark = flattenedMarks.find((n) => n.key === key);
51602
52763
  const hasParentIndent = Object.keys(parent?.attrs?.indent || {});
51603
52764
  const hasParentSpacing = Object.keys(parent?.attrs?.spacing || {});
@@ -51614,10 +52775,28 @@ const generateLinkedStyleString = (linkedStyle, basedOnStyle, node, parent, incl
51614
52775
  if (rightIndent) markValue["margin-right"] = rightIndent + "px";
51615
52776
  if (firstLine) markValue["text-indent"] = firstLine + "px";
51616
52777
  } else if (key === "bold" && node) {
51617
- const val = value?.value;
51618
- if (!listTypes.includes(node.type.name) && val !== "0") {
52778
+ const boldValue = typeof value === "object" && value !== null ? value.value : value;
52779
+ const hasInlineBoldOff = node.marks?.some((m2) => m2.type?.name === "bold" && m2.attrs?.value === "0");
52780
+ const hasInlineBoldOn = node.marks?.some((m2) => m2.type?.name === "bold" && m2.attrs?.value !== "0");
52781
+ if (!listTypes.includes(node.type.name) && !hasInlineBoldOff && !hasInlineBoldOn && boldValue !== "0" && boldValue !== false) {
51619
52782
  markValue["font-weight"] = "bold";
51620
52783
  }
52784
+ } else if (key === "italic" && node) {
52785
+ const italicValue = typeof value === "object" && value !== null ? value.value : value;
52786
+ const hasInlineItalicOff = node.marks?.some((m2) => m2.type?.name === "italic" && m2.attrs?.value === "0");
52787
+ const hasInlineItalicOn = node.marks?.some((m2) => m2.type?.name === "italic" && m2.attrs?.value !== "0");
52788
+ if (!listTypes.includes(node.type.name) && !hasInlineItalicOff && !hasInlineItalicOn && italicValue !== "0" && italicValue !== false) {
52789
+ markValue["font-style"] = "italic";
52790
+ }
52791
+ } else if (key === "strike" && node) {
52792
+ const strikeValue = typeof value === "object" && value !== null ? value.value : value;
52793
+ const hasInlineStrikeOff = node.marks?.some((m2) => m2.type?.name === "strike" && m2.attrs?.value === "0");
52794
+ const hasInlineStrikeOn = node.marks?.some(
52795
+ (m2) => m2.type?.name === "strike" && (m2.attrs?.value === void 0 || m2.attrs?.value !== "0")
52796
+ );
52797
+ if (!listTypes.includes(node.type.name) && !hasInlineStrikeOff && !hasInlineStrikeOn && strikeValue !== "0" && strikeValue !== false) {
52798
+ markValue["text-decoration"] = "line-through";
52799
+ }
51621
52800
  } else if (key === "text-transform" && node) {
51622
52801
  if (!listTypes.includes(node.type.name)) {
51623
52802
  markValue[key] = value;
@@ -51626,10 +52805,44 @@ const generateLinkedStyleString = (linkedStyle, basedOnStyle, node, parent, incl
51626
52805
  if (!listTypes.includes(node.type.name)) {
51627
52806
  markValue[key] = value;
51628
52807
  }
52808
+ } else if (key === "font-family" && node) {
52809
+ if (!listTypes.includes(node.type.name)) {
52810
+ markValue[key] = value;
52811
+ }
51629
52812
  } else if (key === "color" && node) {
51630
52813
  if (!listTypes.includes(node.type.name)) {
51631
52814
  markValue[key] = value;
51632
52815
  }
52816
+ } else if (key === "highlight" && node) {
52817
+ const hasInlineHighlight = node.marks?.some((m2) => m2.type?.name === "highlight");
52818
+ if (!listTypes.includes(node.type.name) && !hasInlineHighlight) {
52819
+ const color = typeof value === "string" ? value : value?.color;
52820
+ if (color) markValue["background-color"] = color;
52821
+ }
52822
+ } else if (key === "underline" && node) {
52823
+ const styleValRaw = value?.value ?? value ?? "";
52824
+ const styleVal = styleValRaw.toString().toLowerCase();
52825
+ const hasInlineUnderlineOff = node.marks?.some(
52826
+ (m2) => m2.type?.name === "underline" && m2.attrs?.underlineType === "none"
52827
+ );
52828
+ const hasInlineUnderlineOn = node.marks?.some(
52829
+ (m2) => m2.type?.name === "underline" && m2.attrs?.underlineType && m2.attrs.underlineType !== "none"
52830
+ );
52831
+ if (!listTypes.includes(node.type.name) && !hasInlineUnderlineOff && !hasInlineUnderlineOn) {
52832
+ if (styleVal && styleVal !== "none" && styleVal !== "0") {
52833
+ const colorVal = value && typeof value === "object" ? value.color || value.underlineColor || null : null;
52834
+ const css = getUnderlineCssString({ type: styleVal, color: colorVal });
52835
+ css.split(";").forEach((decl) => {
52836
+ const d2 = decl.trim();
52837
+ if (!d2) return;
52838
+ const idx = d2.indexOf(":");
52839
+ if (idx === -1) return;
52840
+ const k2 = d2.slice(0, idx).trim();
52841
+ const v2 = d2.slice(idx + 1).trim();
52842
+ markValue[k2] = v2;
52843
+ });
52844
+ }
52845
+ }
51633
52846
  } else if (typeof value === "string") {
51634
52847
  markValue[key] = value;
51635
52848
  }
@@ -51762,23 +52975,51 @@ const createLinkedStylesPlugin = (editor) => {
51762
52975
  };
51763
52976
  const generateDecorations = (state2, styles) => {
51764
52977
  const decorations = [];
51765
- let lastStyleId = null;
51766
52978
  const doc2 = state2?.doc;
52979
+ const getParagraphStyleId = (pos) => {
52980
+ const $pos = state2.doc.resolve(pos);
52981
+ for (let d2 = $pos.depth; d2 >= 0; d2--) {
52982
+ const n = $pos.node(d2);
52983
+ if (n?.type?.name === "paragraph") return n.attrs?.styleId || null;
52984
+ }
52985
+ return null;
52986
+ };
51767
52987
  doc2.descendants((node, pos) => {
51768
52988
  const { name } = node.type;
51769
- if (node?.attrs?.styleId) lastStyleId = node.attrs.styleId;
51770
- if (name === "paragraph" && !node.attrs?.styleId) lastStyleId = null;
51771
- if (name !== "text" && name !== "listItem" && name !== "orderedList") return;
52989
+ if (name !== "text") return;
52990
+ const paragraphStyleId = getParagraphStyleId(pos);
52991
+ let runStyleId = null;
52992
+ let inlineTextStyleId = null;
51772
52993
  for (const mark of node.marks) {
51773
- if (mark.type.name === "textStyle" && mark.attrs.styleId) {
51774
- lastStyleId = mark.attrs.styleId;
51775
- }
51776
- }
51777
- const { linkedStyle, basedOnStyle } = getLinkedStyle(lastStyleId, styles);
51778
- if (!linkedStyle) return;
52994
+ if (mark.type.name === "run") {
52995
+ const rp = mark.attrs?.runProperties;
52996
+ if (rp && typeof rp === "object" && !Array.isArray(rp) && rp.styleId) runStyleId = rp.styleId;
52997
+ else if (Array.isArray(rp)) {
52998
+ const ent = rp.find((e) => e?.xmlName === "w:rStyle");
52999
+ const sid = ent?.attributes?.["w:val"];
53000
+ if (sid) runStyleId = sid;
53001
+ }
53002
+ } else if (mark.type.name === "textStyle" && mark.attrs?.styleId) {
53003
+ inlineTextStyleId = mark.attrs.styleId;
53004
+ }
53005
+ }
53006
+ const buildStyleMap = (sid) => {
53007
+ if (!sid) return {};
53008
+ const { linkedStyle, basedOnStyle: basedOnStyle2 } = getLinkedStyle(sid, styles);
53009
+ if (!linkedStyle) return {};
53010
+ const base2 = { ...basedOnStyle2?.definition?.styles || {} };
53011
+ return { ...base2, ...linkedStyle.definition?.styles || {} };
53012
+ };
53013
+ const pMap = buildStyleMap(paragraphStyleId);
53014
+ const tMap = buildStyleMap(inlineTextStyleId);
53015
+ const rMap = buildStyleMap(runStyleId);
53016
+ const finalStyles = { ...pMap, ...tMap, ...rMap };
53017
+ if (Object.keys(finalStyles).length === 0) return;
53018
+ const mergedLinkedStyle = { definition: { styles: finalStyles, attrs: {} } };
53019
+ const basedOnStyle = null;
51779
53020
  const $pos = state2.doc.resolve(pos);
51780
53021
  const parent = $pos.parent;
51781
- const styleString = generateLinkedStyleString(linkedStyle, basedOnStyle, node, parent);
53022
+ const styleString = generateLinkedStyleString(mergedLinkedStyle, basedOnStyle, node, parent);
51782
53023
  if (!styleString) return;
51783
53024
  const decoration = Decoration.inline(pos, pos + node.nodeSize, { style: styleString });
51784
53025
  decorations.push(decoration);
@@ -51913,6 +53154,70 @@ const LinkedStyles = Extension.create({
51913
53154
  };
51914
53155
  }
51915
53156
  });
53157
+ function getUnderlineCssString({ type: type2 = "single", color = null, thickness = null, approximate = true } = {}) {
53158
+ const parts = [];
53159
+ const add = (k, v2) => {
53160
+ if (!v2) return;
53161
+ parts.push(`${k}: ${v2}`);
53162
+ };
53163
+ const lower = String(type2 || "single").toLowerCase();
53164
+ if (lower === "none" || lower === "0") {
53165
+ add("text-decoration", "none");
53166
+ return parts.join("; ");
53167
+ }
53168
+ add("text-decoration-line", "underline");
53169
+ const HEAVY = thickness || "0.2em";
53170
+ const THICK = thickness || "0.15em";
53171
+ switch (lower) {
53172
+ case "single":
53173
+ break;
53174
+ case "double":
53175
+ add("text-decoration-style", "double");
53176
+ break;
53177
+ case "thick":
53178
+ add("text-decoration-thickness", THICK);
53179
+ break;
53180
+ case "dotted":
53181
+ add("text-decoration-style", "dotted");
53182
+ break;
53183
+ case "dash":
53184
+ case "dashed":
53185
+ add("text-decoration-style", "dashed");
53186
+ break;
53187
+ case "dotdash":
53188
+ case "dotdotdash":
53189
+ case "dashlong":
53190
+ case "dashlongheavy":
53191
+ if (approximate) {
53192
+ add("text-decoration-style", "dashed");
53193
+ if (lower.includes("heavy")) add("text-decoration-thickness", HEAVY);
53194
+ }
53195
+ break;
53196
+ case "dottedheavy":
53197
+ add("text-decoration-style", "dotted");
53198
+ add("text-decoration-thickness", HEAVY);
53199
+ break;
53200
+ case "dashedheavy":
53201
+ add("text-decoration-style", "dashed");
53202
+ add("text-decoration-thickness", HEAVY);
53203
+ break;
53204
+ case "wavy":
53205
+ add("text-decoration-style", "wavy");
53206
+ break;
53207
+ case "wavyheavy":
53208
+ add("text-decoration-style", "wavy");
53209
+ add("text-decoration-thickness", HEAVY);
53210
+ break;
53211
+ case "wavydouble":
53212
+ if (approximate) {
53213
+ add("text-decoration-style", "wavy");
53214
+ add("text-decoration-thickness", HEAVY);
53215
+ }
53216
+ break;
53217
+ }
53218
+ if (color) add("text-decoration-color", color);
53219
+ return parts.join("; ");
53220
+ }
51916
53221
  const generateOrderedListIndex = ({ listLevel, lvlText, listNumberingType, customFormat }) => {
51917
53222
  const handler2 = listIndexMap[listNumberingType];
51918
53223
  return handler2 ? handler2(listLevel, lvlText, customFormat) : null;
@@ -60198,6 +61503,30 @@ const TextStyle = Mark2.create({
60198
61503
  };
60199
61504
  }
60200
61505
  });
61506
+ function createCascadeToggleCommands({
61507
+ markName,
61508
+ setCommand,
61509
+ unsetCommand,
61510
+ toggleCommand,
61511
+ negationAttrs,
61512
+ isNegation,
61513
+ extendEmptyMarkRange
61514
+ } = {}) {
61515
+ if (!markName) throw new Error("createCascadeToggleCommands requires a markName");
61516
+ const capitalized = markName.charAt(0).toUpperCase() + markName.slice(1);
61517
+ const setName = setCommand ?? `set${capitalized}`;
61518
+ const unsetName = unsetCommand ?? `unset${capitalized}`;
61519
+ const toggleName = toggleCommand ?? `toggle${capitalized}`;
61520
+ const cascadeOptions = {};
61521
+ if (negationAttrs) cascadeOptions.negationAttrs = negationAttrs;
61522
+ if (typeof isNegation === "function") cascadeOptions.isNegation = isNegation;
61523
+ if (extendEmptyMarkRange !== void 0) cascadeOptions.extendEmptyMarkRange = extendEmptyMarkRange;
61524
+ return {
61525
+ [setName]: () => ({ commands: commands2 }) => commands2.setMark(markName),
61526
+ [unsetName]: () => ({ commands: commands2 }) => commands2.unsetMark(markName),
61527
+ [toggleName]: () => ({ commands: commands2 }) => commands2.toggleMarkCascade(markName, cascadeOptions)
61528
+ };
61529
+ }
60201
61530
  const Bold = Mark2.create({
60202
61531
  name: "bold",
60203
61532
  addOptions() {
@@ -60232,9 +61561,18 @@ const Bold = Mark2.create({
60232
61561
  ];
60233
61562
  },
60234
61563
  renderDOM({ htmlAttributes }) {
60235
- return ["strong", Attribute2.mergeAttributes(this.options.htmlAttributes, htmlAttributes), 0];
61564
+ const merged = Attribute2.mergeAttributes(this.options.htmlAttributes, htmlAttributes);
61565
+ const { value, ...rest } = merged || {};
61566
+ if (value === "0") {
61567
+ return ["span", rest, 0];
61568
+ }
61569
+ return ["strong", rest, 0];
60236
61570
  },
60237
61571
  addCommands() {
61572
+ const { setBold, unsetBold, toggleBold } = createCascadeToggleCommands({
61573
+ markName: this.name,
61574
+ negationAttrs: { value: "0" }
61575
+ });
60238
61576
  return {
60239
61577
  /**
60240
61578
  * Apply bold formatting
@@ -60244,7 +61582,7 @@ const Bold = Mark2.create({
60244
61582
  * setBold()
60245
61583
  * @note '0' renders as normal weight
60246
61584
  */
60247
- setBold: () => ({ commands: commands2 }) => commands2.setMark(this.name),
61585
+ setBold,
60248
61586
  /**
60249
61587
  * Remove bold formatting
60250
61588
  * @category Command
@@ -60252,7 +61590,7 @@ const Bold = Mark2.create({
60252
61590
  * @example
60253
61591
  * unsetBold()
60254
61592
  */
60255
- unsetBold: () => ({ commands: commands2 }) => commands2.unsetMark(this.name),
61593
+ unsetBold,
60256
61594
  /**
60257
61595
  * Toggle bold formatting
60258
61596
  * @category Command
@@ -60260,7 +61598,7 @@ const Bold = Mark2.create({
60260
61598
  * @example
60261
61599
  * toggleBold()
60262
61600
  */
60263
- toggleBold: () => ({ commands: commands2 }) => commands2.toggleMark(this.name)
61601
+ toggleBold
60264
61602
  };
60265
61603
  },
60266
61604
  addShortcuts() {
@@ -60277,6 +61615,22 @@ const Italic = Mark2.create({
60277
61615
  htmlAttributes: {}
60278
61616
  };
60279
61617
  },
61618
+ addAttributes() {
61619
+ return {
61620
+ /**
61621
+ * @category Attribute
61622
+ * @param {string} [value] - Italic toggle value ('0' renders as normal)
61623
+ */
61624
+ value: {
61625
+ default: null,
61626
+ renderDOM: (attrs) => {
61627
+ if (!attrs.value) return {};
61628
+ if (attrs.value === "0") return { style: "font-style: normal" };
61629
+ return {};
61630
+ }
61631
+ }
61632
+ };
61633
+ },
60280
61634
  parseDOM() {
60281
61635
  return [
60282
61636
  { tag: "i" },
@@ -60286,9 +61640,18 @@ const Italic = Mark2.create({
60286
61640
  ];
60287
61641
  },
60288
61642
  renderDOM({ htmlAttributes }) {
60289
- return ["em", Attribute2.mergeAttributes(this.options.htmlAttributes, htmlAttributes), 0];
61643
+ const merged = Attribute2.mergeAttributes(this.options.htmlAttributes, htmlAttributes);
61644
+ const { value, ...rest } = merged || {};
61645
+ if (value === "0") {
61646
+ return ["span", rest, 0];
61647
+ }
61648
+ return ["em", rest, 0];
60290
61649
  },
60291
61650
  addCommands() {
61651
+ const { setItalic, unsetItalic, toggleItalic } = createCascadeToggleCommands({
61652
+ markName: this.name,
61653
+ negationAttrs: { value: "0" }
61654
+ });
60292
61655
  return {
60293
61656
  /**
60294
61657
  * Apply italic formatting
@@ -60297,7 +61660,7 @@ const Italic = Mark2.create({
60297
61660
  * @example
60298
61661
  * setItalic()
60299
61662
  */
60300
- setItalic: () => ({ commands: commands2 }) => commands2.setMark(this.name),
61663
+ setItalic,
60301
61664
  /**
60302
61665
  * Remove italic formatting
60303
61666
  * @category Command
@@ -60305,7 +61668,7 @@ const Italic = Mark2.create({
60305
61668
  * @example
60306
61669
  * unsetItalic()
60307
61670
  */
60308
- unsetItalic: () => ({ commands: commands2 }) => commands2.unsetMark(this.name),
61671
+ unsetItalic,
60309
61672
  /**
60310
61673
  * Toggle italic formatting
60311
61674
  * @category Command
@@ -60313,7 +61676,7 @@ const Italic = Mark2.create({
60313
61676
  * @example
60314
61677
  * toggleItalic()
60315
61678
  */
60316
- toggleItalic: () => ({ commands: commands2 }) => commands2.toggleMark(this.name)
61679
+ toggleItalic
60317
61680
  };
60318
61681
  },
60319
61682
  addShortcuts() {
@@ -60338,7 +61701,16 @@ const Underline = Mark2.create({
60338
61701
  ];
60339
61702
  },
60340
61703
  renderDOM({ htmlAttributes }) {
60341
- return ["u", Attribute2.mergeAttributes(this.options.htmlAttributes, htmlAttributes), 0];
61704
+ const merged = Attribute2.mergeAttributes(this.options.htmlAttributes, htmlAttributes);
61705
+ const type2 = merged?.underlineType;
61706
+ const color = merged?.underlineColor;
61707
+ const css = getUnderlineCssString({ type: type2, color });
61708
+ const { style: style2, ...rest } = merged || {};
61709
+ const styleString = [style2, css].filter(Boolean).join("; ");
61710
+ if (type2 === "none") {
61711
+ return ["span", { ...rest, ...styleString ? { style: styleString } : {} }, 0];
61712
+ }
61713
+ return ["u", { ...rest, ...styleString ? { style: styleString } : {} }, 0];
60342
61714
  },
60343
61715
  addAttributes() {
60344
61716
  return {
@@ -60348,10 +61720,18 @@ const Underline = Mark2.create({
60348
61720
  */
60349
61721
  underlineType: {
60350
61722
  default: "single"
61723
+ },
61724
+ underlineColor: {
61725
+ default: null
60351
61726
  }
60352
61727
  };
60353
61728
  },
60354
61729
  addCommands() {
61730
+ const { setUnderline, unsetUnderline, toggleUnderline } = createCascadeToggleCommands({
61731
+ markName: this.name,
61732
+ negationAttrs: { underlineType: "none" },
61733
+ isNegation: (attrs) => attrs?.underlineType === "none"
61734
+ });
60355
61735
  return {
60356
61736
  /**
60357
61737
  * Apply underline formatting
@@ -60360,7 +61740,7 @@ const Underline = Mark2.create({
60360
61740
  * @example
60361
61741
  * setUnderline()
60362
61742
  */
60363
- setUnderline: () => ({ commands: commands2 }) => commands2.setMark(this.name),
61743
+ setUnderline,
60364
61744
  /**
60365
61745
  * Remove underline formatting
60366
61746
  * @category Command
@@ -60368,7 +61748,7 @@ const Underline = Mark2.create({
60368
61748
  * @example
60369
61749
  * unsetUnderline()
60370
61750
  */
60371
- unsetUnderline: () => ({ commands: commands2 }) => commands2.unsetMark(this.name),
61751
+ unsetUnderline,
60372
61752
  /**
60373
61753
  * Toggle underline formatting
60374
61754
  * @category Command
@@ -60376,7 +61756,7 @@ const Underline = Mark2.create({
60376
61756
  * @example
60377
61757
  * toggleUnderline()
60378
61758
  */
60379
- toggleUnderline: () => ({ commands: commands2 }) => commands2.toggleMark(this.name)
61759
+ toggleUnderline
60380
61760
  };
60381
61761
  },
60382
61762
  addShortcuts() {
@@ -60471,9 +61851,18 @@ const Strike = Mark2.create({
60471
61851
  ];
60472
61852
  },
60473
61853
  renderDOM({ htmlAttributes }) {
60474
- return ["s", Attribute2.mergeAttributes(this.options.htmlAttributes, htmlAttributes), 0];
61854
+ const merged = Attribute2.mergeAttributes(this.options.htmlAttributes, htmlAttributes);
61855
+ const { value, ...rest } = merged || {};
61856
+ if (value === "0") {
61857
+ return ["span", rest, 0];
61858
+ }
61859
+ return ["s", rest, 0];
60475
61860
  },
60476
61861
  addCommands() {
61862
+ const { setStrike, unsetStrike, toggleStrike } = createCascadeToggleCommands({
61863
+ markName: this.name,
61864
+ negationAttrs: { value: "0" }
61865
+ });
60477
61866
  return {
60478
61867
  /**
60479
61868
  * Apply strikethrough formatting
@@ -60482,9 +61871,7 @@ const Strike = Mark2.create({
60482
61871
  * @example
60483
61872
  * setStrike()
60484
61873
  */
60485
- setStrike: () => ({ commands: commands2 }) => {
60486
- return commands2.setMark(this.name);
60487
- },
61874
+ setStrike,
60488
61875
  /**
60489
61876
  * Remove strikethrough formatting
60490
61877
  * @category Command
@@ -60492,9 +61879,7 @@ const Strike = Mark2.create({
60492
61879
  * @example
60493
61880
  * unsetStrike()
60494
61881
  */
60495
- unsetStrike: () => ({ commands: commands2 }) => {
60496
- return commands2.unsetMark(this.name);
60497
- },
61882
+ unsetStrike,
60498
61883
  /**
60499
61884
  * Toggle strikethrough formatting
60500
61885
  * @category Command
@@ -60502,8 +61887,24 @@ const Strike = Mark2.create({
60502
61887
  * @example
60503
61888
  * toggleStrike()
60504
61889
  */
60505
- toggleStrike: () => ({ commands: commands2 }) => {
60506
- return commands2.toggleMark(this.name);
61890
+ toggleStrike
61891
+ };
61892
+ },
61893
+ addAttributes() {
61894
+ return {
61895
+ /**
61896
+ * @category Attribute
61897
+ * @param {string} [value] - Strike toggle value ('0' renders as normal)
61898
+ */
61899
+ value: {
61900
+ default: null,
61901
+ renderDOM: (attrs) => {
61902
+ if (!attrs.value) return {};
61903
+ if (attrs.value === "0") {
61904
+ return { style: "text-decoration: none" };
61905
+ }
61906
+ return {};
61907
+ }
60507
61908
  }
60508
61909
  };
60509
61910
  },
@@ -66658,7 +68059,7 @@ const getStarterExtensions = () => {
66658
68059
  Paragraph,
66659
68060
  LineBreak,
66660
68061
  HardBreak,
66661
- RunItem,
68062
+ Run,
66662
68063
  SlashMenu,
66663
68064
  Strike,
66664
68065
  TabNode,
@@ -69189,7 +70590,7 @@ function resolveTo(selector) {
69189
70590
  if (typeof selector === "string") {
69190
70591
  return document.querySelector(selector);
69191
70592
  }
69192
- return selector() || null;
70593
+ return selector();
69193
70594
  }
69194
70595
  const LazyTeleport = vue.defineComponent({
69195
70596
  name: "LazyTeleport",
@@ -69277,11 +70678,8 @@ const oppositeAlignCssPositionProps = {
69277
70678
  };
69278
70679
  const keepOffsetDirection = {
69279
70680
  top: true,
69280
- // top++
69281
70681
  bottom: false,
69282
- // top--
69283
70682
  left: true,
69284
- // left++
69285
70683
  right: false
69286
70684
  // left--
69287
70685
  };
@@ -70398,6 +71796,7 @@ function isFocusable(element) {
70398
71796
  return !!element.href && element.rel !== "ignore";
70399
71797
  case "INPUT":
70400
71798
  return element.type !== "hidden" && element.type !== "file";
71799
+ case "BUTTON":
70401
71800
  case "SELECT":
70402
71801
  case "TEXTAREA":
70403
71802
  return true;
@@ -70416,8 +71815,8 @@ const FocusTrap = vue.defineComponent({
70416
71815
  default: true
70417
71816
  },
70418
71817
  onEsc: Function,
70419
- initialFocusTo: [String, Function],
70420
- finalFocusTo: [String, Function],
71818
+ initialFocusTo: String,
71819
+ finalFocusTo: String,
70421
71820
  returnFocusOnDeactivated: {
70422
71821
  type: Boolean,
70423
71822
  default: true
@@ -72515,7 +73914,6 @@ function self$6(vars) {
72515
73914
  });
72516
73915
  }
72517
73916
  const scrollbarLight = {
72518
- name: "Scrollbar",
72519
73917
  common: derived,
72520
73918
  self: self$6
72521
73919
  };
@@ -74031,14 +75429,11 @@ function self$5(vars) {
74031
75429
  boxShadow: boxShadow2
74032
75430
  });
74033
75431
  }
74034
- const popoverLight = createTheme({
75432
+ const popoverLight = {
74035
75433
  name: "Popover",
74036
75434
  common: derived,
74037
- peers: {
74038
- Scrollbar: scrollbarLight
74039
- },
74040
75435
  self: self$5
74041
- });
75436
+ };
74042
75437
  const oppositePlacement = {
74043
75438
  top: "bottom",
74044
75439
  bottom: "top",
@@ -74258,11 +75653,9 @@ const NPopoverBody = vue.defineComponent({
74258
75653
  const {
74259
75654
  namespaceRef,
74260
75655
  mergedClsPrefixRef,
74261
- inlineThemeDisabled,
74262
- mergedRtlRef
75656
+ inlineThemeDisabled
74263
75657
  } = useConfig(props);
74264
75658
  const themeRef = useTheme("Popover", "-popover", style$3, popoverLight, props, mergedClsPrefixRef);
74265
- const rtlEnabledRef = useRtl("Popover", mergedRtlRef, mergedClsPrefixRef);
74266
75659
  const followerRef = vue.ref(null);
74267
75660
  const NPopover2 = vue.inject("NPopover");
74268
75661
  const bodyRef = vue.ref(null);
@@ -74460,8 +75853,6 @@ const NPopoverBody = vue.defineComponent({
74460
75853
  style: props.contentStyle
74461
75854
  }, slots);
74462
75855
  const maybeScrollableBody = props.scrollable ? vue.h(XScrollbar, {
74463
- themeOverrides: themeRef.value.peerOverrides.Scrollbar,
74464
- theme: themeRef.value.peers.Scrollbar,
74465
75856
  contentClass: hasHeaderOrFooter ? void 0 : `${mergedClsPrefix}-popover__content ${(_b = props.contentClass) !== null && _b !== void 0 ? _b : ""}`,
74466
75857
  contentStyle: hasHeaderOrFooter ? void 0 : props.contentStyle
74467
75858
  }, {
@@ -74477,7 +75868,7 @@ const NPopoverBody = vue.defineComponent({
74477
75868
  return [maybeScrollableBody, arrow2];
74478
75869
  };
74479
75870
  contentNode = vue.h("div", vue.mergeProps({
74480
- 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}`), {
75871
+ class: [`${mergedClsPrefix}-popover`, `${mergedClsPrefix}-popover-shared`, themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.themeClass.value, extraClass.map((v2) => `${mergedClsPrefix}-${v2}`), {
74481
75872
  [`${mergedClsPrefix}-popover--scrollable`]: props.scrollable,
74482
75873
  [`${mergedClsPrefix}-popover--show-header-or-footer`]: hasHeaderOrFooter,
74483
75874
  [`${mergedClsPrefix}-popover--raw`]: props.raw,
@@ -74501,7 +75892,7 @@ const NPopoverBody = vue.defineComponent({
74501
75892
  // The popover class and overlap class must exists, they will be used
74502
75893
  // to place the body & transition animation.
74503
75894
  // Shadow class exists for reuse box-shadow.
74504
- [`${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`],
75895
+ [`${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`],
74505
75896
  bodyRef,
74506
75897
  styleRef.value,
74507
75898
  handleMouseEnter,
@@ -79978,10 +81369,14 @@ class SuperToolbar extends EventEmitter2 {
79978
81369
  * @param {string} params.argument - The color to set
79979
81370
  * @returns {void}
79980
81371
  */
79981
- setColor: ({ item, argument }) => {
79982
- __privateMethod(this, _SuperToolbar_instances, runCommandWithArgumentOnly_fn).call(this, { item, argument }, () => {
79983
- this.activeEditor?.commands.setFieldAnnotationsTextColor(argument, true);
79984
- });
81372
+ setColor: ({ argument }) => {
81373
+ if (!argument || !this.activeEditor) return;
81374
+ const isNone = argument === "none";
81375
+ const value = isNone ? "inherit" : argument;
81376
+ if (this.activeEditor?.commands?.setColor) this.activeEditor.commands.setColor(value);
81377
+ const argValue = isNone ? null : argument;
81378
+ this.activeEditor?.commands.setFieldAnnotationsTextColor(argValue, true);
81379
+ this.updateToolbarState();
79985
81380
  },
79986
81381
  /**
79987
81382
  * Sets the highlight color for text
@@ -79990,12 +81385,14 @@ class SuperToolbar extends EventEmitter2 {
79990
81385
  * @param {string} params.argument - The highlight color to set
79991
81386
  * @returns {void}
79992
81387
  */
79993
- setHighlight: ({ item, argument }) => {
79994
- __privateMethod(this, _SuperToolbar_instances, runCommandWithArgumentOnly_fn).call(this, { item, argument, noArgumentCallback: true }, () => {
79995
- let arg = argument !== "none" ? argument : null;
79996
- this.activeEditor?.commands.setFieldAnnotationsTextHighlight(arg, true);
79997
- this.activeEditor?.commands.setCellBackground(arg);
79998
- });
81388
+ setHighlight: ({ argument }) => {
81389
+ if (!argument || !this.activeEditor) return;
81390
+ const inlineColor = argument !== "none" ? argument : "transparent";
81391
+ if (this.activeEditor?.commands?.setHighlight) this.activeEditor.commands.setHighlight(inlineColor);
81392
+ const argValue = argument !== "none" ? argument : null;
81393
+ this.activeEditor?.commands.setFieldAnnotationsTextHighlight(argValue, true);
81394
+ this.activeEditor?.commands.setCellBackground(argValue);
81395
+ this.updateToolbarState();
79999
81396
  },
80000
81397
  /**
80001
81398
  * Toggles the ruler visibility
@@ -80362,7 +81759,6 @@ class SuperToolbar extends EventEmitter2 {
80362
81759
  if (!command2) {
80363
81760
  return;
80364
81761
  }
80365
- this.log("(emmitCommand) Command:", command2, "\n item:", item, "\n argument:", argument, "\n option:", option);
80366
81762
  if (command2 in __privateGet(this, _interceptedCommands)) {
80367
81763
  return __privateGet(this, _interceptedCommands)[command2]({ item, argument });
80368
81764
  }
@@ -81925,11 +83321,32 @@ const _sfc_main = {
81925
83321
  }
81926
83322
  };
81927
83323
  const SuperInput = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-4d5cff52"]]);
81928
- const registeredHandlers = Object.freeze({
81929
- "w:br": translator$j,
81930
- "w:tab": translator$i,
81931
- "w:p": translator$h
81932
- });
83324
+ const baseHandlers = {
83325
+ ...runPropertyTranslators,
83326
+ "w:br": translator$v,
83327
+ "w:cantSplit": translator$r,
83328
+ "w:cnfStyle": translator$q,
83329
+ "w:divId": translator$p,
83330
+ "w:gridAfter": translator$o,
83331
+ "w:gridBefore": translator$n,
83332
+ "w:hidden": translator$m,
83333
+ "w:hyperlink": translator$c,
83334
+ "w:jc": translator$l,
83335
+ "w:p": translator$s,
83336
+ "w:r": translator,
83337
+ "w:rPr": translator$1,
83338
+ "w:sdt": translator$b,
83339
+ "w:tab": translator$t,
83340
+ "w:tblCellSpacing": translator$k,
83341
+ "w:tblHeader": translator$j,
83342
+ "w:tc": translator$d,
83343
+ "w:tr": translator$e,
83344
+ "w:trHeight": translator$i,
83345
+ "w:trPr": translator$f,
83346
+ "w:wAfter": translator$h,
83347
+ "w:wBefore": translator$g
83348
+ };
83349
+ const registeredHandlers = Object.freeze(baseHandlers);
81933
83350
  const Extensions = {
81934
83351
  Node: Node$1,
81935
83352
  Attribute: Attribute2,