@harbour-enterprises/superdoc 1.3.1-next.3 → 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-CPnVLLJm.es.js → PdfViewer-DRTk3dY6.es.js} +2 -2
  2. package/dist/chunks/{PdfViewer-BXbmY3Fc.cjs → PdfViewer-H9_8IbtN.cjs} +2 -2
  3. package/dist/chunks/{SuperConverter-BQ6PNaJ8.es.js → SuperConverter-CFRB4XNw.es.js} +1 -1
  4. package/dist/chunks/{SuperConverter-p1tQGIew.cjs → SuperConverter-CgY28MJz.cjs} +1 -1
  5. package/dist/chunks/{index-DXSUcHli.es.js → index-BP9aFfwI.es.js} +109 -17
  6. package/dist/chunks/{index-BQYtE-5U.cjs → index-BdaseaBw.cjs} +109 -17
  7. package/dist/chunks/{index-DLX_v-vr.cjs → index-C3KRKogJ.cjs} +52 -10
  8. package/dist/chunks/{index-CJec1cbb.es.js → index-CEcYlysg.es.js} +52 -10
  9. package/dist/style.css +32 -32
  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 +158 -24
  26. package/dist/superdoc.umd.js.map +1 -1
  27. package/package.json +3 -3
  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
@@ -36436,7 +36436,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
36436
36436
  static getStoredSuperdocVersion(docx) {
36437
36437
  return SuperConverter.getStoredCustomProperty(docx, "SuperdocVersion");
36438
36438
  }
36439
- static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.3.1-next.3") {
36439
+ static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.4.0-next.1") {
36440
36440
  return SuperConverter.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
36441
36441
  }
36442
36442
  /**
@@ -62252,7 +62252,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
62252
62252
  return false;
62253
62253
  }
62254
62254
  };
62255
- const summaryVersion = "1.3.1-next.3";
62255
+ const summaryVersion = "1.4.0-next.1";
62256
62256
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
62257
62257
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
62258
62258
  function mapAttributes(attrs) {
@@ -64885,7 +64885,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
64885
64885
  * Process collaboration migrations
64886
64886
  */
64887
64887
  processCollaborationMigrations() {
64888
- console.debug("[checkVersionMigrations] Current editor version", "1.3.1-next.3");
64888
+ console.debug("[checkVersionMigrations] Current editor version", "1.4.0-next.1");
64889
64889
  if (!this.options.ydoc) return;
64890
64890
  const metaMap = this.options.ydoc.getMap("meta");
64891
64891
  let docVersion = metaMap.get("version");
@@ -88612,7 +88612,13 @@ ${l}
88612
88612
  const result = {};
88613
88613
  if (spacing.before != null) result.before = pxToPt(spacing.before);
88614
88614
  if (spacing.after != null) result.after = pxToPt(spacing.after);
88615
- 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
+ }
88616
88622
  if (spacing.lineRule) result.lineRule = spacing.lineRule;
88617
88623
  return result;
88618
88624
  };
@@ -88636,8 +88642,13 @@ ${l}
88636
88642
  if (after != null) result.after = after;
88637
88643
  }
88638
88644
  if (rawSpacing.line != null) {
88639
- const line = ptToPx(spacing.line);
88640
- 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
+ }
88641
88652
  if (spacing.lineRule) result.lineRule = spacing.lineRule;
88642
88653
  }
88643
88654
  }
@@ -88717,7 +88728,7 @@ ${l}
88717
88728
  if (value > 0 && value <= MAX_AUTO_LINE_MULTIPLIER) {
88718
88729
  return value;
88719
88730
  }
88720
- return twipsToPx$1(value);
88731
+ return value / 240;
88721
88732
  }
88722
88733
  return twipsToPx$1(value);
88723
88734
  };
@@ -96858,7 +96869,8 @@ ${l}
96858
96869
  return baseLineHeight;
96859
96870
  }
96860
96871
  const raw = spacing.line;
96861
- 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);
96862
96874
  if (treatAsMultiplier) {
96863
96875
  return raw * baseLineHeight;
96864
96876
  }
@@ -97205,6 +97217,8 @@ ${l}
97205
97217
  debugLabel: options.layoutEngineOptions?.debugLabel,
97206
97218
  layoutMode: options.layoutEngineOptions?.layoutMode ?? "vertical",
97207
97219
  trackedChanges: options.layoutEngineOptions?.trackedChanges,
97220
+ emitCommentPositionsInViewing: options.layoutEngineOptions?.emitCommentPositionsInViewing,
97221
+ enableCommentsInViewing: options.layoutEngineOptions?.enableCommentsInViewing,
97208
97222
  presence: validatedPresence
97209
97223
  };
97210
97224
  this.#trackedChangesOverrides = options.layoutEngineOptions?.trackedChanges;
@@ -97793,6 +97807,33 @@ ${l}
97793
97807
  this.#scheduleRerender();
97794
97808
  }
97795
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
+ }
97796
97837
  /**
97797
97838
  * Toggle the custom context menu at runtime to respect host-level guardrails.
97798
97839
  */
@@ -100145,7 +100186,7 @@ ${l}
100145
100186
  } : void 0;
100146
100187
  const atomNodeTypes = getAtomNodeTypes(this.#editor?.schema ?? null);
100147
100188
  const positionMap2 = this.#editor?.state?.doc && docJson ? buildPositionMapFromPmDoc(this.#editor.state.doc, docJson) : null;
100148
- const commentsEnabled = this.#documentMode !== "viewing";
100189
+ const commentsEnabled = this.#documentMode !== "viewing" || this.#layoutOptions.enableCommentsInViewing === true;
100149
100190
  const result = toFlowBlocks(docJson, {
100150
100191
  mediaFiles: this.#editor?.storage?.image?.media,
100151
100192
  emitSectionBreaks: true,
@@ -100285,7 +100326,8 @@ ${l}
100285
100326
  const payload = { layout, blocks: blocks2, measures, metrics };
100286
100327
  this.emit("layoutUpdated", payload);
100287
100328
  this.emit("paginationUpdate", payload);
100288
- if (this.#documentMode !== "viewing") {
100329
+ const allowViewingCommentPositions = this.#layoutOptions.emitCommentPositionsInViewing === true;
100330
+ if (this.#documentMode !== "viewing" || allowViewingCommentPositions) {
100289
100331
  const commentPositions = this.#collectCommentPositions();
100290
100332
  const positionKeys = Object.keys(commentPositions);
100291
100333
  if (positionKeys.length > 0) {
@@ -141442,6 +141484,11 @@ ${reason}`);
141442
141484
  allowResolve: true,
141443
141485
  showResolved: false
141444
141486
  });
141487
+ const viewingVisibility = reactive({
141488
+ documentMode: "editing",
141489
+ commentsVisible: false,
141490
+ trackChangesVisible: false
141491
+ });
141445
141492
  const isDebugging = false;
141446
141493
  const debounceTimers = {};
141447
141494
  const COMMENT_EVENTS = comments_module_events;
@@ -141468,6 +141515,7 @@ ${reason}`);
141468
141515
  const isFloatingCommentsReady = ref(false);
141469
141516
  const generalCommentIds = ref([]);
141470
141517
  const pendingComment = ref(null);
141518
+ const isViewingMode = computed(() => viewingVisibility.documentMode === "viewing");
141471
141519
  const init2 = (config2 = {}) => {
141472
141520
  const updatedConfig = { ...commentsConfig, ...config2 };
141473
141521
  Object.assign(commentsConfig, updatedConfig);
@@ -141480,6 +141528,17 @@ ${reason}`);
141480
141528
  if (id === void 0 || id === null) return null;
141481
141529
  return commentsList.value.find((c2) => c2.commentId == id || c2.importedId == id);
141482
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
+ };
141483
141542
  const setActiveComment = (superdoc, id) => {
141484
141543
  if (id === void 0 || id === null) {
141485
141544
  activeComment.value = null;
@@ -141581,6 +141640,7 @@ ${reason}`);
141581
141640
  const resolvedComments = [];
141582
141641
  const childCommentMap = /* @__PURE__ */ new Map();
141583
141642
  commentsList.value.forEach((comment2) => {
141643
+ if (!isThreadVisible(comment2)) return;
141584
141644
  if (comment2.resolvedTime) {
141585
141645
  resolvedComments.push(comment2);
141586
141646
  } else if (!comment2.parentCommentId && !comment2.resolvedTime) {
@@ -141789,6 +141849,17 @@ ${reason}`);
141789
141849
  });
141790
141850
  return comments;
141791
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
+ };
141792
141863
  const normalizeCommentForEditor = (node2) => {
141793
141864
  if (!node2 || typeof node2 !== "object") return node2;
141794
141865
  const cloneMarks = (marks) => Array.isArray(marks) ? marks.filter(Boolean).map((mark2) => ({
@@ -141868,6 +141939,7 @@ ${reason}`);
141868
141939
  getFloatingComments,
141869
141940
  // Actions
141870
141941
  init: init2,
141942
+ setViewingVisibility,
141871
141943
  getComment,
141872
141944
  setActiveComment,
141873
141945
  getCommentLocation,
@@ -142857,7 +142929,7 @@ ${reason}`);
142857
142929
  const superdocStore = useSuperdocStore();
142858
142930
  const commentsStore = useCommentsStore();
142859
142931
  const { COMMENT_EVENTS } = commentsStore;
142860
- const { documentsWithConverations, activeComment, floatingCommentsOffset, commentsList } = storeToRefs(commentsStore);
142932
+ const { documentsWithConverations, activeComment, floatingCommentsOffset, getGroupedComments } = storeToRefs(commentsStore);
142861
142933
  const { documents, activeZoom } = storeToRefs(superdocStore);
142862
142934
  const { proxy } = getCurrentInstance();
142863
142935
  const emit2 = __emit;
@@ -142919,7 +142991,7 @@ ${reason}`);
142919
142991
  emit2("highlight-click", comment2);
142920
142992
  };
142921
142993
  const getCurrentComments = computed(() => {
142922
- 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");
142923
142995
  });
142924
142996
  watch(activeComment, (newVal) => {
142925
142997
  if (!newVal) return;
@@ -142947,7 +143019,7 @@ ${reason}`);
142947
143019
  };
142948
143020
  }
142949
143021
  };
142950
- 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"]]);
142951
143023
  const _hoisted_1$9 = { class: "sidebar-container calculation-container" };
142952
143024
  const _hoisted_2$3 = ["id"];
142953
143025
  const _sfc_main$a = {
@@ -143789,6 +143861,16 @@ ${reason}`);
143789
143861
  const { isHighContrastMode: isHighContrastMode2 } = useHighContrastMode();
143790
143862
  const { uiFontFamily } = useUiFontFamily();
143791
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
+ });
143792
143874
  const commentsModuleConfig = computed(() => {
143793
143875
  const config2 = modules.comments;
143794
143876
  if (config2 === false || config2 == null) return null;
@@ -143883,7 +143965,7 @@ ${reason}`);
143883
143965
  const commentsConfig = proxy.$superdoc.config.modules?.comments;
143884
143966
  if (!commentsConfig || commentsConfig === false) return;
143885
143967
  if (!positions || Object.keys(positions).length === 0) return;
143886
- if (isViewingMode()) {
143968
+ if (!shouldRenderCommentsInViewing.value) {
143887
143969
  commentsStore.clearEditorCommentPositions?.();
143888
143970
  return;
143889
143971
  }
@@ -144078,7 +144160,9 @@ ${reason}`);
144078
144160
  layoutEngineOptions: useLayoutEngine ? {
144079
144161
  ...proxy.$superdoc.config.layoutEngineOptions || {},
144080
144162
  debugLabel: proxy.$superdoc.config.layoutEngineOptions?.debugLabel ?? doc2.name ?? doc2.id,
144081
- zoom: (activeZoom.value ?? 100) / 100
144163
+ zoom: (activeZoom.value ?? 100) / 100,
144164
+ emitCommentPositionsInViewing: isViewingMode() && shouldRenderCommentsInViewing.value,
144165
+ enableCommentsInViewing: isViewingCommentsVisible.value
144082
144166
  } : void 0,
144083
144167
  permissionResolver: (payload = {}) => proxy.$superdoc.canPerformPermission({
144084
144168
  role: proxy.$superdoc.config.role,
@@ -144091,7 +144175,7 @@ ${reason}`);
144091
144175
  const onEditorCommentLocationsUpdate = (doc2, { allCommentIds: activeThreadId, allCommentPositions } = {}) => {
144092
144176
  const commentsConfig = proxy.$superdoc.config.modules?.comments;
144093
144177
  if (!commentsConfig || commentsConfig === false) return;
144094
- if (isViewingMode()) {
144178
+ if (!shouldRenderCommentsInViewing.value) {
144095
144179
  commentsStore.clearEditorCommentPositions?.();
144096
144180
  return;
144097
144181
  }
@@ -144150,7 +144234,7 @@ ${reason}`);
144150
144234
  };
144151
144235
  const isCommentsEnabled = computed(() => Boolean(commentsModuleConfig.value));
144152
144236
  const showCommentsSidebar = computed(() => {
144153
- if (isViewingMode()) return false;
144237
+ if (!shouldRenderCommentsInViewing.value) return false;
144154
144238
  return pendingComment.value || getFloatingComments.value?.length > 0 && isReady.value && layers.value && isCommentsEnabled.value && !isCommentsListVisible.value;
144155
144239
  });
144156
144240
  const showToolsFloatingMenu = computed(() => {
@@ -144492,7 +144576,7 @@ ${reason}`);
144492
144576
  };
144493
144577
  }
144494
144578
  };
144495
- 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"]]);
144496
144580
  const createSuperdocVueApp = () => {
144497
144581
  const app = createApp(App);
144498
144582
  const pinia = createPinia();
@@ -144598,6 +144682,8 @@ ${reason}`);
144598
144682
  title: "SuperDoc",
144599
144683
  conversations: [],
144600
144684
  isInternal: false,
144685
+ comments: { visible: false },
144686
+ trackChanges: { visible: false },
144601
144687
  // toolbar config
144602
144688
  toolbar: null,
144603
144689
  // Optional DOM element to render the toolbar in
@@ -144647,6 +144733,16 @@ ${reason}`);
144647
144733
  ...this.config,
144648
144734
  ...config2
144649
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
+ }
144650
144746
  const incomingUser = this.config.user;
144651
144747
  if (!incomingUser || typeof incomingUser !== "object") {
144652
144748
  this.config.user = { ...DEFAULT_USER };
@@ -144664,9 +144760,10 @@ ${reason}`);
144664
144760
  }
144665
144761
  if (!this.config.layoutEngineOptions.trackedChanges) {
144666
144762
  const isViewingMode = this.config.documentMode === "viewing";
144763
+ const viewingTrackedChangesVisible = isViewingMode && this.config.trackChanges?.visible === true;
144667
144764
  this.config.layoutEngineOptions.trackedChanges = {
144668
- mode: isViewingMode ? "final" : "review",
144669
- enabled: !isViewingMode
144765
+ mode: isViewingMode ? viewingTrackedChangesVisible ? "review" : "original" : "review",
144766
+ enabled: true
144670
144767
  };
144671
144768
  }
144672
144769
  this.config.modules = this.config.modules || {};
@@ -144676,7 +144773,7 @@ ${reason}`);
144676
144773
  this.config.colors = shuffleArray(this.config.colors);
144677
144774
  this.userColorMap = /* @__PURE__ */ new Map();
144678
144775
  this.colorIndex = 0;
144679
- this.version = "1.3.1-next.3";
144776
+ this.version = "1.4.0-next.1";
144680
144777
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
144681
144778
  this.superdocId = config2.superdocId || v4();
144682
144779
  this.colors = this.config.colors;
@@ -144813,6 +144910,7 @@ ${reason}`);
144813
144910
  this.superdocStore.init(this.config);
144814
144911
  const commentsModuleConfig = this.config.modules.comments;
144815
144912
  this.commentsStore.init(commentsModuleConfig && commentsModuleConfig !== false ? commentsModuleConfig : {});
144913
+ this.#syncViewingVisibility();
144816
144914
  }
144817
144915
  #initListeners() {
144818
144916
  this.on("editorBeforeCreate", this.config.onEditorBeforeCreate);
@@ -145114,6 +145212,7 @@ ${reason}`);
145114
145212
  if (!type) return;
145115
145213
  type = type.toLowerCase();
145116
145214
  this.config.documentMode = type;
145215
+ this.#syncViewingVisibility();
145117
145216
  const types2 = {
145118
145217
  viewing: () => this.#setModeViewing(),
145119
145218
  editing: () => this.#setModeEditing(),
@@ -145193,10 +145292,20 @@ ${reason}`);
145193
145292
  }
145194
145293
  #setModeViewing() {
145195
145294
  this.toolbar.activeEditor = null;
145196
- this.setTrackedChangesPreferences({ mode: "original", enabled: true });
145197
- 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
+ }
145198
145303
  this.superdocStore.documents.forEach((doc2) => {
145199
- doc2.removeComments();
145304
+ if (commentsVisible || trackChangesVisible) {
145305
+ doc2.restoreComments();
145306
+ } else {
145307
+ doc2.removeComments();
145308
+ }
145200
145309
  this.#applyDocumentMode(doc2, "viewing");
145201
145310
  });
145202
145311
  if (this.toolbar) {
@@ -145204,6 +145313,31 @@ ${reason}`);
145204
145313
  this.toolbar.updateToolbarState();
145205
145314
  }
145206
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
+ }
145207
145341
  /**
145208
145342
  * Search for text or regex in the active editor
145209
145343
  * @param {string | RegExp} text The text or regex to search for