@harbour-enterprises/superdoc 1.3.1-next.2 → 1.4.0-next.1

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.
Files changed (58) hide show
  1. package/dist/chunks/{PdfViewer-B0cx-Fxj.es.js → PdfViewer-DRTk3dY6.es.js} +2 -2
  2. package/dist/chunks/{PdfViewer-BFIKd3-b.cjs → PdfViewer-H9_8IbtN.cjs} +2 -2
  3. package/dist/chunks/{SuperConverter-BE5tNyQz.es.js → SuperConverter-CFRB4XNw.es.js} +3 -2
  4. package/dist/chunks/{SuperConverter-Cu6cvHlN.cjs → SuperConverter-CgY28MJz.cjs} +3 -2
  5. package/dist/chunks/{index-Dp7mSzy1.es.js → index-BP9aFfwI.es.js} +115 -22
  6. package/dist/chunks/{index-DWfzQ0RN.cjs → index-BdaseaBw.cjs} +115 -22
  7. package/dist/chunks/{index-BjQU1XSp.cjs → index-C3KRKogJ.cjs} +119 -21
  8. package/dist/chunks/{index-SYGYHKb5.es.js → index-CEcYlysg.es.js} +119 -21
  9. package/dist/style.css +49 -49
  10. package/dist/super-editor/converter.cjs +1 -1
  11. package/dist/super-editor/converter.es.js +1 -1
  12. package/dist/super-editor.cjs +2 -2
  13. package/dist/super-editor.es.js +3 -3
  14. package/dist/superdoc/src/components/CommentsLayer/types.d.ts +3 -157
  15. package/dist/superdoc/src/components/CommentsLayer/types.d.ts.map +1 -1
  16. package/dist/superdoc/src/core/SuperDoc.d.ts.map +1 -1
  17. package/dist/superdoc/src/core/types/index.d.ts +12 -0
  18. package/dist/superdoc/src/core/types/index.d.ts.map +1 -1
  19. package/dist/superdoc/src/stores/comments-store.d.ts +4 -1
  20. package/dist/superdoc/src/stores/comments-store.d.ts.map +1 -1
  21. package/dist/superdoc/src/stores/superdoc-store.d.ts +12 -3
  22. package/dist/superdoc/src/stores/superdoc-store.d.ts.map +1 -1
  23. package/dist/superdoc.cjs +3 -3
  24. package/dist/superdoc.es.js +3 -3
  25. package/dist/superdoc.umd.js +233 -41
  26. package/dist/superdoc.umd.js.map +1 -1
  27. package/package.json +1 -1
  28. package/dist/super-editor/src/core/Extension.d.ts +0 -33
  29. package/dist/super-editor/src/core/Extension.d.ts.map +0 -1
  30. package/dist/super-editor/src/core/helpers/getExtensionConfigField.d.ts +0 -35
  31. package/dist/super-editor/src/core/helpers/getExtensionConfigField.d.ts.map +0 -1
  32. package/dist/super-editor/src/core/utilities/callOrGet.d.ts +0 -13
  33. package/dist/super-editor/src/core/utilities/callOrGet.d.ts.map +0 -1
  34. package/dist/super-editor/src/extensions/comment/comments-constants.d.ts +0 -2
  35. package/dist/super-editor/src/extensions/comment/comments-constants.d.ts.map +0 -1
  36. package/dist/super-editor/src/extensions/comment/comments-plugin.d.ts +0 -1
  37. package/dist/superdoc/src/SuperDoc.test.d.ts +0 -2
  38. package/dist/superdoc/src/SuperDoc.test.d.ts.map +0 -1
  39. package/dist/superdoc/src/components/CommentsLayer/CommentDialog.test.d.ts +0 -2
  40. package/dist/superdoc/src/components/CommentsLayer/CommentDialog.test.d.ts.map +0 -1
  41. package/dist/superdoc/src/components/CommentsLayer/use-comment.test.d.ts +0 -2
  42. package/dist/superdoc/src/components/CommentsLayer/use-comment.test.d.ts.map +0 -1
  43. package/dist/superdoc/src/core/SuperDoc.test.d.ts +0 -2
  44. package/dist/superdoc/src/core/SuperDoc.test.d.ts.map +0 -1
  45. package/dist/superdoc/src/core/collaboration/collaboration.test.d.ts +0 -2
  46. package/dist/superdoc/src/core/collaboration/collaboration.test.d.ts.map +0 -1
  47. package/dist/superdoc/src/core/helpers/export.test.d.ts +0 -2
  48. package/dist/superdoc/src/core/helpers/export.test.d.ts.map +0 -1
  49. package/dist/superdoc/src/core/helpers/file.test.d.ts +0 -2
  50. package/dist/superdoc/src/core/helpers/file.test.d.ts.map +0 -1
  51. package/dist/superdoc/src/stores/comments-store.test.d.ts +0 -2
  52. package/dist/superdoc/src/stores/comments-store.test.d.ts.map +0 -1
  53. package/dist/superdoc/src/stores/hrbr-fields-store.test.d.ts +0 -2
  54. package/dist/superdoc/src/stores/hrbr-fields-store.test.d.ts.map +0 -1
  55. package/dist/superdoc/src/stores/superdoc-store.test.d.ts +0 -2
  56. package/dist/superdoc/src/stores/superdoc-store.test.d.ts.map +0 -1
  57. package/dist/superdoc/src/tests/helpers/group-changes.test.d.ts +0 -2
  58. package/dist/superdoc/src/tests/helpers/group-changes.test.d.ts.map +0 -1
@@ -35842,9 +35842,10 @@ Please report this to https://github.com/markedjs/marked.`, e) {
35842
35842
  const updateCommentsExtendedXml = (comments = [], commentsExtendedXml) => {
35843
35843
  const xmlCopy = carbonCopy(commentsExtendedXml);
35844
35844
  const commentsEx = comments.map((comment2) => {
35845
+ const isResolved = comment2.resolvedTime || comment2.isDone;
35845
35846
  const attributes = {
35846
35847
  "w15:paraId": comment2.commentParaId,
35847
- "w15:done": comment2.resolvedTime ? "1" : "0"
35848
+ "w15:done": isResolved ? "1" : "0"
35848
35849
  };
35849
35850
  const parentId = comment2.parentCommentId;
35850
35851
  if (parentId) {
@@ -36435,7 +36436,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
36435
36436
  static getStoredSuperdocVersion(docx) {
36436
36437
  return SuperConverter.getStoredCustomProperty(docx, "SuperdocVersion");
36437
36438
  }
36438
- static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.3.1-next.2") {
36439
+ static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.4.0-next.1") {
36439
36440
  return SuperConverter.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
36440
36441
  }
36441
36442
  /**
@@ -49888,6 +49889,12 @@ Please report this to https://github.com/markedjs/marked.`, e) {
49888
49889
  if (from2 === null || pos < from2) from2 = pos;
49889
49890
  if (to === null || pos + node2.nodeSize > to) to = pos + node2.nodeSize;
49890
49891
  }
49892
+ if (node2.type.name === "commentRangeStart" && node2.attrs["w:id"] === id) {
49893
+ from2 = pos;
49894
+ }
49895
+ if (node2.type.name === "commentRangeEnd" && node2.attrs["w:id"] === id) {
49896
+ to = pos;
49897
+ }
49891
49898
  });
49892
49899
  return from2 !== null && to !== null ? { from: from2, to } : null;
49893
49900
  }
@@ -62245,7 +62252,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
62245
62252
  return false;
62246
62253
  }
62247
62254
  };
62248
- const summaryVersion = "1.3.1-next.2";
62255
+ const summaryVersion = "1.4.0-next.1";
62249
62256
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
62250
62257
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
62251
62258
  function mapAttributes(attrs) {
@@ -64878,7 +64885,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
64878
64885
  * Process collaboration migrations
64879
64886
  */
64880
64887
  processCollaborationMigrations() {
64881
- console.debug("[checkVersionMigrations] Current editor version", "1.3.1-next.2");
64888
+ console.debug("[checkVersionMigrations] Current editor version", "1.4.0-next.1");
64882
64889
  if (!this.options.ydoc) return;
64883
64890
  const metaMap = this.options.ydoc.getMap("meta");
64884
64891
  let docVersion = metaMap.get("version");
@@ -78488,8 +78495,15 @@ ${l}
78488
78495
  } else if (vRelativeFrom === "paragraph") {
78489
78496
  const baseAnchorY = state.cursorY;
78490
78497
  const firstLineHeight = measure.lines?.[0]?.lineHeight ?? 0;
78491
- const paragraphAdjustment = firstLineHeight / 2;
78492
- anchorY = baseAnchorY + paragraphAdjustment + offsetV;
78498
+ if (alignV === "top") {
78499
+ anchorY = baseAnchorY + offsetV;
78500
+ } else if (alignV === "bottom") {
78501
+ anchorY = baseAnchorY + firstLineHeight - imageHeight + offsetV;
78502
+ } else if (alignV === "center") {
78503
+ anchorY = baseAnchorY + (firstLineHeight - imageHeight) / 2 + offsetV;
78504
+ } else {
78505
+ anchorY = baseAnchorY + offsetV;
78506
+ }
78493
78507
  } else {
78494
78508
  const baseAnchorY = state.cursorY;
78495
78509
  anchorY = baseAnchorY + offsetV;
@@ -79550,6 +79564,13 @@ ${l}
79550
79564
  function collectAnchoredDrawings(blocks2, measures) {
79551
79565
  const map2 = /* @__PURE__ */ new Map();
79552
79566
  const len = Math.min(blocks2.length, measures.length);
79567
+ const paragraphIndexById = /* @__PURE__ */ new Map();
79568
+ for (let i2 = 0; i2 < len; i2 += 1) {
79569
+ const block = blocks2[i2];
79570
+ if (block.kind === "paragraph") {
79571
+ paragraphIndexById.set(block.id, i2);
79572
+ }
79573
+ }
79553
79574
  const nearestPrevParagraph = (fromIndex) => {
79554
79575
  for (let i2 = fromIndex - 1; i2 >= 0; i2 -= 1) {
79555
79576
  if (blocks2[i2].kind === "paragraph") return i2;
@@ -79576,7 +79597,11 @@ ${l}
79576
79597
  if (isPageRelativeAnchor(drawingBlock)) {
79577
79598
  continue;
79578
79599
  }
79579
- let anchorParaIndex = nearestPrevParagraph(i2);
79600
+ const anchorParagraphId = typeof drawingBlock.attrs === "object" && drawingBlock.attrs ? drawingBlock.attrs.anchorParagraphId : void 0;
79601
+ let anchorParaIndex = typeof anchorParagraphId === "string" ? paragraphIndexById.get(anchorParagraphId) ?? null : null;
79602
+ if (anchorParaIndex == null) {
79603
+ anchorParaIndex = nearestPrevParagraph(i2);
79604
+ }
79580
79605
  if (anchorParaIndex == null) anchorParaIndex = nearestNextParagraph(i2);
79581
79606
  if (anchorParaIndex == null) continue;
79582
79607
  const list2 = map2.get(anchorParaIndex) ?? [];
@@ -79587,6 +79612,13 @@ ${l}
79587
79612
  }
79588
79613
  function collectAnchoredTables(blocks2, measures) {
79589
79614
  const map2 = /* @__PURE__ */ new Map();
79615
+ const paragraphIndexById = /* @__PURE__ */ new Map();
79616
+ for (let i2 = 0; i2 < blocks2.length; i2 += 1) {
79617
+ const block = blocks2[i2];
79618
+ if (block.kind === "paragraph") {
79619
+ paragraphIndexById.set(block.id, i2);
79620
+ }
79621
+ }
79590
79622
  const nearestPrevParagraph = (fromIndex) => {
79591
79623
  for (let i2 = fromIndex - 1; i2 >= 0; i2 -= 1) {
79592
79624
  if (blocks2[i2].kind === "paragraph") return i2;
@@ -79606,7 +79638,11 @@ ${l}
79606
79638
  const tableBlock = block;
79607
79639
  const tableMeasure = measure;
79608
79640
  if (!tableBlock.anchor?.isAnchored) continue;
79609
- let anchorParaIndex = nearestPrevParagraph(i2);
79641
+ const anchorParagraphId = typeof tableBlock.attrs === "object" && tableBlock.attrs ? tableBlock.attrs.anchorParagraphId : void 0;
79642
+ let anchorParaIndex = typeof anchorParagraphId === "string" ? paragraphIndexById.get(anchorParagraphId) ?? null : null;
79643
+ if (anchorParaIndex == null) {
79644
+ anchorParaIndex = nearestPrevParagraph(i2);
79645
+ }
79610
79646
  if (anchorParaIndex == null) anchorParaIndex = nearestNextParagraph(i2);
79611
79647
  if (anchorParaIndex == null) continue;
79612
79648
  const list2 = map2.get(anchorParaIndex) ?? [];
@@ -88576,7 +88612,13 @@ ${l}
88576
88612
  const result = {};
88577
88613
  if (spacing.before != null) result.before = pxToPt(spacing.before);
88578
88614
  if (spacing.after != null) result.after = pxToPt(spacing.after);
88579
- if (spacing.line != null) result.line = pxToPt(spacing.line);
88615
+ if (spacing.line != null) {
88616
+ if (spacing.lineRule === "auto" && spacing.line > 0 && spacing.line <= MAX_AUTO_LINE_MULTIPLIER) {
88617
+ result.line = spacing.line;
88618
+ } else {
88619
+ result.line = pxToPt(spacing.line);
88620
+ }
88621
+ }
88580
88622
  if (spacing.lineRule) result.lineRule = spacing.lineRule;
88581
88623
  return result;
88582
88624
  };
@@ -88600,8 +88642,13 @@ ${l}
88600
88642
  if (after != null) result.after = after;
88601
88643
  }
88602
88644
  if (rawSpacing.line != null) {
88603
- const line = ptToPx(spacing.line);
88604
- if (line != null) result.line = line;
88645
+ const isAutoMultiplier = spacing.lineRule === "auto" && spacing.line != null && spacing.line > 0 && spacing.line <= MAX_AUTO_LINE_MULTIPLIER;
88646
+ if (isAutoMultiplier) {
88647
+ result.line = spacing.line;
88648
+ } else {
88649
+ const line = ptToPx(spacing.line);
88650
+ if (line != null) result.line = line;
88651
+ }
88605
88652
  if (spacing.lineRule) result.lineRule = spacing.lineRule;
88606
88653
  }
88607
88654
  }
@@ -88681,7 +88728,7 @@ ${l}
88681
88728
  if (value > 0 && value <= MAX_AUTO_LINE_MULTIPLIER) {
88682
88729
  return value;
88683
88730
  }
88684
- return twipsToPx$1(value);
88731
+ return value / 240;
88685
88732
  }
88686
88733
  return twipsToPx$1(value);
88687
88734
  };
@@ -91956,6 +92003,20 @@ ${l}
91956
92003
  let partIndex = 0;
91957
92004
  let tabOrdinal = 0;
91958
92005
  const nextId = () => partIndex === 0 ? baseBlockId : `${baseBlockId}-${partIndex}`;
92006
+ const attachAnchorParagraphId = (block, anchorParagraphId) => {
92007
+ const applicableKinds = /* @__PURE__ */ new Set(["drawing", "image", "table"]);
92008
+ if (!applicableKinds.has(block.kind)) {
92009
+ return block;
92010
+ }
92011
+ const blockWithAttrs = block;
92012
+ return {
92013
+ ...blockWithAttrs,
92014
+ attrs: {
92015
+ ...blockWithAttrs.attrs ?? {},
92016
+ anchorParagraphId
92017
+ }
92018
+ };
92019
+ };
91959
92020
  const flushParagraph = () => {
91960
92021
  if (currentRuns.length === 0) {
91961
92022
  return;
@@ -92187,6 +92248,7 @@ ${l}
92187
92248
  }
92188
92249
  return;
92189
92250
  }
92251
+ const anchorParagraphId = nextId();
92190
92252
  flushParagraph();
92191
92253
  const mergedMarks = [...node2.marks ?? [], ...inheritedMarks ?? []];
92192
92254
  const trackedMeta = trackedChanges?.enabled ? collectTrackedChangeFromMarks(mergedMarks) : void 0;
@@ -92197,7 +92259,7 @@ ${l}
92197
92259
  const imageBlock = converters.imageNodeToBlock(node2, nextBlockId, positions, trackedMeta, trackedChanges);
92198
92260
  if (imageBlock && imageBlock.kind === "image") {
92199
92261
  annotateBlockWithTrackedChange(imageBlock, trackedMeta, trackedChanges);
92200
- blocks2.push(imageBlock);
92262
+ blocks2.push(attachAnchorParagraphId(imageBlock, anchorParagraphId));
92201
92263
  }
92202
92264
  }
92203
92265
  return;
@@ -92205,6 +92267,7 @@ ${l}
92205
92267
  if (node2.type === "contentBlock") {
92206
92268
  const attrs = node2.attrs ?? {};
92207
92269
  if (attrs.horizontalRule === true) {
92270
+ const anchorParagraphId = nextId();
92208
92271
  flushParagraph();
92209
92272
  const indent2 = paragraphAttrs?.indent;
92210
92273
  const hrIndentLeft = typeof indent2?.left === "number" ? indent2.left : void 0;
@@ -92214,52 +92277,57 @@ ${l}
92214
92277
  const convert2 = converters?.contentBlockNodeToDrawingBlock ?? contentBlockNodeToDrawingBlock;
92215
92278
  const drawingBlock = convert2(hrNode, nextBlockId, positions);
92216
92279
  if (drawingBlock) {
92217
- blocks2.push(drawingBlock);
92280
+ blocks2.push(attachAnchorParagraphId(drawingBlock, anchorParagraphId));
92218
92281
  }
92219
92282
  }
92220
92283
  return;
92221
92284
  }
92222
92285
  if (node2.type === "vectorShape") {
92286
+ const anchorParagraphId = nextId();
92223
92287
  flushParagraph();
92224
92288
  if (converters?.vectorShapeNodeToDrawingBlock) {
92225
92289
  const drawingBlock = converters.vectorShapeNodeToDrawingBlock(node2, nextBlockId, positions);
92226
92290
  if (drawingBlock) {
92227
- blocks2.push(drawingBlock);
92291
+ blocks2.push(attachAnchorParagraphId(drawingBlock, anchorParagraphId));
92228
92292
  }
92229
92293
  }
92230
92294
  return;
92231
92295
  }
92232
92296
  if (node2.type === "shapeGroup") {
92297
+ const anchorParagraphId = nextId();
92233
92298
  flushParagraph();
92234
92299
  if (converters?.shapeGroupNodeToDrawingBlock) {
92235
92300
  const drawingBlock = converters.shapeGroupNodeToDrawingBlock(node2, nextBlockId, positions);
92236
92301
  if (drawingBlock) {
92237
- blocks2.push(drawingBlock);
92302
+ blocks2.push(attachAnchorParagraphId(drawingBlock, anchorParagraphId));
92238
92303
  }
92239
92304
  }
92240
92305
  return;
92241
92306
  }
92242
92307
  if (node2.type === "shapeContainer") {
92308
+ const anchorParagraphId = nextId();
92243
92309
  flushParagraph();
92244
92310
  if (converters?.shapeContainerNodeToDrawingBlock) {
92245
92311
  const drawingBlock = converters.shapeContainerNodeToDrawingBlock(node2, nextBlockId, positions);
92246
92312
  if (drawingBlock) {
92247
- blocks2.push(drawingBlock);
92313
+ blocks2.push(attachAnchorParagraphId(drawingBlock, anchorParagraphId));
92248
92314
  }
92249
92315
  }
92250
92316
  return;
92251
92317
  }
92252
92318
  if (node2.type === "shapeTextbox") {
92319
+ const anchorParagraphId = nextId();
92253
92320
  flushParagraph();
92254
92321
  if (converters?.shapeTextboxNodeToDrawingBlock) {
92255
92322
  const drawingBlock = converters.shapeTextboxNodeToDrawingBlock(node2, nextBlockId, positions);
92256
92323
  if (drawingBlock) {
92257
- blocks2.push(drawingBlock);
92324
+ blocks2.push(attachAnchorParagraphId(drawingBlock, anchorParagraphId));
92258
92325
  }
92259
92326
  }
92260
92327
  return;
92261
92328
  }
92262
92329
  if (node2.type === "table") {
92330
+ const anchorParagraphId = nextId();
92263
92331
  flushParagraph();
92264
92332
  if (converters?.tableNodeToBlock) {
92265
92333
  const tableBlock = converters.tableNodeToBlock(
@@ -92276,7 +92344,7 @@ ${l}
92276
92344
  ...converterContext !== void 0 ? [converterContext] : []
92277
92345
  );
92278
92346
  if (tableBlock) {
92279
- blocks2.push(tableBlock);
92347
+ blocks2.push(attachAnchorParagraphId(tableBlock, anchorParagraphId));
92280
92348
  }
92281
92349
  }
92282
92350
  return;
@@ -96801,7 +96869,8 @@ ${l}
96801
96869
  return baseLineHeight;
96802
96870
  }
96803
96871
  const raw = spacing.line;
96804
- const treatAsMultiplier = (spacing.lineRule === "auto" || spacing.lineRule == null) && raw > 0 && raw <= 10;
96872
+ const isAuto = spacing.lineRule === "auto";
96873
+ const treatAsMultiplier = (isAuto || spacing.lineRule == null) && raw > 0 && (isAuto || raw <= 10);
96805
96874
  if (treatAsMultiplier) {
96806
96875
  return raw * baseLineHeight;
96807
96876
  }
@@ -97148,6 +97217,8 @@ ${l}
97148
97217
  debugLabel: options.layoutEngineOptions?.debugLabel,
97149
97218
  layoutMode: options.layoutEngineOptions?.layoutMode ?? "vertical",
97150
97219
  trackedChanges: options.layoutEngineOptions?.trackedChanges,
97220
+ emitCommentPositionsInViewing: options.layoutEngineOptions?.emitCommentPositionsInViewing,
97221
+ enableCommentsInViewing: options.layoutEngineOptions?.enableCommentsInViewing,
97151
97222
  presence: validatedPresence
97152
97223
  };
97153
97224
  this.#trackedChangesOverrides = options.layoutEngineOptions?.trackedChanges;
@@ -97736,6 +97807,33 @@ ${l}
97736
97807
  this.#scheduleRerender();
97737
97808
  }
97738
97809
  }
97810
+ /**
97811
+ * Update viewing-mode comment rendering behavior and re-render if needed.
97812
+ *
97813
+ * @param options - Viewing mode comment options.
97814
+ */
97815
+ setViewingCommentOptions(options = {}) {
97816
+ if (options !== void 0 && (typeof options !== "object" || options === null || Array.isArray(options))) {
97817
+ throw new TypeError("[PresentationEditor] setViewingCommentOptions expects an object or undefined");
97818
+ }
97819
+ let hasChanges = false;
97820
+ if (typeof options.emitCommentPositionsInViewing === "boolean") {
97821
+ if (this.#layoutOptions.emitCommentPositionsInViewing !== options.emitCommentPositionsInViewing) {
97822
+ this.#layoutOptions.emitCommentPositionsInViewing = options.emitCommentPositionsInViewing;
97823
+ hasChanges = true;
97824
+ }
97825
+ }
97826
+ if (typeof options.enableCommentsInViewing === "boolean") {
97827
+ if (this.#layoutOptions.enableCommentsInViewing !== options.enableCommentsInViewing) {
97828
+ this.#layoutOptions.enableCommentsInViewing = options.enableCommentsInViewing;
97829
+ hasChanges = true;
97830
+ }
97831
+ }
97832
+ if (hasChanges) {
97833
+ this.#pendingDocChange = true;
97834
+ this.#scheduleRerender();
97835
+ }
97836
+ }
97739
97837
  /**
97740
97838
  * Toggle the custom context menu at runtime to respect host-level guardrails.
97741
97839
  */
@@ -100088,7 +100186,7 @@ ${l}
100088
100186
  } : void 0;
100089
100187
  const atomNodeTypes = getAtomNodeTypes(this.#editor?.schema ?? null);
100090
100188
  const positionMap2 = this.#editor?.state?.doc && docJson ? buildPositionMapFromPmDoc(this.#editor.state.doc, docJson) : null;
100091
- const commentsEnabled = this.#documentMode !== "viewing";
100189
+ const commentsEnabled = this.#documentMode !== "viewing" || this.#layoutOptions.enableCommentsInViewing === true;
100092
100190
  const result = toFlowBlocks(docJson, {
100093
100191
  mediaFiles: this.#editor?.storage?.image?.media,
100094
100192
  emitSectionBreaks: true,
@@ -100228,7 +100326,8 @@ ${l}
100228
100326
  const payload = { layout, blocks: blocks2, measures, metrics };
100229
100327
  this.emit("layoutUpdated", payload);
100230
100328
  this.emit("paginationUpdate", payload);
100231
- if (this.#documentMode !== "viewing") {
100329
+ const allowViewingCommentPositions = this.#layoutOptions.emitCommentPositionsInViewing === true;
100330
+ if (this.#documentMode !== "viewing" || allowViewingCommentPositions) {
100232
100331
  const commentPositions = this.#collectCommentPositions();
100233
100332
  const positionKeys = Object.keys(commentPositions);
100234
100333
  if (positionKeys.length > 0) {
@@ -141385,6 +141484,11 @@ ${reason}`);
141385
141484
  allowResolve: true,
141386
141485
  showResolved: false
141387
141486
  });
141487
+ const viewingVisibility = reactive({
141488
+ documentMode: "editing",
141489
+ commentsVisible: false,
141490
+ trackChangesVisible: false
141491
+ });
141388
141492
  const isDebugging = false;
141389
141493
  const debounceTimers = {};
141390
141494
  const COMMENT_EVENTS = comments_module_events;
@@ -141411,6 +141515,7 @@ ${reason}`);
141411
141515
  const isFloatingCommentsReady = ref(false);
141412
141516
  const generalCommentIds = ref([]);
141413
141517
  const pendingComment = ref(null);
141518
+ const isViewingMode = computed(() => viewingVisibility.documentMode === "viewing");
141414
141519
  const init2 = (config2 = {}) => {
141415
141520
  const updatedConfig = { ...commentsConfig, ...config2 };
141416
141521
  Object.assign(commentsConfig, updatedConfig);
@@ -141423,6 +141528,17 @@ ${reason}`);
141423
141528
  if (id === void 0 || id === null) return null;
141424
141529
  return commentsList.value.find((c2) => c2.commentId == id || c2.importedId == id);
141425
141530
  };
141531
+ const getThreadParent = (comment2) => {
141532
+ if (!comment2?.parentCommentId) return comment2;
141533
+ return getComment(comment2.parentCommentId);
141534
+ };
141535
+ const isThreadVisible = (comment2) => {
141536
+ if (!isViewingMode.value) return true;
141537
+ const parent = getThreadParent(comment2);
141538
+ if (!parent && comment2?.parentCommentId) return false;
141539
+ const isTrackedChange = Boolean(parent?.trackedChange);
141540
+ return isTrackedChange ? viewingVisibility.trackChangesVisible : viewingVisibility.commentsVisible;
141541
+ };
141426
141542
  const setActiveComment = (superdoc, id) => {
141427
141543
  if (id === void 0 || id === null) {
141428
141544
  activeComment.value = null;
@@ -141524,6 +141640,7 @@ ${reason}`);
141524
141640
  const resolvedComments = [];
141525
141641
  const childCommentMap = /* @__PURE__ */ new Map();
141526
141642
  commentsList.value.forEach((comment2) => {
141643
+ if (!isThreadVisible(comment2)) return;
141527
141644
  if (comment2.resolvedTime) {
141528
141645
  resolvedComments.push(comment2);
141529
141646
  } else if (!comment2.parentCommentId && !comment2.resolvedTime) {
@@ -141732,6 +141849,17 @@ ${reason}`);
141732
141849
  });
141733
141850
  return comments;
141734
141851
  });
141852
+ const setViewingVisibility = ({ documentMode, commentsVisible, trackChangesVisible } = {}) => {
141853
+ if (typeof documentMode === "string") {
141854
+ viewingVisibility.documentMode = documentMode;
141855
+ }
141856
+ if (typeof commentsVisible === "boolean") {
141857
+ viewingVisibility.commentsVisible = commentsVisible;
141858
+ }
141859
+ if (typeof trackChangesVisible === "boolean") {
141860
+ viewingVisibility.trackChangesVisible = trackChangesVisible;
141861
+ }
141862
+ };
141735
141863
  const normalizeCommentForEditor = (node2) => {
141736
141864
  if (!node2 || typeof node2 !== "object") return node2;
141737
141865
  const cloneMarks = (marks) => Array.isArray(marks) ? marks.filter(Boolean).map((mark2) => ({
@@ -141811,6 +141939,7 @@ ${reason}`);
141811
141939
  getFloatingComments,
141812
141940
  // Actions
141813
141941
  init: init2,
141942
+ setViewingVisibility,
141814
141943
  getComment,
141815
141944
  setActiveComment,
141816
141945
  getCommentLocation,
@@ -142441,12 +142570,13 @@ ${reason}`);
142441
142570
  return currentCommentText.value && currentCommentText.value !== "<p></p>";
142442
142571
  });
142443
142572
  const setFocus = () => {
142444
- if (props.comment.resolvedTime) return;
142445
142573
  const editor = proxy.$superdoc.activeEditor;
142446
- activeComment.value = props.comment.commentId;
142447
- props.comment.setActive(proxy.$superdoc);
142574
+ if (!props.comment.resolvedTime) {
142575
+ activeComment.value = props.comment.commentId;
142576
+ props.comment.setActive(proxy.$superdoc);
142577
+ }
142448
142578
  if (editor) {
142449
- const cursorId = props.comment.importedId || props.comment.commentId;
142579
+ const cursorId = props.comment.resolvedTime ? props.comment.commentId : props.comment.importedId || props.comment.commentId;
142450
142580
  editor.commands?.setCursorById(cursorId);
142451
142581
  }
142452
142582
  };
@@ -142682,7 +142812,7 @@ ${reason}`);
142682
142812
  };
142683
142813
  }
142684
142814
  };
142685
- const CommentDialog = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["__scopeId", "data-v-dc2a79b5"]]);
142815
+ const CommentDialog = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["__scopeId", "data-v-d50fd675"]]);
142686
142816
  const _hoisted_1$b = { class: "comments-list" };
142687
142817
  const _hoisted_2$5 = { key: 0 };
142688
142818
  const _hoisted_3$3 = { class: "comment-item" };
@@ -142799,7 +142929,7 @@ ${reason}`);
142799
142929
  const superdocStore = useSuperdocStore();
142800
142930
  const commentsStore = useCommentsStore();
142801
142931
  const { COMMENT_EVENTS } = commentsStore;
142802
- const { documentsWithConverations, activeComment, floatingCommentsOffset, commentsList } = storeToRefs(commentsStore);
142932
+ const { documentsWithConverations, activeComment, floatingCommentsOffset, getGroupedComments } = storeToRefs(commentsStore);
142803
142933
  const { documents, activeZoom } = storeToRefs(superdocStore);
142804
142934
  const { proxy } = getCurrentInstance();
142805
142935
  const emit2 = __emit;
@@ -142861,7 +142991,7 @@ ${reason}`);
142861
142991
  emit2("highlight-click", comment2);
142862
142992
  };
142863
142993
  const getCurrentComments = computed(() => {
142864
- return commentsList.value.filter((c2) => !c2.parentCommentId).filter((c2) => c2.selection && c2.selection.selectionBounds?.top).filter((c2) => !c2.resolvedTime).filter((c2) => c2.selection?.source !== "super-editor");
142994
+ return getGroupedComments.value?.parentComments.filter((c2) => c2.selection && c2.selection.selectionBounds?.top).filter((c2) => !c2.resolvedTime).filter((c2) => c2.selection?.source !== "super-editor");
142865
142995
  });
142866
142996
  watch(activeComment, (newVal) => {
142867
142997
  if (!newVal) return;
@@ -142889,7 +143019,7 @@ ${reason}`);
142889
143019
  };
142890
143020
  }
142891
143021
  };
142892
- const CommentsLayer = /* @__PURE__ */ _export_sfc(_sfc_main$b, [["__scopeId", "data-v-d019784c"]]);
143022
+ const CommentsLayer = /* @__PURE__ */ _export_sfc(_sfc_main$b, [["__scopeId", "data-v-7d21d613"]]);
142893
143023
  const _hoisted_1$9 = { class: "sidebar-container calculation-container" };
142894
143024
  const _hoisted_2$3 = ["id"];
142895
143025
  const _sfc_main$a = {
@@ -143731,6 +143861,16 @@ ${reason}`);
143731
143861
  const { isHighContrastMode: isHighContrastMode2 } = useHighContrastMode();
143732
143862
  const { uiFontFamily } = useUiFontFamily();
143733
143863
  const isViewingMode = () => proxy?.$superdoc?.config?.documentMode === "viewing";
143864
+ const isViewingCommentsVisible = computed(
143865
+ () => isViewingMode() && proxy?.$superdoc?.config?.comments?.visible === true
143866
+ );
143867
+ const isViewingTrackChangesVisible = computed(
143868
+ () => isViewingMode() && proxy?.$superdoc?.config?.trackChanges?.visible === true
143869
+ );
143870
+ const shouldRenderCommentsInViewing = computed(() => {
143871
+ if (!isViewingMode()) return true;
143872
+ return isViewingCommentsVisible.value || isViewingTrackChangesVisible.value;
143873
+ });
143734
143874
  const commentsModuleConfig = computed(() => {
143735
143875
  const config2 = modules.comments;
143736
143876
  if (config2 === false || config2 == null) return null;
@@ -143825,7 +143965,7 @@ ${reason}`);
143825
143965
  const commentsConfig = proxy.$superdoc.config.modules?.comments;
143826
143966
  if (!commentsConfig || commentsConfig === false) return;
143827
143967
  if (!positions || Object.keys(positions).length === 0) return;
143828
- if (isViewingMode()) {
143968
+ if (!shouldRenderCommentsInViewing.value) {
143829
143969
  commentsStore.clearEditorCommentPositions?.();
143830
143970
  return;
143831
143971
  }
@@ -144020,7 +144160,9 @@ ${reason}`);
144020
144160
  layoutEngineOptions: useLayoutEngine ? {
144021
144161
  ...proxy.$superdoc.config.layoutEngineOptions || {},
144022
144162
  debugLabel: proxy.$superdoc.config.layoutEngineOptions?.debugLabel ?? doc2.name ?? doc2.id,
144023
- zoom: (activeZoom.value ?? 100) / 100
144163
+ zoom: (activeZoom.value ?? 100) / 100,
144164
+ emitCommentPositionsInViewing: isViewingMode() && shouldRenderCommentsInViewing.value,
144165
+ enableCommentsInViewing: isViewingCommentsVisible.value
144024
144166
  } : void 0,
144025
144167
  permissionResolver: (payload = {}) => proxy.$superdoc.canPerformPermission({
144026
144168
  role: proxy.$superdoc.config.role,
@@ -144033,7 +144175,7 @@ ${reason}`);
144033
144175
  const onEditorCommentLocationsUpdate = (doc2, { allCommentIds: activeThreadId, allCommentPositions } = {}) => {
144034
144176
  const commentsConfig = proxy.$superdoc.config.modules?.comments;
144035
144177
  if (!commentsConfig || commentsConfig === false) return;
144036
- if (isViewingMode()) {
144178
+ if (!shouldRenderCommentsInViewing.value) {
144037
144179
  commentsStore.clearEditorCommentPositions?.();
144038
144180
  return;
144039
144181
  }
@@ -144092,7 +144234,7 @@ ${reason}`);
144092
144234
  };
144093
144235
  const isCommentsEnabled = computed(() => Boolean(commentsModuleConfig.value));
144094
144236
  const showCommentsSidebar = computed(() => {
144095
- if (isViewingMode()) return false;
144237
+ if (!shouldRenderCommentsInViewing.value) return false;
144096
144238
  return pendingComment.value || getFloatingComments.value?.length > 0 && isReady.value && layers.value && isCommentsEnabled.value && !isCommentsListVisible.value;
144097
144239
  });
144098
144240
  const showToolsFloatingMenu = computed(() => {
@@ -144434,7 +144576,7 @@ ${reason}`);
144434
144576
  };
144435
144577
  }
144436
144578
  };
144437
- const App = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-5196811d"]]);
144579
+ const App = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-78737564"]]);
144438
144580
  const createSuperdocVueApp = () => {
144439
144581
  const app = createApp(App);
144440
144582
  const pinia = createPinia();
@@ -144540,6 +144682,8 @@ ${reason}`);
144540
144682
  title: "SuperDoc",
144541
144683
  conversations: [],
144542
144684
  isInternal: false,
144685
+ comments: { visible: false },
144686
+ trackChanges: { visible: false },
144543
144687
  // toolbar config
144544
144688
  toolbar: null,
144545
144689
  // Optional DOM element to render the toolbar in
@@ -144589,6 +144733,16 @@ ${reason}`);
144589
144733
  ...this.config,
144590
144734
  ...config2
144591
144735
  };
144736
+ if (!this.config.comments || typeof this.config.comments !== "object") {
144737
+ this.config.comments = { visible: false };
144738
+ } else if (typeof this.config.comments.visible !== "boolean") {
144739
+ this.config.comments.visible = false;
144740
+ }
144741
+ if (!this.config.trackChanges || typeof this.config.trackChanges !== "object") {
144742
+ this.config.trackChanges = { visible: false };
144743
+ } else if (typeof this.config.trackChanges.visible !== "boolean") {
144744
+ this.config.trackChanges.visible = false;
144745
+ }
144592
144746
  const incomingUser = this.config.user;
144593
144747
  if (!incomingUser || typeof incomingUser !== "object") {
144594
144748
  this.config.user = { ...DEFAULT_USER };
@@ -144606,9 +144760,10 @@ ${reason}`);
144606
144760
  }
144607
144761
  if (!this.config.layoutEngineOptions.trackedChanges) {
144608
144762
  const isViewingMode = this.config.documentMode === "viewing";
144763
+ const viewingTrackedChangesVisible = isViewingMode && this.config.trackChanges?.visible === true;
144609
144764
  this.config.layoutEngineOptions.trackedChanges = {
144610
- mode: isViewingMode ? "final" : "review",
144611
- enabled: !isViewingMode
144765
+ mode: isViewingMode ? viewingTrackedChangesVisible ? "review" : "original" : "review",
144766
+ enabled: true
144612
144767
  };
144613
144768
  }
144614
144769
  this.config.modules = this.config.modules || {};
@@ -144618,7 +144773,7 @@ ${reason}`);
144618
144773
  this.config.colors = shuffleArray(this.config.colors);
144619
144774
  this.userColorMap = /* @__PURE__ */ new Map();
144620
144775
  this.colorIndex = 0;
144621
- this.version = "1.3.1-next.2";
144776
+ this.version = "1.4.0-next.1";
144622
144777
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
144623
144778
  this.superdocId = config2.superdocId || v4();
144624
144779
  this.colors = this.config.colors;
@@ -144755,6 +144910,7 @@ ${reason}`);
144755
144910
  this.superdocStore.init(this.config);
144756
144911
  const commentsModuleConfig = this.config.modules.comments;
144757
144912
  this.commentsStore.init(commentsModuleConfig && commentsModuleConfig !== false ? commentsModuleConfig : {});
144913
+ this.#syncViewingVisibility();
144758
144914
  }
144759
144915
  #initListeners() {
144760
144916
  this.on("editorBeforeCreate", this.config.onEditorBeforeCreate);
@@ -145056,6 +145212,7 @@ ${reason}`);
145056
145212
  if (!type) return;
145057
145213
  type = type.toLowerCase();
145058
145214
  this.config.documentMode = type;
145215
+ this.#syncViewingVisibility();
145059
145216
  const types2 = {
145060
145217
  viewing: () => this.#setModeViewing(),
145061
145218
  editing: () => this.#setModeEditing(),
@@ -145135,10 +145292,20 @@ ${reason}`);
145135
145292
  }
145136
145293
  #setModeViewing() {
145137
145294
  this.toolbar.activeEditor = null;
145138
- this.setTrackedChangesPreferences({ mode: "original", enabled: true });
145139
- this.commentsStore?.clearEditorCommentPositions?.();
145295
+ const commentsVisible = this.config.comments?.visible === true;
145296
+ const trackChangesVisible = this.config.trackChanges?.visible === true;
145297
+ this.setTrackedChangesPreferences(
145298
+ trackChangesVisible ? { mode: "review", enabled: true } : { mode: "original", enabled: true }
145299
+ );
145300
+ if (!commentsVisible && !trackChangesVisible) {
145301
+ this.commentsStore?.clearEditorCommentPositions?.();
145302
+ }
145140
145303
  this.superdocStore.documents.forEach((doc2) => {
145141
- doc2.removeComments();
145304
+ if (commentsVisible || trackChangesVisible) {
145305
+ doc2.restoreComments();
145306
+ } else {
145307
+ doc2.removeComments();
145308
+ }
145142
145309
  this.#applyDocumentMode(doc2, "viewing");
145143
145310
  });
145144
145311
  if (this.toolbar) {
@@ -145146,6 +145313,31 @@ ${reason}`);
145146
145313
  this.toolbar.updateToolbarState();
145147
145314
  }
145148
145315
  }
145316
+ #syncViewingVisibility() {
145317
+ const commentsVisible = this.config.comments?.visible === true;
145318
+ const trackChangesVisible = this.config.trackChanges?.visible === true;
145319
+ const isViewingMode = this.config.documentMode === "viewing";
145320
+ const shouldRenderCommentsInViewing = commentsVisible || trackChangesVisible;
145321
+ if (this.commentsStore?.setViewingVisibility) {
145322
+ this.commentsStore.setViewingVisibility({
145323
+ documentMode: this.config.documentMode,
145324
+ commentsVisible,
145325
+ trackChangesVisible
145326
+ });
145327
+ }
145328
+ const docs = this.superdocStore?.documents;
145329
+ if (Array.isArray(docs) && docs.length > 0) {
145330
+ docs.forEach((doc2) => {
145331
+ const presentationEditor = typeof doc2.getPresentationEditor === "function" ? doc2.getPresentationEditor() : null;
145332
+ if (presentationEditor?.setViewingCommentOptions) {
145333
+ presentationEditor.setViewingCommentOptions({
145334
+ emitCommentPositionsInViewing: isViewingMode && shouldRenderCommentsInViewing,
145335
+ enableCommentsInViewing: isViewingMode && commentsVisible
145336
+ });
145337
+ }
145338
+ });
145339
+ }
145340
+ }
145149
145341
  /**
145150
145342
  * Search for text or regex in the active editor
145151
145343
  * @param {string | RegExp} text The text or regex to search for