@harbour-enterprises/superdoc 1.3.0-next.7 → 1.3.0-next.9

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.
@@ -9514,6 +9514,9 @@ function handleTableCellNode({
9514
9514
  columnIndex,
9515
9515
  columnWidth = null,
9516
9516
  allColumnWidths = [],
9517
+ rowIndex = 0,
9518
+ totalRows = 1,
9519
+ totalColumns,
9517
9520
  _referencedStyles
9518
9521
  }) {
9519
9522
  const { nodeListHandler } = params;
@@ -9522,19 +9525,46 @@ function handleTableCellNode({
9522
9525
  const tcPr = node.elements.find((el) => el.name === "w:tcPr");
9523
9526
  const tableCellProperties = tcPr ? translator$J.encode({ ...params, nodes: [tcPr] }) ?? {} : {};
9524
9527
  attributes["tableCellProperties"] = tableCellProperties;
9525
- if (rowBorders?.insideH) {
9526
- rowBorders["bottom"] = rowBorders.insideH;
9527
- delete rowBorders.insideH;
9528
- }
9529
- if (rowBorders?.insideV) {
9530
- rowBorders["right"] = rowBorders.insideV;
9531
- delete rowBorders?.insideV;
9532
- }
9533
- if (rowBorders) attributes["borders"] = { ...rowBorders };
9534
- const inlineBorders = processInlineCellBorders(tableCellProperties.borders, rowBorders);
9535
- if (inlineBorders) attributes["borders"] = Object.assign(attributes["borders"] || {}, inlineBorders);
9536
- const colspan = tableCellProperties.gridSpan;
9537
- if (colspan && !isNaN(parseInt(colspan, 10))) attributes["colspan"] = parseInt(colspan, 10);
9528
+ const effectiveTotalColumns = totalColumns ?? (allColumnWidths.length || 1);
9529
+ const effectiveTotalRows = totalRows ?? (table?.elements?.filter((el) => el.name === "w:tr").length || 1);
9530
+ const colspan = parseInt(tableCellProperties.gridSpan || 1, 10);
9531
+ const isFirstRow = rowIndex === 0;
9532
+ const isLastRow = rowIndex === effectiveTotalRows - 1;
9533
+ const isFirstColumn = columnIndex === 0;
9534
+ const isLastColumn = columnIndex + colspan >= effectiveTotalColumns;
9535
+ const cellBorders = {};
9536
+ if (rowBorders) {
9537
+ if (rowBorders.top?.val === "none") {
9538
+ cellBorders.top = rowBorders.top;
9539
+ } else if (isFirstRow && rowBorders.top) {
9540
+ cellBorders.top = rowBorders.top;
9541
+ }
9542
+ if (rowBorders.bottom?.val === "none") {
9543
+ cellBorders.bottom = rowBorders.bottom;
9544
+ } else if (isLastRow && rowBorders.bottom) {
9545
+ cellBorders.bottom = rowBorders.bottom;
9546
+ }
9547
+ if (rowBorders.left?.val === "none") {
9548
+ cellBorders.left = rowBorders.left;
9549
+ } else if (isFirstColumn && rowBorders.left) {
9550
+ cellBorders.left = rowBorders.left;
9551
+ }
9552
+ if (rowBorders.right?.val === "none") {
9553
+ cellBorders.right = rowBorders.right;
9554
+ } else if (isLastColumn && rowBorders.right) {
9555
+ cellBorders.right = rowBorders.right;
9556
+ }
9557
+ if (!isLastRow && rowBorders.insideH) {
9558
+ cellBorders.bottom = rowBorders.insideH;
9559
+ }
9560
+ if (!isLastColumn && rowBorders.insideV) {
9561
+ cellBorders.right = rowBorders.insideV;
9562
+ }
9563
+ }
9564
+ attributes["borders"] = cellBorders;
9565
+ const inlineBorders = processInlineCellBorders(tableCellProperties.borders, cellBorders);
9566
+ if (inlineBorders) attributes["borders"] = Object.assign(attributes["borders"], inlineBorders);
9567
+ if (colspan > 1) attributes["colspan"] = colspan;
9538
9568
  let width = tableCellProperties.cellWidth?.value ? twipsToPixels(tableCellProperties.cellWidth?.value) : null;
9539
9569
  const widthType = tableCellProperties.cellWidth?.type;
9540
9570
  if (widthType) attributes["widthType"] = widthType;
@@ -9544,10 +9574,9 @@ function handleTableCellNode({
9544
9574
  attributes["widthUnit"] = "px";
9545
9575
  const defaultColWidths = allColumnWidths;
9546
9576
  const hasDefaultColWidths = allColumnWidths && allColumnWidths.length > 0;
9547
- const colspanNum = parseInt(colspan || 1, 10);
9548
- if (colspanNum && colspanNum > 1 && hasDefaultColWidths) {
9577
+ if (colspan > 1 && hasDefaultColWidths) {
9549
9578
  let colwidth = [];
9550
- for (let i = 0; i < colspanNum; i++) {
9579
+ for (let i = 0; i < colspan; i++) {
9551
9580
  let colwidthValue = defaultColWidths[columnIndex + i];
9552
9581
  let defaultColwidth = 100;
9553
9582
  if (typeof colwidthValue !== "undefined") {
@@ -9697,22 +9726,18 @@ const processInlineCellBorders = (borders, rowBorders) => {
9697
9726
  return ["bottom", "top", "left", "right"].reduce((acc, direction) => {
9698
9727
  const borderAttrs = borders[direction];
9699
9728
  const rowBorderAttrs = rowBorders[direction];
9700
- if (borderAttrs && borderAttrs["val"] !== "nil") {
9729
+ if (borderAttrs && borderAttrs["val"] !== "none") {
9701
9730
  const color = borderAttrs["color"];
9702
9731
  let size = borderAttrs["size"];
9703
9732
  if (size) size = eighthPointsToPixels(size);
9704
9733
  acc[direction] = { color, size, val: borderAttrs["val"] };
9705
9734
  return acc;
9706
9735
  }
9707
- if (borderAttrs && borderAttrs["val"] === "nil") {
9736
+ if (borderAttrs && borderAttrs["val"] === "none") {
9708
9737
  const border = Object.assign({}, rowBorderAttrs || {});
9709
- if (!Object.keys(border).length) {
9710
- return acc;
9711
- } else {
9712
- border["val"] = "none";
9713
- acc[direction] = border;
9714
- return acc;
9715
- }
9738
+ border["val"] = "none";
9739
+ acc[direction] = border;
9740
+ return acc;
9716
9741
  }
9717
9742
  return acc;
9718
9743
  }, {});
@@ -9848,6 +9873,9 @@ function encode$w(params, encodedAttrs) {
9848
9873
  columnIndex,
9849
9874
  columnWidth,
9850
9875
  columnWidths: allColumnWidths,
9876
+ rowIndex,
9877
+ totalRows,
9878
+ totalColumns,
9851
9879
  _referencedStyles
9852
9880
  } = params.extraParams;
9853
9881
  const schemaNode = handleTableCellNode({
@@ -9859,6 +9887,9 @@ function encode$w(params, encodedAttrs) {
9859
9887
  columnIndex,
9860
9888
  columnWidth,
9861
9889
  allColumnWidths,
9890
+ rowIndex,
9891
+ totalRows,
9892
+ totalColumns,
9862
9893
  _referencedStyles
9863
9894
  });
9864
9895
  if (encodedAttrs && Object.keys(encodedAttrs).length) {
@@ -9882,13 +9913,26 @@ const config$i = {
9882
9913
  attributes: validXmlAttributes$a
9883
9914
  };
9884
9915
  const translator$I = NodeTranslator.from(config$i);
9885
- const translator$H = NodeTranslator.from({
9916
+ const propertyTranslators$3 = [
9917
+ translator$1q,
9918
+ translator$Z,
9919
+ translator$X,
9920
+ translator$W,
9921
+ translator$1o,
9922
+ translator$1m,
9923
+ translator$V,
9924
+ translator$1k
9925
+ ];
9926
+ const translator$H = NodeTranslator.from(
9927
+ createNestedPropertiesTranslator("w:tblBorders", "borders", propertyTranslators$3)
9928
+ );
9929
+ const translator$G = NodeTranslator.from({
9886
9930
  xmlName: "w:cantSplit",
9887
9931
  sdNodeOrKeyName: "cantSplit",
9888
9932
  encode: ({ nodes }) => ["1", "true"].includes(nodes[0].attributes?.["w:val"] ?? "1"),
9889
9933
  decode: ({ node }) => node.attrs?.cantSplit ? { attributes: {} } : void 0
9890
9934
  });
9891
- const translator$G = NodeTranslator.from(
9935
+ const translator$F = NodeTranslator.from(
9892
9936
  createSingleAttrPropertyHandler(
9893
9937
  "w:gridAfter",
9894
9938
  null,
@@ -9897,7 +9941,7 @@ const translator$G = NodeTranslator.from(
9897
9941
  (v2) => integerToString(v2)
9898
9942
  )
9899
9943
  );
9900
- const translator$F = NodeTranslator.from(
9944
+ const translator$E = NodeTranslator.from(
9901
9945
  createSingleAttrPropertyHandler(
9902
9946
  "w:gridBefore",
9903
9947
  null,
@@ -9906,20 +9950,20 @@ const translator$F = NodeTranslator.from(
9906
9950
  (v2) => integerToString(v2)
9907
9951
  )
9908
9952
  );
9909
- const translator$E = NodeTranslator.from({
9953
+ const translator$D = NodeTranslator.from({
9910
9954
  xmlName: "w:hidden",
9911
9955
  sdNodeOrKeyName: "hidden",
9912
9956
  encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
9913
9957
  decode: ({ node }) => node.attrs.hidden ? { attributes: {} } : void 0
9914
9958
  });
9915
- const translator$D = NodeTranslator.from(createMeasurementPropertyHandler("w:tblCellSpacing", "tableCellSpacing"));
9916
- const translator$C = NodeTranslator.from({
9959
+ const translator$C = NodeTranslator.from(createMeasurementPropertyHandler("w:tblCellSpacing", "tableCellSpacing"));
9960
+ const translator$B = NodeTranslator.from({
9917
9961
  xmlName: "w:tblHeader",
9918
9962
  sdNodeOrKeyName: "repeatHeader",
9919
9963
  encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
9920
9964
  decode: ({ node }) => node.attrs.repeatHeader ? { attributes: {} } : void 0
9921
9965
  });
9922
- const translator$B = NodeTranslator.from({
9966
+ const translator$A = NodeTranslator.from({
9923
9967
  xmlName: "w:trHeight",
9924
9968
  sdNodeOrKeyName: "rowHeight",
9925
9969
  encode: ({ nodes }) => {
@@ -9946,24 +9990,24 @@ const translator$B = NodeTranslator.from({
9946
9990
  return Object.keys(heightAttrs).length > 0 ? { attributes: heightAttrs } : void 0;
9947
9991
  }
9948
9992
  });
9949
- const translator$A = NodeTranslator.from(createMeasurementPropertyHandler("w:wAfter"));
9950
- const translator$z = NodeTranslator.from(createMeasurementPropertyHandler("w:wBefore"));
9951
- const propertyTranslators$3 = [
9952
- translator$H,
9993
+ const translator$z = NodeTranslator.from(createMeasurementPropertyHandler("w:wAfter"));
9994
+ const translator$y = NodeTranslator.from(createMeasurementPropertyHandler("w:wBefore"));
9995
+ const propertyTranslators$2 = [
9996
+ translator$G,
9953
9997
  translator$1I,
9954
9998
  translator$1G,
9955
- translator$G,
9956
9999
  translator$F,
9957
10000
  translator$E,
9958
- translator$1D,
9959
10001
  translator$D,
10002
+ translator$1D,
9960
10003
  translator$C,
9961
10004
  translator$B,
9962
10005
  translator$A,
9963
- translator$z
10006
+ translator$z,
10007
+ translator$y
9964
10008
  ];
9965
- const translator$y = NodeTranslator.from(
9966
- createNestedPropertiesTranslator("w:trPr", "tableRowProperties", propertyTranslators$3, {
10009
+ const translator$x = NodeTranslator.from(
10010
+ createNestedPropertiesTranslator("w:trPr", "tableRowProperties", propertyTranslators$2, {
9967
10011
  cantSplit: false,
9968
10012
  hidden: false,
9969
10013
  repeatHeader: false
@@ -10041,7 +10085,7 @@ const encode$v = (params, encodedAttrs) => {
10041
10085
  let tableRowProperties = {};
10042
10086
  const tPr = row.elements.find((el) => el.name === "w:trPr");
10043
10087
  if (tPr) {
10044
- tableRowProperties = translator$y.encode({
10088
+ tableRowProperties = translator$x.encode({
10045
10089
  ...params,
10046
10090
  nodes: [tPr]
10047
10091
  });
@@ -10051,6 +10095,12 @@ const encode$v = (params, encodedAttrs) => {
10051
10095
  encodedAttrs["tableRowProperties"] = Object.freeze(tableRowProperties);
10052
10096
  encodedAttrs["rowHeight"] = twipsToPixels(tableRowProperties["rowHeight"]?.value);
10053
10097
  encodedAttrs["cantSplit"] = tableRowProperties["cantSplit"];
10098
+ const baseBorders = params.extraParams?.rowBorders;
10099
+ const rowTableBorders = getRowTableBorders({
10100
+ params,
10101
+ row,
10102
+ baseBorders
10103
+ });
10054
10104
  const { columnWidths: gridColumnWidths, activeRowSpans = [] } = params.extraParams;
10055
10105
  const totalColumns = Array.isArray(gridColumnWidths) ? gridColumnWidths.length : 0;
10056
10106
  const pendingRowSpans = Array.isArray(activeRowSpans) ? activeRowSpans.slice() : [];
@@ -10083,6 +10133,10 @@ const encode$v = (params, encodedAttrs) => {
10083
10133
  path: [...params.path || [], node],
10084
10134
  extraParams: {
10085
10135
  ...params.extraParams,
10136
+ rowBorders: {
10137
+ ...baseBorders,
10138
+ ...rowTableBorders
10139
+ },
10086
10140
  node,
10087
10141
  columnIndex: startColumn,
10088
10142
  columnWidth
@@ -10112,6 +10166,33 @@ const encode$v = (params, encodedAttrs) => {
10112
10166
  };
10113
10167
  return newNode;
10114
10168
  };
10169
+ function getRowTableBorders({ params, row, baseBorders }) {
10170
+ const tblPrEx = row?.elements?.find?.((el) => el.name === "w:tblPrEx");
10171
+ const tblBorders = tblPrEx?.elements?.find?.((el) => el.name === "w:tblBorders");
10172
+ if (!tblBorders) {
10173
+ return baseBorders;
10174
+ }
10175
+ const rawOverrides = translator$H.encode({ ...params, nodes: [tblBorders] }) || {};
10176
+ const overrides = processRawTableBorders(rawOverrides);
10177
+ if (!Object.keys(overrides).length) {
10178
+ return baseBorders;
10179
+ }
10180
+ return { ...baseBorders || {}, ...overrides };
10181
+ }
10182
+ function processRawTableBorders(rawBorders) {
10183
+ const borders = {};
10184
+ Object.entries(rawBorders || {}).forEach(([name, attributes]) => {
10185
+ const attrs = {};
10186
+ const color = attributes?.color;
10187
+ const size = attributes?.size;
10188
+ const val = attributes?.val;
10189
+ if (color && color !== "auto") attrs.color = color.startsWith("#") ? color : `#${color}`;
10190
+ if (size != null && size !== "auto") attrs.size = eighthPointsToPixels(size);
10191
+ if (val) attrs.val = val;
10192
+ borders[name] = attrs;
10193
+ });
10194
+ return borders;
10195
+ }
10115
10196
  const decode$x = (params, decodedAttrs) => {
10116
10197
  const { node } = params;
10117
10198
  const cells = node.content || [];
@@ -10152,7 +10233,7 @@ const decode$x = (params, decodedAttrs) => {
10152
10233
  }
10153
10234
  }
10154
10235
  tableRowProperties["cantSplit"] = node.attrs["cantSplit"];
10155
- const trPr = translator$y.decode({
10236
+ const trPr = translator$x.decode({
10156
10237
  ...params,
10157
10238
  node: { ...node, attrs: { ...node.attrs, tableRowProperties } }
10158
10239
  });
@@ -10172,7 +10253,7 @@ const config$h = {
10172
10253
  decode: decode$x,
10173
10254
  attributes: validXmlAttributes$9
10174
10255
  };
10175
- const translator$x = NodeTranslator.from(config$h);
10256
+ const translator$w = NodeTranslator.from(config$h);
10176
10257
  function parseTagValueJSON(json) {
10177
10258
  if (typeof json !== "string") {
10178
10259
  return {};
@@ -24863,7 +24944,7 @@ const config$g = {
24863
24944
  decode: decode$w,
24864
24945
  attributes: validXmlAttributes$8
24865
24946
  };
24866
- const translator$w = NodeTranslator.from(config$g);
24947
+ const translator$v = NodeTranslator.from(config$g);
24867
24948
  function handleInlineNode(params) {
24868
24949
  const { node } = params.extraParams;
24869
24950
  if (node.name !== "wp:inline") {
@@ -24917,7 +24998,7 @@ const config$f = {
24917
24998
  decode: decode$v,
24918
24999
  attributes: validXmlAttributes$7
24919
25000
  };
24920
- const translator$v = NodeTranslator.from(config$f);
25001
+ const translator$u = NodeTranslator.from(config$f);
24921
25002
  const XML_NODE_NAME$f = "w:drawing";
24922
25003
  const SD_NODE_NAME$d = [];
24923
25004
  const validXmlAttributes$6 = [];
@@ -24925,8 +25006,8 @@ function encode$s(params) {
24925
25006
  const nodes = params.nodes;
24926
25007
  const node = nodes[0];
24927
25008
  const translatorByChildName = {
24928
- "wp:anchor": translator$w,
24929
- "wp:inline": translator$v
25009
+ "wp:anchor": translator$v,
25010
+ "wp:inline": translator$u
24930
25011
  };
24931
25012
  const result = (node.elements || []).reduce((acc, child) => {
24932
25013
  if (acc) return acc;
@@ -24949,7 +25030,7 @@ function decode$u(params) {
24949
25030
  if (!node || !node.type) {
24950
25031
  return null;
24951
25032
  }
24952
- const childTranslator = node.attrs.isAnchor ? translator$w : translator$v;
25033
+ const childTranslator = node.attrs.isAnchor ? translator$v : translator$u;
24953
25034
  const resultNode = childTranslator.decode(params);
24954
25035
  return wrapTextInRun(
24955
25036
  {
@@ -24967,7 +25048,7 @@ const config$e = {
24967
25048
  decode: decode$u,
24968
25049
  attributes: validXmlAttributes$6
24969
25050
  };
24970
- const translator$u = NodeTranslator.from(config$e);
25051
+ const translator$t = NodeTranslator.from(config$e);
24971
25052
  function getTextNodeForExport(text, marks, params) {
24972
25053
  const hasLeadingOrTrailingSpace = /^\s|\s$/.test(text);
24973
25054
  const space = hasLeadingOrTrailingSpace ? "preserve" : null;
@@ -25375,7 +25456,7 @@ function prepareTextAnnotation(params) {
25375
25456
  return getTextNodeForExport(attrs.displayLabel, [...marks, ...marksFromAttrs], params);
25376
25457
  }
25377
25458
  function prepareImageAnnotation(params, imageSize) {
25378
- return translator$u.decode({
25459
+ return translator$t.decode({
25379
25460
  ...params,
25380
25461
  imageSize
25381
25462
  });
@@ -25837,7 +25918,7 @@ const config$d = {
25837
25918
  decode: decode$t,
25838
25919
  attributes: validXmlAttributes$5
25839
25920
  };
25840
- const translator$t = NodeTranslator.from(config$d);
25921
+ const translator$s = NodeTranslator.from(config$d);
25841
25922
  function preProcessVerticalMergeCells(table, { editorSchema }) {
25842
25923
  if (!table || !Array.isArray(table.content)) {
25843
25924
  return table;
@@ -25878,17 +25959,17 @@ function preProcessVerticalMergeCells(table, { editorSchema }) {
25878
25959
  }
25879
25960
  return table;
25880
25961
  }
25881
- const translator$s = NodeTranslator.from({
25962
+ const translator$r = NodeTranslator.from({
25882
25963
  xmlName: "w:bidiVisual",
25883
25964
  sdNodeOrKeyName: "rightToLeft",
25884
25965
  encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
25885
25966
  decode: ({ node }) => node.attrs.rightToLeft ? { attributes: {} } : void 0
25886
25967
  });
25887
- const translator$r = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblCaption", "caption"));
25888
- const translator$q = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblDescription", "description"));
25889
- const translator$p = NodeTranslator.from(createMeasurementPropertyHandler("w:tblInd", "tableIndent"));
25890
- const translator$o = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblLayout", "tableLayout", "w:type"));
25891
- const translator$n = NodeTranslator.from({
25968
+ const translator$q = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblCaption", "caption"));
25969
+ const translator$p = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblDescription", "description"));
25970
+ const translator$o = NodeTranslator.from(createMeasurementPropertyHandler("w:tblInd", "tableIndent"));
25971
+ const translator$n = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblLayout", "tableLayout", "w:type"));
25972
+ const translator$m = NodeTranslator.from({
25892
25973
  xmlName: "w:tblLook",
25893
25974
  sdNodeOrKeyName: "tblLook",
25894
25975
  attributes: ["w:firstColumn", "w:firstRow", "w:lastColumn", "w:lastRow", "w:noHBand", "w:noVBand"].map((attr) => createAttributeHandler(attr, null, parseBoolean, booleanToString)).concat([createAttributeHandler("w:val")]),
@@ -25900,16 +25981,16 @@ const translator$n = NodeTranslator.from({
25900
25981
  return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
25901
25982
  }
25902
25983
  });
25903
- const translator$m = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblOverlap", "overlap"));
25904
- const translator$l = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblStyle", "tableStyleId"));
25905
- const translator$k = NodeTranslator.from(
25984
+ const translator$l = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblOverlap", "overlap"));
25985
+ const translator$k = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblStyle", "tableStyleId"));
25986
+ const translator$j = NodeTranslator.from(
25906
25987
  createSingleAttrPropertyHandler("w:tblStyleColBandSize", "tableStyleColBandSize")
25907
25988
  );
25908
- const translator$j = NodeTranslator.from(
25989
+ const translator$i = NodeTranslator.from(
25909
25990
  createSingleAttrPropertyHandler("w:tblStyleRowBandSize", "tableStyleRowBandSize")
25910
25991
  );
25911
- const translator$i = NodeTranslator.from(createMeasurementPropertyHandler("w:tblW", "tableWidth"));
25912
- const translator$h = NodeTranslator.from({
25992
+ const translator$h = NodeTranslator.from(createMeasurementPropertyHandler("w:tblW", "tableWidth"));
25993
+ const translator$g = NodeTranslator.from({
25913
25994
  xmlName: "w:tblpPr",
25914
25995
  sdNodeOrKeyName: "floatingTableProperties",
25915
25996
  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))),
@@ -25921,19 +26002,6 @@ const translator$h = NodeTranslator.from({
25921
26002
  return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
25922
26003
  }
25923
26004
  });
25924
- const propertyTranslators$2 = [
25925
- translator$1q,
25926
- translator$Z,
25927
- translator$X,
25928
- translator$W,
25929
- translator$1o,
25930
- translator$1m,
25931
- translator$V,
25932
- translator$1k
25933
- ];
25934
- const translator$g = NodeTranslator.from(
25935
- createNestedPropertiesTranslator("w:tblBorders", "borders", propertyTranslators$2)
25936
- );
25937
26005
  const propertyTranslators$1 = [
25938
26006
  translator$1p,
25939
26007
  translator$Y,
@@ -25946,12 +26014,11 @@ const translator$f = NodeTranslator.from(
25946
26014
  createNestedPropertiesTranslator("w:tblCellMar", "cellMargins", propertyTranslators$1)
25947
26015
  );
25948
26016
  const propertyTranslators = [
25949
- translator$s,
26017
+ translator$r,
25950
26018
  translator$1D,
25951
26019
  translator$2b,
25952
- translator$r,
25953
- translator$D,
25954
26020
  translator$q,
26021
+ translator$C,
25955
26022
  translator$p,
25956
26023
  translator$o,
25957
26024
  translator$n,
@@ -25962,6 +26029,7 @@ const propertyTranslators = [
25962
26029
  translator$i,
25963
26030
  translator$h,
25964
26031
  translator$g,
26032
+ translator$H,
25965
26033
  translator$f
25966
26034
  ];
25967
26035
  const translator$e = NodeTranslator.from(
@@ -26221,8 +26289,7 @@ const encode$p = (params, encodedAttrs) => {
26221
26289
  }
26222
26290
  const borderProps = _processTableBorders(encodedAttrs.tableProperties.borders || {});
26223
26291
  const referencedStyles = _getReferencedTableStyles(encodedAttrs.tableStyleId, params) || {};
26224
- const rowBorders = { ...referencedStyles.rowBorders, ...borderProps.rowBorders };
26225
- encodedAttrs.borders = { ...referencedStyles.borders, ...borderProps.borders };
26292
+ encodedAttrs.borders = { ...referencedStyles.borders, ...borderProps };
26226
26293
  encodedAttrs.tableProperties.cellMargins = referencedStyles.cellMargins = {
26227
26294
  ...referencedStyles.cellMargins,
26228
26295
  ...encodedAttrs.tableProperties.cellMargins
@@ -26243,19 +26310,22 @@ const encode$p = (params, encodedAttrs) => {
26243
26310
  }
26244
26311
  const content = [];
26245
26312
  const totalColumns = columnWidths.length;
26313
+ const totalRows = rows.length;
26246
26314
  const activeRowSpans = totalColumns > 0 ? new Array(totalColumns).fill(0) : [];
26247
26315
  rows.forEach((row, rowIndex) => {
26248
- const result = translator$x.encode({
26316
+ const result = translator$w.encode({
26249
26317
  ...params,
26250
26318
  path: [...params.path || [], node],
26251
26319
  nodes: [row],
26252
26320
  extraParams: {
26253
26321
  row,
26254
26322
  table: node,
26255
- rowBorders,
26323
+ rowBorders: encodedAttrs.borders,
26256
26324
  columnWidths,
26257
26325
  activeRowSpans: activeRowSpans.slice(),
26258
26326
  rowIndex,
26327
+ totalRows,
26328
+ totalColumns,
26259
26329
  _referencedStyles: referencedStyles
26260
26330
  }
26261
26331
  });
@@ -26330,21 +26400,17 @@ const decode$r = (params, decodedAttrs) => {
26330
26400
  };
26331
26401
  function _processTableBorders(rawBorders) {
26332
26402
  const borders = {};
26333
- const rowBorders = {};
26334
26403
  Object.entries(rawBorders).forEach(([name, attributes]) => {
26335
26404
  const attrs = {};
26336
26405
  const color = attributes.color;
26337
26406
  const size = attributes.size;
26407
+ const val = attributes.val;
26338
26408
  if (color && color !== "auto") attrs["color"] = color.startsWith("#") ? color : `#${color}`;
26339
26409
  if (size && size !== "auto") attrs["size"] = eighthPointsToPixels(size);
26340
- const rowBorderNames = ["insideH", "insideV"];
26341
- if (rowBorderNames.includes(name)) rowBorders[name] = attrs;
26410
+ if (val) attrs["val"] = val;
26342
26411
  borders[name] = attrs;
26343
26412
  });
26344
- return {
26345
- borders,
26346
- rowBorders
26347
- };
26413
+ return borders;
26348
26414
  }
26349
26415
  function _getReferencedTableStyles(tableStyleReference, params) {
26350
26416
  if (!tableStyleReference) return null;
@@ -26384,9 +26450,8 @@ function _getReferencedTableStyles(tableStyleReference, params) {
26384
26450
  }
26385
26451
  const tableProperties = translator$e.encode({ ...params, nodes: [tblPr] });
26386
26452
  if (tableProperties) {
26387
- const { borders, rowBorders } = _processTableBorders(tableProperties.borders || {});
26388
- if (borders) stylesToReturn.borders = borders;
26389
- if (rowBorders) stylesToReturn.rowBorders = rowBorders;
26453
+ const borders = _processTableBorders(tableProperties.borders || {});
26454
+ if (borders || Object.keys(borders).length) stylesToReturn.borders = borders;
26390
26455
  const cellMargins = {};
26391
26456
  Object.entries(tableProperties.cellMargins || {}).forEach(([key, attrs]) => {
26392
26457
  if (attrs?.value != null) {
@@ -27235,7 +27300,7 @@ const handleDrawingNode = (params) => {
27235
27300
  return { nodes: [], consumed: 0 };
27236
27301
  }
27237
27302
  const translatorParams = { ...params, nodes: [node] };
27238
- const schemaNode = translator$u.encode(translatorParams);
27303
+ const schemaNode = translator$t.encode(translatorParams);
27239
27304
  const newNodes = schemaNode ? [schemaNode] : [];
27240
27305
  return { nodes: newNodes, consumed: 1 };
27241
27306
  };
@@ -27478,7 +27543,7 @@ const handleSdtNode = (params) => {
27478
27543
  if (nodes.length === 0 || nodes[0].name !== "w:sdt") {
27479
27544
  return { nodes: [], consumed: 0 };
27480
27545
  }
27481
- const result = translator$t.encode(params);
27546
+ const result = translator$s.encode(params);
27482
27547
  if (!result) {
27483
27548
  return { nodes: [], consumed: 0 };
27484
27549
  }
@@ -27506,12 +27571,12 @@ const translatorList = Array.from(
27506
27571
  translator$1s,
27507
27572
  translator$2n,
27508
27573
  translator$2m,
27509
- translator$s,
27574
+ translator$r,
27510
27575
  translator$9,
27511
27576
  translator$a,
27512
27577
  translator$1q,
27513
27578
  translator$2r,
27514
- translator$H,
27579
+ translator$G,
27515
27580
  translator$2c,
27516
27581
  translator$1I,
27517
27582
  translator$2h,
@@ -27519,7 +27584,7 @@ const translatorList = Array.from(
27519
27584
  translator$1R,
27520
27585
  translator$2,
27521
27586
  translator$1G,
27522
- translator$u,
27587
+ translator$t,
27523
27588
  translator$2i,
27524
27589
  translator$1T,
27525
27590
  translator$1Z,
@@ -27528,13 +27593,13 @@ const translatorList = Array.from(
27528
27593
  translator$Z,
27529
27594
  translator$1U,
27530
27595
  translator$1F,
27531
- translator$G,
27532
27596
  translator$F,
27597
+ translator$E,
27533
27598
  translator$d,
27534
27599
  translator$$,
27535
27600
  translator$L,
27536
27601
  translator$K,
27537
- translator$E,
27602
+ translator$D,
27538
27603
  translator$M,
27539
27604
  translator$2q,
27540
27605
  translator$12,
@@ -27576,7 +27641,7 @@ const translatorList = Array.from(
27576
27641
  translator$2f,
27577
27642
  translator$1S,
27578
27643
  translator$1m,
27579
- translator$t,
27644
+ translator$s,
27580
27645
  translator$20,
27581
27646
  translator$2b,
27582
27647
  translator$27,
@@ -27594,23 +27659,23 @@ const translatorList = Array.from(
27594
27659
  translator$2p,
27595
27660
  translator$1b,
27596
27661
  translator$b,
27597
- translator$g,
27598
- translator$r,
27599
- translator$f,
27600
- translator$D,
27662
+ translator$H,
27601
27663
  translator$q,
27602
- translator$c,
27664
+ translator$f,
27603
27665
  translator$C,
27604
27666
  translator$p,
27667
+ translator$c,
27668
+ translator$B,
27605
27669
  translator$o,
27606
27670
  translator$n,
27607
27671
  translator$m,
27608
- translator$e,
27609
27672
  translator$l,
27673
+ translator$e,
27610
27674
  translator$k,
27611
27675
  translator$j,
27612
27676
  translator$i,
27613
27677
  translator$h,
27678
+ translator$g,
27614
27679
  translator$I,
27615
27680
  translator$R,
27616
27681
  translator$O,
@@ -27619,10 +27684,10 @@ const translatorList = Array.from(
27619
27684
  translator$10,
27620
27685
  translator$19,
27621
27686
  translator$T,
27622
- translator$x,
27687
+ translator$w,
27623
27688
  translator$S,
27624
- translator$B,
27625
- translator$y,
27689
+ translator$A,
27690
+ translator$x,
27626
27691
  translator$1a,
27627
27692
  translator$18,
27628
27693
  translator$17,
@@ -27633,13 +27698,13 @@ const translatorList = Array.from(
27633
27698
  translator$28,
27634
27699
  translator$_,
27635
27700
  translator$1X,
27636
- translator$A,
27637
27701
  translator$z,
27702
+ translator$y,
27638
27703
  translator$1P,
27639
27704
  translator$16,
27640
27705
  translator$15,
27641
- translator$w,
27642
27706
  translator$v,
27707
+ translator$u,
27643
27708
  commentRangeStartTranslator,
27644
27709
  commentRangeEndTranslator
27645
27710
  ])
@@ -27978,8 +28043,8 @@ function importCommentData({ docx, editor, converter }) {
27978
28043
  converter,
27979
28044
  path: [el]
27980
28045
  });
27981
- const { attrs } = parsedElements[0];
27982
- const paraId = attrs["w14:paraId"];
28046
+ const lastElement = parsedElements[parsedElements.length - 1];
28047
+ const paraId = lastElement?.attrs?.["w14:paraId"];
27983
28048
  return {
27984
28049
  commentId: internalId || v4(),
27985
28050
  importedId,
@@ -28022,7 +28087,11 @@ const generateCommentsWithExtendedData = ({ docx, comments }) => {
28022
28087
  if (!extendedDef) return { ...comment, isDone: comment.isDone ?? false };
28023
28088
  const { isDone, paraIdParent } = getExtendedDetails(extendedDef);
28024
28089
  let parentComment;
28025
- if (paraIdParent) parentComment = comments.find((c) => c.paraId === paraIdParent);
28090
+ if (paraIdParent) {
28091
+ parentComment = comments.find(
28092
+ (c) => c.paraId === paraIdParent || c.elements?.some((el) => el.attrs?.["w14:paraId"] === paraIdParent)
28093
+ );
28094
+ }
28026
28095
  const newComment = {
28027
28096
  ...comment,
28028
28097
  isDone: isDone ?? false,
@@ -29907,13 +29976,13 @@ function exportSchemaToJson(params) {
29907
29976
  text: translator$1,
29908
29977
  lineBreak: translator$2r,
29909
29978
  table: translator$b,
29910
- tableRow: translator$x,
29979
+ tableRow: translator$w,
29911
29980
  tableCell: translator$I,
29912
29981
  bookmarkStart: translator$a,
29913
29982
  bookmarkEnd: translator$9,
29914
- fieldAnnotation: translator$t,
29983
+ fieldAnnotation: translator$s,
29915
29984
  tab: translator$2p,
29916
- image: translator$u,
29985
+ image: translator$t,
29917
29986
  hardBreak: translator$2r,
29918
29987
  commentRangeStart: commentRangeStartTranslator,
29919
29988
  commentRangeEnd: commentRangeEndTranslator,
@@ -29925,10 +29994,10 @@ function exportSchemaToJson(params) {
29925
29994
  contentBlock: translator,
29926
29995
  vectorShape: translateVectorShape,
29927
29996
  shapeGroup: translateShapeGroup,
29928
- structuredContent: translator$t,
29929
- structuredContentBlock: translator$t,
29930
- documentPartObject: translator$t,
29931
- documentSection: translator$t,
29997
+ structuredContent: translator$s,
29998
+ structuredContentBlock: translator$s,
29999
+ documentPartObject: translator$s,
30000
+ documentSection: translator$s,
29932
30001
  "page-number": translator$4,
29933
30002
  "total-page-number": translator$3,
29934
30003
  pageReference: translator$6,
@@ -30938,7 +31007,7 @@ class SuperConverter {
30938
31007
  static getStoredSuperdocVersion(docx) {
30939
31008
  return SuperConverter.getStoredCustomProperty(docx, "SuperdocVersion");
30940
31009
  }
30941
- static setStoredSuperdocVersion(docx = this.convertedXml, version = "1.3.0-next.7") {
31010
+ static setStoredSuperdocVersion(docx = this.convertedXml, version = "1.3.0-next.9") {
30942
31011
  return SuperConverter.setStoredCustomProperty(docx, "SuperdocVersion", version, false);
30943
31012
  }
30944
31013
  /**