@harbour-enterprises/superdoc 1.3.0-next.6 → 1.3.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.
@@ -14552,6 +14552,9 @@
14552
14552
  columnIndex,
14553
14553
  columnWidth = null,
14554
14554
  allColumnWidths = [],
14555
+ rowIndex = 0,
14556
+ totalRows = 1,
14557
+ totalColumns,
14555
14558
  _referencedStyles
14556
14559
  }) {
14557
14560
  const { nodeListHandler } = params2;
@@ -14560,19 +14563,46 @@
14560
14563
  const tcPr = node2.elements.find((el) => el.name === "w:tcPr");
14561
14564
  const tableCellProperties = tcPr ? translator$J.encode({ ...params2, nodes: [tcPr] }) ?? {} : {};
14562
14565
  attributes["tableCellProperties"] = tableCellProperties;
14563
- if (rowBorders?.insideH) {
14564
- rowBorders["bottom"] = rowBorders.insideH;
14565
- delete rowBorders.insideH;
14566
- }
14567
- if (rowBorders?.insideV) {
14568
- rowBorders["right"] = rowBorders.insideV;
14569
- delete rowBorders?.insideV;
14570
- }
14571
- if (rowBorders) attributes["borders"] = { ...rowBorders };
14572
- const inlineBorders = processInlineCellBorders(tableCellProperties.borders, rowBorders);
14573
- if (inlineBorders) attributes["borders"] = Object.assign(attributes["borders"] || {}, inlineBorders);
14574
- const colspan = tableCellProperties.gridSpan;
14575
- if (colspan && !isNaN(parseInt(colspan, 10))) attributes["colspan"] = parseInt(colspan, 10);
14566
+ const effectiveTotalColumns = totalColumns ?? (allColumnWidths.length || 1);
14567
+ const effectiveTotalRows = totalRows ?? (table2?.elements?.filter((el) => el.name === "w:tr").length || 1);
14568
+ const colspan = parseInt(tableCellProperties.gridSpan || 1, 10);
14569
+ const isFirstRow = rowIndex === 0;
14570
+ const isLastRow = rowIndex === effectiveTotalRows - 1;
14571
+ const isFirstColumn = columnIndex === 0;
14572
+ const isLastColumn = columnIndex + colspan >= effectiveTotalColumns;
14573
+ const cellBorders = {};
14574
+ if (rowBorders) {
14575
+ if (rowBorders.top?.val === "none") {
14576
+ cellBorders.top = rowBorders.top;
14577
+ } else if (isFirstRow && rowBorders.top) {
14578
+ cellBorders.top = rowBorders.top;
14579
+ }
14580
+ if (rowBorders.bottom?.val === "none") {
14581
+ cellBorders.bottom = rowBorders.bottom;
14582
+ } else if (isLastRow && rowBorders.bottom) {
14583
+ cellBorders.bottom = rowBorders.bottom;
14584
+ }
14585
+ if (rowBorders.left?.val === "none") {
14586
+ cellBorders.left = rowBorders.left;
14587
+ } else if (isFirstColumn && rowBorders.left) {
14588
+ cellBorders.left = rowBorders.left;
14589
+ }
14590
+ if (rowBorders.right?.val === "none") {
14591
+ cellBorders.right = rowBorders.right;
14592
+ } else if (isLastColumn && rowBorders.right) {
14593
+ cellBorders.right = rowBorders.right;
14594
+ }
14595
+ if (!isLastRow && rowBorders.insideH) {
14596
+ cellBorders.bottom = rowBorders.insideH;
14597
+ }
14598
+ if (!isLastColumn && rowBorders.insideV) {
14599
+ cellBorders.right = rowBorders.insideV;
14600
+ }
14601
+ }
14602
+ attributes["borders"] = cellBorders;
14603
+ const inlineBorders = processInlineCellBorders(tableCellProperties.borders, cellBorders);
14604
+ if (inlineBorders) attributes["borders"] = Object.assign(attributes["borders"], inlineBorders);
14605
+ if (colspan > 1) attributes["colspan"] = colspan;
14576
14606
  let width = tableCellProperties.cellWidth?.value ? twipsToPixels$2(tableCellProperties.cellWidth?.value) : null;
14577
14607
  const widthType = tableCellProperties.cellWidth?.type;
14578
14608
  if (widthType) attributes["widthType"] = widthType;
@@ -14582,10 +14612,9 @@
14582
14612
  attributes["widthUnit"] = "px";
14583
14613
  const defaultColWidths = allColumnWidths;
14584
14614
  const hasDefaultColWidths = allColumnWidths && allColumnWidths.length > 0;
14585
- const colspanNum = parseInt(colspan || 1, 10);
14586
- if (colspanNum && colspanNum > 1 && hasDefaultColWidths) {
14615
+ if (colspan > 1 && hasDefaultColWidths) {
14587
14616
  let colwidth = [];
14588
- for (let i2 = 0; i2 < colspanNum; i2++) {
14617
+ for (let i2 = 0; i2 < colspan; i2++) {
14589
14618
  let colwidthValue = defaultColWidths[columnIndex + i2];
14590
14619
  let defaultColwidth = 100;
14591
14620
  if (typeof colwidthValue !== "undefined") {
@@ -14735,22 +14764,18 @@
14735
14764
  return ["bottom", "top", "left", "right"].reduce((acc, direction) => {
14736
14765
  const borderAttrs = borders[direction];
14737
14766
  const rowBorderAttrs = rowBorders[direction];
14738
- if (borderAttrs && borderAttrs["val"] !== "nil") {
14767
+ if (borderAttrs && borderAttrs["val"] !== "none") {
14739
14768
  const color2 = borderAttrs["color"];
14740
14769
  let size2 = borderAttrs["size"];
14741
14770
  if (size2) size2 = eighthPointsToPixels(size2);
14742
14771
  acc[direction] = { color: color2, size: size2, val: borderAttrs["val"] };
14743
14772
  return acc;
14744
14773
  }
14745
- if (borderAttrs && borderAttrs["val"] === "nil") {
14774
+ if (borderAttrs && borderAttrs["val"] === "none") {
14746
14775
  const border = Object.assign({}, rowBorderAttrs || {});
14747
- if (!Object.keys(border).length) {
14748
- return acc;
14749
- } else {
14750
- border["val"] = "none";
14751
- acc[direction] = border;
14752
- return acc;
14753
- }
14776
+ border["val"] = "none";
14777
+ acc[direction] = border;
14778
+ return acc;
14754
14779
  }
14755
14780
  return acc;
14756
14781
  }, {});
@@ -14886,6 +14911,9 @@
14886
14911
  columnIndex,
14887
14912
  columnWidth,
14888
14913
  columnWidths: allColumnWidths,
14914
+ rowIndex,
14915
+ totalRows,
14916
+ totalColumns,
14889
14917
  _referencedStyles
14890
14918
  } = params2.extraParams;
14891
14919
  const schemaNode = handleTableCellNode({
@@ -14897,6 +14925,9 @@
14897
14925
  columnIndex,
14898
14926
  columnWidth,
14899
14927
  allColumnWidths,
14928
+ rowIndex,
14929
+ totalRows,
14930
+ totalColumns,
14900
14931
  _referencedStyles
14901
14932
  });
14902
14933
  if (encodedAttrs && Object.keys(encodedAttrs).length) {
@@ -14920,13 +14951,26 @@
14920
14951
  attributes: validXmlAttributes$a
14921
14952
  };
14922
14953
  const translator$I = NodeTranslator.from(config$i);
14923
- const translator$H = NodeTranslator.from({
14954
+ const propertyTranslators$3 = [
14955
+ translator$1q,
14956
+ translator$Z,
14957
+ translator$X,
14958
+ translator$W,
14959
+ translator$1o,
14960
+ translator$1m,
14961
+ translator$V,
14962
+ translator$1k
14963
+ ];
14964
+ const translator$H = NodeTranslator.from(
14965
+ createNestedPropertiesTranslator("w:tblBorders", "borders", propertyTranslators$3)
14966
+ );
14967
+ const translator$G = NodeTranslator.from({
14924
14968
  xmlName: "w:cantSplit",
14925
14969
  sdNodeOrKeyName: "cantSplit",
14926
14970
  encode: ({ nodes }) => ["1", "true"].includes(nodes[0].attributes?.["w:val"] ?? "1"),
14927
14971
  decode: ({ node: node2 }) => node2.attrs?.cantSplit ? { attributes: {} } : void 0
14928
14972
  });
14929
- const translator$G = NodeTranslator.from(
14973
+ const translator$F = NodeTranslator.from(
14930
14974
  createSingleAttrPropertyHandler(
14931
14975
  "w:gridAfter",
14932
14976
  null,
@@ -14935,7 +14979,7 @@
14935
14979
  (v2) => integerToString(v2)
14936
14980
  )
14937
14981
  );
14938
- const translator$F = NodeTranslator.from(
14982
+ const translator$E = NodeTranslator.from(
14939
14983
  createSingleAttrPropertyHandler(
14940
14984
  "w:gridBefore",
14941
14985
  null,
@@ -14944,20 +14988,20 @@
14944
14988
  (v2) => integerToString(v2)
14945
14989
  )
14946
14990
  );
14947
- const translator$E = NodeTranslator.from({
14991
+ const translator$D = NodeTranslator.from({
14948
14992
  xmlName: "w:hidden",
14949
14993
  sdNodeOrKeyName: "hidden",
14950
14994
  encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
14951
14995
  decode: ({ node: node2 }) => node2.attrs.hidden ? { attributes: {} } : void 0
14952
14996
  });
14953
- const translator$D = NodeTranslator.from(createMeasurementPropertyHandler("w:tblCellSpacing", "tableCellSpacing"));
14954
- const translator$C = NodeTranslator.from({
14997
+ const translator$C = NodeTranslator.from(createMeasurementPropertyHandler("w:tblCellSpacing", "tableCellSpacing"));
14998
+ const translator$B = NodeTranslator.from({
14955
14999
  xmlName: "w:tblHeader",
14956
15000
  sdNodeOrKeyName: "repeatHeader",
14957
15001
  encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
14958
15002
  decode: ({ node: node2 }) => node2.attrs.repeatHeader ? { attributes: {} } : void 0
14959
15003
  });
14960
- const translator$B = NodeTranslator.from({
15004
+ const translator$A = NodeTranslator.from({
14961
15005
  xmlName: "w:trHeight",
14962
15006
  sdNodeOrKeyName: "rowHeight",
14963
15007
  encode: ({ nodes }) => {
@@ -14984,24 +15028,24 @@
14984
15028
  return Object.keys(heightAttrs).length > 0 ? { attributes: heightAttrs } : void 0;
14985
15029
  }
14986
15030
  });
14987
- const translator$A = NodeTranslator.from(createMeasurementPropertyHandler("w:wAfter"));
14988
- const translator$z = NodeTranslator.from(createMeasurementPropertyHandler("w:wBefore"));
14989
- const propertyTranslators$3 = [
14990
- translator$H,
15031
+ const translator$z = NodeTranslator.from(createMeasurementPropertyHandler("w:wAfter"));
15032
+ const translator$y = NodeTranslator.from(createMeasurementPropertyHandler("w:wBefore"));
15033
+ const propertyTranslators$2 = [
15034
+ translator$G,
14991
15035
  translator$1I,
14992
15036
  translator$1G,
14993
- translator$G,
14994
15037
  translator$F,
14995
15038
  translator$E,
14996
- translator$1D,
14997
15039
  translator$D,
15040
+ translator$1D,
14998
15041
  translator$C,
14999
15042
  translator$B,
15000
15043
  translator$A,
15001
- translator$z
15044
+ translator$z,
15045
+ translator$y
15002
15046
  ];
15003
- const translator$y = NodeTranslator.from(
15004
- createNestedPropertiesTranslator("w:trPr", "tableRowProperties", propertyTranslators$3, {
15047
+ const translator$x = NodeTranslator.from(
15048
+ createNestedPropertiesTranslator("w:trPr", "tableRowProperties", propertyTranslators$2, {
15005
15049
  cantSplit: false,
15006
15050
  hidden: false,
15007
15051
  repeatHeader: false
@@ -15079,7 +15123,7 @@
15079
15123
  let tableRowProperties = {};
15080
15124
  const tPr = row2.elements.find((el) => el.name === "w:trPr");
15081
15125
  if (tPr) {
15082
- tableRowProperties = translator$y.encode({
15126
+ tableRowProperties = translator$x.encode({
15083
15127
  ...params2,
15084
15128
  nodes: [tPr]
15085
15129
  });
@@ -15089,6 +15133,12 @@
15089
15133
  encodedAttrs["tableRowProperties"] = Object.freeze(tableRowProperties);
15090
15134
  encodedAttrs["rowHeight"] = twipsToPixels$2(tableRowProperties["rowHeight"]?.value);
15091
15135
  encodedAttrs["cantSplit"] = tableRowProperties["cantSplit"];
15136
+ const baseBorders = params2.extraParams?.rowBorders;
15137
+ const rowTableBorders = getRowTableBorders({
15138
+ params: params2,
15139
+ row: row2,
15140
+ baseBorders
15141
+ });
15092
15142
  const { columnWidths: gridColumnWidths, activeRowSpans = [] } = params2.extraParams;
15093
15143
  const totalColumns = Array.isArray(gridColumnWidths) ? gridColumnWidths.length : 0;
15094
15144
  const pendingRowSpans = Array.isArray(activeRowSpans) ? activeRowSpans.slice() : [];
@@ -15121,6 +15171,10 @@
15121
15171
  path: [...params2.path || [], node2],
15122
15172
  extraParams: {
15123
15173
  ...params2.extraParams,
15174
+ rowBorders: {
15175
+ ...baseBorders,
15176
+ ...rowTableBorders
15177
+ },
15124
15178
  node: node2,
15125
15179
  columnIndex: startColumn,
15126
15180
  columnWidth
@@ -15150,6 +15204,33 @@
15150
15204
  };
15151
15205
  return newNode;
15152
15206
  };
15207
+ function getRowTableBorders({ params: params2, row: row2, baseBorders }) {
15208
+ const tblPrEx = row2?.elements?.find?.((el) => el.name === "w:tblPrEx");
15209
+ const tblBorders = tblPrEx?.elements?.find?.((el) => el.name === "w:tblBorders");
15210
+ if (!tblBorders) {
15211
+ return baseBorders;
15212
+ }
15213
+ const rawOverrides = translator$H.encode({ ...params2, nodes: [tblBorders] }) || {};
15214
+ const overrides = processRawTableBorders(rawOverrides);
15215
+ if (!Object.keys(overrides).length) {
15216
+ return baseBorders;
15217
+ }
15218
+ return { ...baseBorders || {}, ...overrides };
15219
+ }
15220
+ function processRawTableBorders(rawBorders) {
15221
+ const borders = {};
15222
+ Object.entries(rawBorders || {}).forEach(([name, attributes]) => {
15223
+ const attrs = {};
15224
+ const color2 = attributes?.color;
15225
+ const size2 = attributes?.size;
15226
+ const val = attributes?.val;
15227
+ if (color2 && color2 !== "auto") attrs.color = color2.startsWith("#") ? color2 : `#${color2}`;
15228
+ if (size2 != null && size2 !== "auto") attrs.size = eighthPointsToPixels(size2);
15229
+ if (val) attrs.val = val;
15230
+ borders[name] = attrs;
15231
+ });
15232
+ return borders;
15233
+ }
15153
15234
  const decode$y = (params2, decodedAttrs) => {
15154
15235
  const { node: node2 } = params2;
15155
15236
  const cells = node2.content || [];
@@ -15190,7 +15271,7 @@
15190
15271
  }
15191
15272
  }
15192
15273
  tableRowProperties["cantSplit"] = node2.attrs["cantSplit"];
15193
- const trPr = translator$y.decode({
15274
+ const trPr = translator$x.decode({
15194
15275
  ...params2,
15195
15276
  node: { ...node2, attrs: { ...node2.attrs, tableRowProperties } }
15196
15277
  });
@@ -15210,7 +15291,7 @@
15210
15291
  decode: decode$y,
15211
15292
  attributes: validXmlAttributes$9
15212
15293
  };
15213
- const translator$x = NodeTranslator.from(config$h);
15294
+ const translator$w = NodeTranslator.from(config$h);
15214
15295
  function parseTagValueJSON(json) {
15215
15296
  if (typeof json !== "string") {
15216
15297
  return {};
@@ -30436,7 +30517,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
30436
30517
  decode: decode$x,
30437
30518
  attributes: validXmlAttributes$8
30438
30519
  };
30439
- const translator$w = NodeTranslator.from(config$g);
30520
+ const translator$v = NodeTranslator.from(config$g);
30440
30521
  function handleInlineNode(params2) {
30441
30522
  const { node: node2 } = params2.extraParams;
30442
30523
  if (node2.name !== "wp:inline") {
@@ -30490,7 +30571,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
30490
30571
  decode: decode$w,
30491
30572
  attributes: validXmlAttributes$7
30492
30573
  };
30493
- const translator$v = NodeTranslator.from(config$f);
30574
+ const translator$u = NodeTranslator.from(config$f);
30494
30575
  const XML_NODE_NAME$f = "w:drawing";
30495
30576
  const SD_NODE_NAME$d = [];
30496
30577
  const validXmlAttributes$6 = [];
@@ -30498,8 +30579,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
30498
30579
  const nodes = params2.nodes;
30499
30580
  const node2 = nodes[0];
30500
30581
  const translatorByChildName = {
30501
- "wp:anchor": translator$w,
30502
- "wp:inline": translator$v
30582
+ "wp:anchor": translator$v,
30583
+ "wp:inline": translator$u
30503
30584
  };
30504
30585
  const result = (node2.elements || []).reduce((acc, child) => {
30505
30586
  if (acc) return acc;
@@ -30522,7 +30603,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
30522
30603
  if (!node2 || !node2.type) {
30523
30604
  return null;
30524
30605
  }
30525
- const childTranslator = node2.attrs.isAnchor ? translator$w : translator$v;
30606
+ const childTranslator = node2.attrs.isAnchor ? translator$v : translator$u;
30526
30607
  const resultNode = childTranslator.decode(params2);
30527
30608
  return wrapTextInRun(
30528
30609
  {
@@ -30540,7 +30621,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
30540
30621
  decode: decode$v,
30541
30622
  attributes: validXmlAttributes$6
30542
30623
  };
30543
- const translator$u = NodeTranslator.from(config$e);
30624
+ const translator$t = NodeTranslator.from(config$e);
30544
30625
  function getTextNodeForExport(text2, marks, params2) {
30545
30626
  const hasLeadingOrTrailingSpace = /^\s|\s$/.test(text2);
30546
30627
  const space = hasLeadingOrTrailingSpace ? "preserve" : null;
@@ -30948,7 +31029,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
30948
31029
  return getTextNodeForExport(attrs.displayLabel, [...marks, ...marksFromAttrs], params2);
30949
31030
  }
30950
31031
  function prepareImageAnnotation(params2, imageSize) {
30951
- return translator$u.decode({
31032
+ return translator$t.decode({
30952
31033
  ...params2,
30953
31034
  imageSize
30954
31035
  });
@@ -31410,7 +31491,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
31410
31491
  decode: decode$u,
31411
31492
  attributes: validXmlAttributes$5
31412
31493
  };
31413
- const translator$t = NodeTranslator.from(config$d);
31494
+ const translator$s = NodeTranslator.from(config$d);
31414
31495
  function preProcessVerticalMergeCells(table2, { editorSchema }) {
31415
31496
  if (!table2 || !Array.isArray(table2.content)) {
31416
31497
  return table2;
@@ -31451,17 +31532,17 @@ Please report this to https://github.com/markedjs/marked.`, e) {
31451
31532
  }
31452
31533
  return table2;
31453
31534
  }
31454
- const translator$s = NodeTranslator.from({
31535
+ const translator$r = NodeTranslator.from({
31455
31536
  xmlName: "w:bidiVisual",
31456
31537
  sdNodeOrKeyName: "rightToLeft",
31457
31538
  encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
31458
31539
  decode: ({ node: node2 }) => node2.attrs.rightToLeft ? { attributes: {} } : void 0
31459
31540
  });
31460
- const translator$r = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblCaption", "caption"));
31461
- const translator$q = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblDescription", "description"));
31462
- const translator$p = NodeTranslator.from(createMeasurementPropertyHandler("w:tblInd", "tableIndent"));
31463
- const translator$o = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblLayout", "tableLayout", "w:type"));
31464
- const translator$n = NodeTranslator.from({
31541
+ const translator$q = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblCaption", "caption"));
31542
+ const translator$p = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblDescription", "description"));
31543
+ const translator$o = NodeTranslator.from(createMeasurementPropertyHandler("w:tblInd", "tableIndent"));
31544
+ const translator$n = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblLayout", "tableLayout", "w:type"));
31545
+ const translator$m = NodeTranslator.from({
31465
31546
  xmlName: "w:tblLook",
31466
31547
  sdNodeOrKeyName: "tblLook",
31467
31548
  attributes: ["w:firstColumn", "w:firstRow", "w:lastColumn", "w:lastRow", "w:noHBand", "w:noVBand"].map((attr) => createAttributeHandler(attr, null, parseBoolean, booleanToString)).concat([createAttributeHandler("w:val")]),
@@ -31473,16 +31554,16 @@ Please report this to https://github.com/markedjs/marked.`, e) {
31473
31554
  return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
31474
31555
  }
31475
31556
  });
31476
- const translator$m = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblOverlap", "overlap"));
31477
- const translator$l = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblStyle", "tableStyleId"));
31478
- const translator$k = NodeTranslator.from(
31557
+ const translator$l = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblOverlap", "overlap"));
31558
+ const translator$k = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblStyle", "tableStyleId"));
31559
+ const translator$j = NodeTranslator.from(
31479
31560
  createSingleAttrPropertyHandler("w:tblStyleColBandSize", "tableStyleColBandSize")
31480
31561
  );
31481
- const translator$j = NodeTranslator.from(
31562
+ const translator$i = NodeTranslator.from(
31482
31563
  createSingleAttrPropertyHandler("w:tblStyleRowBandSize", "tableStyleRowBandSize")
31483
31564
  );
31484
- const translator$i = NodeTranslator.from(createMeasurementPropertyHandler("w:tblW", "tableWidth"));
31485
- const translator$h = NodeTranslator.from({
31565
+ const translator$h = NodeTranslator.from(createMeasurementPropertyHandler("w:tblW", "tableWidth"));
31566
+ const translator$g = NodeTranslator.from({
31486
31567
  xmlName: "w:tblpPr",
31487
31568
  sdNodeOrKeyName: "floatingTableProperties",
31488
31569
  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))),
@@ -31494,19 +31575,6 @@ Please report this to https://github.com/markedjs/marked.`, e) {
31494
31575
  return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
31495
31576
  }
31496
31577
  });
31497
- const propertyTranslators$2 = [
31498
- translator$1q,
31499
- translator$Z,
31500
- translator$X,
31501
- translator$W,
31502
- translator$1o,
31503
- translator$1m,
31504
- translator$V,
31505
- translator$1k
31506
- ];
31507
- const translator$g = NodeTranslator.from(
31508
- createNestedPropertiesTranslator("w:tblBorders", "borders", propertyTranslators$2)
31509
- );
31510
31578
  const propertyTranslators$1 = [
31511
31579
  translator$1p,
31512
31580
  translator$Y,
@@ -31519,12 +31587,11 @@ Please report this to https://github.com/markedjs/marked.`, e) {
31519
31587
  createNestedPropertiesTranslator("w:tblCellMar", "cellMargins", propertyTranslators$1)
31520
31588
  );
31521
31589
  const propertyTranslators = [
31522
- translator$s,
31590
+ translator$r,
31523
31591
  translator$1D,
31524
31592
  translator$2b,
31525
- translator$r,
31526
- translator$D,
31527
31593
  translator$q,
31594
+ translator$C,
31528
31595
  translator$p,
31529
31596
  translator$o,
31530
31597
  translator$n,
@@ -31535,6 +31602,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
31535
31602
  translator$i,
31536
31603
  translator$h,
31537
31604
  translator$g,
31605
+ translator$H,
31538
31606
  translator$f
31539
31607
  ];
31540
31608
  const translator$e = NodeTranslator.from(
@@ -31794,8 +31862,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
31794
31862
  }
31795
31863
  const borderProps = _processTableBorders(encodedAttrs.tableProperties.borders || {});
31796
31864
  const referencedStyles = _getReferencedTableStyles(encodedAttrs.tableStyleId, params2) || {};
31797
- const rowBorders = { ...referencedStyles.rowBorders, ...borderProps.rowBorders };
31798
- encodedAttrs.borders = { ...referencedStyles.borders, ...borderProps.borders };
31865
+ encodedAttrs.borders = { ...referencedStyles.borders, ...borderProps };
31799
31866
  encodedAttrs.tableProperties.cellMargins = referencedStyles.cellMargins = {
31800
31867
  ...referencedStyles.cellMargins,
31801
31868
  ...encodedAttrs.tableProperties.cellMargins
@@ -31816,19 +31883,22 @@ Please report this to https://github.com/markedjs/marked.`, e) {
31816
31883
  }
31817
31884
  const content2 = [];
31818
31885
  const totalColumns = columnWidths.length;
31886
+ const totalRows = rows.length;
31819
31887
  const activeRowSpans = totalColumns > 0 ? new Array(totalColumns).fill(0) : [];
31820
31888
  rows.forEach((row2, rowIndex) => {
31821
- const result = translator$x.encode({
31889
+ const result = translator$w.encode({
31822
31890
  ...params2,
31823
31891
  path: [...params2.path || [], node2],
31824
31892
  nodes: [row2],
31825
31893
  extraParams: {
31826
31894
  row: row2,
31827
31895
  table: node2,
31828
- rowBorders,
31896
+ rowBorders: encodedAttrs.borders,
31829
31897
  columnWidths,
31830
31898
  activeRowSpans: activeRowSpans.slice(),
31831
31899
  rowIndex,
31900
+ totalRows,
31901
+ totalColumns,
31832
31902
  _referencedStyles: referencedStyles
31833
31903
  }
31834
31904
  });
@@ -31903,21 +31973,17 @@ Please report this to https://github.com/markedjs/marked.`, e) {
31903
31973
  };
31904
31974
  function _processTableBorders(rawBorders) {
31905
31975
  const borders = {};
31906
- const rowBorders = {};
31907
31976
  Object.entries(rawBorders).forEach(([name, attributes]) => {
31908
31977
  const attrs = {};
31909
31978
  const color2 = attributes.color;
31910
31979
  const size2 = attributes.size;
31980
+ const val = attributes.val;
31911
31981
  if (color2 && color2 !== "auto") attrs["color"] = color2.startsWith("#") ? color2 : `#${color2}`;
31912
31982
  if (size2 && size2 !== "auto") attrs["size"] = eighthPointsToPixels(size2);
31913
- const rowBorderNames = ["insideH", "insideV"];
31914
- if (rowBorderNames.includes(name)) rowBorders[name] = attrs;
31983
+ if (val) attrs["val"] = val;
31915
31984
  borders[name] = attrs;
31916
31985
  });
31917
- return {
31918
- borders,
31919
- rowBorders
31920
- };
31986
+ return borders;
31921
31987
  }
31922
31988
  function _getReferencedTableStyles(tableStyleReference, params2) {
31923
31989
  if (!tableStyleReference) return null;
@@ -31957,9 +32023,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
31957
32023
  }
31958
32024
  const tableProperties = translator$e.encode({ ...params2, nodes: [tblPr] });
31959
32025
  if (tableProperties) {
31960
- const { borders, rowBorders } = _processTableBorders(tableProperties.borders || {});
31961
- if (borders) stylesToReturn.borders = borders;
31962
- if (rowBorders) stylesToReturn.rowBorders = rowBorders;
32026
+ const borders = _processTableBorders(tableProperties.borders || {});
32027
+ if (borders || Object.keys(borders).length) stylesToReturn.borders = borders;
31963
32028
  const cellMargins = {};
31964
32029
  Object.entries(tableProperties.cellMargins || {}).forEach(([key2, attrs]) => {
31965
32030
  if (attrs?.value != null) {
@@ -32808,7 +32873,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
32808
32873
  return { nodes: [], consumed: 0 };
32809
32874
  }
32810
32875
  const translatorParams = { ...params2, nodes: [node2] };
32811
- const schemaNode = translator$u.encode(translatorParams);
32876
+ const schemaNode = translator$t.encode(translatorParams);
32812
32877
  const newNodes = schemaNode ? [schemaNode] : [];
32813
32878
  return { nodes: newNodes, consumed: 1 };
32814
32879
  };
@@ -33051,7 +33116,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
33051
33116
  if (nodes.length === 0 || nodes[0].name !== "w:sdt") {
33052
33117
  return { nodes: [], consumed: 0 };
33053
33118
  }
33054
- const result = translator$t.encode(params2);
33119
+ const result = translator$s.encode(params2);
33055
33120
  if (!result) {
33056
33121
  return { nodes: [], consumed: 0 };
33057
33122
  }
@@ -33079,12 +33144,12 @@ Please report this to https://github.com/markedjs/marked.`, e) {
33079
33144
  translator$1s,
33080
33145
  translator$2n,
33081
33146
  translator$2m,
33082
- translator$s,
33147
+ translator$r,
33083
33148
  translator$9,
33084
33149
  translator$a,
33085
33150
  translator$1q,
33086
33151
  translator$2r,
33087
- translator$H,
33152
+ translator$G,
33088
33153
  translator$2c,
33089
33154
  translator$1I,
33090
33155
  translator$2h,
@@ -33092,7 +33157,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
33092
33157
  translator$1R,
33093
33158
  translator$2,
33094
33159
  translator$1G,
33095
- translator$u,
33160
+ translator$t,
33096
33161
  translator$2i,
33097
33162
  translator$1T,
33098
33163
  translator$1Z,
@@ -33101,13 +33166,13 @@ Please report this to https://github.com/markedjs/marked.`, e) {
33101
33166
  translator$Z,
33102
33167
  translator$1U,
33103
33168
  translator$1F,
33104
- translator$G,
33105
33169
  translator$F,
33170
+ translator$E,
33106
33171
  translator$d,
33107
33172
  translator$$,
33108
33173
  translator$L,
33109
33174
  translator$K,
33110
- translator$E,
33175
+ translator$D,
33111
33176
  translator$M,
33112
33177
  translator$2q,
33113
33178
  translator$12,
@@ -33149,7 +33214,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
33149
33214
  translator$2f,
33150
33215
  translator$1S,
33151
33216
  translator$1m,
33152
- translator$t,
33217
+ translator$s,
33153
33218
  translator$20,
33154
33219
  translator$2b,
33155
33220
  translator$27,
@@ -33167,23 +33232,23 @@ Please report this to https://github.com/markedjs/marked.`, e) {
33167
33232
  translator$2p,
33168
33233
  translator$1b,
33169
33234
  translator$b,
33170
- translator$g,
33171
- translator$r,
33172
- translator$f,
33173
- translator$D,
33235
+ translator$H,
33174
33236
  translator$q,
33175
- translator$c,
33237
+ translator$f,
33176
33238
  translator$C,
33177
33239
  translator$p,
33240
+ translator$c,
33241
+ translator$B,
33178
33242
  translator$o,
33179
33243
  translator$n,
33180
33244
  translator$m,
33181
- translator$e,
33182
33245
  translator$l,
33246
+ translator$e,
33183
33247
  translator$k,
33184
33248
  translator$j,
33185
33249
  translator$i,
33186
33250
  translator$h,
33251
+ translator$g,
33187
33252
  translator$I,
33188
33253
  translator$R,
33189
33254
  translator$O,
@@ -33192,10 +33257,10 @@ Please report this to https://github.com/markedjs/marked.`, e) {
33192
33257
  translator$10,
33193
33258
  translator$19,
33194
33259
  translator$T,
33195
- translator$x,
33260
+ translator$w,
33196
33261
  translator$S,
33197
- translator$B,
33198
- translator$y,
33262
+ translator$A,
33263
+ translator$x,
33199
33264
  translator$1a,
33200
33265
  translator$18,
33201
33266
  translator$17,
@@ -33206,13 +33271,13 @@ Please report this to https://github.com/markedjs/marked.`, e) {
33206
33271
  translator$28,
33207
33272
  translator$_,
33208
33273
  translator$1X,
33209
- translator$A,
33210
33274
  translator$z,
33275
+ translator$y,
33211
33276
  translator$1P,
33212
33277
  translator$16,
33213
33278
  translator$15,
33214
- translator$w,
33215
33279
  translator$v,
33280
+ translator$u,
33216
33281
  commentRangeStartTranslator,
33217
33282
  commentRangeEndTranslator
33218
33283
  ])
@@ -33551,8 +33616,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
33551
33616
  converter,
33552
33617
  path: [el]
33553
33618
  });
33554
- const { attrs } = parsedElements[0];
33555
- const paraId = attrs["w14:paraId"];
33619
+ const lastElement = parsedElements[parsedElements.length - 1];
33620
+ const paraId = lastElement?.attrs?.["w14:paraId"];
33556
33621
  return {
33557
33622
  commentId: internalId || v4(),
33558
33623
  importedId,
@@ -33595,7 +33660,11 @@ Please report this to https://github.com/markedjs/marked.`, e) {
33595
33660
  if (!extendedDef) return { ...comment2, isDone: comment2.isDone ?? false };
33596
33661
  const { isDone, paraIdParent } = getExtendedDetails(extendedDef);
33597
33662
  let parentComment;
33598
- if (paraIdParent) parentComment = comments.find((c2) => c2.paraId === paraIdParent);
33663
+ if (paraIdParent) {
33664
+ parentComment = comments.find(
33665
+ (c2) => c2.paraId === paraIdParent || c2.elements?.some((el) => el.attrs?.["w14:paraId"] === paraIdParent)
33666
+ );
33667
+ }
33599
33668
  const newComment = {
33600
33669
  ...comment2,
33601
33670
  isDone: isDone ?? false,
@@ -35335,13 +35404,13 @@ Please report this to https://github.com/markedjs/marked.`, e) {
35335
35404
  text: translator$1,
35336
35405
  lineBreak: translator$2r,
35337
35406
  table: translator$b,
35338
- tableRow: translator$x,
35407
+ tableRow: translator$w,
35339
35408
  tableCell: translator$I,
35340
35409
  bookmarkStart: translator$a,
35341
35410
  bookmarkEnd: translator$9,
35342
- fieldAnnotation: translator$t,
35411
+ fieldAnnotation: translator$s,
35343
35412
  tab: translator$2p,
35344
- image: translator$u,
35413
+ image: translator$t,
35345
35414
  hardBreak: translator$2r,
35346
35415
  commentRangeStart: commentRangeStartTranslator,
35347
35416
  commentRangeEnd: commentRangeEndTranslator,
@@ -35353,10 +35422,10 @@ Please report this to https://github.com/markedjs/marked.`, e) {
35353
35422
  contentBlock: translator,
35354
35423
  vectorShape: translateVectorShape,
35355
35424
  shapeGroup: translateShapeGroup,
35356
- structuredContent: translator$t,
35357
- structuredContentBlock: translator$t,
35358
- documentPartObject: translator$t,
35359
- documentSection: translator$t,
35425
+ structuredContent: translator$s,
35426
+ structuredContentBlock: translator$s,
35427
+ documentPartObject: translator$s,
35428
+ documentSection: translator$s,
35360
35429
  "page-number": translator$4,
35361
35430
  "total-page-number": translator$3,
35362
35431
  pageReference: translator$6,
@@ -36366,7 +36435,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
36366
36435
  static getStoredSuperdocVersion(docx) {
36367
36436
  return SuperConverter.getStoredCustomProperty(docx, "SuperdocVersion");
36368
36437
  }
36369
- static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.3.0-next.6") {
36438
+ static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.3.0-next.8") {
36370
36439
  return SuperConverter.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
36371
36440
  }
36372
36441
  /**
@@ -62076,7 +62145,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
62076
62145
  return false;
62077
62146
  }
62078
62147
  };
62079
- const summaryVersion = "1.3.0-next.6";
62148
+ const summaryVersion = "1.3.0-next.8";
62080
62149
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
62081
62150
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
62082
62151
  function mapAttributes(attrs) {
@@ -64710,7 +64779,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
64710
64779
  * Process collaboration migrations
64711
64780
  */
64712
64781
  processCollaborationMigrations() {
64713
- console.debug("[checkVersionMigrations] Current editor version", "1.3.0-next.6");
64782
+ console.debug("[checkVersionMigrations] Current editor version", "1.3.0-next.8");
64714
64783
  if (!this.options.ydoc) return;
64715
64784
  const metaMap = this.options.ydoc.getMap("meta");
64716
64785
  let docVersion = metaMap.get("version");
@@ -72296,7 +72365,28 @@ ${l}
72296
72365
  section: kind,
72297
72366
  pageNumberText: page.numberText
72298
72367
  };
72299
- data.fragments.forEach((fragment) => {
72368
+ const behindDocFragments = [];
72369
+ const normalFragments = [];
72370
+ for (const fragment of data.fragments) {
72371
+ const isBehindDoc = (fragment.kind === "image" || fragment.kind === "drawing") && "zIndex" in fragment && fragment.zIndex === 0;
72372
+ if (isBehindDoc) {
72373
+ behindDocFragments.push(fragment);
72374
+ } else {
72375
+ normalFragments.push(fragment);
72376
+ }
72377
+ }
72378
+ const behindDocSelector = `[data-behind-doc-section="${kind}"]`;
72379
+ pageEl.querySelectorAll(behindDocSelector).forEach((el) => el.remove());
72380
+ behindDocFragments.forEach((fragment) => {
72381
+ const fragEl = this.renderFragment(fragment, context);
72382
+ const pageY = effectiveOffset + fragment.y + (kind === "footer" ? footerYOffset : 0);
72383
+ fragEl.style.top = `${pageY}px`;
72384
+ fragEl.style.left = `${marginLeft + fragment.x}px`;
72385
+ fragEl.style.zIndex = "0";
72386
+ fragEl.dataset.behindDocSection = kind;
72387
+ pageEl.insertBefore(fragEl, pageEl.firstChild);
72388
+ });
72389
+ normalFragments.forEach((fragment) => {
72300
72390
  const fragEl = this.renderFragment(fragment, context);
72301
72391
  if (footerYOffset > 0) {
72302
72392
  const currentTop = parseFloat(fragEl.style.top) || fragment.y;
@@ -80623,10 +80713,6 @@ ${l}
80623
80713
  if (!Number.isFinite(height) || height <= 0) {
80624
80714
  return { pages: [], height: 0 };
80625
80715
  }
80626
- const overflowBase = typeof constraints.overflowBaseHeight === "number" && Number.isFinite(constraints.overflowBaseHeight) && constraints.overflowBaseHeight > 0 ? constraints.overflowBaseHeight : height;
80627
- const maxBehindDocOverflow = Math.max(192, overflowBase * 4);
80628
- const minBehindDocY = -maxBehindDocOverflow;
80629
- const maxBehindDocY = height + maxBehindDocOverflow;
80630
80716
  const marginLeft = constraints.margins?.left ?? 0;
80631
80717
  const transformedBlocks = marginLeft > 0 ? blocks2.map((block) => {
80632
80718
  const hasPageRelativeAnchor = (block.kind === "image" || block.kind === "drawing") && block.anchor?.hRelativeFrom === "page" && block.anchor.offsetH != null;
@@ -80665,7 +80751,7 @@ ${l}
80665
80751
  );
80666
80752
  }
80667
80753
  const anchoredBlock = block;
80668
- if (anchoredBlock.anchor?.behindDoc && (fragment.y < minBehindDocY || fragment.y > maxBehindDocY)) {
80754
+ if (anchoredBlock.anchor?.behindDoc) {
80669
80755
  continue;
80670
80756
  }
80671
80757
  }
@@ -91527,6 +91613,12 @@ ${l}
91527
91613
  run2.letterSpacing = defaults2.letterSpacing;
91528
91614
  }
91529
91615
  };
91616
+ const applyInlineRunProperties = (run2, runProperties) => {
91617
+ if (!runProperties) return;
91618
+ if (runProperties?.letterSpacing != null) {
91619
+ run2.letterSpacing = twipsToPx$1(runProperties.letterSpacing);
91620
+ }
91621
+ };
91530
91622
  function paragraphToFlowBlocks$1(para, nextBlockId, positions, defaultFont, defaultSize, styleContext, listCounterContext, trackedChanges, bookmarks, hyperlinkConfig = DEFAULT_HYPERLINK_CONFIG$1, themeColors, converters, converterContext) {
91531
91623
  const baseBlockId = nextBlockId("paragraph");
91532
91624
  const paragraphProps = typeof para.attrs?.paragraphProperties === "object" && para.attrs.paragraphProperties !== null ? para.attrs.paragraphProperties : {};
@@ -91679,7 +91771,7 @@ ${l}
91679
91771
  runStyleId
91680
91772
  });
91681
91773
  };
91682
- const visitNode = (node2, inheritedMarks = [], activeSdt, activeRunStyleId = null) => {
91774
+ const visitNode = (node2, inheritedMarks = [], activeSdt, activeRunStyleId = null, activeRunProperties) => {
91683
91775
  if (node2.type === "text" && node2.text) {
91684
91776
  const run2 = textNodeToRun(
91685
91777
  node2,
@@ -91695,6 +91787,7 @@ ${l}
91695
91787
  const inlineStyleId = getInlineStyleId(inheritedMarks);
91696
91788
  applyRunStyles2(run2, inlineStyleId, activeRunStyleId);
91697
91789
  applyBaseRunDefaults(run2, baseRunDefaults, defaultFont, defaultSize);
91790
+ applyInlineRunProperties(run2, activeRunProperties);
91698
91791
  applyMarksToRun(
91699
91792
  run2,
91700
91793
  [...node2.marks ?? [], ...inheritedMarks ?? []],
@@ -91707,14 +91800,16 @@ ${l}
91707
91800
  }
91708
91801
  if (node2.type === "run" && Array.isArray(node2.content)) {
91709
91802
  const mergedMarks = [...node2.marks ?? [], ...inheritedMarks ?? []];
91710
- const nextRunStyleId = extractRunStyleId(node2.attrs?.runProperties) ?? activeRunStyleId;
91711
- node2.content.forEach((child) => visitNode(child, mergedMarks, activeSdt, nextRunStyleId));
91803
+ const runProperties = typeof node2.attrs?.runProperties === "object" && node2.attrs.runProperties !== null ? node2.attrs.runProperties : null;
91804
+ const nextRunStyleId = extractRunStyleId(runProperties) ?? activeRunStyleId;
91805
+ const nextRunProperties = runProperties ?? activeRunProperties;
91806
+ node2.content.forEach((child) => visitNode(child, mergedMarks, activeSdt, nextRunStyleId, nextRunProperties));
91712
91807
  return;
91713
91808
  }
91714
91809
  if (node2.type === "structuredContent" && Array.isArray(node2.content)) {
91715
91810
  const inlineMetadata = resolveNodeSdtMetadata(node2, "structuredContent");
91716
91811
  const nextSdt = inlineMetadata ?? activeSdt;
91717
- node2.content.forEach((child) => visitNode(child, inheritedMarks, nextSdt, activeRunStyleId));
91812
+ node2.content.forEach((child) => visitNode(child, inheritedMarks, nextSdt, activeRunStyleId, activeRunProperties));
91718
91813
  return;
91719
91814
  }
91720
91815
  if (node2.type === "fieldAnnotation") {
@@ -91768,6 +91863,7 @@ ${l}
91768
91863
  const inlineStyleId = getInlineStyleId(mergedMarks);
91769
91864
  applyRunStyles2(tokenRun, inlineStyleId, activeRunStyleId);
91770
91865
  applyBaseRunDefaults(tokenRun, baseRunDefaults, defaultFont, defaultSize);
91866
+ applyInlineRunProperties(tokenRun, activeRunProperties);
91771
91867
  if (pageRefPos) {
91772
91868
  tokenRun.pmStart = pageRefPos.start;
91773
91869
  tokenRun.pmEnd = pageRefPos.end;
@@ -91782,7 +91878,9 @@ ${l}
91782
91878
  }
91783
91879
  currentRuns.push(tokenRun);
91784
91880
  } else if (Array.isArray(node2.content)) {
91785
- node2.content.forEach((child) => visitNode(child, mergedMarks, activeSdt));
91881
+ node2.content.forEach(
91882
+ (child) => visitNode(child, mergedMarks, activeSdt, activeRunStyleId, activeRunProperties)
91883
+ );
91786
91884
  }
91787
91885
  return;
91788
91886
  }
@@ -91796,7 +91894,9 @@ ${l}
91796
91894
  }
91797
91895
  }
91798
91896
  if (Array.isArray(node2.content)) {
91799
- node2.content.forEach((child) => visitNode(child, inheritedMarks, activeSdt));
91897
+ node2.content.forEach(
91898
+ (child) => visitNode(child, inheritedMarks, activeSdt, activeRunStyleId, activeRunProperties)
91899
+ );
91800
91900
  }
91801
91901
  return;
91802
91902
  }
@@ -91848,6 +91948,7 @@ ${l}
91848
91948
  runStyleId: activeRunStyleId,
91849
91949
  mergedMarksCount: mergedMarks.length
91850
91950
  });
91951
+ applyInlineRunProperties(tokenRun, activeRunProperties);
91851
91952
  currentRuns.push(tokenRun);
91852
91953
  }
91853
91954
  return;
@@ -95024,6 +95125,7 @@ ${l}
95024
95125
  let lastFontSize = 12;
95025
95126
  let tabStopCursor = 0;
95026
95127
  let pendingTabAlignment = null;
95128
+ let pendingRunSpacing = 0;
95027
95129
  let lastAppliedTabAlign = null;
95028
95130
  const warnedTabVals = /* @__PURE__ */ new Set();
95029
95131
  let activeTabGroup = null;
@@ -95034,6 +95136,10 @@ ${l}
95034
95136
  }
95035
95137
  return true;
95036
95138
  };
95139
+ const resolveBoundarySpacing = (lineWidth, isRunStart, run2) => {
95140
+ if (lineWidth <= 0) return 0;
95141
+ return isRunStart ? pendingRunSpacing : run2.letterSpacing ?? 0;
95142
+ };
95037
95143
  const alignPendingTabForWidth = (segmentWidth, beforeDecimalWidth) => {
95038
95144
  if (!pendingTabAlignment || !currentLine) return void 0;
95039
95145
  if (segmentWidth < 0) {
@@ -95161,6 +95267,7 @@ ${l}
95161
95267
  tabStopCursor = 0;
95162
95268
  pendingTabAlignment = null;
95163
95269
  lastAppliedTabAlign = null;
95270
+ pendingRunSpacing = 0;
95164
95271
  continue;
95165
95272
  }
95166
95273
  if (isLineBreakRun(run2)) {
@@ -95203,6 +95310,7 @@ ${l}
95203
95310
  tabStopCursor = 0;
95204
95311
  pendingTabAlignment = null;
95205
95312
  lastAppliedTabAlign = null;
95313
+ pendingRunSpacing = 0;
95206
95314
  continue;
95207
95315
  }
95208
95316
  if (isTabRun(run2)) {
@@ -95268,6 +95376,7 @@ ${l}
95268
95376
  } else {
95269
95377
  pendingTabAlignment = null;
95270
95378
  }
95379
+ pendingRunSpacing = 0;
95271
95380
  continue;
95272
95381
  }
95273
95382
  if (isImageRun(run2)) {
@@ -95306,6 +95415,7 @@ ${l}
95306
95415
  }
95307
95416
  ]
95308
95417
  };
95418
+ pendingRunSpacing = 0;
95309
95419
  if (activeTabGroup && runIndex + 1 >= activeTabGroup.measure.endRunIndex) {
95310
95420
  activeTabGroup = null;
95311
95421
  }
@@ -95367,6 +95477,7 @@ ${l}
95367
95477
  currentLine.width = roundValue(tabAlign.target);
95368
95478
  }
95369
95479
  lastAppliedTabAlign = null;
95480
+ pendingRunSpacing = 0;
95370
95481
  continue;
95371
95482
  }
95372
95483
  if (isFieldAnnotationRun(run2)) {
@@ -95406,6 +95517,7 @@ ${l}
95406
95517
  }
95407
95518
  ]
95408
95519
  };
95520
+ pendingRunSpacing = 0;
95409
95521
  continue;
95410
95522
  }
95411
95523
  if (currentLine.width + annotationWidth > currentLine.maxWidth && currentLine.width > 0) {
@@ -95458,9 +95570,11 @@ ${l}
95458
95570
  currentLine.width = roundValue(tabAlign.target);
95459
95571
  }
95460
95572
  lastAppliedTabAlign = null;
95573
+ pendingRunSpacing = 0;
95461
95574
  continue;
95462
95575
  }
95463
95576
  if (!("text" in run2) || !("fontSize" in run2)) {
95577
+ pendingRunSpacing = 0;
95464
95578
  continue;
95465
95579
  }
95466
95580
  lastFontSize = run2.fontSize;
@@ -95471,6 +95585,7 @@ ${l}
95471
95585
  const segment = tabSegments[segmentIndex];
95472
95586
  const isLastSegment = segmentIndex === tabSegments.length - 1;
95473
95587
  if (/^[ ]+$/.test(segment)) {
95588
+ const isRunStart = charPosInRun === 0 && segmentIndex === 0;
95474
95589
  const spacesLength = segment.length;
95475
95590
  const spacesStartChar = charPosInRun;
95476
95591
  const spacesEndChar = charPosInRun + spacesLength;
@@ -95489,7 +95604,7 @@ ${l}
95489
95604
  spaceCount: spacesLength
95490
95605
  };
95491
95606
  } else {
95492
- const boundarySpacing = currentLine.width > 0 ? run2.letterSpacing ?? 0 : 0;
95607
+ const boundarySpacing = resolveBoundarySpacing(currentLine.width, isRunStart, run2);
95493
95608
  if (currentLine.width + boundarySpacing + spacesWidth > currentLine.maxWidth - WIDTH_FUDGE_PX2 && currentLine.width > 0) {
95494
95609
  trimTrailingWrapSpaces(currentLine);
95495
95610
  const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing, currentLine.maxFontInfo);
@@ -95553,6 +95668,7 @@ ${l}
95553
95668
  const spaceStartChar = charPosInRun;
95554
95669
  const spaceEndChar = charPosInRun + 1;
95555
95670
  const singleSpaceWidth = measureRunWidth(" ", font, ctx2, run2, spaceStartChar);
95671
+ const isRunStart2 = charPosInRun === 0 && segmentIndex === 0 && wordIndex === 0;
95556
95672
  if (!currentLine) {
95557
95673
  currentLine = {
95558
95674
  fromRun: runIndex,
@@ -95567,7 +95683,7 @@ ${l}
95567
95683
  spaceCount: 1
95568
95684
  };
95569
95685
  } else {
95570
- const boundarySpacing2 = currentLine.width > 0 ? run2.letterSpacing ?? 0 : 0;
95686
+ const boundarySpacing2 = resolveBoundarySpacing(currentLine.width, isRunStart2, run2);
95571
95687
  if (currentLine.width + boundarySpacing2 + singleSpaceWidth > currentLine.maxWidth - WIDTH_FUDGE_PX2 && currentLine.width > 0) {
95572
95688
  trimTrailingWrapSpaces(currentLine);
95573
95689
  const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing, currentLine.maxFontInfo);
@@ -95752,7 +95868,8 @@ ${l}
95752
95868
  continue;
95753
95869
  }
95754
95870
  const isTocEntry = block.attrs?.isTocEntry;
95755
- const boundarySpacing = currentLine.width > 0 ? run2.letterSpacing ?? 0 : 0;
95871
+ const isRunStart = charPosInRun === 0 && segmentIndex === 0 && wordIndex === 0;
95872
+ const boundarySpacing = resolveBoundarySpacing(currentLine.width, isRunStart, run2);
95756
95873
  const justifyAlignment = block.attrs?.alignment === "justify";
95757
95874
  const totalWidthWithWord = currentLine.width + boundarySpacing + wordCommitWidth + // Safe cast: only TextRuns produce word segments from split(), other run types are handled earlier
95758
95875
  (shouldIncludeDelimiterSpace ? run2.letterSpacing ?? 0 : 0);
@@ -95920,6 +96037,7 @@ ${l}
95920
96037
  }
95921
96038
  }
95922
96039
  }
96040
+ pendingRunSpacing = run2.letterSpacing ?? 0;
95923
96041
  }
95924
96042
  if (!currentLine && lines.length === 0) {
95925
96043
  const uiDisplayFallbackFontSize = (block.runs[0]?.kind === "text" ? block.runs[0].fontSize : void 0) ?? 12;
@@ -96723,6 +96841,7 @@ ${l}
96723
96841
  #dragLastPointer = null;
96724
96842
  #dragLastRawHit = null;
96725
96843
  #dragUsedPageNotMountedFallback = false;
96844
+ #suppressFocusInFromDraggable = false;
96726
96845
  // Cell selection drag state
96727
96846
  // Tracks cell-specific context when drag starts in a table for multi-cell selection
96728
96847
  #cellAnchor = null;
@@ -98703,6 +98822,7 @@ ${l}
98703
98822
  return;
98704
98823
  }
98705
98824
  const isDraggableAnnotation = target?.closest?.('[data-draggable="true"]') != null;
98825
+ this.#suppressFocusInFromDraggable = isDraggableAnnotation;
98706
98826
  if (!this.#layoutState.layout) {
98707
98827
  if (!isDraggableAnnotation) {
98708
98828
  event.preventDefault();
@@ -99433,6 +99553,10 @@ ${l}
99433
99553
  if (isInRegisteredSurface(event)) {
99434
99554
  return;
99435
99555
  }
99556
+ if (this.#suppressFocusInFromDraggable) {
99557
+ this.#suppressFocusInFromDraggable = false;
99558
+ return;
99559
+ }
99436
99560
  const target = event.target;
99437
99561
  const activeTarget = this.#getActiveDomTarget();
99438
99562
  if (!activeTarget) {
@@ -99459,6 +99583,7 @@ ${l}
99459
99583
  }
99460
99584
  };
99461
99585
  #handlePointerUp = (event) => {
99586
+ this.#suppressFocusInFromDraggable = false;
99462
99587
  if (!this.#isDragging) return;
99463
99588
  if (typeof this.#viewportHost.hasPointerCapture === "function" && typeof this.#viewportHost.releasePointerCapture === "function" && this.#viewportHost.hasPointerCapture(event.pointerId)) {
99464
99589
  this.#viewportHost.releasePointerCapture(event.pointerId);
@@ -107188,16 +107313,7 @@ ${l}
107188
107313
  * @param {import("./tableHelpers/createTableBorders.js").TableBorders} [borders] - Border styling for this table
107189
107314
  */
107190
107315
  borders: {
107191
- default: {},
107192
- renderDOM({ borders }) {
107193
- if (!borders) return {};
107194
- const style2 = Object.entries(borders).reduce((acc, [key2, { size: size2, color: color2 }]) => {
107195
- return `${acc}border-${key2}: ${Math.ceil(size2)}px solid ${color2 || "black"};`;
107196
- }, "");
107197
- return {
107198
- style: style2
107199
- };
107200
- }
107316
+ default: {}
107201
107317
  },
107202
107318
  /**
107203
107319
  * @category Attribute
@@ -144013,7 +144129,7 @@ ${reason}`);
144013
144129
  this.config.colors = shuffleArray(this.config.colors);
144014
144130
  this.userColorMap = /* @__PURE__ */ new Map();
144015
144131
  this.colorIndex = 0;
144016
- this.version = "1.3.0-next.6";
144132
+ this.version = "1.3.0-next.8";
144017
144133
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
144018
144134
  this.superdocId = config2.superdocId || v4();
144019
144135
  this.colors = this.config.colors;