@harbour-enterprises/superdoc 1.5.0-next.6 → 1.5.0-next.8

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.
@@ -8332,6 +8332,11 @@
8332
8332
  "xmlns:v": "urn:schemas-microsoft-com:vml",
8333
8333
  "xmlns:wp14": "http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing",
8334
8334
  "xmlns:wp": "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing",
8335
+ "xmlns:a": "http://schemas.openxmlformats.org/drawingml/2006/main",
8336
+ "xmlns:pic": "http://schemas.openxmlformats.org/drawingml/2006/picture",
8337
+ "xmlns:c": "http://schemas.openxmlformats.org/drawingml/2006/chart",
8338
+ "xmlns:dgm": "http://schemas.openxmlformats.org/drawingml/2006/diagram",
8339
+ "xmlns:lc": "http://schemas.openxmlformats.org/drawingml/2006/lockedCanvas",
8335
8340
  "xmlns:w10": "urn:schemas-microsoft-com:office:word",
8336
8341
  "xmlns:w": "http://schemas.openxmlformats.org/wordprocessingml/2006/main",
8337
8342
  "xmlns:w14": "http://schemas.microsoft.com/office/word/2010/wordml",
@@ -10989,7 +10994,7 @@
10989
10994
  decode: decode$$,
10990
10995
  attributes: validXmlAttributes$j
10991
10996
  };
10992
- const translator$2r = NodeTranslator.from(config$r);
10997
+ const translator$2s = NodeTranslator.from(config$r);
10993
10998
  const encode$Y = (attributes) => attributes?.["w:val"];
10994
10999
  const decode$_ = (attrs) => attrs?.highlight;
10995
11000
  const attrConfig$x = Object.freeze({
@@ -11051,7 +11056,7 @@
11051
11056
  decode: decode$Z,
11052
11057
  attributes: validXmlAttributes$i
11053
11058
  };
11054
- const translator$2q = NodeTranslator.from(config$q);
11059
+ const translator$2r = NodeTranslator.from(config$q);
11055
11060
  const encode$W = (attributes) => {
11056
11061
  return attributes["w:val"];
11057
11062
  };
@@ -11130,7 +11135,7 @@
11130
11135
  decode: decode$V,
11131
11136
  attributes: validXmlAttributes$h
11132
11137
  };
11133
- const translator$2p = NodeTranslator.from(config$p);
11138
+ const translator$2q = NodeTranslator.from(config$p);
11134
11139
  const carbonCopy = (obj) => {
11135
11140
  if (!obj) return void 0;
11136
11141
  try {
@@ -11456,10 +11461,10 @@
11456
11461
  const intValue = parseInteger(value);
11457
11462
  return intValue != void 0 ? String(intValue) : void 0;
11458
11463
  };
11459
- const translator$2o = NodeTranslator.from(createSingleBooleanPropertyHandler("w:b", "bold"));
11460
- const translator$2n = NodeTranslator.from(createSingleBooleanPropertyHandler("w:bCs", "boldCs"));
11461
- const translator$2m = NodeTranslator.from(createBorderPropertyHandler("w:bdr", "borders"));
11462
- const translator$2l = NodeTranslator.from(createSingleBooleanPropertyHandler("w:i", "italic"));
11464
+ const translator$2p = NodeTranslator.from(createSingleBooleanPropertyHandler("w:b", "bold"));
11465
+ const translator$2o = NodeTranslator.from(createSingleBooleanPropertyHandler("w:bCs", "boldCs"));
11466
+ const translator$2n = NodeTranslator.from(createBorderPropertyHandler("w:bdr", "borders"));
11467
+ const translator$2m = NodeTranslator.from(createSingleBooleanPropertyHandler("w:i", "italic"));
11463
11468
  const encode$S = (attributes) => attributes?.["w:val"];
11464
11469
  const decode$U = (attrs) => attrs?.underline;
11465
11470
  const attrConfig$t = Object.freeze({
@@ -11554,10 +11559,10 @@
11554
11559
  decode: decode$P,
11555
11560
  attributes: validXmlAttributes$g
11556
11561
  };
11557
- const translator$2k = NodeTranslator.from(config$o);
11558
- const translator$2j = NodeTranslator.from(createSingleBooleanPropertyHandler("w:strike"));
11559
- const translator$2i = NodeTranslator.from(createSingleBooleanPropertyHandler("w:dstrike"));
11560
- const translator$2h = NodeTranslator.from({
11562
+ const translator$2l = NodeTranslator.from(config$o);
11563
+ const translator$2k = NodeTranslator.from(createSingleBooleanPropertyHandler("w:strike"));
11564
+ const translator$2j = NodeTranslator.from(createSingleBooleanPropertyHandler("w:dstrike"));
11565
+ const translator$2i = NodeTranslator.from({
11561
11566
  xmlName: "w:color",
11562
11567
  sdNodeOrKeyName: "color",
11563
11568
  attributes: [
@@ -11574,7 +11579,7 @@
11574
11579
  return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
11575
11580
  }
11576
11581
  });
11577
- const translator$2g = NodeTranslator.from({
11582
+ const translator$2h = NodeTranslator.from({
11578
11583
  xmlName: "w:rFonts",
11579
11584
  sdNodeOrKeyName: "fontFamily",
11580
11585
  attributes: [
@@ -11605,16 +11610,16 @@
11605
11610
  return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
11606
11611
  }
11607
11612
  });
11608
- const translator$2f = NodeTranslator.from(createSingleAttrPropertyHandler("w:rStyle", "styleId"));
11609
- const translator$2e = NodeTranslator.from(createSingleIntegerPropertyHandler("w:sz", "fontSize"));
11610
- const translator$2d = NodeTranslator.from(createSingleIntegerPropertyHandler("w:szCs", "fontSizeCs"));
11611
- const translator$2c = NodeTranslator.from({
11613
+ const translator$2g = NodeTranslator.from(createSingleAttrPropertyHandler("w:rStyle", "styleId"));
11614
+ const translator$2f = NodeTranslator.from(createSingleIntegerPropertyHandler("w:sz", "fontSize"));
11615
+ const translator$2e = NodeTranslator.from(createSingleIntegerPropertyHandler("w:szCs", "fontSizeCs"));
11616
+ const translator$2d = NodeTranslator.from({
11612
11617
  xmlName: "w:caps",
11613
11618
  sdNodeOrKeyName: "textTransform",
11614
11619
  encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1") ? "uppercase" : "none",
11615
11620
  decode: ({ node: node2 }) => node2.attrs["textTransform"] != null ? { name: "w:caps", attributes: { "w:val": booleanToString(node2.attrs["textTransform"] === "uppercase") } } : void 0
11616
11621
  });
11617
- const translator$2b = NodeTranslator.from({
11622
+ const translator$2c = NodeTranslator.from({
11618
11623
  xmlName: "w:shd",
11619
11624
  sdNodeOrKeyName: "shading",
11620
11625
  attributes: [
@@ -11636,7 +11641,7 @@
11636
11641
  return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
11637
11642
  }
11638
11643
  });
11639
- const translator$2a = NodeTranslator.from({
11644
+ const translator$2b = NodeTranslator.from({
11640
11645
  xmlName: "w:lang",
11641
11646
  sdNodeOrKeyName: "lang",
11642
11647
  attributes: [createAttributeHandler("w:val"), createAttributeHandler("w:eastAsia"), createAttributeHandler("w:bidi")],
@@ -11648,24 +11653,24 @@
11648
11653
  return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
11649
11654
  }
11650
11655
  });
11651
- const translator$29 = NodeTranslator.from(createSingleIntegerPropertyHandler("w:spacing", "letterSpacing"));
11652
- const translator$28 = NodeTranslator.from(createSingleAttrPropertyHandler("w:vertAlign"));
11653
- const translator$27 = NodeTranslator.from(createSingleBooleanPropertyHandler("w:smallCaps"));
11654
- const translator$26 = NodeTranslator.from(createSingleBooleanPropertyHandler("w:snapToGrid"));
11655
- const translator$25 = NodeTranslator.from(createSingleBooleanPropertyHandler("w:emboss"));
11656
- const translator$24 = NodeTranslator.from(createSingleBooleanPropertyHandler("w:imprint"));
11657
- const translator$23 = NodeTranslator.from(createSingleBooleanPropertyHandler("w:noProof"));
11658
- const translator$22 = NodeTranslator.from(createSingleBooleanPropertyHandler("w:oMath"));
11659
- const translator$21 = NodeTranslator.from(createSingleBooleanPropertyHandler("w:outline"));
11660
- const translator$20 = NodeTranslator.from(createSingleBooleanPropertyHandler("w:shadow"));
11661
- const translator$1$ = NodeTranslator.from(createSingleBooleanPropertyHandler("w:vanish"));
11662
- const translator$1_ = NodeTranslator.from(createSingleBooleanPropertyHandler("w:specVanish"));
11663
- const translator$1Z = NodeTranslator.from(createSingleAttrPropertyHandler("w:effect"));
11664
- const translator$1Y = NodeTranslator.from(createSingleAttrPropertyHandler("w:em"));
11665
- const translator$1X = NodeTranslator.from(createSingleAttrPropertyHandler("w:w"));
11666
- const translator$1W = NodeTranslator.from(createSingleIntegerPropertyHandler("w:kern"));
11667
- const translator$1V = NodeTranslator.from(createSingleIntegerPropertyHandler("w:position"));
11668
- const translator$1U = NodeTranslator.from({
11656
+ const translator$2a = NodeTranslator.from(createSingleIntegerPropertyHandler("w:spacing", "letterSpacing"));
11657
+ const translator$29 = NodeTranslator.from(createSingleAttrPropertyHandler("w:vertAlign"));
11658
+ const translator$28 = NodeTranslator.from(createSingleBooleanPropertyHandler("w:smallCaps"));
11659
+ const translator$27 = NodeTranslator.from(createSingleBooleanPropertyHandler("w:snapToGrid"));
11660
+ const translator$26 = NodeTranslator.from(createSingleBooleanPropertyHandler("w:emboss"));
11661
+ const translator$25 = NodeTranslator.from(createSingleBooleanPropertyHandler("w:imprint"));
11662
+ const translator$24 = NodeTranslator.from(createSingleBooleanPropertyHandler("w:noProof"));
11663
+ const translator$23 = NodeTranslator.from(createSingleBooleanPropertyHandler("w:oMath"));
11664
+ const translator$22 = NodeTranslator.from(createSingleBooleanPropertyHandler("w:outline"));
11665
+ const translator$21 = NodeTranslator.from(createSingleBooleanPropertyHandler("w:shadow"));
11666
+ const translator$20 = NodeTranslator.from(createSingleBooleanPropertyHandler("w:vanish"));
11667
+ const translator$1$ = NodeTranslator.from(createSingleBooleanPropertyHandler("w:specVanish"));
11668
+ const translator$1_ = NodeTranslator.from(createSingleAttrPropertyHandler("w:effect"));
11669
+ const translator$1Z = NodeTranslator.from(createSingleAttrPropertyHandler("w:em"));
11670
+ const translator$1Y = NodeTranslator.from(createSingleAttrPropertyHandler("w:w"));
11671
+ const translator$1X = NodeTranslator.from(createSingleIntegerPropertyHandler("w:kern"));
11672
+ const translator$1W = NodeTranslator.from(createSingleIntegerPropertyHandler("w:position"));
11673
+ const translator$1V = NodeTranslator.from({
11669
11674
  xmlName: "w:fitText",
11670
11675
  sdNodeOrKeyName: "fitText",
11671
11676
  attributes: [createIntegerAttributeHandler("w:val"), createIntegerAttributeHandler("w:id")],
@@ -11677,7 +11682,7 @@
11677
11682
  return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
11678
11683
  }
11679
11684
  });
11680
- const translator$1T = NodeTranslator.from({
11685
+ const translator$1U = NodeTranslator.from({
11681
11686
  xmlName: "w:eastAsianLayout",
11682
11687
  sdNodeOrKeyName: "eastAsianLayout",
11683
11688
  attributes: [
@@ -11695,53 +11700,53 @@
11695
11700
  return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
11696
11701
  }
11697
11702
  });
11698
- const translator$1S = NodeTranslator.from(createSingleBooleanPropertyHandler("w:rtl"));
11699
- const translator$1R = NodeTranslator.from(createSingleBooleanPropertyHandler("w:cs"));
11700
- const translator$1Q = NodeTranslator.from(createSingleBooleanPropertyHandler("w:iCs"));
11701
- const translator$1P = NodeTranslator.from(createSingleBooleanPropertyHandler("w:webHidden"));
11702
- const propertyTranslators$b = [
11703
- translator$2n,
11703
+ const translator$1T = NodeTranslator.from(createSingleBooleanPropertyHandler("w:rtl"));
11704
+ const translator$1S = NodeTranslator.from(createSingleBooleanPropertyHandler("w:cs"));
11705
+ const translator$1R = NodeTranslator.from(createSingleBooleanPropertyHandler("w:iCs"));
11706
+ const translator$1Q = NodeTranslator.from(createSingleBooleanPropertyHandler("w:webHidden"));
11707
+ const propertyTranslators$c = [
11704
11708
  translator$2o,
11705
- translator$2m,
11706
- translator$2c,
11707
- translator$2h,
11708
- translator$1R,
11709
+ translator$2p,
11710
+ translator$2n,
11711
+ translator$2d,
11709
11712
  translator$2i,
11710
- translator$1T,
11711
- translator$1Z,
11712
- translator$1Y,
11713
- translator$25,
11713
+ translator$1S,
11714
+ translator$2j,
11714
11715
  translator$1U,
11715
- translator$2g,
11716
- translator$2d,
11716
+ translator$1_,
11717
+ translator$1Z,
11718
+ translator$26,
11719
+ translator$1V,
11720
+ translator$2h,
11717
11721
  translator$2e,
11718
- translator$2q,
11719
- translator$24,
11720
- translator$2l,
11721
- translator$1Q,
11722
- translator$1W,
11722
+ translator$2f,
11723
+ translator$2r,
11724
+ translator$25,
11725
+ translator$2m,
11726
+ translator$1R,
11727
+ translator$1X,
11728
+ translator$2b,
11723
11729
  translator$2a,
11724
- translator$29,
11730
+ translator$24,
11725
11731
  translator$23,
11726
11732
  translator$22,
11733
+ translator$1W,
11734
+ translator$1T,
11735
+ translator$2g,
11727
11736
  translator$21,
11728
- translator$1V,
11729
- translator$1S,
11730
- translator$2f,
11731
- translator$20,
11732
- translator$2b,
11737
+ translator$2c,
11738
+ translator$28,
11733
11739
  translator$27,
11734
- translator$26,
11735
- translator$1_,
11736
- translator$2j,
11737
- translator$2k,
11738
11740
  translator$1$,
11739
- translator$28,
11740
- translator$1P,
11741
- translator$1X
11741
+ translator$2k,
11742
+ translator$2l,
11743
+ translator$20,
11744
+ translator$29,
11745
+ translator$1Q,
11746
+ translator$1Y
11742
11747
  ];
11743
- const translator$1O = NodeTranslator.from(
11744
- createNestedPropertiesTranslator("w:rPr", "runProperties", propertyTranslators$b)
11748
+ const translator$1P = NodeTranslator.from(
11749
+ createNestedPropertiesTranslator("w:rPr", "runProperties", propertyTranslators$c)
11745
11750
  );
11746
11751
  const SUPPORTED_ALTERNATE_CONTENT_REQUIRES = /* @__PURE__ */ new Set([
11747
11752
  "wps",
@@ -11822,18 +11827,18 @@
11822
11827
  elements: carbonCopy(selectedElements)
11823
11828
  };
11824
11829
  }
11825
- const translator$1N = NodeTranslator.from(config$n);
11830
+ const translator$1O = NodeTranslator.from(config$n);
11826
11831
  function buildPath(existingPath = [], node2, branch) {
11827
11832
  const path2 = [...existingPath];
11828
11833
  if (node2) path2.push(node2);
11829
11834
  if (branch) path2.push(branch);
11830
11835
  return path2;
11831
11836
  }
11832
- const translator$1M = NodeTranslator.from(createSingleBooleanPropertyHandler("w:adjustRightInd"));
11833
- const translator$1L = NodeTranslator.from(createSingleBooleanPropertyHandler("w:autoSpaceDE"));
11834
- const translator$1K = NodeTranslator.from(createSingleBooleanPropertyHandler("w:autoSpaceDN"));
11835
- const translator$1J = NodeTranslator.from(createSingleBooleanPropertyHandler("w:bidi", "rightToLeft"));
11836
- const translator$1I = NodeTranslator.from({
11837
+ const translator$1N = NodeTranslator.from(createSingleBooleanPropertyHandler("w:adjustRightInd"));
11838
+ const translator$1M = NodeTranslator.from(createSingleBooleanPropertyHandler("w:autoSpaceDE"));
11839
+ const translator$1L = NodeTranslator.from(createSingleBooleanPropertyHandler("w:autoSpaceDN"));
11840
+ const translator$1K = NodeTranslator.from(createSingleBooleanPropertyHandler("w:bidi", "rightToLeft"));
11841
+ const translator$1J = NodeTranslator.from({
11837
11842
  xmlName: "w:cnfStyle",
11838
11843
  sdNodeOrKeyName: "cnfStyle",
11839
11844
  attributes: [
@@ -11859,9 +11864,9 @@
11859
11864
  return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
11860
11865
  }
11861
11866
  });
11862
- const translator$1H = NodeTranslator.from(createSingleBooleanPropertyHandler("w:contextualSpacing"));
11863
- const translator$1G = NodeTranslator.from(createSingleAttrPropertyHandler("w:divId"));
11864
- const translator$1F = NodeTranslator.from({
11867
+ const translator$1I = NodeTranslator.from(createSingleBooleanPropertyHandler("w:contextualSpacing"));
11868
+ const translator$1H = NodeTranslator.from(createSingleAttrPropertyHandler("w:divId"));
11869
+ const translator$1G = NodeTranslator.from({
11865
11870
  xmlName: "w:framePr",
11866
11871
  sdNodeOrKeyName: "framePr",
11867
11872
  attributes: [
@@ -11889,7 +11894,7 @@
11889
11894
  return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
11890
11895
  }
11891
11896
  });
11892
- const translator$1E = NodeTranslator.from({
11897
+ const translator$1F = NodeTranslator.from({
11893
11898
  xmlName: "w:ind",
11894
11899
  sdNodeOrKeyName: "indent",
11895
11900
  attributes: [
@@ -11914,12 +11919,12 @@
11914
11919
  return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
11915
11920
  }
11916
11921
  });
11917
- const translator$1D = NodeTranslator.from(createSingleAttrPropertyHandler("w:jc", "justification"));
11918
- const translator$1C = NodeTranslator.from(createSingleBooleanPropertyHandler("w:keepLines"));
11919
- const translator$1B = NodeTranslator.from(createSingleBooleanPropertyHandler("w:keepNext"));
11920
- const translator$1A = NodeTranslator.from(createSingleBooleanPropertyHandler("w:kinsoku"));
11921
- const translator$1z = NodeTranslator.from(createSingleBooleanPropertyHandler("w:mirrorIndents"));
11922
- const translator$1y = NodeTranslator.from(createSingleIntegerPropertyHandler("w:ilvl"));
11922
+ const translator$1E = NodeTranslator.from(createSingleAttrPropertyHandler("w:jc", "justification"));
11923
+ const translator$1D = NodeTranslator.from(createSingleBooleanPropertyHandler("w:keepLines"));
11924
+ const translator$1C = NodeTranslator.from(createSingleBooleanPropertyHandler("w:keepNext"));
11925
+ const translator$1B = NodeTranslator.from(createSingleBooleanPropertyHandler("w:kinsoku"));
11926
+ const translator$1A = NodeTranslator.from(createSingleBooleanPropertyHandler("w:mirrorIndents"));
11927
+ const translator$1z = NodeTranslator.from(createSingleIntegerPropertyHandler("w:ilvl"));
11923
11928
  const createTrackStyleMark = (marks) => {
11924
11929
  const trackStyleMark = marks.find((mark2) => mark2.type === "trackFormat");
11925
11930
  if (trackStyleMark) {
@@ -12007,41 +12012,41 @@
12007
12012
  decode: decode$N,
12008
12013
  attributes: validXmlAttributes$e
12009
12014
  };
12010
- const translator$1x = NodeTranslator.from(config$m);
12011
- const translator$1w = NodeTranslator.from(createSingleIntegerPropertyHandler("w:numId"));
12012
- const propertyTranslators$a = [translator$1N, translator$1y, translator$1x, translator$1w];
12013
- const translator$1v = NodeTranslator.from(
12014
- createNestedPropertiesTranslator("w:numPr", "numberingProperties", propertyTranslators$a)
12015
+ const translator$1y = NodeTranslator.from(config$m);
12016
+ const translator$1x = NodeTranslator.from(createSingleIntegerPropertyHandler("w:numId"));
12017
+ const propertyTranslators$b = [translator$1O, translator$1z, translator$1y, translator$1x];
12018
+ const translator$1w = NodeTranslator.from(
12019
+ createNestedPropertiesTranslator("w:numPr", "numberingProperties", propertyTranslators$b)
12015
12020
  );
12016
- const translator$1u = NodeTranslator.from(
12021
+ const translator$1v = NodeTranslator.from(
12017
12022
  createSingleAttrPropertyHandler("w:outlineLvl", "outlineLvl", "w:val", parseInteger, integerToString)
12018
12023
  );
12019
- const translator$1t = NodeTranslator.from(createSingleBooleanPropertyHandler("w:overflowPunct"));
12020
- const translator$1s = NodeTranslator.from(createBorderPropertyHandler("w:bar"));
12021
- const translator$1r = NodeTranslator.from(createBorderPropertyHandler("w:between"));
12022
- const translator$1q = NodeTranslator.from(createBorderPropertyHandler("w:bottom"));
12023
- const translator$1p = NodeTranslator.from(createMeasurementPropertyHandler("w:bottom", "marginBottom"));
12024
- const translator$1o = NodeTranslator.from(createBorderPropertyHandler("w:left"));
12025
- const translator$1n = NodeTranslator.from(createMeasurementPropertyHandler("w:left", "marginLeft"));
12026
- const translator$1m = NodeTranslator.from(createBorderPropertyHandler("w:right"));
12027
- const translator$1l = NodeTranslator.from(createMeasurementPropertyHandler("w:right", "marginRight"));
12028
- const translator$1k = NodeTranslator.from(createBorderPropertyHandler("w:top"));
12029
- const translator$1j = NodeTranslator.from(createMeasurementPropertyHandler("w:top", "marginTop"));
12030
- const propertyTranslators$9 = [
12031
- translator$1N,
12024
+ const translator$1u = NodeTranslator.from(createSingleBooleanPropertyHandler("w:overflowPunct"));
12025
+ const translator$1t = NodeTranslator.from(createBorderPropertyHandler("w:bar"));
12026
+ const translator$1s = NodeTranslator.from(createBorderPropertyHandler("w:between"));
12027
+ const translator$1r = NodeTranslator.from(createBorderPropertyHandler("w:bottom"));
12028
+ const translator$1q = NodeTranslator.from(createMeasurementPropertyHandler("w:bottom", "marginBottom"));
12029
+ const translator$1p = NodeTranslator.from(createBorderPropertyHandler("w:left"));
12030
+ const translator$1o = NodeTranslator.from(createMeasurementPropertyHandler("w:left", "marginLeft"));
12031
+ const translator$1n = NodeTranslator.from(createBorderPropertyHandler("w:right"));
12032
+ const translator$1m = NodeTranslator.from(createMeasurementPropertyHandler("w:right", "marginRight"));
12033
+ const translator$1l = NodeTranslator.from(createBorderPropertyHandler("w:top"));
12034
+ const translator$1k = NodeTranslator.from(createMeasurementPropertyHandler("w:top", "marginTop"));
12035
+ const propertyTranslators$a = [
12036
+ translator$1O,
12037
+ translator$1t,
12032
12038
  translator$1s,
12033
12039
  translator$1r,
12034
- translator$1q,
12035
- translator$1o,
12036
- translator$1m,
12037
- translator$1k
12040
+ translator$1p,
12041
+ translator$1n,
12042
+ translator$1l
12038
12043
  ];
12039
- const translator$1i = NodeTranslator.from(
12040
- createNestedPropertiesTranslator("w:pBdr", "borders", propertyTranslators$9)
12044
+ const translator$1j = NodeTranslator.from(
12045
+ createNestedPropertiesTranslator("w:pBdr", "borders", propertyTranslators$a)
12041
12046
  );
12042
- const translator$1h = NodeTranslator.from(createSingleAttrPropertyHandler("w:pStyle", "styleId"));
12043
- const translator$1g = NodeTranslator.from(createSingleBooleanPropertyHandler("w:pageBreakBefore"));
12044
- const translator$1f = NodeTranslator.from({
12047
+ const translator$1i = NodeTranslator.from(createSingleAttrPropertyHandler("w:pStyle", "styleId"));
12048
+ const translator$1h = NodeTranslator.from(createSingleBooleanPropertyHandler("w:pageBreakBefore"));
12049
+ const translator$1g = NodeTranslator.from({
12045
12050
  xmlName: "w:spacing",
12046
12051
  sdNodeOrKeyName: "spacing",
12047
12052
  attributes: [
@@ -12062,20 +12067,21 @@
12062
12067
  return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
12063
12068
  }
12064
12069
  });
12065
- const translator$1e = NodeTranslator.from(createSingleBooleanPropertyHandler("w:suppressAutoHyphens"));
12066
- const translator$1d = NodeTranslator.from(createSingleBooleanPropertyHandler("w:suppressLineNumbers"));
12067
- const translator$1c = NodeTranslator.from(createSingleBooleanPropertyHandler("w:suppressOverlap"));
12068
- const propertyTranslators$8 = [translator$1N, translator$2p];
12069
- const translator$1b = NodeTranslator.from(
12070
- createNestedArrayPropertyHandler("w:tabs", "tabStops", propertyTranslators$8, { skipRun: true })
12070
+ const translator$1f = NodeTranslator.from(createSingleBooleanPropertyHandler("w:suppressAutoHyphens"));
12071
+ const translator$1e = NodeTranslator.from(createSingleBooleanPropertyHandler("w:suppressLineNumbers"));
12072
+ const translator$1d = NodeTranslator.from(createSingleBooleanPropertyHandler("w:suppressOverlap"));
12073
+ const propertyTranslators$9 = [translator$1O, translator$2q];
12074
+ const translator$1c = NodeTranslator.from(
12075
+ createNestedArrayPropertyHandler("w:tabs", "tabStops", propertyTranslators$9, { skipRun: true })
12071
12076
  );
12072
- const translator$1a = NodeTranslator.from(createSingleAttrPropertyHandler("w:textAlignment"));
12073
- const translator$19 = NodeTranslator.from(createSingleAttrPropertyHandler("w:textDirection"));
12074
- const translator$18 = NodeTranslator.from(createSingleAttrPropertyHandler("w:textboxTightWrap"));
12075
- const translator$17 = NodeTranslator.from(createSingleBooleanPropertyHandler("w:topLinePunct"));
12076
- const translator$16 = NodeTranslator.from(createSingleBooleanPropertyHandler("w:widowControl"));
12077
- const translator$15 = NodeTranslator.from(createSingleBooleanPropertyHandler("w:wordWrap"));
12078
- const propertyTranslators$7 = [
12077
+ const translator$1b = NodeTranslator.from(createSingleAttrPropertyHandler("w:textAlignment"));
12078
+ const translator$1a = NodeTranslator.from(createSingleAttrPropertyHandler("w:textDirection"));
12079
+ const translator$19 = NodeTranslator.from(createSingleAttrPropertyHandler("w:textboxTightWrap"));
12080
+ const translator$18 = NodeTranslator.from(createSingleBooleanPropertyHandler("w:topLinePunct"));
12081
+ const translator$17 = NodeTranslator.from(createSingleBooleanPropertyHandler("w:widowControl"));
12082
+ const translator$16 = NodeTranslator.from(createSingleBooleanPropertyHandler("w:wordWrap"));
12083
+ const propertyTranslators$8 = [
12084
+ translator$1O,
12079
12085
  translator$1N,
12080
12086
  translator$1M,
12081
12087
  translator$1L,
@@ -12090,15 +12096,15 @@
12090
12096
  translator$1C,
12091
12097
  translator$1B,
12092
12098
  translator$1A,
12093
- translator$1z,
12099
+ translator$1w,
12094
12100
  translator$1v,
12095
12101
  translator$1u,
12096
- translator$1t,
12102
+ translator$1j,
12097
12103
  translator$1i,
12098
12104
  translator$1h,
12105
+ translator$2c,
12106
+ translator$27,
12099
12107
  translator$1g,
12100
- translator$2b,
12101
- translator$26,
12102
12108
  translator$1f,
12103
12109
  translator$1e,
12104
12110
  translator$1d,
@@ -12109,11 +12115,10 @@
12109
12115
  translator$18,
12110
12116
  translator$17,
12111
12117
  translator$16,
12112
- translator$15,
12113
- translator$1O
12118
+ translator$1P
12114
12119
  ];
12115
- const translator$14 = NodeTranslator.from(
12116
- createNestedPropertiesTranslator("w:pPr", "paragraphProperties", propertyTranslators$7)
12120
+ const translator$15 = NodeTranslator.from(
12121
+ createNestedPropertiesTranslator("w:pPr", "paragraphProperties", propertyTranslators$8)
12117
12122
  );
12118
12123
  function getUnderlineCssString({ type = "single", color: color2 = null, thickness = null, approximate = true } = {}) {
12119
12124
  const parts = [];
@@ -12875,7 +12880,7 @@
12875
12880
  }
12876
12881
  return void 0;
12877
12882
  }
12878
- const ooxmlResolver$1 = createOoxmlResolver({ pPr: translator$14, rPr: translator$1O });
12883
+ const ooxmlResolver$1 = createOoxmlResolver({ pPr: translator$15, rPr: translator$1P });
12879
12884
  const getToCssFontFamily = () => {
12880
12885
  return SuperConverter.toCssFontFamily;
12881
12886
  };
@@ -13569,7 +13574,7 @@
13569
13574
  let submarks = [];
13570
13575
  const rPr = rPrChange.elements?.find((el) => el.name === "w:rPr");
13571
13576
  if (rPr) {
13572
- const runProperties = translator$1O.encode({ ...params2, nodes: [rPr] });
13577
+ const runProperties = translator$1P.encode({ ...params2, nodes: [rPr] });
13573
13578
  submarks = encodeMarksFromRPr(runProperties, params2?.docx);
13574
13579
  }
13575
13580
  return [{ type: TrackFormatMarkName$1, attrs: { ...mappedAttributes, before: submarks, after: [...currentMarks] } }];
@@ -13738,7 +13743,7 @@
13738
13743
  const pPr = node2.elements?.find((el) => el.name === "w:pPr");
13739
13744
  let inlineParagraphProperties = {};
13740
13745
  if (pPr) {
13741
- inlineParagraphProperties = translator$14.encode({ ...params2, nodes: [pPr] }) || {};
13746
+ inlineParagraphProperties = translator$15.encode({ ...params2, nodes: [pPr] }) || {};
13742
13747
  }
13743
13748
  const insideTable = (params2.path || []).some((ancestor) => ancestor.name === "w:tc");
13744
13749
  const tableStyleId = getTableStyleId(params2.path || []);
@@ -13793,7 +13798,7 @@
13793
13798
  const { node: node2 } = params2;
13794
13799
  const { attrs = {} } = node2;
13795
13800
  const paragraphProperties = carbonCopy(attrs.paragraphProperties || {});
13796
- let pPr = translator$14.decode({ node: { ...node2, attrs: { paragraphProperties } } });
13801
+ let pPr = translator$15.decode({ node: { ...node2, attrs: { paragraphProperties } } });
13797
13802
  const sectPr = node2.attrs?.paragraphProperties?.sectPr;
13798
13803
  if (sectPr) {
13799
13804
  if (!pPr) {
@@ -13945,7 +13950,7 @@
13945
13950
  decode: decode$F,
13946
13951
  attributes: validXmlAttributes$d
13947
13952
  };
13948
- const translator$13 = NodeTranslator.from(config$l);
13953
+ const translator$14 = NodeTranslator.from(config$l);
13949
13954
  const EAST_ASIAN_CHARACTER_REGEX = /[\u1100-\u11FF\u2E80-\u2EFF\u2F00-\u2FDF\u3040-\u30FF\u3100-\u312F\u3130-\u318F\u31A0-\u31BF\u3400-\u4DBF\u4E00-\u9FFF\uA960-\uA97F\uAC00-\uD7AF\uF900-\uFAFF\uFF00-\uFFEF]/u;
13950
13955
  const containsEastAsianCharacters = (text2) => EAST_ASIAN_CHARACTER_REGEX.test(text2);
13951
13956
  const resolveFontFamily = (textStyleAttrs, text2) => {
@@ -14230,7 +14235,7 @@
14230
14235
  decode: decode$E,
14231
14236
  attributes: validXmlAttributes$c
14232
14237
  };
14233
- const translator$12 = NodeTranslator.from(config$k);
14238
+ const translator$13 = NodeTranslator.from(config$k);
14234
14239
  const encode$B = (attributes) => {
14235
14240
  return attributes["w:rsidR"];
14236
14241
  };
@@ -14287,7 +14292,7 @@
14287
14292
  if (!runNode) return void 0;
14288
14293
  const elements = Array.isArray(runNode.elements) ? runNode.elements : [];
14289
14294
  const rPrNode = elements.find((child) => child?.name === "w:rPr");
14290
- const runProperties = rPrNode ? translator$1O.encode({ ...params2, nodes: [rPrNode] }) : {};
14295
+ const runProperties = rPrNode ? translator$1P.encode({ ...params2, nodes: [rPrNode] }) : {};
14291
14296
  const paragraphProperties = params2?.extraParams?.paragraphProperties || {};
14292
14297
  const resolvedRunProperties = resolveRunProperties(params2, runProperties ?? {}, paragraphProperties);
14293
14298
  const marksResult = encodeMarksFromRPr(resolvedRunProperties, params2?.docx);
@@ -14359,7 +14364,7 @@
14359
14364
  ...params2.extraParams,
14360
14365
  linkProcessed: true
14361
14366
  };
14362
- return translator$12.decode({ ...params2, extraParams });
14367
+ return translator$13.decode({ ...params2, extraParams });
14363
14368
  }
14364
14369
  const { runNode: runNodeForExport, trackingMarksByType } = prepareRunTrackingContext(node2);
14365
14370
  const runAttrs = runNodeForExport.attrs || {};
@@ -14373,7 +14378,7 @@
14373
14378
  exportParams.editor = { extensionService: { extensions: [] } };
14374
14379
  }
14375
14380
  const childElements = translateChildNodes(exportParams) || [];
14376
- let runPropertiesElement = translator$1O.decode({
14381
+ let runPropertiesElement = translator$1P.decode({
14377
14382
  ...params2,
14378
14383
  node: { attrs: { runProperties } }
14379
14384
  });
@@ -14451,9 +14456,9 @@
14451
14456
  decode: decode$A,
14452
14457
  attributes: validXmlAttributes$b
14453
14458
  };
14454
- const translator$11 = NodeTranslator.from(config$j);
14455
- const translator$10 = NodeTranslator.from(createMeasurementPropertyHandler("w:tcW", "cellWidth"));
14456
- const translator$$ = NodeTranslator.from(
14459
+ const translator$12 = NodeTranslator.from(config$j);
14460
+ const translator$11 = NodeTranslator.from(createMeasurementPropertyHandler("w:tcW", "cellWidth"));
14461
+ const translator$10 = NodeTranslator.from(
14457
14462
  createSingleAttrPropertyHandler(
14458
14463
  "w:gridSpan",
14459
14464
  null,
@@ -14462,33 +14467,33 @@
14462
14467
  (v2) => integerToString(v2)
14463
14468
  )
14464
14469
  );
14465
- const translator$_ = NodeTranslator.from(
14470
+ const translator$$ = NodeTranslator.from(
14466
14471
  createSingleAttrPropertyHandler("w:vMerge", null, "w:val", (val) => !val ? "continue" : val)
14467
14472
  );
14468
- const translator$Z = NodeTranslator.from(createBorderPropertyHandler("w:end"));
14469
- const translator$Y = NodeTranslator.from(createMeasurementPropertyHandler("w:end", "marginEnd"));
14470
- const translator$X = NodeTranslator.from(createBorderPropertyHandler("w:insideH"));
14471
- const translator$W = NodeTranslator.from(createBorderPropertyHandler("w:insideV"));
14472
- const translator$V = NodeTranslator.from(createBorderPropertyHandler("w:start"));
14473
- const translator$U = NodeTranslator.from(createMeasurementPropertyHandler("w:start", "marginStart"));
14474
- const translator$T = NodeTranslator.from(createBorderPropertyHandler("w:tl2br"));
14475
- const translator$S = NodeTranslator.from(createBorderPropertyHandler("w:tr2bl"));
14476
- const propertyTranslators$6 = [
14477
- translator$1k,
14478
- translator$V,
14479
- translator$1o,
14480
- translator$1q,
14481
- translator$Z,
14482
- translator$1m,
14483
- translator$X,
14473
+ const translator$_ = NodeTranslator.from(createBorderPropertyHandler("w:end"));
14474
+ const translator$Z = NodeTranslator.from(createMeasurementPropertyHandler("w:end", "marginEnd"));
14475
+ const translator$Y = NodeTranslator.from(createBorderPropertyHandler("w:insideH"));
14476
+ const translator$X = NodeTranslator.from(createBorderPropertyHandler("w:insideV"));
14477
+ const translator$W = NodeTranslator.from(createBorderPropertyHandler("w:start"));
14478
+ const translator$V = NodeTranslator.from(createMeasurementPropertyHandler("w:start", "marginStart"));
14479
+ const translator$U = NodeTranslator.from(createBorderPropertyHandler("w:tl2br"));
14480
+ const translator$T = NodeTranslator.from(createBorderPropertyHandler("w:tr2bl"));
14481
+ const propertyTranslators$7 = [
14482
+ translator$1l,
14484
14483
  translator$W,
14485
- translator$T,
14486
- translator$S
14484
+ translator$1p,
14485
+ translator$1r,
14486
+ translator$_,
14487
+ translator$1n,
14488
+ translator$Y,
14489
+ translator$X,
14490
+ translator$U,
14491
+ translator$T
14487
14492
  ];
14488
- const translator$R = NodeTranslator.from(
14489
- createNestedPropertiesTranslator("w:tcBorders", "borders", propertyTranslators$6)
14493
+ const translator$S = NodeTranslator.from(
14494
+ createNestedPropertiesTranslator("w:tcBorders", "borders", propertyTranslators$7)
14490
14495
  );
14491
- const translator$Q = NodeTranslator.from(
14496
+ const translator$R = NodeTranslator.from(
14492
14497
  createSingleAttrPropertyHandler(
14493
14498
  "w:noWrap",
14494
14499
  null,
@@ -14497,18 +14502,18 @@
14497
14502
  (v2) => booleanToString(v2)
14498
14503
  )
14499
14504
  );
14500
- const propertyTranslators$5 = [
14501
- translator$1p,
14502
- translator$Y,
14503
- translator$1n,
14504
- translator$1l,
14505
- translator$U,
14506
- translator$1j
14505
+ const propertyTranslators$6 = [
14506
+ translator$1q,
14507
+ translator$Z,
14508
+ translator$1o,
14509
+ translator$1m,
14510
+ translator$V,
14511
+ translator$1k
14507
14512
  ];
14508
- const translator$P = NodeTranslator.from(
14509
- createNestedPropertiesTranslator("w:tcMar", "cellMargins", propertyTranslators$5)
14513
+ const translator$Q = NodeTranslator.from(
14514
+ createNestedPropertiesTranslator("w:tcMar", "cellMargins", propertyTranslators$6)
14510
14515
  );
14511
- const translator$O = NodeTranslator.from(
14516
+ const translator$P = NodeTranslator.from(
14512
14517
  createSingleAttrPropertyHandler(
14513
14518
  "w:tcFitText",
14514
14519
  null,
@@ -14517,8 +14522,8 @@
14517
14522
  (v2) => booleanToString(v2)
14518
14523
  )
14519
14524
  );
14520
- const translator$N = NodeTranslator.from(createSingleAttrPropertyHandler("w:vAlign"));
14521
- const translator$M = NodeTranslator.from(
14525
+ const translator$O = NodeTranslator.from(createSingleAttrPropertyHandler("w:vAlign"));
14526
+ const translator$N = NodeTranslator.from(
14522
14527
  createSingleAttrPropertyHandler(
14523
14528
  "w:hideMark",
14524
14529
  null,
@@ -14527,27 +14532,27 @@
14527
14532
  (v2) => booleanToString(v2)
14528
14533
  )
14529
14534
  );
14530
- const translator$L = NodeTranslator.from(createSingleAttrPropertyHandler("w:header"));
14531
- const translator$K = NodeTranslator.from(
14532
- createNestedArrayPropertyHandler("w:headers", "headers", [translator$L])
14535
+ const translator$M = NodeTranslator.from(createSingleAttrPropertyHandler("w:header"));
14536
+ const translator$L = NodeTranslator.from(
14537
+ createNestedArrayPropertyHandler("w:headers", "headers", [translator$M])
14533
14538
  );
14534
- const propertyTranslators$4 = [
14535
- translator$1I,
14539
+ const propertyTranslators$5 = [
14540
+ translator$1J,
14541
+ translator$11,
14536
14542
  translator$10,
14537
14543
  translator$$,
14538
- translator$_,
14544
+ translator$S,
14545
+ translator$2c,
14539
14546
  translator$R,
14540
- translator$2b,
14541
14547
  translator$Q,
14548
+ translator$1a,
14542
14549
  translator$P,
14543
- translator$19,
14544
14550
  translator$O,
14545
14551
  translator$N,
14546
- translator$M,
14547
- translator$K
14552
+ translator$L
14548
14553
  ];
14549
- const translator$J = NodeTranslator.from(
14550
- createNestedPropertiesTranslator("w:tcPr", "tableCellProperties", propertyTranslators$4)
14554
+ const translator$K = NodeTranslator.from(
14555
+ createNestedPropertiesTranslator("w:tcPr", "tableCellProperties", propertyTranslators$5)
14551
14556
  );
14552
14557
  function handleTableCellNode({
14553
14558
  params: params2,
@@ -14555,6 +14560,9 @@
14555
14560
  table: table2,
14556
14561
  row: row2,
14557
14562
  rowBorders,
14563
+ baseTableBorders,
14564
+ tableLook,
14565
+ rowCnfStyle,
14558
14566
  columnIndex,
14559
14567
  columnWidth = null,
14560
14568
  allColumnWidths = [],
@@ -14567,7 +14575,7 @@
14567
14575
  const attributes = {};
14568
14576
  const referencedStyles = _referencedStyles ?? { fontSize: null, fonts: {}, cellMargins: {} };
14569
14577
  const tcPr = node2.elements.find((el) => el.name === "w:tcPr");
14570
- const tableCellProperties = tcPr ? translator$J.encode({ ...params2, nodes: [tcPr] }) ?? {} : {};
14578
+ const tableCellProperties = tcPr ? translator$K.encode({ ...params2, nodes: [tcPr] }) ?? {} : {};
14571
14579
  attributes["tableCellProperties"] = tableCellProperties;
14572
14580
  const effectiveTotalColumns = totalColumns ?? (allColumnWidths.length || 1);
14573
14581
  const effectiveTotalRows = totalRows ?? (table2?.elements?.filter((el) => el.name === "w:tr").length || 1);
@@ -14576,38 +14584,32 @@
14576
14584
  const isLastRow = rowIndex === effectiveTotalRows - 1;
14577
14585
  const isFirstColumn = columnIndex === 0;
14578
14586
  const isLastColumn = columnIndex + colspan >= effectiveTotalColumns;
14579
- const cellBorders = {};
14580
- if (rowBorders) {
14581
- if (rowBorders.top?.val === "none") {
14582
- cellBorders.top = rowBorders.top;
14583
- } else if (isFirstRow && rowBorders.top) {
14584
- cellBorders.top = rowBorders.top;
14585
- }
14586
- if (rowBorders.bottom?.val === "none") {
14587
- cellBorders.bottom = rowBorders.bottom;
14588
- } else if (isLastRow && rowBorders.bottom) {
14589
- cellBorders.bottom = rowBorders.bottom;
14590
- }
14591
- if (rowBorders.left?.val === "none") {
14592
- cellBorders.left = rowBorders.left;
14593
- } else if (isFirstColumn && rowBorders.left) {
14594
- cellBorders.left = rowBorders.left;
14595
- }
14596
- if (rowBorders.right?.val === "none") {
14597
- cellBorders.right = rowBorders.right;
14598
- } else if (isLastColumn && rowBorders.right) {
14599
- cellBorders.right = rowBorders.right;
14600
- }
14601
- if (!isLastRow && rowBorders.insideH) {
14602
- cellBorders.bottom = rowBorders.insideH;
14603
- }
14604
- if (!isLastColumn && rowBorders.insideV) {
14605
- cellBorders.right = rowBorders.insideV;
14606
- }
14587
+ attributes["borders"] = processCellBorders({
14588
+ baseTableBorders,
14589
+ rowBorders,
14590
+ tableLook,
14591
+ rowCnfStyle,
14592
+ isFirstRow,
14593
+ isLastRow,
14594
+ isFirstColumn,
14595
+ isLastColumn,
14596
+ tableCellProperties,
14597
+ referencedStyles
14598
+ });
14599
+ const hasRowOverrideNone = rowBorders && ["top", "left", "bottom", "right", "insideH", "insideV"].some((side) => rowBorders?.[side]?.val === "none");
14600
+ if (hasRowOverrideNone && isFirstColumn) {
14601
+ console.info(
14602
+ "[sd-table-borders] cell borders",
14603
+ JSON.stringify({
14604
+ rowIndex,
14605
+ columnIndex,
14606
+ totalColumns: effectiveTotalColumns,
14607
+ baseTableBorders,
14608
+ rowBorders,
14609
+ cellBorders: attributes["borders"]
14610
+ })
14611
+ );
14607
14612
  }
14608
- attributes["borders"] = cellBorders;
14609
- const inlineBorders = processInlineCellBorders(tableCellProperties.borders, cellBorders);
14610
- if (inlineBorders) attributes["borders"] = Object.assign(attributes["borders"], inlineBorders);
14611
14613
  if (colspan > 1) attributes["colspan"] = colspan;
14612
14614
  let width = tableCellProperties.cellWidth?.value ? twipsToPixels$2(tableCellProperties.cellWidth?.value) : null;
14613
14615
  const widthType = tableCellProperties.cellWidth?.type;
@@ -14786,6 +14788,81 @@
14786
14788
  return acc;
14787
14789
  }, {});
14788
14790
  };
14791
+ const processCellBorders = ({
14792
+ baseTableBorders,
14793
+ rowBorders,
14794
+ tableLook,
14795
+ rowCnfStyle,
14796
+ isFirstRow,
14797
+ isLastRow,
14798
+ isFirstColumn,
14799
+ isLastColumn,
14800
+ tableCellProperties,
14801
+ referencedStyles
14802
+ }) => {
14803
+ let cellBorders = {};
14804
+ if (baseTableBorders) {
14805
+ if (isFirstRow && baseTableBorders.top) {
14806
+ cellBorders.top = baseTableBorders.top;
14807
+ }
14808
+ if (isLastRow && baseTableBorders.bottom) {
14809
+ cellBorders.bottom = baseTableBorders.bottom;
14810
+ }
14811
+ if (isFirstColumn && baseTableBorders.left) {
14812
+ cellBorders.left = baseTableBorders.left;
14813
+ }
14814
+ if (isLastColumn && baseTableBorders.right) {
14815
+ cellBorders.right = baseTableBorders.right;
14816
+ }
14817
+ }
14818
+ if (rowBorders) {
14819
+ if (rowBorders.top?.val) {
14820
+ cellBorders.top = rowBorders.top;
14821
+ }
14822
+ if (rowBorders.bottom?.val) {
14823
+ cellBorders.bottom = rowBorders.bottom;
14824
+ }
14825
+ if (rowBorders.left?.val) {
14826
+ const applyLeftToAll = rowBorders.left.val === "none";
14827
+ if (applyLeftToAll || isFirstColumn) {
14828
+ cellBorders.left = rowBorders.left;
14829
+ }
14830
+ }
14831
+ if (rowBorders.right?.val) {
14832
+ const applyRightToAll = rowBorders.right.val === "none";
14833
+ if (applyRightToAll || isLastColumn) {
14834
+ cellBorders.right = rowBorders.right;
14835
+ }
14836
+ }
14837
+ if (!isLastRow && rowBorders.insideH) {
14838
+ cellBorders.bottom = rowBorders.insideH;
14839
+ }
14840
+ if (!isLastColumn && rowBorders.insideV) {
14841
+ cellBorders.right = rowBorders.insideV;
14842
+ }
14843
+ }
14844
+ const getStyleTableCellBorders = (styleVariant) => styleVariant?.tableCellProperties?.borders ?? null;
14845
+ const cellCnfStyle = tableCellProperties?.cnfStyle;
14846
+ const getFlag = (source, flag) => source && Object.prototype.hasOwnProperty.call(source, flag) ? source[flag] : void 0;
14847
+ const isStyleEnabled = (flag) => getFlag(cellCnfStyle, flag) ?? getFlag(rowCnfStyle, flag) ?? getFlag(tableLook, flag) ?? true;
14848
+ const applyStyleBorders = (styleVariant, allowedDirections) => {
14849
+ const styleBorders = getStyleTableCellBorders(styleVariant);
14850
+ if (!styleBorders) return;
14851
+ const filteredBorders = allowedDirections.reduce((acc, direction) => {
14852
+ if (styleBorders[direction]) acc[direction] = styleBorders[direction];
14853
+ return acc;
14854
+ }, {});
14855
+ const styleOverrides = processInlineCellBorders(filteredBorders, cellBorders);
14856
+ if (styleOverrides) cellBorders = Object.assign(cellBorders, styleOverrides);
14857
+ };
14858
+ if (isFirstRow && isStyleEnabled("firstRow")) applyStyleBorders(referencedStyles?.firstRow, ["top", "bottom"]);
14859
+ if (isLastRow && isStyleEnabled("lastRow")) applyStyleBorders(referencedStyles?.lastRow, ["top", "bottom"]);
14860
+ if (isFirstColumn && isStyleEnabled("firstColumn")) applyStyleBorders(referencedStyles?.firstCol, ["left", "right"]);
14861
+ if (isLastColumn && isStyleEnabled("lastColumn")) applyStyleBorders(referencedStyles?.lastCol, ["left", "right"]);
14862
+ const inlineBorders = processInlineCellBorders(tableCellProperties.borders, cellBorders);
14863
+ if (inlineBorders) cellBorders = Object.assign(cellBorders, inlineBorders);
14864
+ return cellBorders;
14865
+ };
14789
14866
  const getTableCellVMerge = (node2) => {
14790
14867
  const tcPr = node2.elements.find((el) => el.name === "w:tcPr");
14791
14868
  const vMerge = tcPr?.elements?.find((el) => el.name === "w:vMerge");
@@ -14902,7 +14979,7 @@
14902
14979
  } else if (tableCellProperties?.borders) {
14903
14980
  delete tableCellProperties.borders;
14904
14981
  }
14905
- const result = translator$J.decode({ node: { ...node2, attrs: { ...node2.attrs, tableCellProperties } } });
14982
+ const result = translator$K.decode({ node: { ...node2, attrs: { ...node2.attrs, tableCellProperties } } });
14906
14983
  return result;
14907
14984
  }
14908
14985
  const XML_NODE_NAME$j = "w:tc";
@@ -14914,6 +14991,9 @@
14914
14991
  table: table2,
14915
14992
  row: row2,
14916
14993
  rowBorders,
14994
+ baseTableBorders,
14995
+ tableLook,
14996
+ rowCnfStyle,
14917
14997
  columnIndex,
14918
14998
  columnWidth,
14919
14999
  columnWidths: allColumnWidths,
@@ -14928,6 +15008,9 @@
14928
15008
  table: table2,
14929
15009
  row: row2,
14930
15010
  rowBorders,
15011
+ baseTableBorders,
15012
+ tableLook,
15013
+ rowCnfStyle,
14931
15014
  columnIndex,
14932
15015
  columnWidth,
14933
15016
  allColumnWidths,
@@ -14956,27 +15039,27 @@
14956
15039
  decode: decode$z,
14957
15040
  attributes: validXmlAttributes$a
14958
15041
  };
14959
- const translator$I = NodeTranslator.from(config$i);
14960
- const propertyTranslators$3 = [
14961
- translator$1q,
14962
- translator$Z,
15042
+ const translator$J = NodeTranslator.from(config$i);
15043
+ const propertyTranslators$4 = [
15044
+ translator$1r,
15045
+ translator$_,
15046
+ translator$Y,
14963
15047
  translator$X,
15048
+ translator$1p,
15049
+ translator$1n,
14964
15050
  translator$W,
14965
- translator$1o,
14966
- translator$1m,
14967
- translator$V,
14968
- translator$1k
15051
+ translator$1l
14969
15052
  ];
14970
- const translator$H = NodeTranslator.from(
14971
- createNestedPropertiesTranslator("w:tblBorders", "borders", propertyTranslators$3)
15053
+ const translator$I = NodeTranslator.from(
15054
+ createNestedPropertiesTranslator("w:tblBorders", "borders", propertyTranslators$4)
14972
15055
  );
14973
- const translator$G = NodeTranslator.from({
15056
+ const translator$H = NodeTranslator.from({
14974
15057
  xmlName: "w:cantSplit",
14975
15058
  sdNodeOrKeyName: "cantSplit",
14976
15059
  encode: ({ nodes }) => ["1", "true"].includes(nodes[0].attributes?.["w:val"] ?? "1"),
14977
15060
  decode: ({ node: node2 }) => node2.attrs?.cantSplit ? { attributes: {} } : void 0
14978
15061
  });
14979
- const translator$F = NodeTranslator.from(
15062
+ const translator$G = NodeTranslator.from(
14980
15063
  createSingleAttrPropertyHandler(
14981
15064
  "w:gridAfter",
14982
15065
  null,
@@ -14985,7 +15068,7 @@
14985
15068
  (v2) => integerToString(v2)
14986
15069
  )
14987
15070
  );
14988
- const translator$E = NodeTranslator.from(
15071
+ const translator$F = NodeTranslator.from(
14989
15072
  createSingleAttrPropertyHandler(
14990
15073
  "w:gridBefore",
14991
15074
  null,
@@ -14994,20 +15077,20 @@
14994
15077
  (v2) => integerToString(v2)
14995
15078
  )
14996
15079
  );
14997
- const translator$D = NodeTranslator.from({
15080
+ const translator$E = NodeTranslator.from({
14998
15081
  xmlName: "w:hidden",
14999
15082
  sdNodeOrKeyName: "hidden",
15000
15083
  encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
15001
15084
  decode: ({ node: node2 }) => node2.attrs.hidden ? { attributes: {} } : void 0
15002
15085
  });
15003
- const translator$C = NodeTranslator.from(createMeasurementPropertyHandler("w:tblCellSpacing", "tableCellSpacing"));
15004
- const translator$B = NodeTranslator.from({
15086
+ const translator$D = NodeTranslator.from(createMeasurementPropertyHandler("w:tblCellSpacing", "tableCellSpacing"));
15087
+ const translator$C = NodeTranslator.from({
15005
15088
  xmlName: "w:tblHeader",
15006
15089
  sdNodeOrKeyName: "repeatHeader",
15007
15090
  encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
15008
15091
  decode: ({ node: node2 }) => node2.attrs.repeatHeader ? { attributes: {} } : void 0
15009
15092
  });
15010
- const translator$A = NodeTranslator.from({
15093
+ const translator$B = NodeTranslator.from({
15011
15094
  xmlName: "w:trHeight",
15012
15095
  sdNodeOrKeyName: "rowHeight",
15013
15096
  encode: ({ nodes }) => {
@@ -15034,24 +15117,24 @@
15034
15117
  return Object.keys(heightAttrs).length > 0 ? { attributes: heightAttrs } : void 0;
15035
15118
  }
15036
15119
  });
15037
- const translator$z = NodeTranslator.from(createMeasurementPropertyHandler("w:wAfter"));
15038
- const translator$y = NodeTranslator.from(createMeasurementPropertyHandler("w:wBefore"));
15039
- const propertyTranslators$2 = [
15120
+ const translator$A = NodeTranslator.from(createMeasurementPropertyHandler("w:wAfter"));
15121
+ const translator$z = NodeTranslator.from(createMeasurementPropertyHandler("w:wBefore"));
15122
+ const propertyTranslators$3 = [
15123
+ translator$H,
15124
+ translator$1J,
15125
+ translator$1H,
15040
15126
  translator$G,
15041
- translator$1I,
15042
- translator$1G,
15043
15127
  translator$F,
15044
15128
  translator$E,
15129
+ translator$1E,
15045
15130
  translator$D,
15046
- translator$1D,
15047
15131
  translator$C,
15048
15132
  translator$B,
15049
15133
  translator$A,
15050
- translator$z,
15051
- translator$y
15134
+ translator$z
15052
15135
  ];
15053
- const translator$x = NodeTranslator.from(
15054
- createNestedPropertiesTranslator("w:trPr", "tableRowProperties", propertyTranslators$2, {
15136
+ const translator$y = NodeTranslator.from(
15137
+ createNestedPropertiesTranslator("w:trPr", "tableRowProperties", propertyTranslators$3, {
15055
15138
  cantSplit: false,
15056
15139
  hidden: false,
15057
15140
  repeatHeader: false
@@ -15130,11 +15213,11 @@
15130
15213
  return Number.isFinite(numericColspan) && numericColspan > 0 ? numericColspan : 1;
15131
15214
  };
15132
15215
  const encode$w = (params2, encodedAttrs) => {
15133
- const { row: row2 } = params2.extraParams;
15216
+ const { row: row2, tableLook } = params2.extraParams;
15134
15217
  let tableRowProperties = {};
15135
15218
  const tPr = row2.elements.find((el) => el.name === "w:trPr");
15136
15219
  if (tPr) {
15137
- tableRowProperties = translator$x.encode({
15220
+ tableRowProperties = translator$y.encode({
15138
15221
  ...params2,
15139
15222
  nodes: [tPr]
15140
15223
  });
@@ -15144,8 +15227,9 @@
15144
15227
  encodedAttrs["tableRowProperties"] = Object.freeze(tableRowProperties);
15145
15228
  encodedAttrs["rowHeight"] = twipsToPixels$2(tableRowProperties["rowHeight"]?.value);
15146
15229
  encodedAttrs["cantSplit"] = tableRowProperties["cantSplit"];
15147
- const baseBorders = params2.extraParams?.rowBorders;
15148
- const rowTableBorders = getRowTableBorders({
15230
+ const rowCnfStyle = tableRowProperties?.cnfStyle;
15231
+ const baseBorders = params2.extraParams?.tableBorders;
15232
+ const rowBorders = getRowBorders({
15149
15233
  params: params2,
15150
15234
  row: row2,
15151
15235
  baseBorders
@@ -15177,15 +15261,15 @@
15177
15261
  skipOccupiedColumns();
15178
15262
  const startColumn = currentColumnIndex;
15179
15263
  const columnWidth = gridColumnWidths?.[startColumn] || null;
15180
- const result = translator$I.encode({
15264
+ const result = translator$J.encode({
15181
15265
  ...params2,
15182
15266
  path: [...params2.path || [], node2],
15183
15267
  extraParams: {
15184
15268
  ...params2.extraParams,
15185
- rowBorders: {
15186
- ...baseBorders,
15187
- ...rowTableBorders
15188
- },
15269
+ rowBorders,
15270
+ baseTableBorders: baseBorders,
15271
+ tableLook,
15272
+ rowCnfStyle,
15189
15273
  node: node2,
15190
15274
  columnIndex: startColumn,
15191
15275
  columnWidth
@@ -15215,18 +15299,35 @@
15215
15299
  };
15216
15300
  return newNode;
15217
15301
  };
15218
- function getRowTableBorders({ params: params2, row: row2, baseBorders }) {
15302
+ function getRowBorders({ params: params2, row: row2, baseBorders }) {
15303
+ const rowIndex = params2?.extraParams?.rowIndex;
15219
15304
  const tblPrEx = row2?.elements?.find?.((el) => el.name === "w:tblPrEx");
15220
15305
  const tblBorders = tblPrEx?.elements?.find?.((el) => el.name === "w:tblBorders");
15306
+ const rowBaseBorders = {};
15307
+ if (baseBorders?.insideV) {
15308
+ rowBaseBorders.insideV = baseBorders?.insideV;
15309
+ }
15310
+ if (baseBorders?.insideH) {
15311
+ rowBaseBorders.insideH = baseBorders?.insideH;
15312
+ }
15221
15313
  if (!tblBorders) {
15222
- return baseBorders;
15314
+ return rowBaseBorders;
15223
15315
  }
15224
- const rawOverrides = translator$H.encode({ ...params2, nodes: [tblBorders] }) || {};
15316
+ const rawOverrides = translator$I.encode({ ...params2, nodes: [tblBorders] }) || {};
15225
15317
  const overrides = processRawTableBorders(rawOverrides);
15226
15318
  if (!Object.keys(overrides).length) {
15227
- return baseBorders;
15319
+ console.info(
15320
+ "[sd-table-borders] row tblPrEx overrides empty",
15321
+ JSON.stringify({ rowIndex, baseBorders: rowBaseBorders, rawOverrides })
15322
+ );
15323
+ return rowBaseBorders;
15228
15324
  }
15229
- return { ...baseBorders || {}, ...overrides };
15325
+ const rowBorders = { ...rowBaseBorders, ...overrides };
15326
+ console.info(
15327
+ "[sd-table-borders] row tblPrEx overrides",
15328
+ JSON.stringify({ rowIndex, baseBorders: rowBaseBorders, rawOverrides, overrides, rowBorders })
15329
+ );
15330
+ return rowBorders;
15230
15331
  }
15231
15332
  function processRawTableBorders(rawBorders) {
15232
15333
  const borders = {};
@@ -15302,7 +15403,7 @@
15302
15403
  }
15303
15404
  }
15304
15405
  tableRowProperties["cantSplit"] = node2.attrs["cantSplit"];
15305
- const trPr = translator$x.decode({
15406
+ const trPr = translator$y.decode({
15306
15407
  ...params2,
15307
15408
  node: { ...node2, attrs: { ...node2.attrs, tableRowProperties } }
15308
15409
  });
@@ -15322,7 +15423,7 @@
15322
15423
  decode: decode$y,
15323
15424
  attributes: validXmlAttributes$9
15324
15425
  };
15325
- const translator$w = NodeTranslator.from(config$h);
15426
+ const translator$x = NodeTranslator.from(config$h);
15326
15427
  function parseTagValueJSON(json) {
15327
15428
  if (typeof json !== "string") {
15328
15429
  return {};
@@ -24303,9 +24404,9 @@
24303
24404
  if (!blip) {
24304
24405
  return null;
24305
24406
  }
24306
- const stretch = blipFill?.elements.find((el) => el.name === "a:stretch");
24307
- const fillRect = stretch?.elements.find((el) => el.name === "a:fillRect");
24308
- const srcRect = blipFill?.elements.find((el) => el.name === "a:srcRect");
24407
+ const stretch = blipFill?.elements?.find((el) => el.name === "a:stretch");
24408
+ const fillRect = stretch?.elements?.find((el) => el.name === "a:fillRect");
24409
+ const srcRect = blipFill?.elements?.find((el) => el.name === "a:srcRect");
24309
24410
  const srcRectAttrs = srcRect?.attributes || {};
24310
24411
  const srcRectHasNegativeValues = ["l", "t", "r", "b"].some((attr) => {
24311
24412
  const val = srcRectAttrs[attr];
@@ -30586,7 +30687,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
30586
30687
  decode: decode$x,
30587
30688
  attributes: validXmlAttributes$8
30588
30689
  };
30589
- const translator$v = NodeTranslator.from(config$g);
30690
+ const translator$w = NodeTranslator.from(config$g);
30590
30691
  function handleInlineNode(params2) {
30591
30692
  const { node: node2 } = params2.extraParams;
30592
30693
  if (node2.name !== "wp:inline") {
@@ -30640,7 +30741,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
30640
30741
  decode: decode$w,
30641
30742
  attributes: validXmlAttributes$7
30642
30743
  };
30643
- const translator$u = NodeTranslator.from(config$f);
30744
+ const translator$v = NodeTranslator.from(config$f);
30644
30745
  const XML_NODE_NAME$f = "w:drawing";
30645
30746
  const SD_NODE_NAME$d = [];
30646
30747
  const validXmlAttributes$6 = [];
@@ -30648,8 +30749,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
30648
30749
  const nodes = params2.nodes;
30649
30750
  const node2 = nodes[0];
30650
30751
  const translatorByChildName = {
30651
- "wp:anchor": translator$v,
30652
- "wp:inline": translator$u
30752
+ "wp:anchor": translator$w,
30753
+ "wp:inline": translator$v
30653
30754
  };
30654
30755
  const result = (node2.elements || []).reduce((acc, child) => {
30655
30756
  if (acc) return acc;
@@ -30672,7 +30773,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
30672
30773
  if (!node2 || !node2.type) {
30673
30774
  return null;
30674
30775
  }
30675
- const childTranslator = node2.attrs.isAnchor ? translator$v : translator$u;
30776
+ const childTranslator = node2.attrs.isAnchor ? translator$w : translator$v;
30676
30777
  const resultNode = childTranslator.decode(params2);
30677
30778
  return wrapTextInRun(
30678
30779
  {
@@ -30690,7 +30791,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
30690
30791
  decode: decode$v,
30691
30792
  attributes: validXmlAttributes$6
30692
30793
  };
30693
- const translator$t = NodeTranslator.from(config$e);
30794
+ const translator$u = NodeTranslator.from(config$e);
30694
30795
  function getTextNodeForExport(text2, marks, params2) {
30695
30796
  const hasLeadingOrTrailingSpace = /^\s|\s$/.test(text2);
30696
30797
  const space = hasLeadingOrTrailingSpace ? "preserve" : null;
@@ -30699,7 +30800,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
30699
30800
  const textRunProperties = decodeRPrFromMarks(marks || []);
30700
30801
  const parentRunProperties = params2.extraParams?.runProperties || {};
30701
30802
  const combinedRunProperties = combineRunProperties([parentRunProperties, textRunProperties]);
30702
- const rPrNode = translator$1O.decode({ node: { attrs: { runProperties: combinedRunProperties } } });
30803
+ const rPrNode = translator$1P.decode({ node: { attrs: { runProperties: combinedRunProperties } } });
30703
30804
  textNodes.push({
30704
30805
  name: "w:t",
30705
30806
  elements: [{ text: text2, type: "text" }],
@@ -31098,7 +31199,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
31098
31199
  return getTextNodeForExport(attrs.displayLabel, [...marks, ...marksFromAttrs], params2);
31099
31200
  }
31100
31201
  function prepareImageAnnotation(params2, imageSize) {
31101
- return translator$t.decode({
31202
+ return translator$u.decode({
31102
31203
  ...params2,
31103
31204
  imageSize
31104
31205
  });
@@ -31183,7 +31284,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
31183
31284
  }
31184
31285
  ]
31185
31286
  };
31186
- return translator$12.decode({
31287
+ return translator$13.decode({
31187
31288
  ...params2,
31188
31289
  node: linkTextNode
31189
31290
  });
@@ -31560,7 +31661,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
31560
31661
  decode: decode$u,
31561
31662
  attributes: validXmlAttributes$5
31562
31663
  };
31563
- const translator$s = NodeTranslator.from(config$d);
31664
+ const translator$t = NodeTranslator.from(config$d);
31564
31665
  const getColspan = (cell2) => {
31565
31666
  const rawColspan = cell2?.attrs?.colspan;
31566
31667
  const numericColspan = typeof rawColspan === "string" ? parseInt(rawColspan, 10) : rawColspan;
@@ -31651,21 +31752,47 @@ Please report this to https://github.com/markedjs/marked.`, e) {
31651
31752
  }
31652
31753
  return table2;
31653
31754
  }
31654
- const translator$r = NodeTranslator.from({
31755
+ const translator$s = NodeTranslator.from({
31655
31756
  xmlName: "w:bidiVisual",
31656
31757
  sdNodeOrKeyName: "rightToLeft",
31657
31758
  encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
31658
31759
  decode: ({ node: node2 }) => node2.attrs.rightToLeft ? { attributes: {} } : void 0
31659
31760
  });
31660
- const translator$q = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblCaption", "caption"));
31661
- const translator$p = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblDescription", "description"));
31662
- const translator$o = NodeTranslator.from(createMeasurementPropertyHandler("w:tblInd", "tableIndent"));
31663
- const translator$n = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblLayout", "tableLayout", "w:type"));
31664
- const translator$m = NodeTranslator.from({
31761
+ const translator$r = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblCaption", "caption"));
31762
+ const translator$q = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblDescription", "description"));
31763
+ const translator$p = NodeTranslator.from(createMeasurementPropertyHandler("w:tblInd", "tableIndent"));
31764
+ const translator$o = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblLayout", "tableLayout", "w:type"));
31765
+ const tblLookBitmask = Object.freeze({
31766
+ firstRow: 32,
31767
+ lastRow: 64,
31768
+ firstColumn: 128,
31769
+ lastColumn: 256,
31770
+ noHBand: 512,
31771
+ noVBand: 1024
31772
+ });
31773
+ const decodeTblLookVal = (val) => {
31774
+ if (!val) return null;
31775
+ const raw = typeof val === "string" ? val.trim() : String(val);
31776
+ let numeric = Number.parseInt(raw, 16);
31777
+ if (!Number.isFinite(numeric)) {
31778
+ numeric = Number.parseInt(raw, 10);
31779
+ }
31780
+ if (!Number.isFinite(numeric)) return null;
31781
+ return Object.fromEntries(Object.entries(tblLookBitmask).map(([key2, mask]) => [key2, (numeric & mask) === mask]));
31782
+ };
31783
+ const translator$n = NodeTranslator.from({
31665
31784
  xmlName: "w:tblLook",
31666
31785
  sdNodeOrKeyName: "tblLook",
31667
31786
  attributes: ["w:firstColumn", "w:firstRow", "w:lastColumn", "w:lastRow", "w:noHBand", "w:noVBand"].map((attr) => createAttributeHandler(attr, null, parseBoolean, booleanToString)).concat([createAttributeHandler("w:val")]),
31668
31787
  encode: (params2, encodedAttrs) => {
31788
+ const decoded = decodeTblLookVal(encodedAttrs.val);
31789
+ if (decoded) {
31790
+ Object.entries(decoded).forEach(([key2, value]) => {
31791
+ if (!Object.prototype.hasOwnProperty.call(encodedAttrs, key2)) {
31792
+ encodedAttrs[key2] = value;
31793
+ }
31794
+ });
31795
+ }
31669
31796
  return Object.keys(encodedAttrs).length > 0 ? encodedAttrs : void 0;
31670
31797
  },
31671
31798
  decode: function({ node: node2 }, context) {
@@ -31673,16 +31800,16 @@ Please report this to https://github.com/markedjs/marked.`, e) {
31673
31800
  return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
31674
31801
  }
31675
31802
  });
31676
- const translator$l = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblOverlap", "overlap"));
31677
- const translator$k = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblStyle", "tableStyleId"));
31678
- const translator$j = NodeTranslator.from(
31803
+ const translator$m = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblOverlap", "overlap"));
31804
+ const translator$l = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblStyle", "tableStyleId"));
31805
+ const translator$k = NodeTranslator.from(
31679
31806
  createSingleAttrPropertyHandler("w:tblStyleColBandSize", "tableStyleColBandSize")
31680
31807
  );
31681
- const translator$i = NodeTranslator.from(
31808
+ const translator$j = NodeTranslator.from(
31682
31809
  createSingleAttrPropertyHandler("w:tblStyleRowBandSize", "tableStyleRowBandSize")
31683
31810
  );
31684
- const translator$h = NodeTranslator.from(createMeasurementPropertyHandler("w:tblW", "tableWidth"));
31685
- const translator$g = NodeTranslator.from({
31811
+ const translator$i = NodeTranslator.from(createMeasurementPropertyHandler("w:tblW", "tableWidth"));
31812
+ const translator$h = NodeTranslator.from({
31686
31813
  xmlName: "w:tblpPr",
31687
31814
  sdNodeOrKeyName: "floatingTableProperties",
31688
31815
  attributes: ["w:leftFromText", "w:rightFromText", "w:topFromText", "w:bottomFromText", "w:tblpX", "w:tblpY"].map((attr) => createAttributeHandler(attr, null, parseInteger, integerToString)).concat(["w:horzAnchor", "w:vertAnchor", "w:tblpXSpec", "w:tblpYSpec"].map((attr) => createAttributeHandler(attr))),
@@ -31694,23 +31821,24 @@ Please report this to https://github.com/markedjs/marked.`, e) {
31694
31821
  return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
31695
31822
  }
31696
31823
  });
31697
- const propertyTranslators$1 = [
31698
- translator$1p,
31699
- translator$Y,
31700
- translator$1n,
31701
- translator$1l,
31702
- translator$U,
31703
- translator$1j
31824
+ const propertyTranslators$2 = [
31825
+ translator$1q,
31826
+ translator$Z,
31827
+ translator$1o,
31828
+ translator$1m,
31829
+ translator$V,
31830
+ translator$1k
31704
31831
  ];
31705
- const translator$f = NodeTranslator.from(
31706
- createNestedPropertiesTranslator("w:tblCellMar", "cellMargins", propertyTranslators$1)
31832
+ const translator$g = NodeTranslator.from(
31833
+ createNestedPropertiesTranslator("w:tblCellMar", "cellMargins", propertyTranslators$2)
31707
31834
  );
31708
- const propertyTranslators = [
31835
+ const propertyTranslators$1 = [
31836
+ translator$s,
31837
+ translator$1E,
31838
+ translator$2c,
31709
31839
  translator$r,
31710
- translator$1D,
31711
- translator$2b,
31840
+ translator$D,
31712
31841
  translator$q,
31713
- translator$C,
31714
31842
  translator$p,
31715
31843
  translator$o,
31716
31844
  translator$n,
@@ -31720,14 +31848,13 @@ Please report this to https://github.com/markedjs/marked.`, e) {
31720
31848
  translator$j,
31721
31849
  translator$i,
31722
31850
  translator$h,
31723
- translator$g,
31724
- translator$H,
31725
- translator$f
31851
+ translator$I,
31852
+ translator$g
31726
31853
  ];
31727
- const translator$e = NodeTranslator.from(
31728
- createNestedPropertiesTranslator("w:tblPr", "tableProperties", propertyTranslators)
31854
+ const translator$f = NodeTranslator.from(
31855
+ createNestedPropertiesTranslator("w:tblPr", "tableProperties", propertyTranslators$1)
31729
31856
  );
31730
- const translator$d = NodeTranslator.from(
31857
+ const translator$e = NodeTranslator.from(
31731
31858
  createSingleAttrPropertyHandler("w:gridCol", "col", "w:w", parseInteger, integerToString)
31732
31859
  );
31733
31860
  const DEFAULT_COLUMN_WIDTH_PX = 100;
@@ -31785,7 +31912,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
31785
31912
  const node2 = nodes[0];
31786
31913
  const attributes = encodeProperties(
31787
31914
  { ...params2, nodes: [node2] },
31788
- { [translator$d.xmlName]: translator$d },
31915
+ { [translator$e.xmlName]: translator$e },
31789
31916
  true
31790
31917
  );
31791
31918
  return {
@@ -31827,10 +31954,10 @@ Please report this to https://github.com/markedjs/marked.`, e) {
31827
31954
  const roundedWidth = Math.round(numericWidth);
31828
31955
  const minimumWidth = shouldEnforceMinimum ? cellMinWidth : 1;
31829
31956
  const safeWidth = Math.max(roundedWidth, minimumWidth);
31830
- const decoded = translator$d.decode({
31957
+ const decoded = translator$e.decode({
31831
31958
  node: { type: (
31832
31959
  /** @type {string} */
31833
- translator$d.sdNodeOrKeyName
31960
+ translator$e.sdNodeOrKeyName
31834
31961
  ), attrs: { col: safeWidth } }
31835
31962
  });
31836
31963
  if (decoded) elements.push(decoded);
@@ -31872,7 +31999,11 @@ Please report this to https://github.com/markedjs/marked.`, e) {
31872
31999
  encode: encode$r,
31873
32000
  decode: decode$t
31874
32001
  };
31875
- const translator$c = NodeTranslator.from(config$c);
32002
+ const translator$d = NodeTranslator.from(config$c);
32003
+ const propertyTranslators = [translator$f, translator$K];
32004
+ const translator$c = NodeTranslator.from(
32005
+ createNestedPropertiesTranslator("w:tblStylePr", "tableStyleProperties", propertyTranslators)
32006
+ );
31876
32007
  const DEFAULT_PAGE_WIDTH_TWIPS = 12240;
31877
32008
  const DEFAULT_PAGE_MARGIN_TWIPS = 1440;
31878
32009
  const DEFAULT_CONTENT_WIDTH_TWIPS = DEFAULT_PAGE_WIDTH_TWIPS - 2 * DEFAULT_PAGE_MARGIN_TWIPS;
@@ -31942,14 +32073,14 @@ Please report this to https://github.com/markedjs/marked.`, e) {
31942
32073
  const node2 = nodes[0];
31943
32074
  const tblPr = node2.elements.find((el) => el.name === "w:tblPr");
31944
32075
  if (tblPr) {
31945
- const encodedProperties = translator$e.encode({ ...params2, nodes: [tblPr] });
32076
+ const encodedProperties = translator$f.encode({ ...params2, nodes: [tblPr] });
31946
32077
  encodedAttrs["tableProperties"] = encodedProperties || {};
31947
32078
  } else {
31948
32079
  encodedAttrs["tableProperties"] ||= {};
31949
32080
  }
31950
32081
  const tblGrid = node2.elements.find((el) => el.name === "w:tblGrid");
31951
32082
  if (tblGrid) {
31952
- encodedAttrs["grid"] = translator$c.encode({ ...params2, nodes: [tblGrid] }).attributes;
32083
+ encodedAttrs["grid"] = translator$d.encode({ ...params2, nodes: [tblGrid] }).attributes;
31953
32084
  }
31954
32085
  [
31955
32086
  "tableStyleId",
@@ -31988,6 +32119,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
31988
32119
  };
31989
32120
  }
31990
32121
  }
32122
+ const tableLook = encodedAttrs.tableProperties.tblLook;
31991
32123
  const borderProps = _processTableBorders(encodedAttrs.tableProperties.borders || {});
31992
32124
  const referencedStyles = _getReferencedTableStyles(encodedAttrs.tableStyleId, params2) || {};
31993
32125
  encodedAttrs.borders = { ...referencedStyles.borders, ...borderProps };
@@ -32014,14 +32146,15 @@ Please report this to https://github.com/markedjs/marked.`, e) {
32014
32146
  const totalRows = rows.length;
32015
32147
  const activeRowSpans = totalColumns > 0 ? new Array(totalColumns).fill(0) : [];
32016
32148
  rows.forEach((row2, rowIndex) => {
32017
- const result = translator$w.encode({
32149
+ const result = translator$x.encode({
32018
32150
  ...params2,
32019
32151
  path: [...params2.path || [], node2],
32020
32152
  nodes: [row2],
32021
32153
  extraParams: {
32022
32154
  row: row2,
32023
32155
  table: node2,
32024
- rowBorders: encodedAttrs.borders,
32156
+ tableBorders: encodedAttrs.borders,
32157
+ tableLook,
32025
32158
  columnWidths,
32026
32159
  activeRowSpans: activeRowSpans.slice(),
32027
32160
  rowIndex,
@@ -32085,7 +32218,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
32085
32218
  };
32086
32219
  const elements = translateChildNodes({ ...params2, extraParams });
32087
32220
  const firstRow = node2.content?.find((n) => n.type === "tableRow");
32088
- const element2 = translator$c.decode({
32221
+ const element2 = translator$d.decode({
32089
32222
  ...params2,
32090
32223
  node: { ...node2, attrs: { ...node2.attrs, grid } },
32091
32224
  extraParams: {
@@ -32096,7 +32229,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
32096
32229
  if (element2) elements.unshift(element2);
32097
32230
  if (node2.attrs?.tableProperties) {
32098
32231
  const properties = { ...node2.attrs.tableProperties };
32099
- const element22 = translator$e.decode({
32232
+ const element22 = translator$f.decode({
32100
32233
  ...params2,
32101
32234
  node: { ...node2, attrs: { ...node2.attrs, tableProperties: properties } }
32102
32235
  });
@@ -32158,7 +32291,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
32158
32291
  if (baseTblPr && baseTblPr.elements) {
32159
32292
  tblPr.elements = [...baseTblPr.elements, ...tblPr.elements];
32160
32293
  }
32161
- const tableProperties = translator$e.encode({ ...params2, nodes: [tblPr] });
32294
+ const tableProperties = translator$f.encode({ ...params2, nodes: [tblPr] });
32162
32295
  if (tableProperties) {
32163
32296
  const borders = _processTableBorders(tableProperties.borders || {});
32164
32297
  if (borders || Object.keys(borders).length) stylesToReturn.borders = borders;
@@ -32174,7 +32307,18 @@ Please report this to https://github.com/markedjs/marked.`, e) {
32174
32307
  if (Object.keys(cellMargins).length) stylesToReturn.cellMargins = cellMargins;
32175
32308
  }
32176
32309
  }
32177
- return stylesToReturn;
32310
+ const tblStylePr = styleTag.elements.filter((el) => el.name === "w:tblStylePr");
32311
+ let styleProps = {};
32312
+ if (tblStylePr) {
32313
+ styleProps = tblStylePr.reduce((acc, el) => {
32314
+ acc[el.attributes["w:type"]] = translator$c.encode({ ...params2, nodes: [el] });
32315
+ return acc;
32316
+ }, {});
32317
+ }
32318
+ return {
32319
+ ...stylesToReturn,
32320
+ ...styleProps
32321
+ };
32178
32322
  }
32179
32323
  const config$b = {
32180
32324
  xmlName: XML_NODE_NAME$c,
@@ -32950,7 +33094,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
32950
33094
  if (isHorizontalRule) {
32951
33095
  schemaAttrs.horizontalRule = true;
32952
33096
  }
32953
- const pElement = translator$13.encode({
33097
+ const pElement = translator$14.encode({
32954
33098
  ...params2,
32955
33099
  nodes: [{ ...pNode, elements: pNode.elements.filter((el) => el.name !== "w:r") }]
32956
33100
  });
@@ -33010,7 +33154,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
33010
33154
  return { nodes: [], consumed: 0 };
33011
33155
  }
33012
33156
  const translatorParams = { ...params2, nodes: [node2] };
33013
- const schemaNode = translator$t.encode(translatorParams);
33157
+ const schemaNode = translator$u.encode(translatorParams);
33014
33158
  const newNodes = schemaNode ? [schemaNode] : [];
33015
33159
  return { nodes: newNodes, consumed: 1 };
33016
33160
  };
@@ -33138,7 +33282,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
33138
33282
  });
33139
33283
  break;
33140
33284
  case "w:ins":
33141
- result = translator$1x.encode({
33285
+ result = translator$1y.encode({
33142
33286
  ...translatorParams,
33143
33287
  extraParams: {
33144
33288
  ...translatorParams.extraParams,
@@ -33153,8 +33297,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
33153
33297
  handlerName: "trackChangeNodeHandler",
33154
33298
  handler: handleTrackChangeNode
33155
33299
  };
33156
- const hyperlinkNodeHandlerEntity = generateV2HandlerEntity("hyperlinkNodeHandler", translator$12);
33157
- const runNodeHandlerEntity = generateV2HandlerEntity("runNodeHandler", translator$11);
33300
+ const hyperlinkNodeHandlerEntity = generateV2HandlerEntity("hyperlinkNodeHandler", translator$13);
33301
+ const runNodeHandlerEntity = generateV2HandlerEntity("runNodeHandler", translator$12);
33158
33302
  const XML_NODE_NAME$1 = "w:t";
33159
33303
  const SD_NODE_NAME$1 = "text";
33160
33304
  const validXmlAttributes$1 = [createAttributeHandler("xml:space", "xmlSpace")];
@@ -33199,12 +33343,12 @@ Please report this to https://github.com/markedjs/marked.`, e) {
33199
33343
  case "trackDelete":
33200
33344
  return translator$2.decode(params2);
33201
33345
  case "trackInsert":
33202
- return translator$1x.decode(params2);
33346
+ return translator$1y.decode(params2);
33203
33347
  }
33204
33348
  }
33205
33349
  const isLinkNode = node2.marks?.some((m2) => m2.type === "link");
33206
33350
  if (isLinkNode && !extraParams?.linkProcessed) {
33207
- return translator$12.decode(params2);
33351
+ return translator$13.decode(params2);
33208
33352
  }
33209
33353
  const { text: text2, marks = [] } = node2;
33210
33354
  return getTextNodeForExport(text2, marks, params2);
@@ -33246,7 +33390,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
33246
33390
  if (nodes.length === 0 || nodes[0].name !== "w:p") {
33247
33391
  return { nodes: [], consumed: 0 };
33248
33392
  }
33249
- const schemaNode = translator$13.encode(params2);
33393
+ const schemaNode = translator$14.encode(params2);
33250
33394
  const newNodes = schemaNode ? [schemaNode] : [];
33251
33395
  return { nodes: newNodes, consumed: 1 };
33252
33396
  };
@@ -33259,7 +33403,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
33259
33403
  if (nodes.length === 0 || nodes[0].name !== "w:sdt") {
33260
33404
  return { nodes: [], consumed: 0 };
33261
33405
  }
33262
- const result = translator$s.encode(params2);
33406
+ const result = translator$t.encode(params2);
33263
33407
  if (!result) {
33264
33408
  return { nodes: [], consumed: 0 };
33265
33409
  }
@@ -33275,152 +33419,152 @@ Please report this to https://github.com/markedjs/marked.`, e) {
33275
33419
  };
33276
33420
  const translatorList = Array.from(
33277
33421
  /* @__PURE__ */ new Set([
33278
- translator$1N,
33422
+ translator$1O,
33279
33423
  translator$6,
33280
33424
  translator$5,
33281
33425
  translator$4,
33282
33426
  translator$3,
33427
+ translator$1N,
33283
33428
  translator$1M,
33284
33429
  translator$1L,
33285
- translator$1K,
33430
+ translator$2p,
33431
+ translator$1t,
33286
33432
  translator$2o,
33287
- translator$1s,
33288
33433
  translator$2n,
33289
- translator$2m,
33290
- translator$r,
33434
+ translator$s,
33291
33435
  translator$9,
33292
33436
  translator$a,
33293
- translator$1q,
33294
- translator$2r,
33295
- translator$G,
33296
- translator$2c,
33437
+ translator$1r,
33438
+ translator$2s,
33439
+ translator$H,
33440
+ translator$2d,
33441
+ translator$1J,
33442
+ translator$2i,
33297
33443
  translator$1I,
33298
- translator$2h,
33299
- translator$1H,
33300
- translator$1R,
33444
+ translator$1S,
33301
33445
  translator$2,
33302
- translator$1G,
33303
- translator$t,
33304
- translator$2i,
33305
- translator$1T,
33306
- translator$1Z,
33307
- translator$1Y,
33308
- translator$25,
33309
- translator$Z,
33446
+ translator$1H,
33447
+ translator$u,
33448
+ translator$2j,
33310
33449
  translator$1U,
33311
- translator$1F,
33450
+ translator$1_,
33451
+ translator$1Z,
33452
+ translator$26,
33453
+ translator$_,
33454
+ translator$1V,
33455
+ translator$1G,
33456
+ translator$G,
33312
33457
  translator$F,
33313
- translator$E,
33314
- translator$d,
33315
- translator$$,
33316
- translator$L,
33317
- translator$K,
33318
- translator$D,
33458
+ translator$e,
33459
+ translator$10,
33319
33460
  translator$M,
33320
- translator$2q,
33321
- translator$12,
33322
- translator$2l,
33323
- translator$1Q,
33461
+ translator$L,
33462
+ translator$E,
33463
+ translator$N,
33464
+ translator$2r,
33465
+ translator$13,
33466
+ translator$2m,
33467
+ translator$1R,
33468
+ translator$1z,
33469
+ translator$1F,
33470
+ translator$25,
33324
33471
  translator$1y,
33325
- translator$1E,
33326
- translator$24,
33327
- translator$1x,
33472
+ translator$Y,
33328
33473
  translator$X,
33329
- translator$W,
33474
+ translator$1E,
33330
33475
  translator$1D,
33331
33476
  translator$1C,
33477
+ translator$1X,
33332
33478
  translator$1B,
33333
- translator$1W,
33479
+ translator$2b,
33480
+ translator$1p,
33334
33481
  translator$1A,
33335
- translator$2a,
33336
- translator$1o,
33337
- translator$1z,
33338
- translator$23,
33339
- translator$Q,
33482
+ translator$24,
33483
+ translator$R,
33484
+ translator$1x,
33340
33485
  translator$1w,
33486
+ translator$22,
33341
33487
  translator$1v,
33342
- translator$21,
33343
33488
  translator$1u,
33344
- translator$1t,
33345
- translator$22,
33346
- translator$13,
33347
- translator$1g,
33348
- translator$1i,
33349
- translator$1V,
33489
+ translator$23,
33350
33490
  translator$14,
33351
33491
  translator$1h,
33492
+ translator$1j,
33493
+ translator$1W,
33494
+ translator$15,
33495
+ translator$1i,
33352
33496
  translator$8,
33353
33497
  translator$7,
33354
- translator$11,
33498
+ translator$12,
33499
+ translator$2h,
33500
+ translator$1P,
33355
33501
  translator$2g,
33356
- translator$1O,
33357
- translator$2f,
33358
- translator$1S,
33359
- translator$1m,
33360
- translator$s,
33361
- translator$20,
33362
- translator$2b,
33502
+ translator$1T,
33503
+ translator$1n,
33504
+ translator$t,
33505
+ translator$21,
33506
+ translator$2c,
33507
+ translator$28,
33363
33508
  translator$27,
33364
- translator$26,
33509
+ translator$1g,
33365
33510
  translator$1f,
33366
33511
  translator$1e,
33367
33512
  translator$1d,
33368
- translator$1c,
33369
- translator$1_,
33370
- translator$V,
33371
- translator$2j,
33513
+ translator$1$,
33514
+ translator$W,
33515
+ translator$2k,
33516
+ translator$2f,
33372
33517
  translator$2e,
33373
- translator$2d,
33374
33518
  translator$1,
33375
- translator$2p,
33376
- translator$1b,
33519
+ translator$2q,
33520
+ translator$1c,
33377
33521
  translator$b,
33378
- translator$H,
33522
+ translator$I,
33523
+ translator$r,
33524
+ translator$g,
33525
+ translator$D,
33379
33526
  translator$q,
33380
- translator$f,
33527
+ translator$d,
33381
33528
  translator$C,
33382
33529
  translator$p,
33383
- translator$c,
33384
- translator$B,
33385
33530
  translator$o,
33386
33531
  translator$n,
33387
33532
  translator$m,
33533
+ translator$f,
33388
33534
  translator$l,
33389
- translator$e,
33390
33535
  translator$k,
33391
33536
  translator$j,
33392
33537
  translator$i,
33393
33538
  translator$h,
33394
- translator$g,
33395
- translator$I,
33396
- translator$R,
33397
- translator$O,
33398
- translator$P,
33399
33539
  translator$J,
33400
- translator$10,
33401
- translator$19,
33402
- translator$T,
33403
- translator$w,
33404
33540
  translator$S,
33405
- translator$A,
33406
- translator$x,
33541
+ translator$P,
33542
+ translator$Q,
33543
+ translator$K,
33544
+ translator$11,
33407
33545
  translator$1a,
33546
+ translator$U,
33547
+ translator$x,
33548
+ translator$T,
33549
+ translator$B,
33550
+ translator$y,
33551
+ translator$1b,
33552
+ translator$19,
33408
33553
  translator$18,
33409
- translator$17,
33410
- translator$1k,
33411
- translator$2k,
33412
- translator$N,
33413
- translator$1$,
33414
- translator$28,
33415
- translator$_,
33416
- translator$1X,
33554
+ translator$1l,
33555
+ translator$2l,
33556
+ translator$O,
33557
+ translator$20,
33558
+ translator$29,
33559
+ translator$$,
33560
+ translator$1Y,
33561
+ translator$A,
33417
33562
  translator$z,
33418
- translator$y,
33419
- translator$1P,
33563
+ translator$1Q,
33564
+ translator$17,
33420
33565
  translator$16,
33421
- translator$15,
33566
+ translator$w,
33422
33567
  translator$v,
33423
- translator$u,
33424
33568
  commentRangeStartTranslator,
33425
33569
  commentRangeEndTranslator
33426
33570
  ])
@@ -33525,7 +33669,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
33525
33669
  if (nodes.length === 0 || nodes[0].name !== "w:br") {
33526
33670
  return { nodes: [], consumed: 0 };
33527
33671
  }
33528
- const result = translator$2r.encode(params2);
33672
+ const result = translator$2s.encode(params2);
33529
33673
  if (!result) return { nodes: [], consumed: 0 };
33530
33674
  return {
33531
33675
  nodes: [result],
@@ -33669,7 +33813,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
33669
33813
  ...currentNode,
33670
33814
  type: "element"
33671
33815
  };
33672
- const translated = translator$1N.encode({
33816
+ const translated = translator$1O.encode({
33673
33817
  ...params2,
33674
33818
  nodes: [nodeForTranslator],
33675
33819
  extraParams: { ...params2.extraParams || {}, node: nodeForTranslator }
@@ -34451,7 +34595,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34451
34595
  if (!nodes.length || nodes[0].name !== "w:tab") {
34452
34596
  return { nodes: [], consumed: 0 };
34453
34597
  }
34454
- const node2 = translator$2p.encode(params2);
34598
+ const node2 = translator$2q.encode(params2);
34455
34599
  return { nodes: [node2], consumed: 1 };
34456
34600
  };
34457
34601
  const tabNodeEntityHandler = {
@@ -35554,7 +35698,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
35554
35698
  }
35555
35699
  return style2;
35556
35700
  }
35557
- function handleShapeImageImport({ params: params2, pict }) {
35701
+ function handleShapeImageWatermarkImport({ params: params2, pict }) {
35558
35702
  const shape = pict.elements?.find((el) => el.name === "v:shape");
35559
35703
  if (!shape) return null;
35560
35704
  const imagedata = shape.elements?.find((el) => el.name === "v:imagedata");
@@ -35580,7 +35724,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
35580
35724
  const targetPath = rel.attributes["Target"];
35581
35725
  const normalizedPath = normalizeTargetPath(targetPath);
35582
35726
  const style2 = shapeAttrs.style || "";
35583
- const styleObj = parseVmlStyle(style2);
35727
+ const styleObj = parseVmlStyle$1(style2);
35584
35728
  const width = styleObj.width || "100px";
35585
35729
  const height = styleObj.height || "100px";
35586
35730
  const position2 = {
@@ -35626,12 +35770,12 @@ Please report this to https://github.com/markedjs/marked.`, e) {
35626
35770
  },
35627
35771
  // Size
35628
35772
  size: {
35629
- width: convertToPixels(width),
35630
- height: convertToPixels(height)
35773
+ width: convertToPixels$1(width),
35774
+ height: convertToPixels$1(height)
35631
35775
  },
35632
35776
  marginOffset: {
35633
- horizontal: convertToPixels(position2.marginLeft),
35634
- top: convertToPixels(position2.marginTop)
35777
+ horizontal: convertToPixels$1(position2.marginLeft),
35778
+ top: convertToPixels$1(position2.marginTop)
35635
35779
  },
35636
35780
  // Image adjustments
35637
35781
  ...gain && { gain },
@@ -35647,7 +35791,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
35647
35791
  if (trimmed.startsWith("media/")) return `word/${trimmed}`;
35648
35792
  return `word/${trimmed}`;
35649
35793
  }
35650
- function parseVmlStyle(style2) {
35794
+ function parseVmlStyle$1(style2) {
35651
35795
  const result = {};
35652
35796
  if (!style2) return result;
35653
35797
  const declarations = style2.split(";").filter((s2) => s2.trim());
@@ -35659,6 +35803,267 @@ Please report this to https://github.com/markedjs/marked.`, e) {
35659
35803
  }
35660
35804
  return result;
35661
35805
  }
35806
+ function convertToPixels$1(value) {
35807
+ if (typeof value === "number") return value;
35808
+ if (!value || typeof value !== "string") return 0;
35809
+ const match = value.match(/^([\d.]+)([a-z%]+)?$/i);
35810
+ if (!match) return 0;
35811
+ const num = parseFloat(match[1]);
35812
+ const unit = match[2] || "px";
35813
+ switch (unit.toLowerCase()) {
35814
+ case "px":
35815
+ return num;
35816
+ case "pt":
35817
+ return num * (96 / 72);
35818
+ // 1pt = 1/72 inch, 96 DPI
35819
+ case "in":
35820
+ return num * 96;
35821
+ case "cm":
35822
+ return num * (96 / 2.54);
35823
+ case "mm":
35824
+ return num * (96 / 25.4);
35825
+ case "pc":
35826
+ return num * 16;
35827
+ // 1pc = 12pt
35828
+ default:
35829
+ return num;
35830
+ }
35831
+ }
35832
+ function handleShapeTextWatermarkImport({ pict }) {
35833
+ const shape = pict.elements?.find((el) => el.name === "v:shape");
35834
+ if (!shape) return null;
35835
+ const textpath = shape.elements?.find((el) => el.name === "v:textpath");
35836
+ if (!textpath) return null;
35837
+ const shapeAttrs = shape.attributes || {};
35838
+ const textpathAttrs = textpath.attributes || {};
35839
+ const watermarkText = textpathAttrs["string"] || "";
35840
+ if (!watermarkText) {
35841
+ console.warn("v:textpath missing string attribute");
35842
+ return null;
35843
+ }
35844
+ const style2 = shapeAttrs.style || "";
35845
+ const styleObj = parseVmlStyle(style2);
35846
+ const width = styleObj.width || "481.8pt";
35847
+ const height = styleObj.height || "82.8pt";
35848
+ const position2 = {
35849
+ type: styleObj.position || "absolute",
35850
+ marginLeft: styleObj["margin-left"] || "0",
35851
+ marginTop: styleObj["margin-top"] || "0"
35852
+ };
35853
+ const rotation = parseFloat(styleObj.rotation) || 0;
35854
+ const hPosition = styleObj["mso-position-horizontal"] || "center";
35855
+ const vPosition = styleObj["mso-position-vertical"] || "center";
35856
+ const hRelativeTo = styleObj["mso-position-horizontal-relative"] || "margin";
35857
+ const vRelativeTo = styleObj["mso-position-vertical-relative"] || "margin";
35858
+ const textAnchor = styleObj["v-text-anchor"] || "middle";
35859
+ const fill = shape.elements?.find((el) => el.name === "v:fill");
35860
+ const fillAttrs = fill?.attributes || {};
35861
+ const rawFillColor = shapeAttrs.fillcolor || fillAttrs.color || "silver";
35862
+ const rawFillColor2 = fillAttrs.color2 || "#3f3f3f";
35863
+ const fillColor = sanitizeColor(rawFillColor, "silver");
35864
+ const fillColor2 = sanitizeColor(rawFillColor2, "#3f3f3f");
35865
+ const opacity = fillAttrs.opacity || "0.5";
35866
+ const fillType = fillAttrs.type || "solid";
35867
+ const stroke = shape.elements?.find((el) => el.name === "v:stroke");
35868
+ const strokeAttrs = stroke?.attributes || {};
35869
+ const stroked = shapeAttrs.stroked || "f";
35870
+ const strokeColor = strokeAttrs.color || "#3465a4";
35871
+ const strokeJoinstyle = strokeAttrs.joinstyle || "round";
35872
+ const strokeEndcap = strokeAttrs.endcap || "flat";
35873
+ const textpathStyle = textpathAttrs.style || "";
35874
+ const textStyleObj = parseVmlStyle(textpathStyle);
35875
+ const rawFontFamily = textStyleObj["font-family"]?.replace(/['"]/g, "");
35876
+ const fontFamily2 = sanitizeFontFamily$1(rawFontFamily);
35877
+ const fontSize2 = textStyleObj["font-size"] || "1pt";
35878
+ const fitshape = textpathAttrs.fitshape || "t";
35879
+ const trim = textpathAttrs.trim || "t";
35880
+ const textpathOn = textpathAttrs.on || "t";
35881
+ const path2 = shape.elements?.find((el) => el.name === "v:path");
35882
+ const pathAttrs = path2?.attributes || {};
35883
+ const textpathok = pathAttrs.textpathok || "t";
35884
+ const wrap2 = shape.elements?.find((el) => el.name === "w10:wrap");
35885
+ const wrapAttrs = wrap2?.attributes || {};
35886
+ const wrapType = wrapAttrs.type || "none";
35887
+ const widthPx = convertToPixels(width);
35888
+ const heightPx = convertToPixels(height);
35889
+ const sanitizedOpacity = sanitizeNumeric(parseFloat(opacity), 0.5, 0, 1);
35890
+ const sanitizedRotation = sanitizeNumeric(rotation, 0, -360, 360);
35891
+ const svgResult = generateTextWatermarkSVG({
35892
+ text: watermarkText,
35893
+ width: widthPx,
35894
+ height: heightPx,
35895
+ rotation: sanitizedRotation,
35896
+ fill: {
35897
+ color: fillColor,
35898
+ opacity: sanitizedOpacity
35899
+ },
35900
+ textStyle: {
35901
+ fontFamily: fontFamily2,
35902
+ fontSize: fontSize2
35903
+ }
35904
+ });
35905
+ const svgDataUri = svgResult.dataUri;
35906
+ const imageWatermarkNode = {
35907
+ type: "image",
35908
+ attrs: {
35909
+ src: svgDataUri,
35910
+ alt: watermarkText,
35911
+ title: watermarkText,
35912
+ extension: "svg",
35913
+ // Mark this as a text watermark for export
35914
+ vmlWatermark: true,
35915
+ vmlTextWatermark: true,
35916
+ // Store VML-specific attributes for round-trip
35917
+ vmlStyle: style2,
35918
+ vmlAttributes: shapeAttrs,
35919
+ vmlTextpathAttributes: textpathAttrs,
35920
+ vmlPathAttributes: pathAttrs,
35921
+ vmlFillAttributes: fillAttrs,
35922
+ vmlStrokeAttributes: strokeAttrs,
35923
+ vmlWrapAttributes: wrapAttrs,
35924
+ // Positioning (same as image watermarks)
35925
+ isAnchor: true,
35926
+ inline: false,
35927
+ wrap: {
35928
+ type: wrapType === "none" ? "None" : wrapType,
35929
+ attrs: {
35930
+ behindDoc: true
35931
+ }
35932
+ },
35933
+ anchorData: {
35934
+ hRelativeFrom: hRelativeTo,
35935
+ vRelativeFrom: vRelativeTo,
35936
+ alignH: hPosition,
35937
+ alignV: vPosition
35938
+ },
35939
+ // Size - use rotated bounding box dimensions to prevent clipping
35940
+ size: {
35941
+ width: svgResult.svgWidth,
35942
+ height: svgResult.svgHeight
35943
+ },
35944
+ marginOffset: {
35945
+ horizontal: convertToPixels(position2.marginLeft),
35946
+ // For center-aligned watermarks relative to margin, Word's margin-top value
35947
+ // is not suitable for browser rendering. Set to 0 to let center alignment work.
35948
+ top: vPosition === "center" && vRelativeTo === "margin" ? 0 : convertToPixels(position2.marginTop)
35949
+ },
35950
+ // Store text watermark specific data for export
35951
+ textWatermarkData: {
35952
+ text: watermarkText,
35953
+ rotation: sanitizedRotation,
35954
+ textStyle: {
35955
+ fontFamily: fontFamily2,
35956
+ fontSize: fontSize2,
35957
+ textAnchor
35958
+ },
35959
+ fill: {
35960
+ color: fillColor,
35961
+ color2: fillColor2,
35962
+ opacity: sanitizedOpacity,
35963
+ type: fillType
35964
+ },
35965
+ stroke: {
35966
+ enabled: stroked !== "f",
35967
+ color: strokeColor,
35968
+ joinstyle: strokeJoinstyle,
35969
+ endcap: strokeEndcap
35970
+ },
35971
+ textpath: {
35972
+ on: textpathOn === "t",
35973
+ fitshape: fitshape === "t",
35974
+ trim: trim === "t",
35975
+ textpathok: textpathok === "t"
35976
+ }
35977
+ }
35978
+ }
35979
+ };
35980
+ return imageWatermarkNode;
35981
+ }
35982
+ function sanitizeFontFamily$1(fontFamily2) {
35983
+ if (!fontFamily2 || typeof fontFamily2 !== "string") {
35984
+ return "Arial";
35985
+ }
35986
+ const sanitized = fontFamily2.replace(/[^a-zA-Z0-9\s,\-]/g, "").trim();
35987
+ return sanitized || "Arial";
35988
+ }
35989
+ function sanitizeColor(color2, defaultColor = "silver") {
35990
+ if (!color2 || typeof color2 !== "string") {
35991
+ return defaultColor;
35992
+ }
35993
+ const sanitized = color2.replace(/[^a-zA-Z0-9#%(),.]/g, "").trim();
35994
+ return sanitized || defaultColor;
35995
+ }
35996
+ function sanitizeNumeric(value, defaultValue, min2 = -Infinity, max2 = Infinity) {
35997
+ const num = typeof value === "number" ? value : parseFloat(value);
35998
+ if (isNaN(num) || !isFinite(num)) {
35999
+ return defaultValue;
36000
+ }
36001
+ return Math.max(min2, Math.min(max2, num));
36002
+ }
36003
+ function generateTextWatermarkSVG({ text: text2, width, height, rotation, fill, textStyle }) {
36004
+ let fontSize2 = height * 0.9;
36005
+ if (textStyle?.fontSize && textStyle.fontSize.trim() !== "1pt") {
36006
+ const match = textStyle.fontSize.match(/^([\d.]+)(pt|px)?$/);
36007
+ if (match) {
36008
+ const value = parseFloat(match[1]);
36009
+ const unit = match[2] || "pt";
36010
+ fontSize2 = (unit === "pt" ? value * (96 / 72) : value) * 50;
36011
+ }
36012
+ }
36013
+ fontSize2 = Math.max(fontSize2, 48);
36014
+ const color2 = sanitizeColor(fill?.color, "silver");
36015
+ const opacity = sanitizeNumeric(fill?.opacity, 0.5, 0, 1);
36016
+ const fontFamily2 = sanitizeFontFamily$1(textStyle?.fontFamily);
36017
+ const sanitizedRotation = sanitizeNumeric(rotation, 0, -360, 360);
36018
+ const sanitizedWidth = sanitizeNumeric(width, 100, 1, 1e4);
36019
+ const sanitizedHeight = sanitizeNumeric(height, 100, 1, 1e4);
36020
+ const sanitizedFontSize = sanitizeNumeric(fontSize2, 48, 1, 1e3);
36021
+ const radians = sanitizedRotation * Math.PI / 180;
36022
+ const cos = Math.abs(Math.cos(radians));
36023
+ const sin = Math.abs(Math.sin(radians));
36024
+ const rotatedWidth = sanitizedWidth * cos + sanitizedHeight * sin;
36025
+ const rotatedHeight = sanitizedWidth * sin + sanitizedHeight * cos;
36026
+ const svgWidth = Math.max(sanitizedWidth, rotatedWidth);
36027
+ const svgHeight = Math.max(sanitizedHeight, rotatedHeight);
36028
+ const centerX = svgWidth / 2;
36029
+ const centerY = svgHeight / 2;
36030
+ const svg2 = `<svg xmlns="http://www.w3.org/2000/svg" width="${svgWidth}" height="${svgHeight}" viewBox="0 0 ${svgWidth} ${svgHeight}">
36031
+ <text
36032
+ x="${centerX}"
36033
+ y="${centerY}"
36034
+ text-anchor="middle"
36035
+ dominant-baseline="middle"
36036
+ font-family="${fontFamily2}"
36037
+ font-size="${sanitizedFontSize}px"
36038
+ font-weight="bold"
36039
+ fill="${color2}"
36040
+ opacity="${opacity}"
36041
+ transform="rotate(${sanitizedRotation} ${centerX} ${centerY})">${escapeXml(text2)}</text>
36042
+ </svg>`;
36043
+ return {
36044
+ dataUri: `data:image/svg+xml,${encodeURIComponent(svg2)}`,
36045
+ svgWidth,
36046
+ svgHeight
36047
+ };
36048
+ }
36049
+ function escapeXml(text2) {
36050
+ return text2.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
36051
+ }
36052
+ function parseVmlStyle(style2) {
36053
+ const result = {};
36054
+ if (!style2) return result;
36055
+ const declarations = style2.split(";").filter((s2) => s2.trim());
36056
+ for (const decl of declarations) {
36057
+ const colonIndex = decl.indexOf(":");
36058
+ if (colonIndex === -1) continue;
36059
+ const prop = decl.substring(0, colonIndex).trim();
36060
+ const value = decl.substring(colonIndex + 1).trim();
36061
+ if (prop && value) {
36062
+ result[prop] = value;
36063
+ }
36064
+ }
36065
+ return result;
36066
+ }
35662
36067
  function convertToPixels(value) {
35663
36068
  if (typeof value === "number") return value;
35664
36069
  if (!value || typeof value !== "string") return 0;
@@ -35703,9 +36108,13 @@ Please report this to https://github.com/markedjs/marked.`, e) {
35703
36108
  if (textbox) {
35704
36109
  return { type: "shapeContainer", handler: handleShapeTextboxImport };
35705
36110
  }
36111
+ const textpath = shape.elements?.find((el) => el.name === "v:textpath");
36112
+ if (textpath) {
36113
+ return { type: "image", handler: handleShapeTextWatermarkImport };
36114
+ }
35706
36115
  const imagedata = shape.elements?.find((el) => el.name === "v:imagedata");
35707
36116
  if (imagedata) {
35708
- return { type: "image", handler: handleShapeImageImport };
36117
+ return { type: "image", handler: handleShapeImageWatermarkImport };
35709
36118
  }
35710
36119
  }
35711
36120
  return { type: "unknown", handler: null };
@@ -35764,7 +36173,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
35764
36173
  if (vmlAttributes || horizontalRule) {
35765
36174
  return translateVRectContentBlock(params2);
35766
36175
  }
35767
- const alternateContent = translator$1N.decode(params2);
36176
+ const alternateContent = translator$1O.decode(params2);
35768
36177
  return wrapTextInRun(alternateContent);
35769
36178
  }
35770
36179
  function translateVRectContentBlock(params2) {
@@ -35805,7 +36214,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
35805
36214
  };
35806
36215
  return wrapTextInRun(pict);
35807
36216
  }
35808
- function translateVmlWatermark(params2) {
36217
+ function translateImageWatermark(params2) {
35809
36218
  const { node: node2 } = params2;
35810
36219
  const { attrs } = node2;
35811
36220
  if (attrs.vmlAttributes && attrs.vmlImagedata) {
@@ -35835,7 +36244,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
35835
36244
  };
35836
36245
  return par2;
35837
36246
  }
35838
- const style2 = buildVmlStyle(attrs);
36247
+ const style2 = buildVmlStyle$1(attrs);
35839
36248
  const shape = {
35840
36249
  name: "v:shape",
35841
36250
  attributes: {
@@ -35870,23 +36279,23 @@ Please report this to https://github.com/markedjs/marked.`, e) {
35870
36279
  };
35871
36280
  return par;
35872
36281
  }
35873
- function buildVmlStyle(attrs) {
36282
+ function buildVmlStyle$1(attrs) {
35874
36283
  const styles = [];
35875
36284
  styles.push("position:absolute");
35876
36285
  if (attrs.size) {
35877
36286
  if (attrs.size.width) {
35878
- styles.push(`width:${convertToPt(attrs.size.width)}pt`);
36287
+ styles.push(`width:${convertToPt$1(attrs.size.width)}pt`);
35879
36288
  }
35880
36289
  if (attrs.size.height) {
35881
- styles.push(`height:${convertToPt(attrs.size.height)}pt`);
36290
+ styles.push(`height:${convertToPt$1(attrs.size.height)}pt`);
35882
36291
  }
35883
36292
  }
35884
36293
  if (attrs.marginOffset) {
35885
36294
  if (attrs.marginOffset.horizontal !== void 0) {
35886
- styles.push(`margin-left:${convertToPt(attrs.marginOffset.horizontal)}pt`);
36295
+ styles.push(`margin-left:${convertToPt$1(attrs.marginOffset.horizontal)}pt`);
35887
36296
  }
35888
36297
  if (attrs.marginOffset.top !== void 0) {
35889
- styles.push(`margin-top:${convertToPt(attrs.marginOffset.top)}pt`);
36298
+ styles.push(`margin-top:${convertToPt$1(attrs.marginOffset.top)}pt`);
35890
36299
  }
35891
36300
  }
35892
36301
  if (attrs.wrap?.attrs?.behindDoc) {
@@ -35910,9 +36319,215 @@ Please report this to https://github.com/markedjs/marked.`, e) {
35910
36319
  styles.push("mso-height-percent:0");
35911
36320
  return styles.join(";");
35912
36321
  }
35913
- function convertToPt(pixels) {
36322
+ function convertToPt$1(pixels) {
35914
36323
  return pixels * 72 / 96;
35915
36324
  }
36325
+ function translateTextWatermark(params2) {
36326
+ const { node: node2 } = params2;
36327
+ const { attrs } = node2;
36328
+ const text2 = attrs.textWatermarkData?.text || attrs.vmlTextpathAttributes?.string || "";
36329
+ if (attrs.vmlAttributes && attrs.vmlTextpathAttributes) {
36330
+ const shapeElements2 = [];
36331
+ if (attrs.vmlPathAttributes) {
36332
+ shapeElements2.push({
36333
+ name: "v:path",
36334
+ attributes: attrs.vmlPathAttributes
36335
+ });
36336
+ }
36337
+ shapeElements2.push({
36338
+ name: "v:textpath",
36339
+ attributes: {
36340
+ ...attrs.vmlTextpathAttributes,
36341
+ string: text2
36342
+ }
36343
+ });
36344
+ if (attrs.vmlFillAttributes && Object.keys(attrs.vmlFillAttributes).length > 0) {
36345
+ shapeElements2.push({
36346
+ name: "v:fill",
36347
+ attributes: attrs.vmlFillAttributes
36348
+ });
36349
+ }
36350
+ if (attrs.vmlStrokeAttributes && Object.keys(attrs.vmlStrokeAttributes).length > 0) {
36351
+ shapeElements2.push({
36352
+ name: "v:stroke",
36353
+ attributes: attrs.vmlStrokeAttributes
36354
+ });
36355
+ }
36356
+ if (attrs.vmlWrapAttributes) {
36357
+ shapeElements2.push({
36358
+ name: "w10:wrap",
36359
+ attributes: attrs.vmlWrapAttributes
36360
+ });
36361
+ }
36362
+ const shape2 = {
36363
+ name: "v:shape",
36364
+ attributes: attrs.vmlAttributes,
36365
+ elements: shapeElements2
36366
+ };
36367
+ const pict2 = {
36368
+ name: "w:pict",
36369
+ elements: [shape2]
36370
+ };
36371
+ const par2 = {
36372
+ name: "w:p",
36373
+ elements: [wrapTextInRun(pict2)]
36374
+ };
36375
+ return par2;
36376
+ }
36377
+ const wmData = attrs.textWatermarkData || {};
36378
+ const style2 = buildVmlStyle(attrs, wmData);
36379
+ const textpathStyle = buildTextpathStyle(wmData);
36380
+ const shapeElements = [];
36381
+ shapeElements.push({
36382
+ name: "v:path",
36383
+ attributes: {
36384
+ textpathok: "t"
36385
+ }
36386
+ });
36387
+ shapeElements.push({
36388
+ name: "v:textpath",
36389
+ attributes: {
36390
+ on: "t",
36391
+ fitshape: "t",
36392
+ string: text2,
36393
+ style: textpathStyle,
36394
+ ...wmData.textpath?.trim !== void 0 && { trim: wmData.textpath.trim ? "t" : "f" }
36395
+ }
36396
+ });
36397
+ const fillAttrs = {};
36398
+ const fill = wmData.fill || attrs.fill;
36399
+ if (fill) {
36400
+ if (fill.type) fillAttrs.type = fill.type;
36401
+ if (fill.color2) fillAttrs.color2 = fill.color2;
36402
+ if (fill.opacity !== void 0) fillAttrs.opacity = fill.opacity.toString();
36403
+ if (fill.detectmouseclick !== void 0) {
36404
+ fillAttrs["o:detectmouseclick"] = fill.detectmouseclick ? "t" : "f";
36405
+ }
36406
+ }
36407
+ if (Object.keys(fillAttrs).length > 0) {
36408
+ shapeElements.push({
36409
+ name: "v:fill",
36410
+ attributes: fillAttrs
36411
+ });
36412
+ }
36413
+ const stroke = wmData.stroke || attrs.stroke;
36414
+ if (stroke && stroke.enabled !== false) {
36415
+ const strokeAttrs = {};
36416
+ if (stroke.color) strokeAttrs.color = stroke.color;
36417
+ if (stroke.joinstyle) strokeAttrs.joinstyle = stroke.joinstyle;
36418
+ if (stroke.endcap) strokeAttrs.endcap = stroke.endcap;
36419
+ if (Object.keys(strokeAttrs).length > 0) {
36420
+ shapeElements.push({
36421
+ name: "v:stroke",
36422
+ attributes: strokeAttrs
36423
+ });
36424
+ }
36425
+ }
36426
+ shapeElements.push({
36427
+ name: "w10:wrap",
36428
+ attributes: {
36429
+ type: attrs.wrap?.type?.toLowerCase() || "none"
36430
+ }
36431
+ });
36432
+ const shape = {
36433
+ name: "v:shape",
36434
+ attributes: {
36435
+ id: `PowerPlusWaterMarkObject${generateRandomSigned32BitIntStrId().replace("-", "")}`,
36436
+ "o:spid": `shape_${Math.floor(Math.random() * 1e4)}`,
36437
+ type: "#_x0000_t136",
36438
+ style: style2,
36439
+ fillcolor: fill?.color || "silver",
36440
+ stroked: stroke?.enabled !== false ? "t" : "f",
36441
+ "o:allowincell": "f",
36442
+ ...attrs.vmlAttributes?.adj && { adj: attrs.vmlAttributes.adj }
36443
+ },
36444
+ elements: shapeElements
36445
+ };
36446
+ const pict = {
36447
+ name: "w:pict",
36448
+ elements: [shape]
36449
+ };
36450
+ const par = {
36451
+ name: "w:p",
36452
+ elements: [wrapTextInRun(pict)]
36453
+ };
36454
+ return par;
36455
+ }
36456
+ function buildVmlStyle(attrs, wmData) {
36457
+ const styles = [];
36458
+ styles.push("position:absolute");
36459
+ if (attrs.marginOffset) {
36460
+ if (attrs.marginOffset.horizontal !== void 0) {
36461
+ styles.push(`margin-left:${convertToPt(attrs.marginOffset.horizontal)}pt`);
36462
+ }
36463
+ if (attrs.marginOffset.top !== void 0) {
36464
+ styles.push(`margin-top:${convertToPt(attrs.marginOffset.top)}pt`);
36465
+ }
36466
+ } else {
36467
+ styles.push("margin-left:0.05pt");
36468
+ styles.push("margin-top:315.7pt");
36469
+ }
36470
+ if (attrs.size) {
36471
+ if (attrs.size.width) {
36472
+ styles.push(`width:${convertToPt(attrs.size.width)}pt`);
36473
+ }
36474
+ if (attrs.size.height) {
36475
+ styles.push(`height:${convertToPt(attrs.size.height)}pt`);
36476
+ }
36477
+ }
36478
+ const wrapType = attrs.wrap?.type;
36479
+ let msoWrapStyle = "none";
36480
+ if (wrapType) {
36481
+ const wrapTypeLower = wrapType.toLowerCase();
36482
+ if (wrapTypeLower === "topandbottom") {
36483
+ msoWrapStyle = "top-and-bottom";
36484
+ } else if (["square", "tight", "through"].includes(wrapTypeLower)) {
36485
+ msoWrapStyle = wrapTypeLower;
36486
+ }
36487
+ }
36488
+ styles.push(`mso-wrap-style:${msoWrapStyle}`);
36489
+ const textAnchor = wmData.textStyle?.textAnchor || attrs.textStyle?.textAnchor;
36490
+ if (textAnchor) {
36491
+ styles.push(`v-text-anchor:${textAnchor}`);
36492
+ }
36493
+ const rotation = wmData.rotation || attrs.rotation;
36494
+ if (rotation !== void 0 && rotation !== 0) {
36495
+ styles.push(`rotation:${rotation}`);
36496
+ }
36497
+ if (attrs.anchorData) {
36498
+ if (attrs.anchorData.alignH) {
36499
+ styles.push(`mso-position-horizontal:${attrs.anchorData.alignH}`);
36500
+ }
36501
+ if (attrs.anchorData.alignV) {
36502
+ styles.push(`mso-position-vertical:${attrs.anchorData.alignV}`);
36503
+ }
36504
+ if (attrs.anchorData.hRelativeFrom) {
36505
+ styles.push(`mso-position-horizontal-relative:${attrs.anchorData.hRelativeFrom}`);
36506
+ }
36507
+ if (attrs.anchorData.vRelativeFrom) {
36508
+ styles.push(`mso-position-vertical-relative:${attrs.anchorData.vRelativeFrom}`);
36509
+ }
36510
+ }
36511
+ return styles.join(";");
36512
+ }
36513
+ function buildTextpathStyle(wmData) {
36514
+ const styles = [];
36515
+ if (wmData.textStyle) {
36516
+ if (wmData.textStyle.fontFamily) {
36517
+ styles.push(`font-family:"${wmData.textStyle.fontFamily}"`);
36518
+ }
36519
+ if (wmData.textStyle.fontSize) {
36520
+ styles.push(`font-size:${wmData.textStyle.fontSize}`);
36521
+ }
36522
+ }
36523
+ return styles.join(";");
36524
+ }
36525
+ function convertToPt(pixels) {
36526
+ if (typeof pixels === "number") {
36527
+ return pixels * 72 / 96;
36528
+ }
36529
+ return parseFloat(pixels) || 0;
36530
+ }
35916
36531
  const XML_NODE_NAME = "w:pict";
35917
36532
  const SD_NODE_NAME = ["shapeContainer", "contentBlock", "image"];
35918
36533
  const validXmlAttributes = [];
@@ -35940,7 +36555,10 @@ Please report this to https://github.com/markedjs/marked.`, e) {
35940
36555
  contentBlock: () => translateContentBlock(params2),
35941
36556
  image: () => {
35942
36557
  if (node2.attrs?.vmlWatermark) {
35943
- return translateVmlWatermark(params2);
36558
+ if (node2.attrs?.vmlTextWatermark) {
36559
+ return translateTextWatermark(params2);
36560
+ }
36561
+ return translateImageWatermark(params2);
35944
36562
  }
35945
36563
  return null;
35946
36564
  },
@@ -36022,19 +36640,19 @@ Please report this to https://github.com/markedjs/marked.`, e) {
36022
36640
  doc: translateDocumentNode,
36023
36641
  body: translateBodyNode,
36024
36642
  heading: translateHeadingNode,
36025
- paragraph: translator$13,
36026
- run: translator$11,
36643
+ paragraph: translator$14,
36644
+ run: translator$12,
36027
36645
  text: translator$1,
36028
- lineBreak: translator$2r,
36646
+ lineBreak: translator$2s,
36029
36647
  table: translator$b,
36030
- tableRow: translator$w,
36031
- tableCell: translator$I,
36648
+ tableRow: translator$x,
36649
+ tableCell: translator$J,
36032
36650
  bookmarkStart: translator$a,
36033
36651
  bookmarkEnd: translator$9,
36034
- fieldAnnotation: translator$s,
36035
- tab: translator$2p,
36036
- image: translator$t,
36037
- hardBreak: translator$2r,
36652
+ fieldAnnotation: translator$t,
36653
+ tab: translator$2q,
36654
+ image: translator$u,
36655
+ hardBreak: translator$2s,
36038
36656
  commentRangeStart: commentRangeStartTranslator,
36039
36657
  commentRangeEnd: commentRangeEndTranslator,
36040
36658
  permStart: translator$8,
@@ -36045,10 +36663,10 @@ Please report this to https://github.com/markedjs/marked.`, e) {
36045
36663
  contentBlock: translator,
36046
36664
  vectorShape: translateVectorShape,
36047
36665
  shapeGroup: translateShapeGroup,
36048
- structuredContent: translator$s,
36049
- structuredContentBlock: translator$s,
36050
- documentPartObject: translator$s,
36051
- documentSection: translator$s,
36666
+ structuredContent: translator$t,
36667
+ structuredContentBlock: translator$t,
36668
+ documentPartObject: translator$t,
36669
+ documentSection: translator$t,
36052
36670
  "page-number": translator$4,
36053
36671
  "total-page-number": translator$3,
36054
36672
  pageReference: translator$6,
@@ -36133,7 +36751,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
36133
36751
  // Maps to Heading1, Heading2, etc. in Word
36134
36752
  }
36135
36753
  };
36136
- return translator$13.decode({ ...params2, node: paragraphNode });
36754
+ return translator$14.decode({ ...params2, node: paragraphNode });
36137
36755
  }
36138
36756
  function translateDocumentNode(params2) {
36139
36757
  const bodyNode = {
@@ -36202,7 +36820,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
36202
36820
  markElement.type = "element";
36203
36821
  break;
36204
36822
  case "underline": {
36205
- const translated = translator$2k.decode({
36823
+ const translated = translator$2l.decode({
36206
36824
  node: {
36207
36825
  attrs: {
36208
36826
  underlineType: attrs.underlineType ?? attrs.underline ?? null,
@@ -36266,7 +36884,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
36266
36884
  break;
36267
36885
  case "highlight": {
36268
36886
  const highlightValue = attrs.color ?? attrs.highlight ?? null;
36269
- const translated = translator$2q.decode({ node: { attrs: { highlight: highlightValue } } });
36887
+ const translated = translator$2r.decode({ node: { attrs: { highlight: highlightValue } } });
36270
36888
  return translated || {};
36271
36889
  }
36272
36890
  case "strike":
@@ -36400,7 +37018,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
36400
37018
  return newComment;
36401
37019
  };
36402
37020
  const getCommentDefinition = (comment2, commentId, allComments, editor) => {
36403
- const translatedText = translator$13.decode({ editor, node: comment2.commentJSON });
37021
+ const translatedText = translator$14.decode({ editor, node: comment2.commentJSON });
36404
37022
  const attributes = {
36405
37023
  "w:id": String(commentId),
36406
37024
  "w:author": comment2.creatorName || comment2.importedAuthor?.name,
@@ -37085,7 +37703,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
37085
37703
  static getStoredSuperdocVersion(docx) {
37086
37704
  return SuperConverter.getStoredCustomProperty(docx, "SuperdocVersion");
37087
37705
  }
37088
- static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.5.0-next.6") {
37706
+ static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.5.0-next.8") {
37089
37707
  return SuperConverter.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
37090
37708
  }
37091
37709
  /**
@@ -62968,7 +63586,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
62968
63586
  return false;
62969
63587
  }
62970
63588
  };
62971
- const summaryVersion = "1.5.0-next.6";
63589
+ const summaryVersion = "1.5.0-next.8";
62972
63590
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
62973
63591
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
62974
63592
  function mapAttributes(attrs) {
@@ -65626,7 +66244,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
65626
66244
  * Process collaboration migrations
65627
66245
  */
65628
66246
  processCollaborationMigrations() {
65629
- console.debug("[checkVersionMigrations] Current editor version", "1.5.0-next.6");
66247
+ console.debug("[checkVersionMigrations] Current editor version", "1.5.0-next.8");
65630
66248
  if (!this.options.ydoc) return;
65631
66249
  const metaMap = this.options.ydoc.getMap("meta");
65632
66250
  let docVersion = metaMap.get("version");
@@ -70914,7 +71532,8 @@ ${o}
70914
71532
  // The primary fix uses accurate font metrics from Canvas API, but this
70915
71533
  // provides defense-in-depth against any remaining sub-pixel rendering
70916
71534
  // differences between measurement and display.
70917
- overflow: "visible"
71535
+ overflow: "visible",
71536
+ zIndex: "10"
70918
71537
  });
70919
71538
  const PRINT_STYLES = `
70920
71539
  @media print {
@@ -71220,6 +71839,7 @@ ${o}
71220
71839
  border: 1px solid #629be7;
71221
71840
  position: relative;
71222
71841
  display: inline;
71842
+ z-index: 10;
71223
71843
  }
71224
71844
 
71225
71845
  /* Hover effect for inline structured content */
@@ -91101,7 +91721,14 @@ ${o}
91101
91721
  definitions: {},
91102
91722
  abstracts: {}
91103
91723
  };
91104
- const ooxmlResolver = createOoxmlResolver({ pPr: translator$14, rPr: translator$1O });
91724
+ const toOoxmlTranslator = (translator2) => ({
91725
+ xmlName: translator2.xmlName,
91726
+ encode: (params2) => translator2.encode(params2)
91727
+ });
91728
+ const ooxmlResolver = createOoxmlResolver({
91729
+ pPr: toOoxmlTranslator(translator$15),
91730
+ rPr: toOoxmlTranslator(translator$1P)
91731
+ });
91105
91732
  const hydrateParagraphStyleAttrs = (para, context, preResolved) => {
91106
91733
  if (!hasParagraphStyleContext(context)) {
91107
91734
  return null;
@@ -96494,8 +97121,6 @@ ${o}
96494
97121
  #activeRegion = null;
96495
97122
  /** Full-width border line element (MS Word style) */
96496
97123
  #borderLine = null;
96497
- /** Dimming overlay element (for dimming body content during editing) */
96498
- #dimmingOverlay = null;
96499
97124
  /**
96500
97125
  * Creates a new EditorOverlayManager instance.
96501
97126
  *
@@ -96789,17 +97414,6 @@ ${o}
96789
97414
  }
96790
97415
  }
96791
97416
  }
96792
- /**
96793
- * Hides and removes the dimming overlay.
96794
- * @internal Reserved for future implementation of body dimming during header/footer editing.
96795
- */
96796
- // eslint-disable-next-line no-unused-private-class-members
96797
- #hideDimmingOverlay() {
96798
- if (this.#dimmingOverlay) {
96799
- this.#dimmingOverlay.remove();
96800
- this.#dimmingOverlay = null;
96801
- }
96802
- }
96803
97417
  /**
96804
97418
  * Shows a full-width border line at the bottom of the header or top of the footer.
96805
97419
  * This creates the MS Word style visual indicator spanning edge-to-edge of the page.
@@ -98972,6 +99586,7 @@ ${o}
98972
99586
  #viewportHost;
98973
99587
  #painterHost;
98974
99588
  #selectionOverlay;
99589
+ #permissionOverlay = null;
98975
99590
  #hiddenHost;
98976
99591
  #layoutOptions;
98977
99592
  #layoutState = { blocks: [], measures: [], layout: null, bookmarks: /* @__PURE__ */ new Map() };
@@ -99131,6 +99746,16 @@ ${o}
99131
99746
  });
99132
99747
  this.#domIndexObserverManager.setup();
99133
99748
  this.#selectionSync.on("render", () => this.#updateSelection());
99749
+ this.#selectionSync.on("render", () => this.#updatePermissionOverlay());
99750
+ this.#permissionOverlay = doc2.createElement("div");
99751
+ this.#permissionOverlay.className = "presentation-editor__permission-overlay";
99752
+ Object.assign(this.#permissionOverlay.style, {
99753
+ position: "absolute",
99754
+ inset: "0",
99755
+ pointerEvents: "none",
99756
+ zIndex: "5"
99757
+ });
99758
+ this.#viewportHost.appendChild(this.#permissionOverlay);
99134
99759
  this.#selectionOverlay = doc2.createElement("div");
99135
99760
  this.#selectionOverlay.className = "presentation-editor__selection-overlay";
99136
99761
  this.#selectionOverlay.id = `presentation-overlay-${options.documentId || "default"}`;
@@ -99216,7 +99841,7 @@ ${o}
99216
99841
  const normalizedEditorProps = {
99217
99842
  ...editorOptions.editorProps ?? {},
99218
99843
  editable: () => {
99219
- return this.#documentMode !== "viewing";
99844
+ return !this.#isViewLocked();
99220
99845
  }
99221
99846
  };
99222
99847
  try {
@@ -99658,6 +100283,7 @@ ${o}
99658
100283
  this.#pendingDocChange = true;
99659
100284
  this.#scheduleRerender();
99660
100285
  }
100286
+ this.#updatePermissionOverlay();
99661
100287
  }
99662
100288
  #syncDocumentModeClass() {
99663
100289
  if (!this.#visibleHost) return;
@@ -101044,7 +101670,7 @@ ${o}
101044
101670
  win,
101045
101671
  this.#visibleHost,
101046
101672
  () => this.#getActiveDomTarget(),
101047
- () => this.#documentMode !== "viewing"
101673
+ () => !this.#isViewLocked()
101048
101674
  );
101049
101675
  this.#inputBridge.bind();
101050
101676
  }
@@ -101943,7 +102569,7 @@ ${o}
101943
102569
  this.#dragUsedPageNotMountedFallback = false;
101944
102570
  return;
101945
102571
  }
101946
- if (this.#session.mode !== "body" || this.#documentMode === "viewing") {
102572
+ if (this.#session.mode !== "body" || this.#isViewLocked()) {
101947
102573
  this.#dragLastPointer = null;
101948
102574
  this.#dragLastRawHit = null;
101949
102575
  this.#dragUsedPageNotMountedFallback = false;
@@ -102293,6 +102919,7 @@ ${o}
102293
102919
  this.#epochMapper.onLayoutComplete(layoutEpoch);
102294
102920
  this.#selectionSync.onLayoutComplete(layoutEpoch);
102295
102921
  layoutCompleted = true;
102922
+ this.#updatePermissionOverlay();
102296
102923
  this.#layoutError = null;
102297
102924
  this.#layoutErrorState = "healthy";
102298
102925
  this.#dismissErrorBanner();
@@ -102381,7 +103008,7 @@ ${o}
102381
103008
  if (!this.#localSelectionLayer) {
102382
103009
  return;
102383
103010
  }
102384
- if (this.#documentMode === "viewing") {
103011
+ if (this.#isViewLocked()) {
102385
103012
  try {
102386
103013
  this.#localSelectionLayer.innerHTML = "";
102387
103014
  } catch (error) {
@@ -102451,6 +103078,76 @@ ${o}
102451
103078
  } catch (error) {
102452
103079
  }
102453
103080
  }
103081
+ /**
103082
+ * Updates the permission overlay (w:permStart/w:permEnd) to match the current editor permission ranges.
103083
+ *
103084
+ * This method is called after layout completes to ensure permission overlay
103085
+ * is based on stable permission ranges data.
103086
+ */
103087
+ #updatePermissionOverlay() {
103088
+ const overlay2 = this.#permissionOverlay;
103089
+ if (!overlay2) {
103090
+ return;
103091
+ }
103092
+ if (this.#session.mode !== "body") {
103093
+ overlay2.innerHTML = "";
103094
+ return;
103095
+ }
103096
+ const permissionStorage = this.#editor?.storage?.permissionRanges;
103097
+ const ranges = permissionStorage?.ranges ?? [];
103098
+ const shouldRender = ranges.length > 0;
103099
+ if (!shouldRender) {
103100
+ overlay2.innerHTML = "";
103101
+ return;
103102
+ }
103103
+ const layout = this.#layoutState.layout;
103104
+ if (!layout) {
103105
+ overlay2.innerHTML = "";
103106
+ return;
103107
+ }
103108
+ const docEpoch = this.#epochMapper.getCurrentEpoch();
103109
+ if (this.#layoutEpoch < docEpoch) {
103110
+ return;
103111
+ }
103112
+ const pageHeight = this.#getBodyPageHeight();
103113
+ const pageGap = layout.pageGap ?? this.#getEffectivePageGap();
103114
+ const fragment = overlay2.ownerDocument?.createDocumentFragment();
103115
+ if (!fragment) {
103116
+ overlay2.innerHTML = "";
103117
+ return;
103118
+ }
103119
+ ranges.forEach(({ from: from2, to }) => {
103120
+ const rects = this.#computeSelectionRectsFromDom(from2, to);
103121
+ if (!rects?.length) {
103122
+ return;
103123
+ }
103124
+ rects.forEach((rect) => {
103125
+ const pageLocalY = rect.y - rect.pageIndex * (pageHeight + pageGap);
103126
+ const coords = this.#convertPageLocalToOverlayCoords(rect.pageIndex, rect.x, pageLocalY);
103127
+ if (!coords) {
103128
+ return;
103129
+ }
103130
+ const highlight = overlay2.ownerDocument?.createElement("div");
103131
+ if (!highlight) {
103132
+ return;
103133
+ }
103134
+ highlight.className = "presentation-editor__permission-highlight";
103135
+ Object.assign(highlight.style, {
103136
+ position: "absolute",
103137
+ left: `${coords.x}px`,
103138
+ top: `${coords.y}px`,
103139
+ width: `${Math.max(1, rect.width)}px`,
103140
+ height: `${Math.max(1, rect.height)}px`,
103141
+ borderRadius: "2px",
103142
+ pointerEvents: "none",
103143
+ zIndex: 1
103144
+ });
103145
+ fragment.appendChild(highlight);
103146
+ });
103147
+ });
103148
+ overlay2.innerHTML = "";
103149
+ overlay2.appendChild(fragment);
103150
+ }
102454
103151
  #resolveLayoutOptions(blocks2, sectionMetadata) {
102455
103152
  const defaults2 = this.#computeDefaultLayoutDefaults();
102456
103153
  const firstSection = blocks2?.find(
@@ -103196,7 +103893,7 @@ ${o}
103196
103893
  this.#announce(announcement.message);
103197
103894
  }
103198
103895
  #validateHeaderFooterEditPermission() {
103199
- if (this.#documentMode === "viewing") {
103896
+ if (this.#isViewLocked()) {
103200
103897
  return { allowed: false, reason: "documentMode" };
103201
103898
  }
103202
103899
  if (!this.#editor.isEditable) {
@@ -104053,6 +104750,17 @@ ${o}
104053
104750
  this.#errorBanner = null;
104054
104751
  this.#errorBannerMessage = null;
104055
104752
  }
104753
+ /**
104754
+ * Determines whether the current viewing mode should block edits.
104755
+ * When documentMode is viewing but the active editor has been toggled
104756
+ * back to editable (e.g. permission ranges), we treat the view as editable.
104757
+ */
104758
+ #isViewLocked() {
104759
+ if (this.#documentMode !== "viewing") return false;
104760
+ const hasPermissionOverride = !!this.#editor?.storage?.permissionRanges?.hasAllowedRanges;
104761
+ if (hasPermissionOverride) return false;
104762
+ return this.#documentMode === "viewing";
104763
+ }
104056
104764
  /**
104057
104765
  * Applies vertical alignment and font scaling to layout DOM elements for subscript/superscript rendering.
104058
104766
  *
@@ -105932,6 +106640,11 @@ ${o}
105932
106640
  parseTagObject
105933
106641
  }, Symbol.toStringTag, { value: "Module" }));
105934
106642
  const STRUCTURED_CONTENT_NAMES = ["structuredContent", "structuredContentBlock"];
106643
+ function isValidIntegerId(id) {
106644
+ if (id === null || id === void 0) return true;
106645
+ const str = String(id);
106646
+ return /^-?\d+$/.test(str);
106647
+ }
105935
106648
  const findFirstTextNode = (node2) => {
105936
106649
  let firstTextNode = null;
105937
106650
  node2.descendants((child) => {
@@ -105973,6 +106686,9 @@ ${o}
105973
106686
  * });
105974
106687
  */
105975
106688
  insertStructuredContentInline: (options = {}) => ({ editor, dispatch, state, tr }) => {
106689
+ if (options.attrs?.id !== void 0 && !isValidIntegerId(options.attrs.id)) {
106690
+ throw new Error("Invalid structured content id - must be an integer, got: " + options.attrs.id);
106691
+ }
105976
106692
  const { schema } = editor;
105977
106693
  let { from: from2, to } = state.selection;
105978
106694
  if (dispatch) {
@@ -106035,6 +106751,9 @@ ${o}
106035
106751
  * });
106036
106752
  */
106037
106753
  insertStructuredContentBlock: (options = {}) => ({ editor, dispatch, state, tr }) => {
106754
+ if (options.attrs?.id !== void 0 && !isValidIntegerId(options.attrs.id)) {
106755
+ throw new Error("Invalid structured content id - must be an integer, got: " + options.attrs.id);
106756
+ }
106038
106757
  const { schema } = editor;
106039
106758
  let { from: from2, to } = state.selection;
106040
106759
  if (dispatch) {
@@ -106092,6 +106811,9 @@ ${o}
106092
106811
  * });
106093
106812
  */
106094
106813
  updateStructuredContentById: (id, options = {}) => ({ editor, dispatch, state, tr }) => {
106814
+ if (options.attrs?.id !== void 0 && !isValidIntegerId(options.attrs.id)) {
106815
+ throw new Error("Invalid structured content id - must be an integer, got: " + options.attrs.id);
106816
+ }
106095
106817
  const structuredContentTags = getStructuredContentTagsById(id, state);
106096
106818
  if (!structuredContentTags.length) {
106097
106819
  return true;
@@ -106219,6 +106941,9 @@ ${o}
106219
106941
  * });
106220
106942
  */
106221
106943
  updateStructuredContentByGroup: (group, options = {}) => ({ editor, dispatch, state, tr }) => {
106944
+ if (options.attrs?.id !== void 0 && !isValidIntegerId(options.attrs.id)) {
106945
+ throw new Error("Invalid structured content id - must be an integer, got: " + options.attrs.id);
106946
+ }
106222
106947
  const structuredContentTags = getStructuredContentByGroup(group, state);
106223
106948
  if (!structuredContentTags.length) {
106224
106949
  return true;
@@ -106896,7 +107621,7 @@ ${o}
106896
107621
  }
106897
107622
  return merged;
106898
107623
  };
106899
- const collectChangedRanges = (trs, docSize) => {
107624
+ const collectChangedRanges$1 = (trs, docSize) => {
106900
107625
  const ranges = [];
106901
107626
  trs.forEach((tr) => {
106902
107627
  if (!tr.docChanged) return;
@@ -107099,7 +107824,7 @@ ${o}
107099
107824
  const runType = newState.schema.nodes.run;
107100
107825
  if (!runType) return null;
107101
107826
  pendingRanges = mapRangesThroughTransactions(pendingRanges, transactions, docSize);
107102
- const changedRanges = collectChangedRanges(transactions, docSize);
107827
+ const changedRanges = collectChangedRanges$1(transactions, docSize);
107103
107828
  pendingRanges = mergeRanges$2([...pendingRanges, ...changedRanges], docSize);
107104
107829
  if (view?.composing) {
107105
107830
  return null;
@@ -121850,6 +122575,283 @@ ${o}
121850
122575
  return [nodeResizer(["image"], this.editor)];
121851
122576
  }
121852
122577
  });
122578
+ const PERMISSION_PLUGIN_KEY = new PluginKey("permissionRanges");
122579
+ const EVERYONE_GROUP = "everyone";
122580
+ const EMPTY_IDENTIFIER_SET = Object.freeze(/* @__PURE__ */ new Set());
122581
+ const normalizeIdentifier$1 = (value) => typeof value === "string" ? value.trim().toLowerCase() : "";
122582
+ const buildAllowedIdentifierSet = (editor) => {
122583
+ const email = normalizeIdentifier$1(editor?.options?.user?.email);
122584
+ if (!email) {
122585
+ return EMPTY_IDENTIFIER_SET;
122586
+ }
122587
+ const [localPart, domain2] = email.split("@");
122588
+ if (!localPart || !domain2) {
122589
+ return EMPTY_IDENTIFIER_SET;
122590
+ }
122591
+ const formatted = `${domain2}\\${localPart}`;
122592
+ return formatted ? /* @__PURE__ */ new Set([formatted]) : EMPTY_IDENTIFIER_SET;
122593
+ };
122594
+ const isEveryoneGroup = (value) => normalizeIdentifier$1(value) === EVERYONE_GROUP;
122595
+ const isRangeAllowedForUser = (attrs, allowedIdentifiers) => {
122596
+ if (!attrs) return false;
122597
+ if (isEveryoneGroup(attrs.edGrp)) {
122598
+ return true;
122599
+ }
122600
+ if (!allowedIdentifiers?.size) {
122601
+ return false;
122602
+ }
122603
+ const normalizedEd = normalizeIdentifier$1(attrs.ed);
122604
+ return normalizedEd && allowedIdentifiers.has(normalizedEd);
122605
+ };
122606
+ const getPermissionNodeId = (node2, pos, fallbackPrefix) => String(node2.attrs?.id ?? `${fallbackPrefix}-${pos}`);
122607
+ const buildPermissionState = (doc2, allowedIdentifiers = EMPTY_IDENTIFIER_SET) => {
122608
+ const ranges = [];
122609
+ const openRanges = /* @__PURE__ */ new Map();
122610
+ doc2.descendants((node2, pos) => {
122611
+ if (node2.type?.name === "permStart") {
122612
+ const id = getPermissionNodeId(node2, pos, "permStart");
122613
+ openRanges.set(id, {
122614
+ from: pos + node2.nodeSize,
122615
+ attrs: node2.attrs ?? {}
122616
+ });
122617
+ return false;
122618
+ }
122619
+ if (node2.type?.name === "permEnd") {
122620
+ const id = getPermissionNodeId(node2, pos, "permEnd");
122621
+ const start2 = openRanges.get(id);
122622
+ if (start2 && isRangeAllowedForUser(start2.attrs, allowedIdentifiers)) {
122623
+ const to = Math.max(pos, start2.from);
122624
+ if (to > start2.from) {
122625
+ ranges.push({
122626
+ id,
122627
+ from: start2.from,
122628
+ to
122629
+ });
122630
+ }
122631
+ }
122632
+ if (start2) {
122633
+ openRanges.delete(id);
122634
+ }
122635
+ return false;
122636
+ }
122637
+ });
122638
+ return {
122639
+ ranges,
122640
+ hasAllowedRanges: ranges.length > 0
122641
+ };
122642
+ };
122643
+ const collectPermissionTags = (doc2, permStartType, permEndType) => {
122644
+ const tags = /* @__PURE__ */ new Map();
122645
+ doc2.descendants((node2, pos) => {
122646
+ if (node2.type !== permStartType && node2.type !== permEndType) {
122647
+ return;
122648
+ }
122649
+ const id = node2.attrs?.id;
122650
+ if (!id) {
122651
+ return;
122652
+ }
122653
+ const entry = tags.get(id) ?? {};
122654
+ if (node2.type === permStartType) {
122655
+ entry.start = { pos, attrs: node2.attrs ?? {} };
122656
+ } else if (node2.type === permEndType) {
122657
+ entry.end = { pos, attrs: node2.attrs ?? {} };
122658
+ }
122659
+ tags.set(id, entry);
122660
+ });
122661
+ return tags;
122662
+ };
122663
+ const clampPosition = (pos, size2) => {
122664
+ if (Number.isNaN(pos) || !Number.isFinite(pos)) {
122665
+ return 0;
122666
+ }
122667
+ return Math.max(0, Math.min(pos, size2));
122668
+ };
122669
+ const trimPermissionTagsFromRange = (doc2, range2, permStartType, permEndType) => {
122670
+ let from2 = range2.from;
122671
+ let to = range2.to;
122672
+ while (from2 < to) {
122673
+ const node2 = doc2.nodeAt(from2);
122674
+ if (!node2 || node2.type !== permStartType && node2.type !== permEndType) {
122675
+ break;
122676
+ }
122677
+ from2 += node2.nodeSize;
122678
+ }
122679
+ while (to > from2) {
122680
+ const $pos = doc2.resolve(to);
122681
+ const nodeBefore = $pos.nodeBefore;
122682
+ if (!nodeBefore || nodeBefore.type !== permStartType && nodeBefore.type !== permEndType) {
122683
+ break;
122684
+ }
122685
+ to -= nodeBefore.nodeSize;
122686
+ }
122687
+ return { from: from2, to };
122688
+ };
122689
+ const collectChangedRanges = (tr) => {
122690
+ const ranges = [];
122691
+ tr.mapping.maps.forEach((map2) => {
122692
+ map2.forEach((oldStart, oldEnd) => {
122693
+ const from2 = Math.min(oldStart, oldEnd);
122694
+ const to = Math.max(oldStart, oldEnd);
122695
+ ranges.push({ from: from2, to });
122696
+ });
122697
+ });
122698
+ return ranges;
122699
+ };
122700
+ const isRangeAllowed = (range2, allowedRanges) => {
122701
+ if (!allowedRanges?.length) return false;
122702
+ return allowedRanges.some((allowed) => range2.from >= allowed.from && range2.to <= allowed.to);
122703
+ };
122704
+ const PermissionRanges = Extension.create({
122705
+ name: "permissionRanges",
122706
+ addStorage() {
122707
+ return {
122708
+ ranges: [],
122709
+ hasAllowedRanges: false
122710
+ };
122711
+ },
122712
+ addPmPlugins() {
122713
+ const editor = this.editor;
122714
+ const storage = this.storage;
122715
+ let originalSetDocumentMode = null;
122716
+ const getAllowedIdentifiers = () => buildAllowedIdentifierSet(editor);
122717
+ const toggleEditableIfAllowed = (hasAllowedRanges) => {
122718
+ if (!editor || editor.isDestroyed) return;
122719
+ if (editor.options.documentMode !== "viewing") return;
122720
+ if (hasAllowedRanges && !editor.isEditable) {
122721
+ editor.setEditable(true, false);
122722
+ } else if (!hasAllowedRanges && editor.isEditable) {
122723
+ editor.setEditable(false, false);
122724
+ }
122725
+ };
122726
+ const updateEditableState = (hasAllowedRanges) => {
122727
+ const nextValue = Boolean(hasAllowedRanges);
122728
+ const previousValue = storage.hasAllowedRanges;
122729
+ storage.hasAllowedRanges = nextValue;
122730
+ if (previousValue === nextValue) {
122731
+ return;
122732
+ }
122733
+ toggleEditableIfAllowed(nextValue);
122734
+ };
122735
+ if (editor && typeof editor.setDocumentMode === "function") {
122736
+ originalSetDocumentMode = editor.setDocumentMode.bind(editor);
122737
+ editor.setDocumentMode = (mode, caller) => {
122738
+ originalSetDocumentMode(mode, caller);
122739
+ const state = editor.state;
122740
+ if (!state) return;
122741
+ const pluginState = PERMISSION_PLUGIN_KEY.getState(state);
122742
+ if (pluginState) {
122743
+ toggleEditableIfAllowed(pluginState.hasAllowedRanges);
122744
+ }
122745
+ };
122746
+ }
122747
+ return [
122748
+ new Plugin({
122749
+ key: PERMISSION_PLUGIN_KEY,
122750
+ state: {
122751
+ init(_2, state) {
122752
+ const permissionState = buildPermissionState(state.doc, getAllowedIdentifiers());
122753
+ storage.ranges = permissionState.ranges;
122754
+ updateEditableState(permissionState.hasAllowedRanges);
122755
+ return permissionState;
122756
+ },
122757
+ apply(tr, value, _oldState, newState) {
122758
+ let permissionState = value;
122759
+ if (tr.docChanged) {
122760
+ permissionState = buildPermissionState(newState.doc, getAllowedIdentifiers());
122761
+ storage.ranges = permissionState.ranges;
122762
+ updateEditableState(permissionState.hasAllowedRanges);
122763
+ }
122764
+ return permissionState;
122765
+ }
122766
+ },
122767
+ view() {
122768
+ return {
122769
+ destroy() {
122770
+ if (editor && originalSetDocumentMode) {
122771
+ editor.setDocumentMode = originalSetDocumentMode;
122772
+ }
122773
+ }
122774
+ };
122775
+ },
122776
+ // Appends transactions to the document to ensure permission ranges are updated.
122777
+ appendTransaction(transactions, oldState, newState) {
122778
+ if (!transactions.some((tr2) => tr2.docChanged)) return null;
122779
+ const permStartType = newState.schema.nodes["permStart"];
122780
+ const permEndType = newState.schema.nodes["permEnd"];
122781
+ if (!permStartType || !permEndType) return null;
122782
+ const oldTags = collectPermissionTags(oldState.doc, permStartType, permEndType);
122783
+ if (!oldTags.size) {
122784
+ return null;
122785
+ }
122786
+ const newTags = collectPermissionTags(newState.doc, permStartType, permEndType);
122787
+ const mappingToNew = new Mapping();
122788
+ transactions.forEach((tr2) => {
122789
+ mappingToNew.appendMapping(tr2.mapping);
122790
+ });
122791
+ const pendingInsertions = [];
122792
+ oldTags.forEach((tag, id) => {
122793
+ const current = newTags.get(id);
122794
+ if (tag.start && !current?.start) {
122795
+ const mapped = mappingToNew.mapResult(tag.start.pos, -1);
122796
+ pendingInsertions.push({
122797
+ pos: mapped.pos,
122798
+ nodeType: permStartType,
122799
+ attrs: tag.start.attrs,
122800
+ priority: 0
122801
+ });
122802
+ }
122803
+ if (tag.end && !current?.end) {
122804
+ const mapped = mappingToNew.mapResult(tag.end.pos, 1);
122805
+ pendingInsertions.push({
122806
+ pos: mapped.pos,
122807
+ nodeType: permEndType,
122808
+ attrs: tag.end.attrs,
122809
+ priority: 1
122810
+ });
122811
+ }
122812
+ });
122813
+ if (!pendingInsertions.length) {
122814
+ return null;
122815
+ }
122816
+ pendingInsertions.sort((a2, b2) => {
122817
+ if (a2.pos === b2.pos) {
122818
+ return a2.priority - b2.priority;
122819
+ }
122820
+ return a2.pos - b2.pos;
122821
+ });
122822
+ const tr = newState.tr;
122823
+ let offset2 = 0;
122824
+ pendingInsertions.forEach((item) => {
122825
+ const node2 = item.nodeType.create(item.attrs);
122826
+ const insertPos = clampPosition(item.pos + offset2, tr.doc.content.size);
122827
+ tr.insert(insertPos, node2);
122828
+ offset2 += node2.nodeSize;
122829
+ });
122830
+ return tr.docChanged ? tr : null;
122831
+ },
122832
+ // Filters transactions to ensure only allowed edits are applied.
122833
+ filterTransaction(tr, state) {
122834
+ if (!tr.docChanged) return true;
122835
+ if (!editor || editor.options.documentMode !== "viewing") return true;
122836
+ const pluginState = PERMISSION_PLUGIN_KEY.getState(state);
122837
+ if (!pluginState?.hasAllowedRanges) {
122838
+ return true;
122839
+ }
122840
+ const changedRanges = collectChangedRanges(tr);
122841
+ if (!changedRanges.length) return true;
122842
+ const permStartType = state.schema.nodes["permStart"];
122843
+ const permEndType = state.schema.nodes["permEnd"];
122844
+ if (!permStartType || !permEndType) return true;
122845
+ const allRangesAllowed = changedRanges.every((range2) => {
122846
+ const trimmed = trimPermissionTagsFromRange(state.doc, range2, permStartType, permEndType);
122847
+ return isRangeAllowed(trimmed, pluginState.ranges);
122848
+ });
122849
+ return allRangesAllowed;
122850
+ }
122851
+ })
122852
+ ];
122853
+ }
122854
+ });
121853
122855
  const PermStart = Node$2.create({
121854
122856
  name: "permStart",
121855
122857
  group: "inline",
@@ -122009,6 +123011,7 @@ ${o}
122009
123011
  ShapeGroup,
122010
123012
  PermStart,
122011
123013
  PermEnd,
123014
+ PermissionRanges,
122012
123015
  PassthroughInline,
122013
123016
  PassthroughBlock
122014
123017
  ];
@@ -147030,7 +148033,7 @@ ${reason}`);
147030
148033
  this.config.colors = shuffleArray(this.config.colors);
147031
148034
  this.userColorMap = /* @__PURE__ */ new Map();
147032
148035
  this.colorIndex = 0;
147033
- this.version = "1.5.0-next.6";
148036
+ this.version = "1.5.0-next.8";
147034
148037
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
147035
148038
  this.superdocId = config2.superdocId || v4();
147036
148039
  this.colors = this.config.colors;