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

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-Dnv-LGqI.es.js} +2 -2
  2. package/dist/chunks/{PdfViewer-BXbmY3Fc.cjs → PdfViewer-DqN1vOXI.cjs} +2 -2
  3. package/dist/chunks/{SuperConverter-BQ6PNaJ8.es.js → SuperConverter-DxlpZQZQ.es.js} +266 -6
  4. package/dist/chunks/{SuperConverter-p1tQGIew.cjs → SuperConverter-Dy4wkQEB.cjs} +266 -6
  5. package/dist/chunks/{index-DXSUcHli.es.js → index-D246eEeJ.es.js} +109 -17
  6. package/dist/chunks/{index-DLX_v-vr.cjs → index-DJuBZura.cjs} +106 -27
  7. package/dist/chunks/{index-BQYtE-5U.cjs → index-DpgrTjYC.cjs} +109 -17
  8. package/dist/chunks/{index-CJec1cbb.es.js → index-dnQEKI-e.es.js} +106 -27
  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 +477 -46
  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
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  const jszip = require("./jszip-C8_CqJxM.cjs");
3
3
  const helpers$1 = require("./helpers-nOdwpmwb.cjs");
4
- const superEditor_converter = require("./SuperConverter-p1tQGIew.cjs");
4
+ const superEditor_converter = require("./SuperConverter-Dy4wkQEB.cjs");
5
5
  const vue = require("./vue-De9wkgLl.cjs");
6
6
  require("./jszip.min-BPh2MMAa.cjs");
7
7
  const eventemitter3 = require("./eventemitter3-BQuRcMPI.cjs");
@@ -15457,7 +15457,7 @@ const canUseDOM = () => {
15457
15457
  return false;
15458
15458
  }
15459
15459
  };
15460
- const summaryVersion = "1.3.1-next.3";
15460
+ const summaryVersion = "1.4.0-next.2";
15461
15461
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
15462
15462
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
15463
15463
  function mapAttributes(attrs) {
@@ -18089,7 +18089,7 @@ class Editor extends EventEmitter {
18089
18089
  * Process collaboration migrations
18090
18090
  */
18091
18091
  processCollaborationMigrations() {
18092
- console.debug("[checkVersionMigrations] Current editor version", "1.3.1-next.3");
18092
+ console.debug("[checkVersionMigrations] Current editor version", "1.4.0-next.2");
18093
18093
  if (!this.options.ydoc) return;
18094
18094
  const metaMap = this.options.ydoc.getMap("meta");
18095
18095
  let docVersion = metaMap.get("version");
@@ -23822,6 +23822,9 @@ const renderTableCell = (deps) => {
23822
23822
  imgEl.style.width = "100%";
23823
23823
  imgEl.style.height = "100%";
23824
23824
  imgEl.style.objectFit = block.objectFit ?? "contain";
23825
+ if (block.objectFit === "cover") {
23826
+ imgEl.style.objectPosition = "left top";
23827
+ }
23825
23828
  imgEl.style.display = "block";
23826
23829
  imageWrapper.appendChild(imgEl);
23827
23830
  content.appendChild(imageWrapper);
@@ -23851,6 +23854,9 @@ const renderTableCell = (deps) => {
23851
23854
  img.style.width = "100%";
23852
23855
  img.style.height = "100%";
23853
23856
  img.style.objectFit = block.objectFit ?? "contain";
23857
+ if (block.objectFit === "cover") {
23858
+ img.style.objectPosition = "left top";
23859
+ }
23854
23860
  drawingInner.appendChild(img);
23855
23861
  } else if (renderDrawingContent) {
23856
23862
  const drawingContent = renderDrawingContent(block);
@@ -26422,7 +26428,7 @@ class DomPainter {
26422
26428
  if (fragment.pmEnd != null) {
26423
26429
  fragmentEl.dataset.pmEnd = String(fragment.pmEnd);
26424
26430
  }
26425
- if (fragment.metadata) {
26431
+ if (fragment.metadata && !block.attrs?.vmlWatermark) {
26426
26432
  fragmentEl.setAttribute("data-image-metadata", JSON.stringify(fragment.metadata));
26427
26433
  }
26428
26434
  const img = this.doc.createElement("img");
@@ -26433,7 +26439,28 @@ class DomPainter {
26433
26439
  img.style.width = "100%";
26434
26440
  img.style.height = "100%";
26435
26441
  img.style.objectFit = block.objectFit ?? "contain";
26442
+ if (block.objectFit === "cover") {
26443
+ img.style.objectPosition = "left top";
26444
+ }
26436
26445
  img.style.display = block.display === "inline" ? "inline-block" : "block";
26446
+ const filters = [];
26447
+ if (block.gain != null || block.blacklevel != null) {
26448
+ if (block.gain && typeof block.gain === "string" && block.gain.endsWith("f")) {
26449
+ const contrast = Math.max(0, parseInt(block.gain) / 65536);
26450
+ if (contrast > 0) {
26451
+ filters.push(`contrast(${contrast})`);
26452
+ }
26453
+ }
26454
+ if (block.blacklevel && typeof block.blacklevel === "string" && block.blacklevel.endsWith("f")) {
26455
+ const brightness = Math.max(0, 1 + parseInt(block.blacklevel) / 327 / 100) + 0.5;
26456
+ if (brightness > 0) {
26457
+ filters.push(`brightness(${brightness})`);
26458
+ }
26459
+ }
26460
+ if (filters.length > 0) {
26461
+ img.style.filter = filters.join(" ");
26462
+ }
26463
+ }
26437
26464
  fragmentEl.appendChild(img);
26438
26465
  return fragmentEl;
26439
26466
  } catch (error) {
@@ -26513,6 +26540,9 @@ class DomPainter {
26513
26540
  img.style.width = "100%";
26514
26541
  img.style.height = "100%";
26515
26542
  img.style.objectFit = drawing.objectFit ?? "contain";
26543
+ if (drawing.objectFit === "cover") {
26544
+ img.style.objectPosition = "left top";
26545
+ }
26516
26546
  img.style.display = "block";
26517
26547
  return img;
26518
26548
  }
@@ -31263,13 +31293,8 @@ function computeAnchorX(anchor, columnIndex, columns, imageWidth, margins, pageW
31263
31293
  let baseX;
31264
31294
  let availableWidth;
31265
31295
  if (relativeFrom === "page") {
31266
- if (columns.count === 1) {
31267
- baseX = contentLeft;
31268
- availableWidth = contentWidth;
31269
- } else {
31270
- baseX = 0;
31271
- availableWidth = pageWidth != null ? pageWidth : contentWidth;
31272
- }
31296
+ baseX = 0;
31297
+ availableWidth = pageWidth != null ? pageWidth : contentWidth + marginLeft + marginRight;
31273
31298
  } else if (relativeFrom === "margin") {
31274
31299
  baseX = contentLeft;
31275
31300
  availableWidth = contentWidth;
@@ -32758,7 +32783,9 @@ function collectPreRegisteredAnchors(blocks, measures) {
32758
32783
  if (!isImage && !isDrawing) continue;
32759
32784
  const drawingBlock = block;
32760
32785
  const drawingMeasure = measure;
32761
- if (!drawingBlock.anchor?.isAnchored) continue;
32786
+ if (!drawingBlock.anchor?.isAnchored) {
32787
+ continue;
32788
+ }
32762
32789
  if (isPageRelativeAnchor(drawingBlock)) {
32763
32790
  result.push({ block: drawingBlock, measure: drawingMeasure });
32764
32791
  }
@@ -41868,7 +41895,13 @@ const spacingPxToPt = (spacing) => {
41868
41895
  const result = {};
41869
41896
  if (spacing.before != null) result.before = pxToPt(spacing.before);
41870
41897
  if (spacing.after != null) result.after = pxToPt(spacing.after);
41871
- if (spacing.line != null) result.line = pxToPt(spacing.line);
41898
+ if (spacing.line != null) {
41899
+ if (spacing.lineRule === "auto" && spacing.line > 0 && spacing.line <= MAX_AUTO_LINE_MULTIPLIER) {
41900
+ result.line = spacing.line;
41901
+ } else {
41902
+ result.line = pxToPt(spacing.line);
41903
+ }
41904
+ }
41872
41905
  if (spacing.lineRule) result.lineRule = spacing.lineRule;
41873
41906
  return result;
41874
41907
  };
@@ -41892,8 +41925,13 @@ const spacingPtToPx = (spacing, rawSpacing) => {
41892
41925
  if (after != null) result.after = after;
41893
41926
  }
41894
41927
  if (rawSpacing.line != null) {
41895
- const line = ptToPx(spacing.line);
41896
- if (line != null) result.line = line;
41928
+ const isAutoMultiplier = spacing.lineRule === "auto" && spacing.line != null && spacing.line > 0 && spacing.line <= MAX_AUTO_LINE_MULTIPLIER;
41929
+ if (isAutoMultiplier) {
41930
+ result.line = spacing.line;
41931
+ } else {
41932
+ const line = ptToPx(spacing.line);
41933
+ if (line != null) result.line = line;
41934
+ }
41897
41935
  if (spacing.lineRule) result.lineRule = spacing.lineRule;
41898
41936
  }
41899
41937
  }
@@ -41973,7 +42011,7 @@ const normalizeLineValue = (value, lineRule) => {
41973
42011
  if (value > 0 && value <= MAX_AUTO_LINE_MULTIPLIER) {
41974
42012
  return value;
41975
42013
  }
41976
- return twipsToPx$1(value);
42014
+ return value / 240;
41977
42015
  }
41978
42016
  return twipsToPx$1(value);
41979
42017
  };
@@ -45895,8 +45933,9 @@ function imageNodeToBlock(node, nextBlockId, positions, _trackedMeta, _trackedCh
45895
45933
  const isInline2 = normalizedWrap?.type === "Inline" || typeof attrs.inline === "boolean" && attrs.inline;
45896
45934
  const display = explicitDisplay === "inline" || explicitDisplay === "block" ? explicitDisplay : isInline2 ? "inline" : "block";
45897
45935
  const explicitObjectFit = typeof attrs.objectFit === "string" ? attrs.objectFit : void 0;
45936
+ const shouldCover = attrs.shouldCover === true;
45898
45937
  const isAnchor = anchor?.isAnchored ?? (typeof attrs.isAnchor === "boolean" ? attrs.isAnchor : false);
45899
- const objectFit = isAllowedObjectFit(explicitObjectFit) ? explicitObjectFit : display === "inline" ? "scale-down" : isAnchor ? "contain" : "contain";
45938
+ const objectFit = isAllowedObjectFit(explicitObjectFit) ? explicitObjectFit : shouldCover ? "cover" : display === "inline" ? "scale-down" : isAnchor ? "contain" : "contain";
45900
45939
  return {
45901
45940
  kind: "image",
45902
45941
  id: nextBlockId("image"),
@@ -45911,7 +45950,10 @@ function imageNodeToBlock(node, nextBlockId, positions, _trackedMeta, _trackedCh
45911
45950
  margin: toBoxSpacing(attrs.marginOffset),
45912
45951
  anchor,
45913
45952
  wrap: normalizedWrap,
45914
- attrs: attrsWithPm
45953
+ attrs: attrsWithPm,
45954
+ // VML image adjustments for watermark effects
45955
+ gain: typeof attrs.gain === "string" || typeof attrs.gain === "number" ? attrs.gain : void 0,
45956
+ blacklevel: typeof attrs.blacklevel === "string" || typeof attrs.blacklevel === "number" ? attrs.blacklevel : void 0
45915
45957
  };
45916
45958
  }
45917
45959
  function handleImageNode(node, context) {
@@ -49861,11 +49903,13 @@ async function measureImageBlock(block, constraints) {
49861
49903
  const intrinsic = getIntrinsicImageSize(block, constraints.maxWidth);
49862
49904
  const isBlockBehindDoc = block.anchor?.behindDoc;
49863
49905
  const isBlockWrapBehindDoc = block.wrap?.type === "None" && block.wrap?.behindDoc;
49864
- const bypassWidthConstraint = isBlockBehindDoc || isBlockWrapBehindDoc;
49906
+ const isPageRelativeAnchor2 = block.anchor?.isAnchored && (block.anchor?.hRelativeFrom === "page" || block.anchor?.hRelativeFrom === "margin");
49907
+ const bypassWidthConstraint = isBlockBehindDoc || isBlockWrapBehindDoc || isPageRelativeAnchor2;
49865
49908
  const isWidthConstraintBypassed = bypassWidthConstraint || constraints.maxWidth <= 0;
49866
49909
  const maxWidth = isWidthConstraintBypassed ? intrinsic.width : constraints.maxWidth;
49867
49910
  const hasNegativeVerticalPosition = block.anchor?.isAnchored && (typeof block.anchor?.offsetV === "number" && block.anchor.offsetV < 0 || typeof block.margin?.top === "number" && block.margin.top < 0);
49868
- const maxHeight = hasNegativeVerticalPosition || !constraints.maxHeight || constraints.maxHeight <= 0 ? Infinity : constraints.maxHeight;
49911
+ const shouldBypassHeightConstraint = hasNegativeVerticalPosition || block.objectFit === "cover";
49912
+ const maxHeight = shouldBypassHeightConstraint || !constraints.maxHeight || constraints.maxHeight <= 0 ? Infinity : constraints.maxHeight;
49869
49913
  const widthScale = maxWidth / intrinsic.width;
49870
49914
  const heightScale = maxHeight / intrinsic.height;
49871
49915
  const scale = Math.min(1, widthScale, heightScale);
@@ -50114,7 +50158,8 @@ const resolveLineHeight = (spacing, baseLineHeight) => {
50114
50158
  return baseLineHeight;
50115
50159
  }
50116
50160
  const raw = spacing.line;
50117
- const treatAsMultiplier = (spacing.lineRule === "auto" || spacing.lineRule == null) && raw > 0 && raw <= 10;
50161
+ const isAuto = spacing.lineRule === "auto";
50162
+ const treatAsMultiplier = (isAuto || spacing.lineRule == null) && raw > 0 && (isAuto || raw <= 10);
50118
50163
  if (treatAsMultiplier) {
50119
50164
  return raw * baseLineHeight;
50120
50165
  }
@@ -50461,6 +50506,8 @@ class PresentationEditor extends EventEmitter {
50461
50506
  debugLabel: options.layoutEngineOptions?.debugLabel,
50462
50507
  layoutMode: options.layoutEngineOptions?.layoutMode ?? "vertical",
50463
50508
  trackedChanges: options.layoutEngineOptions?.trackedChanges,
50509
+ emitCommentPositionsInViewing: options.layoutEngineOptions?.emitCommentPositionsInViewing,
50510
+ enableCommentsInViewing: options.layoutEngineOptions?.enableCommentsInViewing,
50464
50511
  presence: validatedPresence
50465
50512
  };
50466
50513
  this.#trackedChangesOverrides = options.layoutEngineOptions?.trackedChanges;
@@ -51049,6 +51096,33 @@ class PresentationEditor extends EventEmitter {
51049
51096
  this.#scheduleRerender();
51050
51097
  }
51051
51098
  }
51099
+ /**
51100
+ * Update viewing-mode comment rendering behavior and re-render if needed.
51101
+ *
51102
+ * @param options - Viewing mode comment options.
51103
+ */
51104
+ setViewingCommentOptions(options = {}) {
51105
+ if (options !== void 0 && (typeof options !== "object" || options === null || Array.isArray(options))) {
51106
+ throw new TypeError("[PresentationEditor] setViewingCommentOptions expects an object or undefined");
51107
+ }
51108
+ let hasChanges = false;
51109
+ if (typeof options.emitCommentPositionsInViewing === "boolean") {
51110
+ if (this.#layoutOptions.emitCommentPositionsInViewing !== options.emitCommentPositionsInViewing) {
51111
+ this.#layoutOptions.emitCommentPositionsInViewing = options.emitCommentPositionsInViewing;
51112
+ hasChanges = true;
51113
+ }
51114
+ }
51115
+ if (typeof options.enableCommentsInViewing === "boolean") {
51116
+ if (this.#layoutOptions.enableCommentsInViewing !== options.enableCommentsInViewing) {
51117
+ this.#layoutOptions.enableCommentsInViewing = options.enableCommentsInViewing;
51118
+ hasChanges = true;
51119
+ }
51120
+ }
51121
+ if (hasChanges) {
51122
+ this.#pendingDocChange = true;
51123
+ this.#scheduleRerender();
51124
+ }
51125
+ }
51052
51126
  /**
51053
51127
  * Toggle the custom context menu at runtime to respect host-level guardrails.
51054
51128
  */
@@ -53430,7 +53504,7 @@ class PresentationEditor extends EventEmitter {
53430
53504
  } : void 0;
53431
53505
  const atomNodeTypes = getAtomNodeTypes(this.#editor?.schema ?? null);
53432
53506
  const positionMap = this.#editor?.state?.doc && docJson ? buildPositionMapFromPmDoc(this.#editor.state.doc, docJson) : null;
53433
- const commentsEnabled = this.#documentMode !== "viewing";
53507
+ const commentsEnabled = this.#documentMode !== "viewing" || this.#layoutOptions.enableCommentsInViewing === true;
53434
53508
  const result = toFlowBlocks(docJson, {
53435
53509
  mediaFiles: this.#editor?.storage?.image?.media,
53436
53510
  emitSectionBreaks: true,
@@ -53570,7 +53644,8 @@ class PresentationEditor extends EventEmitter {
53570
53644
  const payload = { layout, blocks, measures, metrics };
53571
53645
  this.emit("layoutUpdated", payload);
53572
53646
  this.emit("paginationUpdate", payload);
53573
- if (this.#documentMode !== "viewing") {
53647
+ const allowViewingCommentPositions = this.#layoutOptions.emitCommentPositionsInViewing === true;
53648
+ if (this.#documentMode !== "viewing" || allowViewingCommentPositions) {
53574
53649
  const commentPositions = this.#collectCommentPositions();
53575
53650
  const positionKeys = Object.keys(commentPositions);
53576
53651
  if (positionKeys.length > 0) {
@@ -64496,18 +64571,18 @@ const Image = Node$1.create({
64496
64571
  // Used during DOCX export to restore the original metafile format.
64497
64572
  originalExtension: { rendered: false },
64498
64573
  originalSrc: { rendered: false },
64499
- shouldStretch: {
64574
+ shouldCover: {
64500
64575
  default: false,
64501
64576
  rendered: false
64502
64577
  },
64503
64578
  size: {
64504
64579
  default: {},
64505
- renderDOM: ({ size: size2, shouldStretch }) => {
64580
+ renderDOM: ({ size: size2, shouldCover }) => {
64506
64581
  let style2 = "";
64507
64582
  let { width, height } = size2 ?? {};
64508
64583
  if (width) style2 += `width: ${width}px;`;
64509
- if (height && shouldStretch) {
64510
- style2 += `height: ${height}px; object-fit: fill;`;
64584
+ if (height && shouldCover) {
64585
+ style2 += `height: ${height}px; object-fit: cover; object-position: left top;`;
64511
64586
  } else if (height) style2 += "height: auto;";
64512
64587
  return { style: style2 };
64513
64588
  }
@@ -72790,6 +72865,9 @@ const nodeResizer = (nodeNames = ["image"], editor) => {
72790
72865
  if (!node || !nodeNames.includes(node.type.name)) {
72791
72866
  return DecorationSet.empty;
72792
72867
  }
72868
+ if (node.attrs?.vmlWatermark === true) {
72869
+ return DecorationSet.empty;
72870
+ }
72793
72871
  const decorations = [];
72794
72872
  if (nodeNames.includes(selection.node?.type.name)) {
72795
72873
  decorations.push(
@@ -72872,6 +72950,7 @@ const nodeResizer = (nodeNames = ["image"], editor) => {
72872
72950
  const pos = Number.parseInt(wrapper.getAttribute("data-pos"), 10);
72873
72951
  const node = view.state.doc.nodeAt(pos);
72874
72952
  if (!nodeNames.includes(node?.type.name)) return;
72953
+ if (node?.attrs?.vmlWatermark === true) return;
72875
72954
  currentWrapper = wrapper;
72876
72955
  resizeContainer = document.createElement("div");
72877
72956
  resizeContainer.className = "sd-editor-resize-container";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
- const index = require("./index-DLX_v-vr.cjs");
3
- require("./SuperConverter-p1tQGIew.cjs");
2
+ const index = require("./index-DJuBZura.cjs");
3
+ require("./SuperConverter-Dy4wkQEB.cjs");
4
4
  const blankDocx = require("./blank-docx-DfW3Eeh2.cjs");
5
5
  const eventemitter3 = require("./eventemitter3-BQuRcMPI.cjs");
6
6
  const provider = require("@hocuspocus/provider");
@@ -5161,6 +5161,11 @@ const useCommentsStore = /* @__PURE__ */ defineStore("comments", () => {
5161
5161
  allowResolve: true,
5162
5162
  showResolved: false
5163
5163
  });
5164
+ const viewingVisibility = vue.reactive({
5165
+ documentMode: "editing",
5166
+ commentsVisible: false,
5167
+ trackChangesVisible: false
5168
+ });
5164
5169
  const isDebugging = false;
5165
5170
  const debounceTimers = {};
5166
5171
  const COMMENT_EVENTS = index.comments_module_events;
@@ -5187,6 +5192,7 @@ const useCommentsStore = /* @__PURE__ */ defineStore("comments", () => {
5187
5192
  const isFloatingCommentsReady = vue.ref(false);
5188
5193
  const generalCommentIds = vue.ref([]);
5189
5194
  const pendingComment = vue.ref(null);
5195
+ const isViewingMode = vue.computed(() => viewingVisibility.documentMode === "viewing");
5190
5196
  const init = (config = {}) => {
5191
5197
  const updatedConfig = { ...commentsConfig, ...config };
5192
5198
  Object.assign(commentsConfig, updatedConfig);
@@ -5199,6 +5205,17 @@ const useCommentsStore = /* @__PURE__ */ defineStore("comments", () => {
5199
5205
  if (id === void 0 || id === null) return null;
5200
5206
  return commentsList.value.find((c) => c.commentId == id || c.importedId == id);
5201
5207
  };
5208
+ const getThreadParent = (comment) => {
5209
+ if (!comment?.parentCommentId) return comment;
5210
+ return getComment(comment.parentCommentId);
5211
+ };
5212
+ const isThreadVisible = (comment) => {
5213
+ if (!isViewingMode.value) return true;
5214
+ const parent = getThreadParent(comment);
5215
+ if (!parent && comment?.parentCommentId) return false;
5216
+ const isTrackedChange = Boolean(parent?.trackedChange);
5217
+ return isTrackedChange ? viewingVisibility.trackChangesVisible : viewingVisibility.commentsVisible;
5218
+ };
5202
5219
  const setActiveComment = (superdoc, id) => {
5203
5220
  if (id === void 0 || id === null) {
5204
5221
  activeComment.value = null;
@@ -5300,6 +5317,7 @@ const useCommentsStore = /* @__PURE__ */ defineStore("comments", () => {
5300
5317
  const resolvedComments = [];
5301
5318
  const childCommentMap = /* @__PURE__ */ new Map();
5302
5319
  commentsList.value.forEach((comment) => {
5320
+ if (!isThreadVisible(comment)) return;
5303
5321
  if (comment.resolvedTime) {
5304
5322
  resolvedComments.push(comment);
5305
5323
  } else if (!comment.parentCommentId && !comment.resolvedTime) {
@@ -5508,6 +5526,17 @@ const useCommentsStore = /* @__PURE__ */ defineStore("comments", () => {
5508
5526
  });
5509
5527
  return comments;
5510
5528
  });
5529
+ const setViewingVisibility = ({ documentMode, commentsVisible, trackChangesVisible } = {}) => {
5530
+ if (typeof documentMode === "string") {
5531
+ viewingVisibility.documentMode = documentMode;
5532
+ }
5533
+ if (typeof commentsVisible === "boolean") {
5534
+ viewingVisibility.commentsVisible = commentsVisible;
5535
+ }
5536
+ if (typeof trackChangesVisible === "boolean") {
5537
+ viewingVisibility.trackChangesVisible = trackChangesVisible;
5538
+ }
5539
+ };
5511
5540
  const normalizeCommentForEditor = (node) => {
5512
5541
  if (!node || typeof node !== "object") return node;
5513
5542
  const cloneMarks = (marks) => Array.isArray(marks) ? marks.filter(Boolean).map((mark) => ({
@@ -5587,6 +5616,7 @@ const useCommentsStore = /* @__PURE__ */ defineStore("comments", () => {
5587
5616
  getFloatingComments,
5588
5617
  // Actions
5589
5618
  init,
5619
+ setViewingVisibility,
5590
5620
  getComment,
5591
5621
  setActiveComment,
5592
5622
  getCommentLocation,
@@ -6576,7 +6606,7 @@ const _sfc_main$a = {
6576
6606
  const superdocStore = useSuperdocStore();
6577
6607
  const commentsStore = useCommentsStore();
6578
6608
  const { COMMENT_EVENTS } = commentsStore;
6579
- const { documentsWithConverations, activeComment, floatingCommentsOffset, commentsList } = storeToRefs(commentsStore);
6609
+ const { documentsWithConverations, activeComment, floatingCommentsOffset, getGroupedComments } = storeToRefs(commentsStore);
6580
6610
  const { documents, activeZoom } = storeToRefs(superdocStore);
6581
6611
  const { proxy } = vue.getCurrentInstance();
6582
6612
  const emit = __emit;
@@ -6638,7 +6668,7 @@ const _sfc_main$a = {
6638
6668
  emit("highlight-click", comment);
6639
6669
  };
6640
6670
  const getCurrentComments = vue.computed(() => {
6641
- return commentsList.value.filter((c) => !c.parentCommentId).filter((c) => c.selection && c.selection.selectionBounds?.top).filter((c) => !c.resolvedTime).filter((c) => c.selection?.source !== "super-editor");
6671
+ return getGroupedComments.value?.parentComments.filter((c) => c.selection && c.selection.selectionBounds?.top).filter((c) => !c.resolvedTime).filter((c) => c.selection?.source !== "super-editor");
6642
6672
  });
6643
6673
  vue.watch(activeComment, (newVal) => {
6644
6674
  if (!newVal) return;
@@ -6666,7 +6696,7 @@ const _sfc_main$a = {
6666
6696
  };
6667
6697
  }
6668
6698
  };
6669
- const CommentsLayer = /* @__PURE__ */ index._export_sfc(_sfc_main$a, [["__scopeId", "data-v-d019784c"]]);
6699
+ const CommentsLayer = /* @__PURE__ */ index._export_sfc(_sfc_main$a, [["__scopeId", "data-v-7d21d613"]]);
6670
6700
  const _hoisted_1$8 = { class: "sidebar-container calculation-container" };
6671
6701
  const _hoisted_2$3 = ["id"];
6672
6702
  const _sfc_main$9 = {
@@ -7466,7 +7496,7 @@ const _sfc_main = {
7466
7496
  __name: "SuperDoc",
7467
7497
  emits: ["selection-update"],
7468
7498
  setup(__props, { emit: __emit }) {
7469
- const PdfViewer = vue.defineAsyncComponent(() => Promise.resolve().then(() => require("./PdfViewer-BXbmY3Fc.cjs")));
7499
+ const PdfViewer = vue.defineAsyncComponent(() => Promise.resolve().then(() => require("./PdfViewer-DqN1vOXI.cjs")));
7470
7500
  const superdocStore = useSuperdocStore();
7471
7501
  const commentsStore = useCommentsStore();
7472
7502
  const {
@@ -7508,6 +7538,16 @@ const _sfc_main = {
7508
7538
  const { isHighContrastMode: isHighContrastMode2 } = useHighContrastMode();
7509
7539
  const { uiFontFamily } = useUiFontFamily();
7510
7540
  const isViewingMode = () => proxy?.$superdoc?.config?.documentMode === "viewing";
7541
+ const isViewingCommentsVisible = vue.computed(
7542
+ () => isViewingMode() && proxy?.$superdoc?.config?.comments?.visible === true
7543
+ );
7544
+ const isViewingTrackChangesVisible = vue.computed(
7545
+ () => isViewingMode() && proxy?.$superdoc?.config?.trackChanges?.visible === true
7546
+ );
7547
+ const shouldRenderCommentsInViewing = vue.computed(() => {
7548
+ if (!isViewingMode()) return true;
7549
+ return isViewingCommentsVisible.value || isViewingTrackChangesVisible.value;
7550
+ });
7511
7551
  const commentsModuleConfig = vue.computed(() => {
7512
7552
  const config = modules.comments;
7513
7553
  if (config === false || config == null) return null;
@@ -7602,7 +7642,7 @@ const _sfc_main = {
7602
7642
  const commentsConfig = proxy.$superdoc.config.modules?.comments;
7603
7643
  if (!commentsConfig || commentsConfig === false) return;
7604
7644
  if (!positions || Object.keys(positions).length === 0) return;
7605
- if (isViewingMode()) {
7645
+ if (!shouldRenderCommentsInViewing.value) {
7606
7646
  commentsStore.clearEditorCommentPositions?.();
7607
7647
  return;
7608
7648
  }
@@ -7797,7 +7837,9 @@ const _sfc_main = {
7797
7837
  layoutEngineOptions: useLayoutEngine ? {
7798
7838
  ...proxy.$superdoc.config.layoutEngineOptions || {},
7799
7839
  debugLabel: proxy.$superdoc.config.layoutEngineOptions?.debugLabel ?? doc.name ?? doc.id,
7800
- zoom: (activeZoom.value ?? 100) / 100
7840
+ zoom: (activeZoom.value ?? 100) / 100,
7841
+ emitCommentPositionsInViewing: isViewingMode() && shouldRenderCommentsInViewing.value,
7842
+ enableCommentsInViewing: isViewingCommentsVisible.value
7801
7843
  } : void 0,
7802
7844
  permissionResolver: (payload = {}) => proxy.$superdoc.canPerformPermission({
7803
7845
  role: proxy.$superdoc.config.role,
@@ -7810,7 +7852,7 @@ const _sfc_main = {
7810
7852
  const onEditorCommentLocationsUpdate = (doc, { allCommentIds: activeThreadId, allCommentPositions } = {}) => {
7811
7853
  const commentsConfig = proxy.$superdoc.config.modules?.comments;
7812
7854
  if (!commentsConfig || commentsConfig === false) return;
7813
- if (isViewingMode()) {
7855
+ if (!shouldRenderCommentsInViewing.value) {
7814
7856
  commentsStore.clearEditorCommentPositions?.();
7815
7857
  return;
7816
7858
  }
@@ -7869,7 +7911,7 @@ const _sfc_main = {
7869
7911
  };
7870
7912
  const isCommentsEnabled = vue.computed(() => Boolean(commentsModuleConfig.value));
7871
7913
  const showCommentsSidebar = vue.computed(() => {
7872
- if (isViewingMode()) return false;
7914
+ if (!shouldRenderCommentsInViewing.value) return false;
7873
7915
  return pendingComment.value || getFloatingComments.value?.length > 0 && isReady.value && layers.value && isCommentsEnabled.value && !isCommentsListVisible.value;
7874
7916
  });
7875
7917
  const showToolsFloatingMenu = vue.computed(() => {
@@ -8211,7 +8253,7 @@ const _sfc_main = {
8211
8253
  };
8212
8254
  }
8213
8255
  };
8214
- const App = /* @__PURE__ */ index._export_sfc(_sfc_main, [["__scopeId", "data-v-5196811d"]]);
8256
+ const App = /* @__PURE__ */ index._export_sfc(_sfc_main, [["__scopeId", "data-v-78737564"]]);
8215
8257
  const createSuperdocVueApp = () => {
8216
8258
  const app = vue.createApp(App);
8217
8259
  const pinia = createPinia();
@@ -8317,6 +8359,8 @@ class SuperDoc extends eventemitter3.EventEmitter {
8317
8359
  title: "SuperDoc",
8318
8360
  conversations: [],
8319
8361
  isInternal: false,
8362
+ comments: { visible: false },
8363
+ trackChanges: { visible: false },
8320
8364
  // toolbar config
8321
8365
  toolbar: null,
8322
8366
  // Optional DOM element to render the toolbar in
@@ -8366,6 +8410,16 @@ class SuperDoc extends eventemitter3.EventEmitter {
8366
8410
  ...this.config,
8367
8411
  ...config
8368
8412
  };
8413
+ if (!this.config.comments || typeof this.config.comments !== "object") {
8414
+ this.config.comments = { visible: false };
8415
+ } else if (typeof this.config.comments.visible !== "boolean") {
8416
+ this.config.comments.visible = false;
8417
+ }
8418
+ if (!this.config.trackChanges || typeof this.config.trackChanges !== "object") {
8419
+ this.config.trackChanges = { visible: false };
8420
+ } else if (typeof this.config.trackChanges.visible !== "boolean") {
8421
+ this.config.trackChanges.visible = false;
8422
+ }
8369
8423
  const incomingUser = this.config.user;
8370
8424
  if (!incomingUser || typeof incomingUser !== "object") {
8371
8425
  this.config.user = { ...DEFAULT_USER };
@@ -8383,9 +8437,10 @@ class SuperDoc extends eventemitter3.EventEmitter {
8383
8437
  }
8384
8438
  if (!this.config.layoutEngineOptions.trackedChanges) {
8385
8439
  const isViewingMode = this.config.documentMode === "viewing";
8440
+ const viewingTrackedChangesVisible = isViewingMode && this.config.trackChanges?.visible === true;
8386
8441
  this.config.layoutEngineOptions.trackedChanges = {
8387
- mode: isViewingMode ? "final" : "review",
8388
- enabled: !isViewingMode
8442
+ mode: isViewingMode ? viewingTrackedChangesVisible ? "review" : "original" : "review",
8443
+ enabled: true
8389
8444
  };
8390
8445
  }
8391
8446
  this.config.modules = this.config.modules || {};
@@ -8395,7 +8450,7 @@ class SuperDoc extends eventemitter3.EventEmitter {
8395
8450
  this.config.colors = shuffleArray(this.config.colors);
8396
8451
  this.userColorMap = /* @__PURE__ */ new Map();
8397
8452
  this.colorIndex = 0;
8398
- this.version = "1.3.1-next.3";
8453
+ this.version = "1.4.0-next.2";
8399
8454
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
8400
8455
  this.superdocId = config.superdocId || uuid.v4();
8401
8456
  this.colors = this.config.colors;
@@ -8532,6 +8587,7 @@ class SuperDoc extends eventemitter3.EventEmitter {
8532
8587
  this.superdocStore.init(this.config);
8533
8588
  const commentsModuleConfig = this.config.modules.comments;
8534
8589
  this.commentsStore.init(commentsModuleConfig && commentsModuleConfig !== false ? commentsModuleConfig : {});
8590
+ this.#syncViewingVisibility();
8535
8591
  }
8536
8592
  #initListeners() {
8537
8593
  this.on("editorBeforeCreate", this.config.onEditorBeforeCreate);
@@ -8833,6 +8889,7 @@ class SuperDoc extends eventemitter3.EventEmitter {
8833
8889
  if (!type) return;
8834
8890
  type = type.toLowerCase();
8835
8891
  this.config.documentMode = type;
8892
+ this.#syncViewingVisibility();
8836
8893
  const types = {
8837
8894
  viewing: () => this.#setModeViewing(),
8838
8895
  editing: () => this.#setModeEditing(),
@@ -8912,10 +8969,20 @@ class SuperDoc extends eventemitter3.EventEmitter {
8912
8969
  }
8913
8970
  #setModeViewing() {
8914
8971
  this.toolbar.activeEditor = null;
8915
- this.setTrackedChangesPreferences({ mode: "original", enabled: true });
8916
- this.commentsStore?.clearEditorCommentPositions?.();
8972
+ const commentsVisible = this.config.comments?.visible === true;
8973
+ const trackChangesVisible = this.config.trackChanges?.visible === true;
8974
+ this.setTrackedChangesPreferences(
8975
+ trackChangesVisible ? { mode: "review", enabled: true } : { mode: "original", enabled: true }
8976
+ );
8977
+ if (!commentsVisible && !trackChangesVisible) {
8978
+ this.commentsStore?.clearEditorCommentPositions?.();
8979
+ }
8917
8980
  this.superdocStore.documents.forEach((doc) => {
8918
- doc.removeComments();
8981
+ if (commentsVisible || trackChangesVisible) {
8982
+ doc.restoreComments();
8983
+ } else {
8984
+ doc.removeComments();
8985
+ }
8919
8986
  this.#applyDocumentMode(doc, "viewing");
8920
8987
  });
8921
8988
  if (this.toolbar) {
@@ -8923,6 +8990,31 @@ class SuperDoc extends eventemitter3.EventEmitter {
8923
8990
  this.toolbar.updateToolbarState();
8924
8991
  }
8925
8992
  }
8993
+ #syncViewingVisibility() {
8994
+ const commentsVisible = this.config.comments?.visible === true;
8995
+ const trackChangesVisible = this.config.trackChanges?.visible === true;
8996
+ const isViewingMode = this.config.documentMode === "viewing";
8997
+ const shouldRenderCommentsInViewing = commentsVisible || trackChangesVisible;
8998
+ if (this.commentsStore?.setViewingVisibility) {
8999
+ this.commentsStore.setViewingVisibility({
9000
+ documentMode: this.config.documentMode,
9001
+ commentsVisible,
9002
+ trackChangesVisible
9003
+ });
9004
+ }
9005
+ const docs = this.superdocStore?.documents;
9006
+ if (Array.isArray(docs) && docs.length > 0) {
9007
+ docs.forEach((doc) => {
9008
+ const presentationEditor = typeof doc.getPresentationEditor === "function" ? doc.getPresentationEditor() : null;
9009
+ if (presentationEditor?.setViewingCommentOptions) {
9010
+ presentationEditor.setViewingCommentOptions({
9011
+ emitCommentPositionsInViewing: isViewingMode && shouldRenderCommentsInViewing,
9012
+ enableCommentsInViewing: isViewingMode && commentsVisible
9013
+ });
9014
+ }
9015
+ });
9016
+ }
9017
+ }
8926
9018
  /**
8927
9019
  * Search for text or regex in the active editor
8928
9020
  * @param {string | RegExp} text The text or regex to search for