@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
@@ -24064,7 +24064,7 @@
24064
24064
  const DRAWING_XML_TAG = "w:drawing";
24065
24065
  const SHAPE_URI = "http://schemas.microsoft.com/office/word/2010/wordprocessingShape";
24066
24066
  const GROUP_URI = "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup";
24067
- const normalizeTargetPath = (targetPath = "") => {
24067
+ const normalizeTargetPath$1 = (targetPath = "") => {
24068
24068
  if (!targetPath) return targetPath;
24069
24069
  const trimmed = targetPath.replace(/^\/+/, "");
24070
24070
  if (trimmed.startsWith("word/")) return trimmed;
@@ -24223,7 +24223,14 @@
24223
24223
  }
24224
24224
  const stretch = blipFill?.elements.find((el) => el.name === "a:stretch");
24225
24225
  const fillRect = stretch?.elements.find((el) => el.name === "a:fillRect");
24226
+ const srcRect = blipFill?.elements.find((el) => el.name === "a:srcRect");
24227
+ const srcRectAttrs = srcRect?.attributes || {};
24228
+ const srcRectHasNegativeValues = ["l", "t", "r", "b"].some((attr) => {
24229
+ const val = srcRectAttrs[attr];
24230
+ return val != null && parseFloat(val) < 0;
24231
+ });
24226
24232
  const shouldStretch = Boolean(stretch && fillRect);
24233
+ const shouldCover = shouldStretch && !srcRectHasNegativeValues;
24227
24234
  const spPr = picture.elements.find((el) => el.name === "pic:spPr");
24228
24235
  if (spPr) {
24229
24236
  const xfrm = spPr.elements.find((el) => el.name === "a:xfrm");
@@ -24252,7 +24259,7 @@
24252
24259
  }
24253
24260
  const { attributes: relAttributes } = rel;
24254
24261
  const targetPath = relAttributes["Target"];
24255
- const path2 = normalizeTargetPath(targetPath);
24262
+ const path2 = normalizeTargetPath$1(targetPath);
24256
24263
  const extension = path2.substring(path2.lastIndexOf(".") + 1);
24257
24264
  let finalSrc = path2;
24258
24265
  let finalExtension = extension;
@@ -24300,7 +24307,7 @@
24300
24307
  wrapText: wrap2.attrs.wrapText
24301
24308
  } : {},
24302
24309
  wrapTopAndBottom: wrap2.type === "TopAndBottom",
24303
- shouldStretch,
24310
+ shouldCover,
24304
24311
  originalPadding: {
24305
24312
  distT: attributes["distT"],
24306
24313
  distB: attributes["distB"],
@@ -24493,7 +24500,7 @@
24493
24500
  const { elements } = relationships || [];
24494
24501
  const rel = elements?.find((el) => el.attributes["Id"] === rEmbed);
24495
24502
  if (!rel) return null;
24496
- const targetPath = normalizeTargetPath(rel.attributes?.["Target"]);
24503
+ const targetPath = normalizeTargetPath$1(rel.attributes?.["Target"]);
24497
24504
  const path2 = targetPath;
24498
24505
  const nvPicPr = pic.elements?.find((el) => el.name === "pic:nvPicPr");
24499
24506
  const cNvPr = nvPicPr?.elements?.find((el) => el.name === "pic:cNvPr");
@@ -34987,6 +34994,10 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34987
34994
  if (!node2 || typeof node2.type !== "string") return;
34988
34995
  const type = node2.type;
34989
34996
  const preservableNodeName = PRESERVABLE_INLINE_XML_NAMES[type];
34997
+ if (type === "image" && node2.attrs?.isAnchor) {
34998
+ result.push(node2);
34999
+ return;
35000
+ }
34990
35001
  if (!INLINE_TYPES.has(type)) {
34991
35002
  result.push(node2);
34992
35003
  } else if (preservableNodeName) {
@@ -35180,6 +35191,137 @@ Please report this to https://github.com/markedjs/marked.`, e) {
35180
35191
  }
35181
35192
  return style2;
35182
35193
  }
35194
+ function handleShapeImageImport({ params: params2, pict }) {
35195
+ const shape = pict.elements?.find((el) => el.name === "v:shape");
35196
+ if (!shape) return null;
35197
+ const imagedata = shape.elements?.find((el) => el.name === "v:imagedata");
35198
+ if (!imagedata) return null;
35199
+ const { docx, filename } = params2;
35200
+ const shapeAttrs = shape.attributes || {};
35201
+ const imagedataAttrs = imagedata.attributes || {};
35202
+ const rId = imagedataAttrs["r:id"];
35203
+ if (!rId) {
35204
+ console.warn("v:imagedata missing r:id attribute");
35205
+ return null;
35206
+ }
35207
+ const currentFile = filename || "document.xml";
35208
+ let rels = docx[`word/_rels/${currentFile}.rels`];
35209
+ if (!rels) rels = docx[`word/_rels/document.xml.rels`];
35210
+ const relationships = rels?.elements?.find((el) => el.name === "Relationships");
35211
+ const { elements } = relationships || [];
35212
+ const rel = elements?.find((el) => el.attributes["Id"] === rId);
35213
+ if (!rel) {
35214
+ console.warn(`Relationship not found for r:id="${rId}"`);
35215
+ return null;
35216
+ }
35217
+ const targetPath = rel.attributes["Target"];
35218
+ const normalizedPath = normalizeTargetPath(targetPath);
35219
+ const style2 = shapeAttrs.style || "";
35220
+ const styleObj = parseVmlStyle(style2);
35221
+ const width = styleObj.width || "100px";
35222
+ const height = styleObj.height || "100px";
35223
+ const position2 = {
35224
+ type: styleObj.position || "absolute",
35225
+ marginLeft: styleObj["margin-left"] || "0",
35226
+ marginTop: styleObj["margin-top"] || "0"
35227
+ };
35228
+ const zIndex = styleObj["z-index"] ? parseInt(styleObj["z-index"], 10) : void 0;
35229
+ const hPosition = styleObj["mso-position-horizontal"] || "center";
35230
+ const vPosition = styleObj["mso-position-vertical"] || "center";
35231
+ const hRelativeTo = styleObj["mso-position-horizontal-relative"] || "margin";
35232
+ const vRelativeTo = styleObj["mso-position-vertical-relative"] || "margin";
35233
+ const gain = imagedataAttrs["gain"];
35234
+ const blacklevel = imagedataAttrs["blacklevel"];
35235
+ const title = imagedataAttrs["o:title"] || "Watermark";
35236
+ const imageNode = {
35237
+ type: "image",
35238
+ attrs: {
35239
+ src: normalizedPath,
35240
+ alt: title,
35241
+ extension: normalizedPath.substring(normalizedPath.lastIndexOf(".") + 1),
35242
+ title,
35243
+ rId,
35244
+ // Store VML-specific attributes for round-trip
35245
+ vmlWatermark: true,
35246
+ vmlStyle: style2,
35247
+ vmlAttributes: shapeAttrs,
35248
+ vmlImagedata: imagedataAttrs,
35249
+ // Positioning
35250
+ isAnchor: true,
35251
+ inline: false,
35252
+ wrap: {
35253
+ type: "None",
35254
+ attrs: {
35255
+ behindDoc: Number.isFinite(zIndex) ? zIndex < 0 : true
35256
+ }
35257
+ },
35258
+ anchorData: {
35259
+ hRelativeFrom: hRelativeTo,
35260
+ vRelativeFrom: vRelativeTo,
35261
+ alignH: hPosition,
35262
+ alignV: vPosition
35263
+ },
35264
+ // Size
35265
+ size: {
35266
+ width: convertToPixels(width),
35267
+ height: convertToPixels(height)
35268
+ },
35269
+ marginOffset: {
35270
+ horizontal: convertToPixels(position2.marginLeft),
35271
+ top: convertToPixels(position2.marginTop)
35272
+ },
35273
+ // Image adjustments
35274
+ ...gain && { gain },
35275
+ ...blacklevel && { blacklevel }
35276
+ }
35277
+ };
35278
+ return imageNode;
35279
+ }
35280
+ function normalizeTargetPath(targetPath = "") {
35281
+ if (!targetPath) return targetPath;
35282
+ const trimmed = targetPath.replace(/^\/+/, "");
35283
+ if (trimmed.startsWith("word/")) return trimmed;
35284
+ if (trimmed.startsWith("media/")) return `word/${trimmed}`;
35285
+ return `word/${trimmed}`;
35286
+ }
35287
+ function parseVmlStyle(style2) {
35288
+ const result = {};
35289
+ if (!style2) return result;
35290
+ const declarations = style2.split(";").filter((s2) => s2.trim());
35291
+ for (const decl of declarations) {
35292
+ const [prop, value] = decl.split(":").map((s2) => s2.trim());
35293
+ if (prop && value) {
35294
+ result[prop] = value;
35295
+ }
35296
+ }
35297
+ return result;
35298
+ }
35299
+ function convertToPixels(value) {
35300
+ if (typeof value === "number") return value;
35301
+ if (!value || typeof value !== "string") return 0;
35302
+ const match = value.match(/^([\d.]+)([a-z%]+)?$/i);
35303
+ if (!match) return 0;
35304
+ const num = parseFloat(match[1]);
35305
+ const unit = match[2] || "px";
35306
+ switch (unit.toLowerCase()) {
35307
+ case "px":
35308
+ return num;
35309
+ case "pt":
35310
+ return num * (96 / 72);
35311
+ // 1pt = 1/72 inch, 96 DPI
35312
+ case "in":
35313
+ return num * 96;
35314
+ case "cm":
35315
+ return num * (96 / 2.54);
35316
+ case "mm":
35317
+ return num * (96 / 25.4);
35318
+ case "pc":
35319
+ return num * 16;
35320
+ // 1pc = 12pt
35321
+ default:
35322
+ return num;
35323
+ }
35324
+ }
35183
35325
  function pictNodeTypeStrategy(node2) {
35184
35326
  const shape = node2.elements?.find((el) => el.name === "v:shape");
35185
35327
  const group = node2.elements?.find((el) => el.name === "v:group");
@@ -35198,6 +35340,10 @@ Please report this to https://github.com/markedjs/marked.`, e) {
35198
35340
  if (textbox) {
35199
35341
  return { type: "shapeContainer", handler: handleShapeTextboxImport };
35200
35342
  }
35343
+ const imagedata = shape.elements?.find((el) => el.name === "v:imagedata");
35344
+ if (imagedata) {
35345
+ return { type: "image", handler: handleShapeImageImport };
35346
+ }
35201
35347
  }
35202
35348
  return { type: "unknown", handler: null };
35203
35349
  }
@@ -35296,8 +35442,116 @@ Please report this to https://github.com/markedjs/marked.`, e) {
35296
35442
  };
35297
35443
  return wrapTextInRun(pict);
35298
35444
  }
35445
+ function translateVmlWatermark(params2) {
35446
+ const { node: node2 } = params2;
35447
+ const { attrs } = node2;
35448
+ if (attrs.vmlAttributes && attrs.vmlImagedata) {
35449
+ const shape2 = {
35450
+ name: "v:shape",
35451
+ attributes: attrs.vmlAttributes,
35452
+ elements: [
35453
+ {
35454
+ name: "v:imagedata",
35455
+ attributes: {
35456
+ ...attrs.vmlImagedata,
35457
+ "r:id": attrs.rId
35458
+ }
35459
+ }
35460
+ ]
35461
+ };
35462
+ const pict2 = {
35463
+ name: "w:pict",
35464
+ attributes: {
35465
+ "w14:anchorId": generateRandomSigned32BitIntStrId()
35466
+ },
35467
+ elements: [shape2]
35468
+ };
35469
+ const par2 = {
35470
+ name: "w:p",
35471
+ elements: [wrapTextInRun(pict2)]
35472
+ };
35473
+ return par2;
35474
+ }
35475
+ const style2 = buildVmlStyle(attrs);
35476
+ const shape = {
35477
+ name: "v:shape",
35478
+ attributes: {
35479
+ id: `WordPictureWatermark${generateRandomSigned32BitIntStrId().replace("-", "")}`,
35480
+ "o:spid": `_x0000_s${Math.floor(Math.random() * 1e4)}`,
35481
+ type: "#_x0000_t75",
35482
+ style: style2,
35483
+ "o:allowincell": "f"
35484
+ },
35485
+ elements: [
35486
+ {
35487
+ name: "v:imagedata",
35488
+ attributes: {
35489
+ "r:id": attrs.rId,
35490
+ "o:title": attrs.title || attrs.alt || "Watermark",
35491
+ ...attrs.gain && { gain: attrs.gain },
35492
+ ...attrs.blacklevel && { blacklevel: attrs.blacklevel }
35493
+ }
35494
+ }
35495
+ ]
35496
+ };
35497
+ const pict = {
35498
+ name: "w:pict",
35499
+ attributes: {
35500
+ "w14:anchorId": generateRandomSigned32BitIntStrId()
35501
+ },
35502
+ elements: [shape]
35503
+ };
35504
+ const par = {
35505
+ name: "w:p",
35506
+ elements: [wrapTextInRun(pict)]
35507
+ };
35508
+ return par;
35509
+ }
35510
+ function buildVmlStyle(attrs) {
35511
+ const styles = [];
35512
+ styles.push("position:absolute");
35513
+ if (attrs.size) {
35514
+ if (attrs.size.width) {
35515
+ styles.push(`width:${convertToPt(attrs.size.width)}pt`);
35516
+ }
35517
+ if (attrs.size.height) {
35518
+ styles.push(`height:${convertToPt(attrs.size.height)}pt`);
35519
+ }
35520
+ }
35521
+ if (attrs.marginOffset) {
35522
+ if (attrs.marginOffset.horizontal !== void 0) {
35523
+ styles.push(`margin-left:${convertToPt(attrs.marginOffset.horizontal)}pt`);
35524
+ }
35525
+ if (attrs.marginOffset.top !== void 0) {
35526
+ styles.push(`margin-top:${convertToPt(attrs.marginOffset.top)}pt`);
35527
+ }
35528
+ }
35529
+ if (attrs.wrap?.attrs?.behindDoc) {
35530
+ styles.push("z-index:-251653120");
35531
+ }
35532
+ if (attrs.anchorData) {
35533
+ if (attrs.anchorData.alignH) {
35534
+ styles.push(`mso-position-horizontal:${attrs.anchorData.alignH}`);
35535
+ }
35536
+ if (attrs.anchorData.alignV) {
35537
+ styles.push(`mso-position-vertical:${attrs.anchorData.alignV}`);
35538
+ }
35539
+ if (attrs.anchorData.hRelativeFrom) {
35540
+ styles.push(`mso-position-horizontal-relative:${attrs.anchorData.hRelativeFrom}`);
35541
+ }
35542
+ if (attrs.anchorData.vRelativeFrom) {
35543
+ styles.push(`mso-position-vertical-relative:${attrs.anchorData.vRelativeFrom}`);
35544
+ }
35545
+ }
35546
+ styles.push("mso-width-percent:0");
35547
+ styles.push("mso-height-percent:0");
35548
+ return styles.join(";");
35549
+ }
35550
+ function convertToPt(pixels) {
35551
+ return pixels * 72 / 96;
35552
+ }
35299
35553
  const XML_NODE_NAME = "w:pict";
35300
- const SD_NODE_NAME = ["shapeContainer", "contentBlock"];
35554
+ const SD_NODE_NAME = ["shapeContainer", "contentBlock", "image"];
35301
35555
  const validXmlAttributes = [];
35302
35556
  function encode$1(params2) {
35303
35557
  const { node: node2, pNode } = params2.extraParams;
@@ -35321,6 +35575,12 @@ Please report this to https://github.com/markedjs/marked.`, e) {
35321
35575
  shapeContainer: () => translateShapeContainer(params2),
35322
35576
  shapeTextbox: () => translateShapeTextbox(params2),
35323
35577
  contentBlock: () => translateContentBlock(params2),
35578
+ image: () => {
35579
+ if (node2.attrs?.vmlWatermark) {
35580
+ return translateVmlWatermark(params2);
35581
+ }
35582
+ return null;
35583
+ },
35324
35584
  default: () => null
35325
35585
  };
35326
35586
  const decoder = types2[node2.type] ?? types2.default;
@@ -36436,7 +36696,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
36436
36696
  static getStoredSuperdocVersion(docx) {
36437
36697
  return SuperConverter.getStoredCustomProperty(docx, "SuperdocVersion");
36438
36698
  }
36439
- static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.3.1-next.3") {
36699
+ static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.4.0-next.2") {
36440
36700
  return SuperConverter.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
36441
36701
  }
36442
36702
  /**
@@ -62252,7 +62512,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
62252
62512
  return false;
62253
62513
  }
62254
62514
  };
62255
- const summaryVersion = "1.3.1-next.3";
62515
+ const summaryVersion = "1.4.0-next.2";
62256
62516
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
62257
62517
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
62258
62518
  function mapAttributes(attrs) {
@@ -64885,7 +65145,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
64885
65145
  * Process collaboration migrations
64886
65146
  */
64887
65147
  processCollaborationMigrations() {
64888
- console.debug("[checkVersionMigrations] Current editor version", "1.3.1-next.3");
65148
+ console.debug("[checkVersionMigrations] Current editor version", "1.4.0-next.2");
64889
65149
  if (!this.options.ydoc) return;
64890
65150
  const metaMap = this.options.ydoc.getMap("meta");
64891
65151
  let docVersion = metaMap.get("version");
@@ -70619,6 +70879,9 @@ ${l}
70619
70879
  imgEl.style.width = "100%";
70620
70880
  imgEl.style.height = "100%";
70621
70881
  imgEl.style.objectFit = block.objectFit ?? "contain";
70882
+ if (block.objectFit === "cover") {
70883
+ imgEl.style.objectPosition = "left top";
70884
+ }
70622
70885
  imgEl.style.display = "block";
70623
70886
  imageWrapper.appendChild(imgEl);
70624
70887
  content2.appendChild(imageWrapper);
@@ -70648,6 +70911,9 @@ ${l}
70648
70911
  img2.style.width = "100%";
70649
70912
  img2.style.height = "100%";
70650
70913
  img2.style.objectFit = block.objectFit ?? "contain";
70914
+ if (block.objectFit === "cover") {
70915
+ img2.style.objectPosition = "left top";
70916
+ }
70651
70917
  drawingInner.appendChild(img2);
70652
70918
  } else if (renderDrawingContent) {
70653
70919
  const drawingContent = renderDrawingContent(block);
@@ -73220,7 +73486,7 @@ ${l}
73220
73486
  if (fragment.pmEnd != null) {
73221
73487
  fragmentEl.dataset.pmEnd = String(fragment.pmEnd);
73222
73488
  }
73223
- if (fragment.metadata) {
73489
+ if (fragment.metadata && !block.attrs?.vmlWatermark) {
73224
73490
  fragmentEl.setAttribute("data-image-metadata", JSON.stringify(fragment.metadata));
73225
73491
  }
73226
73492
  const img2 = this.doc.createElement("img");
@@ -73231,7 +73497,28 @@ ${l}
73231
73497
  img2.style.width = "100%";
73232
73498
  img2.style.height = "100%";
73233
73499
  img2.style.objectFit = block.objectFit ?? "contain";
73500
+ if (block.objectFit === "cover") {
73501
+ img2.style.objectPosition = "left top";
73502
+ }
73234
73503
  img2.style.display = block.display === "inline" ? "inline-block" : "block";
73504
+ const filters = [];
73505
+ if (block.gain != null || block.blacklevel != null) {
73506
+ if (block.gain && typeof block.gain === "string" && block.gain.endsWith("f")) {
73507
+ const contrast = Math.max(0, parseInt(block.gain) / 65536);
73508
+ if (contrast > 0) {
73509
+ filters.push(`contrast(${contrast})`);
73510
+ }
73511
+ }
73512
+ if (block.blacklevel && typeof block.blacklevel === "string" && block.blacklevel.endsWith("f")) {
73513
+ const brightness = Math.max(0, 1 + parseInt(block.blacklevel) / 327 / 100) + 0.5;
73514
+ if (brightness > 0) {
73515
+ filters.push(`brightness(${brightness})`);
73516
+ }
73517
+ }
73518
+ if (filters.length > 0) {
73519
+ img2.style.filter = filters.join(" ");
73520
+ }
73521
+ }
73235
73522
  fragmentEl.appendChild(img2);
73236
73523
  return fragmentEl;
73237
73524
  } catch (error) {
@@ -73311,6 +73598,9 @@ ${l}
73311
73598
  img2.style.width = "100%";
73312
73599
  img2.style.height = "100%";
73313
73600
  img2.style.objectFit = drawing.objectFit ?? "contain";
73601
+ if (drawing.objectFit === "cover") {
73602
+ img2.style.objectPosition = "left top";
73603
+ }
73314
73604
  img2.style.display = "block";
73315
73605
  return img2;
73316
73606
  }
@@ -78059,13 +78349,8 @@ ${l}
78059
78349
  let baseX;
78060
78350
  let availableWidth;
78061
78351
  if (relativeFrom === "page") {
78062
- if (columns.count === 1) {
78063
- baseX = contentLeft;
78064
- availableWidth = contentWidth;
78065
- } else {
78066
- baseX = 0;
78067
- availableWidth = pageWidth != null ? pageWidth : contentWidth;
78068
- }
78352
+ baseX = 0;
78353
+ availableWidth = pageWidth != null ? pageWidth : contentWidth + marginLeft + marginRight;
78069
78354
  } else if (relativeFrom === "margin") {
78070
78355
  baseX = contentLeft;
78071
78356
  availableWidth = contentWidth;
@@ -79554,7 +79839,9 @@ ${l}
79554
79839
  if (!isImage && !isDrawing) continue;
79555
79840
  const drawingBlock = block;
79556
79841
  const drawingMeasure = measure;
79557
- if (!drawingBlock.anchor?.isAnchored) continue;
79842
+ if (!drawingBlock.anchor?.isAnchored) {
79843
+ continue;
79844
+ }
79558
79845
  if (isPageRelativeAnchor(drawingBlock)) {
79559
79846
  result.push({ block: drawingBlock, measure: drawingMeasure });
79560
79847
  }
@@ -88612,7 +88899,13 @@ ${l}
88612
88899
  const result = {};
88613
88900
  if (spacing.before != null) result.before = pxToPt(spacing.before);
88614
88901
  if (spacing.after != null) result.after = pxToPt(spacing.after);
88615
- if (spacing.line != null) result.line = pxToPt(spacing.line);
88902
+ if (spacing.line != null) {
88903
+ if (spacing.lineRule === "auto" && spacing.line > 0 && spacing.line <= MAX_AUTO_LINE_MULTIPLIER) {
88904
+ result.line = spacing.line;
88905
+ } else {
88906
+ result.line = pxToPt(spacing.line);
88907
+ }
88908
+ }
88616
88909
  if (spacing.lineRule) result.lineRule = spacing.lineRule;
88617
88910
  return result;
88618
88911
  };
@@ -88636,8 +88929,13 @@ ${l}
88636
88929
  if (after != null) result.after = after;
88637
88930
  }
88638
88931
  if (rawSpacing.line != null) {
88639
- const line = ptToPx(spacing.line);
88640
- if (line != null) result.line = line;
88932
+ const isAutoMultiplier = spacing.lineRule === "auto" && spacing.line != null && spacing.line > 0 && spacing.line <= MAX_AUTO_LINE_MULTIPLIER;
88933
+ if (isAutoMultiplier) {
88934
+ result.line = spacing.line;
88935
+ } else {
88936
+ const line = ptToPx(spacing.line);
88937
+ if (line != null) result.line = line;
88938
+ }
88641
88939
  if (spacing.lineRule) result.lineRule = spacing.lineRule;
88642
88940
  }
88643
88941
  }
@@ -88717,7 +89015,7 @@ ${l}
88717
89015
  if (value > 0 && value <= MAX_AUTO_LINE_MULTIPLIER) {
88718
89016
  return value;
88719
89017
  }
88720
- return twipsToPx$1(value);
89018
+ return value / 240;
88721
89019
  }
88722
89020
  return twipsToPx$1(value);
88723
89021
  };
@@ -92639,8 +92937,9 @@ ${l}
92639
92937
  const isInline2 = normalizedWrap?.type === "Inline" || typeof attrs.inline === "boolean" && attrs.inline;
92640
92938
  const display = explicitDisplay === "inline" || explicitDisplay === "block" ? explicitDisplay : isInline2 ? "inline" : "block";
92641
92939
  const explicitObjectFit = typeof attrs.objectFit === "string" ? attrs.objectFit : void 0;
92940
+ const shouldCover = attrs.shouldCover === true;
92642
92941
  const isAnchor = anchor?.isAnchored ?? (typeof attrs.isAnchor === "boolean" ? attrs.isAnchor : false);
92643
- const objectFit = isAllowedObjectFit(explicitObjectFit) ? explicitObjectFit : display === "inline" ? "scale-down" : isAnchor ? "contain" : "contain";
92942
+ const objectFit = isAllowedObjectFit(explicitObjectFit) ? explicitObjectFit : shouldCover ? "cover" : display === "inline" ? "scale-down" : isAnchor ? "contain" : "contain";
92644
92943
  return {
92645
92944
  kind: "image",
92646
92945
  id: nextBlockId("image"),
@@ -92655,7 +92954,10 @@ ${l}
92655
92954
  margin: toBoxSpacing(attrs.marginOffset),
92656
92955
  anchor,
92657
92956
  wrap: normalizedWrap,
92658
- attrs: attrsWithPm
92957
+ attrs: attrsWithPm,
92958
+ // VML image adjustments for watermark effects
92959
+ gain: typeof attrs.gain === "string" || typeof attrs.gain === "number" ? attrs.gain : void 0,
92960
+ blacklevel: typeof attrs.blacklevel === "string" || typeof attrs.blacklevel === "number" ? attrs.blacklevel : void 0
92659
92961
  };
92660
92962
  }
92661
92963
  function handleImageNode(node2, context) {
@@ -96605,11 +96907,13 @@ ${l}
96605
96907
  const intrinsic = getIntrinsicImageSize(block, constraints.maxWidth);
96606
96908
  const isBlockBehindDoc = block.anchor?.behindDoc;
96607
96909
  const isBlockWrapBehindDoc = block.wrap?.type === "None" && block.wrap?.behindDoc;
96608
- const bypassWidthConstraint = isBlockBehindDoc || isBlockWrapBehindDoc;
96910
+ const isPageRelativeAnchor2 = block.anchor?.isAnchored && (block.anchor?.hRelativeFrom === "page" || block.anchor?.hRelativeFrom === "margin");
96911
+ const bypassWidthConstraint = isBlockBehindDoc || isBlockWrapBehindDoc || isPageRelativeAnchor2;
96609
96912
  const isWidthConstraintBypassed = bypassWidthConstraint || constraints.maxWidth <= 0;
96610
96913
  const maxWidth = isWidthConstraintBypassed ? intrinsic.width : constraints.maxWidth;
96611
96914
  const hasNegativeVerticalPosition = block.anchor?.isAnchored && (typeof block.anchor?.offsetV === "number" && block.anchor.offsetV < 0 || typeof block.margin?.top === "number" && block.margin.top < 0);
96612
- const maxHeight = hasNegativeVerticalPosition || !constraints.maxHeight || constraints.maxHeight <= 0 ? Infinity : constraints.maxHeight;
96915
+ const shouldBypassHeightConstraint = hasNegativeVerticalPosition || block.objectFit === "cover";
96916
+ const maxHeight = shouldBypassHeightConstraint || !constraints.maxHeight || constraints.maxHeight <= 0 ? Infinity : constraints.maxHeight;
96613
96917
  const widthScale = maxWidth / intrinsic.width;
96614
96918
  const heightScale = maxHeight / intrinsic.height;
96615
96919
  const scale = Math.min(1, widthScale, heightScale);
@@ -96858,7 +97162,8 @@ ${l}
96858
97162
  return baseLineHeight;
96859
97163
  }
96860
97164
  const raw = spacing.line;
96861
- const treatAsMultiplier = (spacing.lineRule === "auto" || spacing.lineRule == null) && raw > 0 && raw <= 10;
97165
+ const isAuto = spacing.lineRule === "auto";
97166
+ const treatAsMultiplier = (isAuto || spacing.lineRule == null) && raw > 0 && (isAuto || raw <= 10);
96862
97167
  if (treatAsMultiplier) {
96863
97168
  return raw * baseLineHeight;
96864
97169
  }
@@ -97205,6 +97510,8 @@ ${l}
97205
97510
  debugLabel: options.layoutEngineOptions?.debugLabel,
97206
97511
  layoutMode: options.layoutEngineOptions?.layoutMode ?? "vertical",
97207
97512
  trackedChanges: options.layoutEngineOptions?.trackedChanges,
97513
+ emitCommentPositionsInViewing: options.layoutEngineOptions?.emitCommentPositionsInViewing,
97514
+ enableCommentsInViewing: options.layoutEngineOptions?.enableCommentsInViewing,
97208
97515
  presence: validatedPresence
97209
97516
  };
97210
97517
  this.#trackedChangesOverrides = options.layoutEngineOptions?.trackedChanges;
@@ -97793,6 +98100,33 @@ ${l}
97793
98100
  this.#scheduleRerender();
97794
98101
  }
97795
98102
  }
98103
+ /**
98104
+ * Update viewing-mode comment rendering behavior and re-render if needed.
98105
+ *
98106
+ * @param options - Viewing mode comment options.
98107
+ */
98108
+ setViewingCommentOptions(options = {}) {
98109
+ if (options !== void 0 && (typeof options !== "object" || options === null || Array.isArray(options))) {
98110
+ throw new TypeError("[PresentationEditor] setViewingCommentOptions expects an object or undefined");
98111
+ }
98112
+ let hasChanges = false;
98113
+ if (typeof options.emitCommentPositionsInViewing === "boolean") {
98114
+ if (this.#layoutOptions.emitCommentPositionsInViewing !== options.emitCommentPositionsInViewing) {
98115
+ this.#layoutOptions.emitCommentPositionsInViewing = options.emitCommentPositionsInViewing;
98116
+ hasChanges = true;
98117
+ }
98118
+ }
98119
+ if (typeof options.enableCommentsInViewing === "boolean") {
98120
+ if (this.#layoutOptions.enableCommentsInViewing !== options.enableCommentsInViewing) {
98121
+ this.#layoutOptions.enableCommentsInViewing = options.enableCommentsInViewing;
98122
+ hasChanges = true;
98123
+ }
98124
+ }
98125
+ if (hasChanges) {
98126
+ this.#pendingDocChange = true;
98127
+ this.#scheduleRerender();
98128
+ }
98129
+ }
97796
98130
  /**
97797
98131
  * Toggle the custom context menu at runtime to respect host-level guardrails.
97798
98132
  */
@@ -100145,7 +100479,7 @@ ${l}
100145
100479
  } : void 0;
100146
100480
  const atomNodeTypes = getAtomNodeTypes(this.#editor?.schema ?? null);
100147
100481
  const positionMap2 = this.#editor?.state?.doc && docJson ? buildPositionMapFromPmDoc(this.#editor.state.doc, docJson) : null;
100148
- const commentsEnabled = this.#documentMode !== "viewing";
100482
+ const commentsEnabled = this.#documentMode !== "viewing" || this.#layoutOptions.enableCommentsInViewing === true;
100149
100483
  const result = toFlowBlocks(docJson, {
100150
100484
  mediaFiles: this.#editor?.storage?.image?.media,
100151
100485
  emitSectionBreaks: true,
@@ -100285,7 +100619,8 @@ ${l}
100285
100619
  const payload = { layout, blocks: blocks2, measures, metrics };
100286
100620
  this.emit("layoutUpdated", payload);
100287
100621
  this.emit("paginationUpdate", payload);
100288
- if (this.#documentMode !== "viewing") {
100622
+ const allowViewingCommentPositions = this.#layoutOptions.emitCommentPositionsInViewing === true;
100623
+ if (this.#documentMode !== "viewing" || allowViewingCommentPositions) {
100289
100624
  const commentPositions = this.#collectCommentPositions();
100290
100625
  const positionKeys = Object.keys(commentPositions);
100291
100626
  if (positionKeys.length > 0) {
@@ -111193,18 +111528,18 @@ ${l}
111193
111528
  // Used during DOCX export to restore the original metafile format.
111194
111529
  originalExtension: { rendered: false },
111195
111530
  originalSrc: { rendered: false },
111196
- shouldStretch: {
111531
+ shouldCover: {
111197
111532
  default: false,
111198
111533
  rendered: false
111199
111534
  },
111200
111535
  size: {
111201
111536
  default: {},
111202
- renderDOM: ({ size: size2, shouldStretch }) => {
111537
+ renderDOM: ({ size: size2, shouldCover }) => {
111203
111538
  let style2 = "";
111204
111539
  let { width, height } = size2 ?? {};
111205
111540
  if (width) style2 += `width: ${width}px;`;
111206
- if (height && shouldStretch) {
111207
- style2 += `height: ${height}px; object-fit: fill;`;
111541
+ if (height && shouldCover) {
111542
+ style2 += `height: ${height}px; object-fit: cover; object-position: left top;`;
111208
111543
  } else if (height) style2 += "height: auto;";
111209
111544
  return { style: style2 };
111210
111545
  }
@@ -119363,6 +119698,9 @@ ${l}
119363
119698
  if (!node2 || !nodeNames.includes(node2.type.name)) {
119364
119699
  return DecorationSet.empty;
119365
119700
  }
119701
+ if (node2.attrs?.vmlWatermark === true) {
119702
+ return DecorationSet.empty;
119703
+ }
119366
119704
  const decorations = [];
119367
119705
  if (nodeNames.includes(selection.node?.type.name)) {
119368
119706
  decorations.push(
@@ -119445,6 +119783,7 @@ ${l}
119445
119783
  const pos = Number.parseInt(wrapper.getAttribute("data-pos"), 10);
119446
119784
  const node2 = view.state.doc.nodeAt(pos);
119447
119785
  if (!nodeNames.includes(node2?.type.name)) return;
119786
+ if (node2?.attrs?.vmlWatermark === true) return;
119448
119787
  currentWrapper = wrapper;
119449
119788
  resizeContainer = document.createElement("div");
119450
119789
  resizeContainer.className = "sd-editor-resize-container";
@@ -141442,6 +141781,11 @@ ${reason}`);
141442
141781
  allowResolve: true,
141443
141782
  showResolved: false
141444
141783
  });
141784
+ const viewingVisibility = reactive({
141785
+ documentMode: "editing",
141786
+ commentsVisible: false,
141787
+ trackChangesVisible: false
141788
+ });
141445
141789
  const isDebugging = false;
141446
141790
  const debounceTimers = {};
141447
141791
  const COMMENT_EVENTS = comments_module_events;
@@ -141468,6 +141812,7 @@ ${reason}`);
141468
141812
  const isFloatingCommentsReady = ref(false);
141469
141813
  const generalCommentIds = ref([]);
141470
141814
  const pendingComment = ref(null);
141815
+ const isViewingMode = computed(() => viewingVisibility.documentMode === "viewing");
141471
141816
  const init2 = (config2 = {}) => {
141472
141817
  const updatedConfig = { ...commentsConfig, ...config2 };
141473
141818
  Object.assign(commentsConfig, updatedConfig);
@@ -141480,6 +141825,17 @@ ${reason}`);
141480
141825
  if (id === void 0 || id === null) return null;
141481
141826
  return commentsList.value.find((c2) => c2.commentId == id || c2.importedId == id);
141482
141827
  };
141828
+ const getThreadParent = (comment2) => {
141829
+ if (!comment2?.parentCommentId) return comment2;
141830
+ return getComment(comment2.parentCommentId);
141831
+ };
141832
+ const isThreadVisible = (comment2) => {
141833
+ if (!isViewingMode.value) return true;
141834
+ const parent = getThreadParent(comment2);
141835
+ if (!parent && comment2?.parentCommentId) return false;
141836
+ const isTrackedChange = Boolean(parent?.trackedChange);
141837
+ return isTrackedChange ? viewingVisibility.trackChangesVisible : viewingVisibility.commentsVisible;
141838
+ };
141483
141839
  const setActiveComment = (superdoc, id) => {
141484
141840
  if (id === void 0 || id === null) {
141485
141841
  activeComment.value = null;
@@ -141581,6 +141937,7 @@ ${reason}`);
141581
141937
  const resolvedComments = [];
141582
141938
  const childCommentMap = /* @__PURE__ */ new Map();
141583
141939
  commentsList.value.forEach((comment2) => {
141940
+ if (!isThreadVisible(comment2)) return;
141584
141941
  if (comment2.resolvedTime) {
141585
141942
  resolvedComments.push(comment2);
141586
141943
  } else if (!comment2.parentCommentId && !comment2.resolvedTime) {
@@ -141789,6 +142146,17 @@ ${reason}`);
141789
142146
  });
141790
142147
  return comments;
141791
142148
  });
142149
+ const setViewingVisibility = ({ documentMode, commentsVisible, trackChangesVisible } = {}) => {
142150
+ if (typeof documentMode === "string") {
142151
+ viewingVisibility.documentMode = documentMode;
142152
+ }
142153
+ if (typeof commentsVisible === "boolean") {
142154
+ viewingVisibility.commentsVisible = commentsVisible;
142155
+ }
142156
+ if (typeof trackChangesVisible === "boolean") {
142157
+ viewingVisibility.trackChangesVisible = trackChangesVisible;
142158
+ }
142159
+ };
141792
142160
  const normalizeCommentForEditor = (node2) => {
141793
142161
  if (!node2 || typeof node2 !== "object") return node2;
141794
142162
  const cloneMarks = (marks) => Array.isArray(marks) ? marks.filter(Boolean).map((mark2) => ({
@@ -141868,6 +142236,7 @@ ${reason}`);
141868
142236
  getFloatingComments,
141869
142237
  // Actions
141870
142238
  init: init2,
142239
+ setViewingVisibility,
141871
142240
  getComment,
141872
142241
  setActiveComment,
141873
142242
  getCommentLocation,
@@ -142857,7 +143226,7 @@ ${reason}`);
142857
143226
  const superdocStore = useSuperdocStore();
142858
143227
  const commentsStore = useCommentsStore();
142859
143228
  const { COMMENT_EVENTS } = commentsStore;
142860
- const { documentsWithConverations, activeComment, floatingCommentsOffset, commentsList } = storeToRefs(commentsStore);
143229
+ const { documentsWithConverations, activeComment, floatingCommentsOffset, getGroupedComments } = storeToRefs(commentsStore);
142861
143230
  const { documents, activeZoom } = storeToRefs(superdocStore);
142862
143231
  const { proxy } = getCurrentInstance();
142863
143232
  const emit2 = __emit;
@@ -142919,7 +143288,7 @@ ${reason}`);
142919
143288
  emit2("highlight-click", comment2);
142920
143289
  };
142921
143290
  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");
143291
+ return getGroupedComments.value?.parentComments.filter((c2) => c2.selection && c2.selection.selectionBounds?.top).filter((c2) => !c2.resolvedTime).filter((c2) => c2.selection?.source !== "super-editor");
142923
143292
  });
142924
143293
  watch(activeComment, (newVal) => {
142925
143294
  if (!newVal) return;
@@ -142947,7 +143316,7 @@ ${reason}`);
142947
143316
  };
142948
143317
  }
142949
143318
  };
142950
- const CommentsLayer = /* @__PURE__ */ _export_sfc(_sfc_main$b, [["__scopeId", "data-v-d019784c"]]);
143319
+ const CommentsLayer = /* @__PURE__ */ _export_sfc(_sfc_main$b, [["__scopeId", "data-v-7d21d613"]]);
142951
143320
  const _hoisted_1$9 = { class: "sidebar-container calculation-container" };
142952
143321
  const _hoisted_2$3 = ["id"];
142953
143322
  const _sfc_main$a = {
@@ -143789,6 +144158,16 @@ ${reason}`);
143789
144158
  const { isHighContrastMode: isHighContrastMode2 } = useHighContrastMode();
143790
144159
  const { uiFontFamily } = useUiFontFamily();
143791
144160
  const isViewingMode = () => proxy?.$superdoc?.config?.documentMode === "viewing";
144161
+ const isViewingCommentsVisible = computed(
144162
+ () => isViewingMode() && proxy?.$superdoc?.config?.comments?.visible === true
144163
+ );
144164
+ const isViewingTrackChangesVisible = computed(
144165
+ () => isViewingMode() && proxy?.$superdoc?.config?.trackChanges?.visible === true
144166
+ );
144167
+ const shouldRenderCommentsInViewing = computed(() => {
144168
+ if (!isViewingMode()) return true;
144169
+ return isViewingCommentsVisible.value || isViewingTrackChangesVisible.value;
144170
+ });
143792
144171
  const commentsModuleConfig = computed(() => {
143793
144172
  const config2 = modules.comments;
143794
144173
  if (config2 === false || config2 == null) return null;
@@ -143883,7 +144262,7 @@ ${reason}`);
143883
144262
  const commentsConfig = proxy.$superdoc.config.modules?.comments;
143884
144263
  if (!commentsConfig || commentsConfig === false) return;
143885
144264
  if (!positions || Object.keys(positions).length === 0) return;
143886
- if (isViewingMode()) {
144265
+ if (!shouldRenderCommentsInViewing.value) {
143887
144266
  commentsStore.clearEditorCommentPositions?.();
143888
144267
  return;
143889
144268
  }
@@ -144078,7 +144457,9 @@ ${reason}`);
144078
144457
  layoutEngineOptions: useLayoutEngine ? {
144079
144458
  ...proxy.$superdoc.config.layoutEngineOptions || {},
144080
144459
  debugLabel: proxy.$superdoc.config.layoutEngineOptions?.debugLabel ?? doc2.name ?? doc2.id,
144081
- zoom: (activeZoom.value ?? 100) / 100
144460
+ zoom: (activeZoom.value ?? 100) / 100,
144461
+ emitCommentPositionsInViewing: isViewingMode() && shouldRenderCommentsInViewing.value,
144462
+ enableCommentsInViewing: isViewingCommentsVisible.value
144082
144463
  } : void 0,
144083
144464
  permissionResolver: (payload = {}) => proxy.$superdoc.canPerformPermission({
144084
144465
  role: proxy.$superdoc.config.role,
@@ -144091,7 +144472,7 @@ ${reason}`);
144091
144472
  const onEditorCommentLocationsUpdate = (doc2, { allCommentIds: activeThreadId, allCommentPositions } = {}) => {
144092
144473
  const commentsConfig = proxy.$superdoc.config.modules?.comments;
144093
144474
  if (!commentsConfig || commentsConfig === false) return;
144094
- if (isViewingMode()) {
144475
+ if (!shouldRenderCommentsInViewing.value) {
144095
144476
  commentsStore.clearEditorCommentPositions?.();
144096
144477
  return;
144097
144478
  }
@@ -144150,7 +144531,7 @@ ${reason}`);
144150
144531
  };
144151
144532
  const isCommentsEnabled = computed(() => Boolean(commentsModuleConfig.value));
144152
144533
  const showCommentsSidebar = computed(() => {
144153
- if (isViewingMode()) return false;
144534
+ if (!shouldRenderCommentsInViewing.value) return false;
144154
144535
  return pendingComment.value || getFloatingComments.value?.length > 0 && isReady.value && layers.value && isCommentsEnabled.value && !isCommentsListVisible.value;
144155
144536
  });
144156
144537
  const showToolsFloatingMenu = computed(() => {
@@ -144492,7 +144873,7 @@ ${reason}`);
144492
144873
  };
144493
144874
  }
144494
144875
  };
144495
- const App = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-5196811d"]]);
144876
+ const App = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-78737564"]]);
144496
144877
  const createSuperdocVueApp = () => {
144497
144878
  const app = createApp(App);
144498
144879
  const pinia = createPinia();
@@ -144598,6 +144979,8 @@ ${reason}`);
144598
144979
  title: "SuperDoc",
144599
144980
  conversations: [],
144600
144981
  isInternal: false,
144982
+ comments: { visible: false },
144983
+ trackChanges: { visible: false },
144601
144984
  // toolbar config
144602
144985
  toolbar: null,
144603
144986
  // Optional DOM element to render the toolbar in
@@ -144647,6 +145030,16 @@ ${reason}`);
144647
145030
  ...this.config,
144648
145031
  ...config2
144649
145032
  };
145033
+ if (!this.config.comments || typeof this.config.comments !== "object") {
145034
+ this.config.comments = { visible: false };
145035
+ } else if (typeof this.config.comments.visible !== "boolean") {
145036
+ this.config.comments.visible = false;
145037
+ }
145038
+ if (!this.config.trackChanges || typeof this.config.trackChanges !== "object") {
145039
+ this.config.trackChanges = { visible: false };
145040
+ } else if (typeof this.config.trackChanges.visible !== "boolean") {
145041
+ this.config.trackChanges.visible = false;
145042
+ }
144650
145043
  const incomingUser = this.config.user;
144651
145044
  if (!incomingUser || typeof incomingUser !== "object") {
144652
145045
  this.config.user = { ...DEFAULT_USER };
@@ -144664,9 +145057,10 @@ ${reason}`);
144664
145057
  }
144665
145058
  if (!this.config.layoutEngineOptions.trackedChanges) {
144666
145059
  const isViewingMode = this.config.documentMode === "viewing";
145060
+ const viewingTrackedChangesVisible = isViewingMode && this.config.trackChanges?.visible === true;
144667
145061
  this.config.layoutEngineOptions.trackedChanges = {
144668
- mode: isViewingMode ? "final" : "review",
144669
- enabled: !isViewingMode
145062
+ mode: isViewingMode ? viewingTrackedChangesVisible ? "review" : "original" : "review",
145063
+ enabled: true
144670
145064
  };
144671
145065
  }
144672
145066
  this.config.modules = this.config.modules || {};
@@ -144676,7 +145070,7 @@ ${reason}`);
144676
145070
  this.config.colors = shuffleArray(this.config.colors);
144677
145071
  this.userColorMap = /* @__PURE__ */ new Map();
144678
145072
  this.colorIndex = 0;
144679
- this.version = "1.3.1-next.3";
145073
+ this.version = "1.4.0-next.2";
144680
145074
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
144681
145075
  this.superdocId = config2.superdocId || v4();
144682
145076
  this.colors = this.config.colors;
@@ -144813,6 +145207,7 @@ ${reason}`);
144813
145207
  this.superdocStore.init(this.config);
144814
145208
  const commentsModuleConfig = this.config.modules.comments;
144815
145209
  this.commentsStore.init(commentsModuleConfig && commentsModuleConfig !== false ? commentsModuleConfig : {});
145210
+ this.#syncViewingVisibility();
144816
145211
  }
144817
145212
  #initListeners() {
144818
145213
  this.on("editorBeforeCreate", this.config.onEditorBeforeCreate);
@@ -145114,6 +145509,7 @@ ${reason}`);
145114
145509
  if (!type) return;
145115
145510
  type = type.toLowerCase();
145116
145511
  this.config.documentMode = type;
145512
+ this.#syncViewingVisibility();
145117
145513
  const types2 = {
145118
145514
  viewing: () => this.#setModeViewing(),
145119
145515
  editing: () => this.#setModeEditing(),
@@ -145193,10 +145589,20 @@ ${reason}`);
145193
145589
  }
145194
145590
  #setModeViewing() {
145195
145591
  this.toolbar.activeEditor = null;
145196
- this.setTrackedChangesPreferences({ mode: "original", enabled: true });
145197
- this.commentsStore?.clearEditorCommentPositions?.();
145592
+ const commentsVisible = this.config.comments?.visible === true;
145593
+ const trackChangesVisible = this.config.trackChanges?.visible === true;
145594
+ this.setTrackedChangesPreferences(
145595
+ trackChangesVisible ? { mode: "review", enabled: true } : { mode: "original", enabled: true }
145596
+ );
145597
+ if (!commentsVisible && !trackChangesVisible) {
145598
+ this.commentsStore?.clearEditorCommentPositions?.();
145599
+ }
145198
145600
  this.superdocStore.documents.forEach((doc2) => {
145199
- doc2.removeComments();
145601
+ if (commentsVisible || trackChangesVisible) {
145602
+ doc2.restoreComments();
145603
+ } else {
145604
+ doc2.removeComments();
145605
+ }
145200
145606
  this.#applyDocumentMode(doc2, "viewing");
145201
145607
  });
145202
145608
  if (this.toolbar) {
@@ -145204,6 +145610,31 @@ ${reason}`);
145204
145610
  this.toolbar.updateToolbarState();
145205
145611
  }
145206
145612
  }
145613
+ #syncViewingVisibility() {
145614
+ const commentsVisible = this.config.comments?.visible === true;
145615
+ const trackChangesVisible = this.config.trackChanges?.visible === true;
145616
+ const isViewingMode = this.config.documentMode === "viewing";
145617
+ const shouldRenderCommentsInViewing = commentsVisible || trackChangesVisible;
145618
+ if (this.commentsStore?.setViewingVisibility) {
145619
+ this.commentsStore.setViewingVisibility({
145620
+ documentMode: this.config.documentMode,
145621
+ commentsVisible,
145622
+ trackChangesVisible
145623
+ });
145624
+ }
145625
+ const docs = this.superdocStore?.documents;
145626
+ if (Array.isArray(docs) && docs.length > 0) {
145627
+ docs.forEach((doc2) => {
145628
+ const presentationEditor = typeof doc2.getPresentationEditor === "function" ? doc2.getPresentationEditor() : null;
145629
+ if (presentationEditor?.setViewingCommentOptions) {
145630
+ presentationEditor.setViewingCommentOptions({
145631
+ emitCommentPositionsInViewing: isViewingMode && shouldRenderCommentsInViewing,
145632
+ enableCommentsInViewing: isViewingMode && commentsVisible
145633
+ });
145634
+ }
145635
+ });
145636
+ }
145637
+ }
145207
145638
  /**
145208
145639
  * Search for text or regex in the active editor
145209
145640
  * @param {string | RegExp} text The text or regex to search for