@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.
@@ -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.7") {
36438
+ static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.3.0-next.9") {
36370
36439
  return SuperConverter.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
36371
36440
  }
36372
36441
  /**
@@ -49479,8 +49548,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
49479
49548
  }
49480
49549
  if (!onlyActiveThreadChanged) {
49481
49550
  const positionsChanged = hasPositionsChanged(prevAllCommentPositions, allCommentPositions);
49482
- const hasComments = Object.keys(allCommentPositions).length > 0;
49483
- const shouldEmitPositions = positionsChanged || !hasEverEmitted && hasComments;
49551
+ const hasComments2 = Object.keys(allCommentPositions).length > 0;
49552
+ const shouldEmitPositions = positionsChanged || !hasEverEmitted && hasComments2;
49484
49553
  if (shouldEmitPositions) {
49485
49554
  prevAllCommentPositions = allCommentPositions;
49486
49555
  hasEverEmitted = true;
@@ -52788,7 +52857,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
52788
52857
  }
52789
52858
  const xmlJson = JSON.parse(libExports.xml2json(contentTypesXml, null, 2));
52790
52859
  const types2 = xmlJson.elements?.find((el) => el.name === "Types") || {};
52791
- const hasComments = types2.elements?.some(
52860
+ const hasComments2 = types2.elements?.some(
52792
52861
  (el) => el.name === "Override" && el.attributes.PartName === "/word/comments.xml"
52793
52862
  );
52794
52863
  const hasCommentsExtended = types2.elements?.some(
@@ -52808,7 +52877,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
52808
52877
  };
52809
52878
  if (hasFile("word/comments.xml")) {
52810
52879
  const commentsDef = `<Override PartName="/word/comments.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml" />`;
52811
- if (!hasComments) typesString += commentsDef;
52880
+ if (!hasComments2) typesString += commentsDef;
52812
52881
  }
52813
52882
  if (hasFile("word/commentsExtended.xml")) {
52814
52883
  const commentsExtendedDef = `<Override PartName="/word/commentsExtended.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtended+xml" />`;
@@ -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.7";
62148
+ const summaryVersion = "1.3.0-next.9";
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.7");
64782
+ console.debug("[checkVersionMigrations] Current editor version", "1.3.0-next.9");
64714
64783
  if (!this.options.ydoc) return;
64715
64784
  const metaMap = this.options.ydoc.getMap("meta");
64716
64785
  let docVersion = metaMap.get("version");
@@ -74943,7 +75012,9 @@ ${l}
74943
75012
  textRun.pmEnd ?? "",
74944
75013
  textRun.token ?? "",
74945
75014
  // Tracked changes - force re-render when added or removed tracked change
74946
- textRun.trackedChange ? 1 : 0
75015
+ textRun.trackedChange ? 1 : 0,
75016
+ // Comment annotations - force re-render when comments are enabled/disabled
75017
+ textRun.comments?.length ?? 0
74947
75018
  ].join(",");
74948
75019
  }).join("|");
74949
75020
  const attrs = block.attrs;
@@ -80814,6 +80885,9 @@ ${l}
80814
80885
  if (borders.left) parts.push(`l:[${hashBorderSpec(borders.left)}]`);
80815
80886
  return parts.join(";");
80816
80887
  };
80888
+ function hasComments$1(run2) {
80889
+ return "comments" in run2 && Array.isArray(run2.comments) && run2.comments.length > 0;
80890
+ }
80817
80891
  const MAX_CACHE_SIZE$1 = 1e4;
80818
80892
  const BYTES_PER_ENTRY_ESTIMATE = 5e3;
80819
80893
  const hashParagraphFrame = (frame) => {
@@ -80881,6 +80955,7 @@ ${l}
80881
80955
  fontFamily2 ? `ff:${fontFamily2}` : "",
80882
80956
  highlight ? `hl:${highlight}` : ""
80883
80957
  ].join("");
80958
+ const commentHash = hasComments$1(run2) ? run2.comments.map((c2) => `${c2.commentId ?? ""}:${c2.internal ? "1" : "0"}`).join("|") : "";
80884
80959
  let trackedKey = "";
80885
80960
  if (hasTrackedChange(run2)) {
80886
80961
  const tc = run2.trackedChange;
@@ -80888,7 +80963,8 @@ ${l}
80888
80963
  const afterHash = tc.after ? JSON.stringify(tc.after) : "";
80889
80964
  trackedKey = `|tc:${tc.kind ?? ""}:${tc.id ?? ""}:${tc.author ?? ""}:${tc.date ?? ""}:${beforeHash}:${afterHash}`;
80890
80965
  }
80891
- cellHashes.push(`${text2}:${marks}${trackedKey}`);
80966
+ const commentKey = commentHash ? `|cm:${commentHash}` : "";
80967
+ cellHashes.push(`${text2}:${marks}${trackedKey}${commentKey}`);
80892
80968
  }
80893
80969
  if (paragraphBlock.attrs) {
80894
80970
  const attrs = paragraphBlock.attrs;
@@ -82020,6 +82096,9 @@ ${l}
82020
82096
  const totalHeight = lines.reduce((s2, l) => s2 + l.lineHeight, 0);
82021
82097
  return { kind: "paragraph", lines, totalHeight };
82022
82098
  }
82099
+ function hasComments(run2) {
82100
+ return "comments" in run2 && Array.isArray(run2.comments) && run2.comments.length > 0;
82101
+ }
82023
82102
  const computeDirtyRegions = (previous2, next2) => {
82024
82103
  const prevMap = new Map(previous2.map((block, index2) => [block.id, { block, index: index2 }]));
82025
82104
  const nextMap = new Map(next2.map((block, index2) => [block.id, { block, index: index2 }]));
@@ -82080,6 +82159,10 @@ ${l}
82080
82159
  }
82081
82160
  return "";
82082
82161
  };
82162
+ const getCommentKey = (run2) => {
82163
+ if (!hasComments(run2)) return "";
82164
+ return run2.comments.map((c2) => `${c2.commentId ?? ""}:${c2.internal ? "1" : "0"}`).join("|");
82165
+ };
82083
82166
  const paragraphSpacingEqual = (a2, b2) => {
82084
82167
  if (a2 === b2) return true;
82085
82168
  if (!a2 || !b2) return !a2 && !b2;
@@ -82161,7 +82244,7 @@ ${l}
82161
82244
  for (let i2 = 0; i2 < a2.runs.length; i2 += 1) {
82162
82245
  const runA = a2.runs[i2];
82163
82246
  const runB = b2.runs[i2];
82164
- if (("src" in runA || runA.kind === "lineBreak" || runA.kind === "break" || runA.kind === "fieldAnnotation" ? "" : runA.text) !== ("src" in runB || runB.kind === "lineBreak" || runB.kind === "break" || runB.kind === "fieldAnnotation" ? "" : runB.text) || ("bold" in runA ? runA.bold : false) !== ("bold" in runB ? runB.bold : false) || ("italic" in runA ? runA.italic : false) !== ("italic" in runB ? runB.italic : false) || ("color" in runA ? runA.color : void 0) !== ("color" in runB ? runB.color : void 0) || ("fontSize" in runA ? runA.fontSize : void 0) !== ("fontSize" in runB ? runB.fontSize : void 0) || ("fontFamily" in runA ? runA.fontFamily : void 0) !== ("fontFamily" in runB ? runB.fontFamily : void 0) || ("highlight" in runA ? runA.highlight : void 0) !== ("highlight" in runB ? runB.highlight : void 0) || getTrackedChangeKey(runA) !== getTrackedChangeKey(runB)) {
82247
+ if (("src" in runA || runA.kind === "lineBreak" || runA.kind === "break" || runA.kind === "fieldAnnotation" ? "" : runA.text) !== ("src" in runB || runB.kind === "lineBreak" || runB.kind === "break" || runB.kind === "fieldAnnotation" ? "" : runB.text) || ("bold" in runA ? runA.bold : false) !== ("bold" in runB ? runB.bold : false) || ("italic" in runA ? runA.italic : false) !== ("italic" in runB ? runB.italic : false) || ("color" in runA ? runA.color : void 0) !== ("color" in runB ? runB.color : void 0) || ("fontSize" in runA ? runA.fontSize : void 0) !== ("fontSize" in runB ? runB.fontSize : void 0) || ("fontFamily" in runA ? runA.fontFamily : void 0) !== ("fontFamily" in runB ? runB.fontFamily : void 0) || ("highlight" in runA ? runA.highlight : void 0) !== ("highlight" in runB ? runB.highlight : void 0) || getTrackedChangeKey(runA) !== getTrackedChangeKey(runB) || getCommentKey(runA) !== getCommentKey(runB)) {
82165
82248
  return false;
82166
82249
  }
82167
82250
  }
@@ -86903,7 +86986,7 @@ ${l}
86903
86986
  delete run2.link;
86904
86987
  delete run2.letterSpacing;
86905
86988
  };
86906
- const applyFormatChangeMarks = (run2, config2, hyperlinkConfig, applyMarksToRun2, themeColors) => {
86989
+ const applyFormatChangeMarks = (run2, config2, hyperlinkConfig, applyMarksToRun2, themeColors, enableComments = true) => {
86907
86990
  const tracked = run2.trackedChange;
86908
86991
  if (!tracked || tracked.kind !== "format") {
86909
86992
  return;
@@ -86925,12 +87008,12 @@ ${l}
86925
87008
  }
86926
87009
  resetRunFormatting(run2);
86927
87010
  try {
86928
- applyMarksToRun2(run2, beforeMarks, hyperlinkConfig, themeColors);
87011
+ applyMarksToRun2(run2, beforeMarks, hyperlinkConfig, themeColors, void 0, enableComments);
86929
87012
  } catch (error) {
86930
87013
  resetRunFormatting(run2);
86931
87014
  }
86932
87015
  };
86933
- const applyTrackedChangesModeToRuns = (runs2, config2, hyperlinkConfig, applyMarksToRun2, themeColors) => {
87016
+ const applyTrackedChangesModeToRuns = (runs2, config2, hyperlinkConfig, applyMarksToRun2, themeColors, enableComments = true) => {
86934
87017
  if (!config2) {
86935
87018
  return runs2;
86936
87019
  }
@@ -86943,7 +87026,7 @@ ${l}
86943
87026
  } else {
86944
87027
  runs2.forEach((run2) => {
86945
87028
  if (isTextRun$1(run2)) {
86946
- applyFormatChangeMarks(run2, config2, hyperlinkConfig, applyMarksToRun2, themeColors);
87029
+ applyFormatChangeMarks(run2, config2, hyperlinkConfig, applyMarksToRun2, themeColors, enableComments);
86947
87030
  }
86948
87031
  });
86949
87032
  }
@@ -86973,7 +87056,14 @@ ${l}
86973
87056
  } else {
86974
87057
  filtered.forEach((run2) => {
86975
87058
  if (isTextRun$1(run2)) {
86976
- applyFormatChangeMarks(run2, config2, hyperlinkConfig || DEFAULT_HYPERLINK_CONFIG$1, applyMarksToRun2, themeColors);
87059
+ applyFormatChangeMarks(
87060
+ run2,
87061
+ config2,
87062
+ hyperlinkConfig || DEFAULT_HYPERLINK_CONFIG$1,
87063
+ applyMarksToRun2,
87064
+ themeColors,
87065
+ enableComments
87066
+ );
86977
87067
  }
86978
87068
  });
86979
87069
  }
@@ -87884,7 +87974,10 @@ ${l}
87884
87974
  const DEFAULT_HYPERLINK_CONFIG = {
87885
87975
  enableRichHyperlinks: false
87886
87976
  };
87887
- const applyMarksToRun = (run2, marks, hyperlinkConfig = DEFAULT_HYPERLINK_CONFIG, themeColors, backgroundColor) => {
87977
+ const applyMarksToRun = (run2, marks, hyperlinkConfig = DEFAULT_HYPERLINK_CONFIG, themeColors, backgroundColor, enableComments = true) => {
87978
+ if (!enableComments && "comments" in run2 && run2.comments) {
87979
+ delete run2.comments;
87980
+ }
87888
87981
  const isTabRun2 = run2.kind === "tab";
87889
87982
  let markSetColor = false;
87890
87983
  marks.forEach((mark2) => {
@@ -87931,7 +88024,7 @@ ${l}
87931
88024
  break;
87932
88025
  case "commentMark":
87933
88026
  case "comment": {
87934
- if (!isTabRun2) {
88027
+ if (!isTabRun2 && enableComments) {
87935
88028
  pushCommentAnnotation(run2, mark2.attrs ?? {});
87936
88029
  }
87937
88030
  break;
@@ -91544,7 +91637,13 @@ ${l}
91544
91637
  run2.letterSpacing = defaults2.letterSpacing;
91545
91638
  }
91546
91639
  };
91547
- function paragraphToFlowBlocks$1(para, nextBlockId, positions, defaultFont, defaultSize, styleContext, listCounterContext, trackedChanges, bookmarks, hyperlinkConfig = DEFAULT_HYPERLINK_CONFIG$1, themeColors, converters, converterContext) {
91640
+ const applyInlineRunProperties = (run2, runProperties) => {
91641
+ if (!runProperties) return;
91642
+ if (runProperties?.letterSpacing != null) {
91643
+ run2.letterSpacing = twipsToPx$1(runProperties.letterSpacing);
91644
+ }
91645
+ };
91646
+ function paragraphToFlowBlocks$1(para, nextBlockId, positions, defaultFont, defaultSize, styleContext, listCounterContext, trackedChanges, bookmarks, hyperlinkConfig = DEFAULT_HYPERLINK_CONFIG$1, themeColors, converters, converterContext, enableComments = true) {
91548
91647
  const baseBlockId = nextBlockId("paragraph");
91549
91648
  const paragraphProps = typeof para.attrs?.paragraphProperties === "object" && para.attrs.paragraphProperties !== null ? para.attrs.paragraphProperties : {};
91550
91649
  const paragraphStyleId = typeof para.attrs?.styleId === "string" && para.attrs.styleId.trim() ? para.attrs.styleId : typeof paragraphProps.styleId === "string" && paragraphProps.styleId.trim() ? paragraphProps.styleId : null;
@@ -91696,7 +91795,7 @@ ${l}
91696
91795
  runStyleId
91697
91796
  });
91698
91797
  };
91699
- const visitNode = (node2, inheritedMarks = [], activeSdt, activeRunStyleId = null) => {
91798
+ const visitNode = (node2, inheritedMarks = [], activeSdt, activeRunStyleId = null, activeRunProperties) => {
91700
91799
  if (node2.type === "text" && node2.text) {
91701
91800
  const run2 = textNodeToRun(
91702
91801
  node2,
@@ -91712,26 +91811,30 @@ ${l}
91712
91811
  const inlineStyleId = getInlineStyleId(inheritedMarks);
91713
91812
  applyRunStyles2(run2, inlineStyleId, activeRunStyleId);
91714
91813
  applyBaseRunDefaults(run2, baseRunDefaults, defaultFont, defaultSize);
91814
+ applyInlineRunProperties(run2, activeRunProperties);
91715
91815
  applyMarksToRun(
91716
91816
  run2,
91717
91817
  [...node2.marks ?? [], ...inheritedMarks ?? []],
91718
91818
  hyperlinkConfig,
91719
91819
  themeColors,
91720
- converterContext?.backgroundColor
91820
+ converterContext?.backgroundColor,
91821
+ enableComments
91721
91822
  );
91722
91823
  currentRuns.push(run2);
91723
91824
  return;
91724
91825
  }
91725
91826
  if (node2.type === "run" && Array.isArray(node2.content)) {
91726
91827
  const mergedMarks = [...node2.marks ?? [], ...inheritedMarks ?? []];
91727
- const nextRunStyleId = extractRunStyleId(node2.attrs?.runProperties) ?? activeRunStyleId;
91728
- node2.content.forEach((child) => visitNode(child, mergedMarks, activeSdt, nextRunStyleId));
91828
+ const runProperties = typeof node2.attrs?.runProperties === "object" && node2.attrs.runProperties !== null ? node2.attrs.runProperties : null;
91829
+ const nextRunStyleId = extractRunStyleId(runProperties) ?? activeRunStyleId;
91830
+ const nextRunProperties = runProperties ?? activeRunProperties;
91831
+ node2.content.forEach((child) => visitNode(child, mergedMarks, activeSdt, nextRunStyleId, nextRunProperties));
91729
91832
  return;
91730
91833
  }
91731
91834
  if (node2.type === "structuredContent" && Array.isArray(node2.content)) {
91732
91835
  const inlineMetadata = resolveNodeSdtMetadata(node2, "structuredContent");
91733
91836
  const nextSdt = inlineMetadata ?? activeSdt;
91734
- node2.content.forEach((child) => visitNode(child, inheritedMarks, nextSdt, activeRunStyleId));
91837
+ node2.content.forEach((child) => visitNode(child, inheritedMarks, nextSdt, activeRunStyleId, activeRunProperties));
91735
91838
  return;
91736
91839
  }
91737
91840
  if (node2.type === "fieldAnnotation") {
@@ -91777,7 +91880,8 @@ ${l}
91777
91880
  positions,
91778
91881
  defaultFont,
91779
91882
  defaultSize,
91780
- mergedMarks,
91883
+ [],
91884
+ // Empty marks - will be applied after linked styles
91781
91885
  activeSdt,
91782
91886
  hyperlinkConfig,
91783
91887
  themeColors
@@ -91785,6 +91889,15 @@ ${l}
91785
91889
  const inlineStyleId = getInlineStyleId(mergedMarks);
91786
91890
  applyRunStyles2(tokenRun, inlineStyleId, activeRunStyleId);
91787
91891
  applyBaseRunDefaults(tokenRun, baseRunDefaults, defaultFont, defaultSize);
91892
+ applyInlineRunProperties(tokenRun, activeRunProperties);
91893
+ applyMarksToRun(
91894
+ tokenRun,
91895
+ mergedMarks,
91896
+ hyperlinkConfig,
91897
+ themeColors,
91898
+ converterContext?.backgroundColor,
91899
+ enableComments
91900
+ );
91788
91901
  if (pageRefPos) {
91789
91902
  tokenRun.pmStart = pageRefPos.start;
91790
91903
  tokenRun.pmEnd = pageRefPos.end;
@@ -91799,7 +91912,9 @@ ${l}
91799
91912
  }
91800
91913
  currentRuns.push(tokenRun);
91801
91914
  } else if (Array.isArray(node2.content)) {
91802
- node2.content.forEach((child) => visitNode(child, mergedMarks, activeSdt));
91915
+ node2.content.forEach(
91916
+ (child) => visitNode(child, mergedMarks, activeSdt, activeRunStyleId, activeRunProperties)
91917
+ );
91803
91918
  }
91804
91919
  return;
91805
91920
  }
@@ -91813,7 +91928,9 @@ ${l}
91813
91928
  }
91814
91929
  }
91815
91930
  if (Array.isArray(node2.content)) {
91816
- node2.content.forEach((child) => visitNode(child, inheritedMarks, activeSdt));
91931
+ node2.content.forEach(
91932
+ (child) => visitNode(child, inheritedMarks, activeSdt, activeRunStyleId, activeRunProperties)
91933
+ );
91817
91934
  }
91818
91935
  return;
91819
91936
  }
@@ -91854,7 +91971,8 @@ ${l}
91854
91971
  mergedMarks,
91855
91972
  hyperlinkConfig,
91856
91973
  themeColors,
91857
- converterContext?.backgroundColor
91974
+ converterContext?.backgroundColor,
91975
+ enableComments
91858
91976
  );
91859
91977
  }
91860
91978
  console.debug("[token-debug] paragraph-token-run", {
@@ -91865,6 +91983,7 @@ ${l}
91865
91983
  runStyleId: activeRunStyleId,
91866
91984
  mergedMarksCount: mergedMarks.length
91867
91985
  });
91986
+ applyInlineRunProperties(tokenRun, activeRunProperties);
91868
91987
  currentRuns.push(tokenRun);
91869
91988
  }
91870
91989
  return;
@@ -92052,7 +92171,8 @@ ${l}
92052
92171
  trackedChanges,
92053
92172
  hyperlinkConfig,
92054
92173
  applyMarksToRun,
92055
- themeColors
92174
+ themeColors,
92175
+ enableComments
92056
92176
  );
92057
92177
  if (trackedChanges.enabled && filteredRuns.length === 0) {
92058
92178
  return;
@@ -92951,6 +93071,7 @@ ${l}
92951
93071
  const hyperlinkConfig = {
92952
93072
  enableRichHyperlinks: options?.enableRichHyperlinks ?? false
92953
93073
  };
93074
+ const enableComments = options?.enableComments ?? true;
92954
93075
  const themeColors = options?.themeColors;
92955
93076
  const converterContext = options?.converterContext;
92956
93077
  if (!doc2.content) {
@@ -93000,7 +93121,8 @@ ${l}
93000
93121
  bookmarks2,
93001
93122
  hyperlinkConfig2,
93002
93123
  themeColorsParam ?? themeColors,
93003
- converterCtx ?? converterContext
93124
+ converterCtx ?? converterContext,
93125
+ enableComments
93004
93126
  );
93005
93127
  const tableConverter = (node2, nextBlockId2, positions2, defaultFont2, defaultSize2, context, trackedChanges, bookmarks2, hyperlinkConfig2, themeColorsParam, converterCtx) => tableNodeToBlock(
93006
93128
  node2,
@@ -93039,6 +93161,7 @@ ${l}
93039
93161
  listCounterContext: { getListCounter, incrementListCounter, resetListCounter },
93040
93162
  trackedChangesConfig,
93041
93163
  hyperlinkConfig,
93164
+ enableComments,
93042
93165
  bookmarks,
93043
93166
  sectionState: {
93044
93167
  ranges: sectionRanges,
@@ -93107,7 +93230,7 @@ ${l}
93107
93230
  }
93108
93231
  return result;
93109
93232
  }
93110
- function paragraphToFlowBlocks(para, nextBlockId, positions, defaultFont, defaultSize, styleContext, listCounterContext, trackedChanges, bookmarks, hyperlinkConfig = DEFAULT_HYPERLINK_CONFIG$1, themeColors, converterContext) {
93233
+ function paragraphToFlowBlocks(para, nextBlockId, positions, defaultFont, defaultSize, styleContext, listCounterContext, trackedChanges, bookmarks, hyperlinkConfig = DEFAULT_HYPERLINK_CONFIG$1, themeColors, converterContext, enableComments = true) {
93111
93234
  return paragraphToFlowBlocks$1(
93112
93235
  para,
93113
93236
  nextBlockId,
@@ -93154,7 +93277,8 @@ ${l}
93154
93277
  }
93155
93278
  )
93156
93279
  },
93157
- converterContext
93280
+ converterContext,
93281
+ enableComments
93158
93282
  );
93159
93283
  }
93160
93284
  function tableNodeToBlock(node2, nextBlockId, positions, defaultFont, defaultSize, styleContext, trackedChanges, bookmarks, hyperlinkConfig, themeColors, _paragraphToFlowBlocksParam, converterContext, options) {
@@ -95041,6 +95165,7 @@ ${l}
95041
95165
  let lastFontSize = 12;
95042
95166
  let tabStopCursor = 0;
95043
95167
  let pendingTabAlignment = null;
95168
+ let pendingRunSpacing = 0;
95044
95169
  let lastAppliedTabAlign = null;
95045
95170
  const warnedTabVals = /* @__PURE__ */ new Set();
95046
95171
  let activeTabGroup = null;
@@ -95051,6 +95176,10 @@ ${l}
95051
95176
  }
95052
95177
  return true;
95053
95178
  };
95179
+ const resolveBoundarySpacing = (lineWidth, isRunStart, run2) => {
95180
+ if (lineWidth <= 0) return 0;
95181
+ return isRunStart ? pendingRunSpacing : run2.letterSpacing ?? 0;
95182
+ };
95054
95183
  const alignPendingTabForWidth = (segmentWidth, beforeDecimalWidth) => {
95055
95184
  if (!pendingTabAlignment || !currentLine) return void 0;
95056
95185
  if (segmentWidth < 0) {
@@ -95178,6 +95307,7 @@ ${l}
95178
95307
  tabStopCursor = 0;
95179
95308
  pendingTabAlignment = null;
95180
95309
  lastAppliedTabAlign = null;
95310
+ pendingRunSpacing = 0;
95181
95311
  continue;
95182
95312
  }
95183
95313
  if (isLineBreakRun(run2)) {
@@ -95220,6 +95350,7 @@ ${l}
95220
95350
  tabStopCursor = 0;
95221
95351
  pendingTabAlignment = null;
95222
95352
  lastAppliedTabAlign = null;
95353
+ pendingRunSpacing = 0;
95223
95354
  continue;
95224
95355
  }
95225
95356
  if (isTabRun(run2)) {
@@ -95285,6 +95416,7 @@ ${l}
95285
95416
  } else {
95286
95417
  pendingTabAlignment = null;
95287
95418
  }
95419
+ pendingRunSpacing = 0;
95288
95420
  continue;
95289
95421
  }
95290
95422
  if (isImageRun(run2)) {
@@ -95323,6 +95455,7 @@ ${l}
95323
95455
  }
95324
95456
  ]
95325
95457
  };
95458
+ pendingRunSpacing = 0;
95326
95459
  if (activeTabGroup && runIndex + 1 >= activeTabGroup.measure.endRunIndex) {
95327
95460
  activeTabGroup = null;
95328
95461
  }
@@ -95384,6 +95517,7 @@ ${l}
95384
95517
  currentLine.width = roundValue(tabAlign.target);
95385
95518
  }
95386
95519
  lastAppliedTabAlign = null;
95520
+ pendingRunSpacing = 0;
95387
95521
  continue;
95388
95522
  }
95389
95523
  if (isFieldAnnotationRun(run2)) {
@@ -95423,6 +95557,7 @@ ${l}
95423
95557
  }
95424
95558
  ]
95425
95559
  };
95560
+ pendingRunSpacing = 0;
95426
95561
  continue;
95427
95562
  }
95428
95563
  if (currentLine.width + annotationWidth > currentLine.maxWidth && currentLine.width > 0) {
@@ -95475,9 +95610,11 @@ ${l}
95475
95610
  currentLine.width = roundValue(tabAlign.target);
95476
95611
  }
95477
95612
  lastAppliedTabAlign = null;
95613
+ pendingRunSpacing = 0;
95478
95614
  continue;
95479
95615
  }
95480
95616
  if (!("text" in run2) || !("fontSize" in run2)) {
95617
+ pendingRunSpacing = 0;
95481
95618
  continue;
95482
95619
  }
95483
95620
  lastFontSize = run2.fontSize;
@@ -95488,6 +95625,7 @@ ${l}
95488
95625
  const segment = tabSegments[segmentIndex];
95489
95626
  const isLastSegment = segmentIndex === tabSegments.length - 1;
95490
95627
  if (/^[ ]+$/.test(segment)) {
95628
+ const isRunStart = charPosInRun === 0 && segmentIndex === 0;
95491
95629
  const spacesLength = segment.length;
95492
95630
  const spacesStartChar = charPosInRun;
95493
95631
  const spacesEndChar = charPosInRun + spacesLength;
@@ -95506,7 +95644,7 @@ ${l}
95506
95644
  spaceCount: spacesLength
95507
95645
  };
95508
95646
  } else {
95509
- const boundarySpacing = currentLine.width > 0 ? run2.letterSpacing ?? 0 : 0;
95647
+ const boundarySpacing = resolveBoundarySpacing(currentLine.width, isRunStart, run2);
95510
95648
  if (currentLine.width + boundarySpacing + spacesWidth > currentLine.maxWidth - WIDTH_FUDGE_PX2 && currentLine.width > 0) {
95511
95649
  trimTrailingWrapSpaces(currentLine);
95512
95650
  const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing, currentLine.maxFontInfo);
@@ -95570,6 +95708,7 @@ ${l}
95570
95708
  const spaceStartChar = charPosInRun;
95571
95709
  const spaceEndChar = charPosInRun + 1;
95572
95710
  const singleSpaceWidth = measureRunWidth(" ", font, ctx2, run2, spaceStartChar);
95711
+ const isRunStart2 = charPosInRun === 0 && segmentIndex === 0 && wordIndex === 0;
95573
95712
  if (!currentLine) {
95574
95713
  currentLine = {
95575
95714
  fromRun: runIndex,
@@ -95584,7 +95723,7 @@ ${l}
95584
95723
  spaceCount: 1
95585
95724
  };
95586
95725
  } else {
95587
- const boundarySpacing2 = currentLine.width > 0 ? run2.letterSpacing ?? 0 : 0;
95726
+ const boundarySpacing2 = resolveBoundarySpacing(currentLine.width, isRunStart2, run2);
95588
95727
  if (currentLine.width + boundarySpacing2 + singleSpaceWidth > currentLine.maxWidth - WIDTH_FUDGE_PX2 && currentLine.width > 0) {
95589
95728
  trimTrailingWrapSpaces(currentLine);
95590
95729
  const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing, currentLine.maxFontInfo);
@@ -95769,7 +95908,8 @@ ${l}
95769
95908
  continue;
95770
95909
  }
95771
95910
  const isTocEntry = block.attrs?.isTocEntry;
95772
- const boundarySpacing = currentLine.width > 0 ? run2.letterSpacing ?? 0 : 0;
95911
+ const isRunStart = charPosInRun === 0 && segmentIndex === 0 && wordIndex === 0;
95912
+ const boundarySpacing = resolveBoundarySpacing(currentLine.width, isRunStart, run2);
95773
95913
  const justifyAlignment = block.attrs?.alignment === "justify";
95774
95914
  const totalWidthWithWord = currentLine.width + boundarySpacing + wordCommitWidth + // Safe cast: only TextRuns produce word segments from split(), other run types are handled earlier
95775
95915
  (shouldIncludeDelimiterSpace ? run2.letterSpacing ?? 0 : 0);
@@ -95937,6 +96077,7 @@ ${l}
95937
96077
  }
95938
96078
  }
95939
96079
  }
96080
+ pendingRunSpacing = run2.letterSpacing ?? 0;
95940
96081
  }
95941
96082
  if (!currentLine && lines.length === 0) {
95942
96083
  const uiDisplayFallbackFontSize = (block.runs[0]?.kind === "text" ? block.runs[0].fontSize : void 0) ?? 12;
@@ -96740,6 +96881,7 @@ ${l}
96740
96881
  #dragLastPointer = null;
96741
96882
  #dragLastRawHit = null;
96742
96883
  #dragUsedPageNotMountedFallback = false;
96884
+ #suppressFocusInFromDraggable = false;
96743
96885
  // Cell selection drag state
96744
96886
  // Tracks cell-specific context when drag starts in a table for multi-cell selection
96745
96887
  #cellAnchor = null;
@@ -97345,12 +97487,13 @@ ${l}
97345
97487
  if (!validModes.includes(mode)) {
97346
97488
  throw new TypeError(`[PresentationEditor] Invalid mode "${mode}". Must be one of: ${validModes.join(", ")}`);
97347
97489
  }
97490
+ const modeChanged = this.#documentMode !== mode;
97348
97491
  this.#documentMode = mode;
97349
97492
  this.#editor.setDocumentMode(mode);
97350
97493
  this.#syncDocumentModeClass();
97351
97494
  this.#syncHiddenEditorA11yAttributes();
97352
97495
  const trackedChangesChanged = this.#syncTrackedChangesPreferences();
97353
- if (trackedChangesChanged) {
97496
+ if (modeChanged || trackedChangesChanged) {
97354
97497
  this.#pendingDocChange = true;
97355
97498
  this.#scheduleRerender();
97356
97499
  }
@@ -98720,6 +98863,7 @@ ${l}
98720
98863
  return;
98721
98864
  }
98722
98865
  const isDraggableAnnotation = target?.closest?.('[data-draggable="true"]') != null;
98866
+ this.#suppressFocusInFromDraggable = isDraggableAnnotation;
98723
98867
  if (!this.#layoutState.layout) {
98724
98868
  if (!isDraggableAnnotation) {
98725
98869
  event.preventDefault();
@@ -99450,6 +99594,10 @@ ${l}
99450
99594
  if (isInRegisteredSurface(event)) {
99451
99595
  return;
99452
99596
  }
99597
+ if (this.#suppressFocusInFromDraggable) {
99598
+ this.#suppressFocusInFromDraggable = false;
99599
+ return;
99600
+ }
99453
99601
  const target = event.target;
99454
99602
  const activeTarget = this.#getActiveDomTarget();
99455
99603
  if (!activeTarget) {
@@ -99476,6 +99624,7 @@ ${l}
99476
99624
  }
99477
99625
  };
99478
99626
  #handlePointerUp = (event) => {
99627
+ this.#suppressFocusInFromDraggable = false;
99479
99628
  if (!this.#isDragging) return;
99480
99629
  if (typeof this.#viewportHost.hasPointerCapture === "function" && typeof this.#viewportHost.releasePointerCapture === "function" && this.#viewportHost.hasPointerCapture(event.pointerId)) {
99481
99630
  this.#viewportHost.releasePointerCapture(event.pointerId);
@@ -99720,12 +99869,14 @@ ${l}
99720
99869
  } : void 0;
99721
99870
  const atomNodeTypes = getAtomNodeTypes(this.#editor?.schema ?? null);
99722
99871
  const positionMap2 = this.#editor?.state?.doc && docJson ? buildPositionMapFromPmDoc(this.#editor.state.doc, docJson) : null;
99872
+ const commentsEnabled = this.#documentMode !== "viewing";
99723
99873
  const result = toFlowBlocks(docJson, {
99724
99874
  mediaFiles: this.#editor?.storage?.image?.media,
99725
99875
  emitSectionBreaks: true,
99726
99876
  sectionMetadata,
99727
99877
  trackedChangesMode: this.#trackedChangesMode,
99728
99878
  enableTrackedChanges: this.#trackedChangesEnabled,
99879
+ enableComments: commentsEnabled,
99729
99880
  enableRichHyperlinks: true,
99730
99881
  themeColors: this.#editor?.converter?.themeColors ?? void 0,
99731
99882
  converterContext,
@@ -99856,10 +100007,12 @@ ${l}
99856
100007
  const payload = { layout, blocks: blocks2, measures, metrics };
99857
100008
  this.emit("layoutUpdated", payload);
99858
100009
  this.emit("paginationUpdate", payload);
99859
- const commentPositions = this.#collectCommentPositions();
99860
- const positionKeys = Object.keys(commentPositions);
99861
- if (positionKeys.length > 0) {
99862
- this.emit("commentPositions", { positions: commentPositions });
100010
+ if (this.#documentMode !== "viewing") {
100011
+ const commentPositions = this.#collectCommentPositions();
100012
+ const positionKeys = Object.keys(commentPositions);
100013
+ if (positionKeys.length > 0) {
100014
+ this.emit("commentPositions", { positions: commentPositions });
100015
+ }
99863
100016
  }
99864
100017
  if (this.#telemetryEmitter && metrics) {
99865
100018
  this.#telemetryEmitter({ type: "layout", data: { layout, blocks: blocks2, measures, metrics } });
@@ -107205,16 +107358,7 @@ ${l}
107205
107358
  * @param {import("./tableHelpers/createTableBorders.js").TableBorders} [borders] - Border styling for this table
107206
107359
  */
107207
107360
  borders: {
107208
- default: {},
107209
- renderDOM({ borders }) {
107210
- if (!borders) return {};
107211
- const style2 = Object.entries(borders).reduce((acc, [key2, { size: size2, color: color2 }]) => {
107212
- return `${acc}border-${key2}: ${Math.ceil(size2)}px solid ${color2 || "black"};`;
107213
- }, "");
107214
- return {
107215
- style: style2
107216
- };
107217
- }
107361
+ default: {}
107218
107362
  },
107219
107363
  /**
107220
107364
  * @category Attribute
@@ -141158,6 +141302,9 @@ ${reason}`);
141158
141302
  const handleEditorLocationsUpdate = (allCommentPositions) => {
141159
141303
  editorCommentPositions.value = allCommentPositions || {};
141160
141304
  };
141305
+ const clearEditorCommentPositions = () => {
141306
+ editorCommentPositions.value = {};
141307
+ };
141161
141308
  const getFloatingComments = computed(() => {
141162
141309
  const comments = getGroupedComments.value?.parentComments.filter((c2) => !c2.resolvedTime).filter((c2) => {
141163
141310
  const keys2 = Object.keys(editorCommentPositions.value);
@@ -141260,6 +141407,7 @@ ${reason}`);
141260
141407
  processLoadedDocxComments,
141261
141408
  translateCommentsForExport,
141262
141409
  handleEditorLocationsUpdate,
141410
+ clearEditorCommentPositions,
141263
141411
  handleTrackedChangeUpdate
141264
141412
  };
141265
141413
  });
@@ -144030,7 +144178,7 @@ ${reason}`);
144030
144178
  this.config.colors = shuffleArray(this.config.colors);
144031
144179
  this.userColorMap = /* @__PURE__ */ new Map();
144032
144180
  this.colorIndex = 0;
144033
- this.version = "1.3.0-next.7";
144181
+ this.version = "1.3.0-next.9";
144034
144182
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
144035
144183
  this.superdocId = config2.superdocId || v4();
144036
144184
  this.colors = this.config.colors;
@@ -144547,7 +144695,8 @@ ${reason}`);
144547
144695
  }
144548
144696
  #setModeViewing() {
144549
144697
  this.toolbar.activeEditor = null;
144550
- this.setTrackedChangesPreferences({ mode: "original", enabled: false });
144698
+ this.setTrackedChangesPreferences({ mode: "original", enabled: true });
144699
+ this.commentsStore?.clearEditorCommentPositions?.();
144551
144700
  this.superdocStore.documents.forEach((doc2) => {
144552
144701
  doc2.removeComments();
144553
144702
  this.#applyDocumentMode(doc2, "viewing");