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