@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
@@ -19027,7 +19027,7 @@ function isMetafileExtension(extension) {
19027
19027
  const DRAWING_XML_TAG = "w:drawing";
19028
19028
  const SHAPE_URI = "http://schemas.microsoft.com/office/word/2010/wordprocessingShape";
19029
19029
  const GROUP_URI = "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup";
19030
- const normalizeTargetPath = (targetPath = "") => {
19030
+ const normalizeTargetPath$1 = (targetPath = "") => {
19031
19031
  if (!targetPath) return targetPath;
19032
19032
  const trimmed = targetPath.replace(/^\/+/, "");
19033
19033
  if (trimmed.startsWith("word/")) return trimmed;
@@ -19186,7 +19186,14 @@ function handleImageNode(node, params, isAnchor) {
19186
19186
  }
19187
19187
  const stretch = blipFill?.elements.find((el) => el.name === "a:stretch");
19188
19188
  const fillRect = stretch?.elements.find((el) => el.name === "a:fillRect");
19189
+ const srcRect = blipFill?.elements.find((el) => el.name === "a:srcRect");
19190
+ const srcRectAttrs = srcRect?.attributes || {};
19191
+ const srcRectHasNegativeValues = ["l", "t", "r", "b"].some((attr) => {
19192
+ const val = srcRectAttrs[attr];
19193
+ return val != null && parseFloat(val) < 0;
19194
+ });
19189
19195
  const shouldStretch = Boolean(stretch && fillRect);
19196
+ const shouldCover = shouldStretch && !srcRectHasNegativeValues;
19190
19197
  const spPr = picture.elements.find((el) => el.name === "pic:spPr");
19191
19198
  if (spPr) {
19192
19199
  const xfrm = spPr.elements.find((el) => el.name === "a:xfrm");
@@ -19215,7 +19222,7 @@ function handleImageNode(node, params, isAnchor) {
19215
19222
  }
19216
19223
  const { attributes: relAttributes } = rel;
19217
19224
  const targetPath = relAttributes["Target"];
19218
- const path = normalizeTargetPath(targetPath);
19225
+ const path = normalizeTargetPath$1(targetPath);
19219
19226
  const extension = path.substring(path.lastIndexOf(".") + 1);
19220
19227
  let finalSrc = path;
19221
19228
  let finalExtension = extension;
@@ -19263,7 +19270,7 @@ function handleImageNode(node, params, isAnchor) {
19263
19270
  wrapText: wrap2.attrs.wrapText
19264
19271
  } : {},
19265
19272
  wrapTopAndBottom: wrap2.type === "TopAndBottom",
19266
- shouldStretch,
19273
+ shouldCover,
19267
19274
  originalPadding: {
19268
19275
  distT: attributes["distT"],
19269
19276
  distB: attributes["distB"],
@@ -19456,7 +19463,7 @@ const handleShapeGroup = (params, node, graphicData, size, padding, marginOffset
19456
19463
  const { elements } = relationships || [];
19457
19464
  const rel = elements?.find((el) => el.attributes["Id"] === rEmbed);
19458
19465
  if (!rel) return null;
19459
- const targetPath = normalizeTargetPath(rel.attributes?.["Target"]);
19466
+ const targetPath = normalizeTargetPath$1(rel.attributes?.["Target"]);
19460
19467
  const path = targetPath;
19461
19468
  const nvPicPr = pic.elements?.find((el) => el.name === "pic:nvPicPr");
19462
19469
  const cNvPr = nvPicPr?.elements?.find((el) => el.name === "pic:cNvPr");
@@ -29560,6 +29567,10 @@ function filterOutRootInlineNodes(content = []) {
29560
29567
  if (!node || typeof node.type !== "string") return;
29561
29568
  const type = node.type;
29562
29569
  const preservableNodeName = PRESERVABLE_INLINE_XML_NAMES[type];
29570
+ if (type === "image" && node.attrs?.isAnchor) {
29571
+ result.push(node);
29572
+ return;
29573
+ }
29563
29574
  if (!INLINE_TYPES.has(type)) {
29564
29575
  result.push(node);
29565
29576
  } else if (preservableNodeName) {
@@ -29753,6 +29764,137 @@ function buildStyles(styleObject) {
29753
29764
  }
29754
29765
  return style;
29755
29766
  }
29767
+ function handleShapeImageImport({ params, pict }) {
29768
+ const shape = pict.elements?.find((el) => el.name === "v:shape");
29769
+ if (!shape) return null;
29770
+ const imagedata = shape.elements?.find((el) => el.name === "v:imagedata");
29771
+ if (!imagedata) return null;
29772
+ const { docx, filename } = params;
29773
+ const shapeAttrs = shape.attributes || {};
29774
+ const imagedataAttrs = imagedata.attributes || {};
29775
+ const rId = imagedataAttrs["r:id"];
29776
+ if (!rId) {
29777
+ console.warn("v:imagedata missing r:id attribute");
29778
+ return null;
29779
+ }
29780
+ const currentFile = filename || "document.xml";
29781
+ let rels = docx[`word/_rels/${currentFile}.rels`];
29782
+ if (!rels) rels = docx[`word/_rels/document.xml.rels`];
29783
+ const relationships = rels?.elements?.find((el) => el.name === "Relationships");
29784
+ const { elements } = relationships || [];
29785
+ const rel = elements?.find((el) => el.attributes["Id"] === rId);
29786
+ if (!rel) {
29787
+ console.warn(`Relationship not found for r:id="${rId}"`);
29788
+ return null;
29789
+ }
29790
+ const targetPath = rel.attributes["Target"];
29791
+ const normalizedPath = normalizeTargetPath(targetPath);
29792
+ const style = shapeAttrs.style || "";
29793
+ const styleObj = parseVmlStyle(style);
29794
+ const width = styleObj.width || "100px";
29795
+ const height = styleObj.height || "100px";
29796
+ const position = {
29797
+ type: styleObj.position || "absolute",
29798
+ marginLeft: styleObj["margin-left"] || "0",
29799
+ marginTop: styleObj["margin-top"] || "0"
29800
+ };
29801
+ const zIndex = styleObj["z-index"] ? parseInt(styleObj["z-index"], 10) : void 0;
29802
+ const hPosition = styleObj["mso-position-horizontal"] || "center";
29803
+ const vPosition = styleObj["mso-position-vertical"] || "center";
29804
+ const hRelativeTo = styleObj["mso-position-horizontal-relative"] || "margin";
29805
+ const vRelativeTo = styleObj["mso-position-vertical-relative"] || "margin";
29806
+ const gain = imagedataAttrs["gain"];
29807
+ const blacklevel = imagedataAttrs["blacklevel"];
29808
+ const title = imagedataAttrs["o:title"] || "Watermark";
29809
+ const imageNode = {
29810
+ type: "image",
29811
+ attrs: {
29812
+ src: normalizedPath,
29813
+ alt: title,
29814
+ extension: normalizedPath.substring(normalizedPath.lastIndexOf(".") + 1),
29815
+ title,
29816
+ rId,
29817
+ // Store VML-specific attributes for round-trip
29818
+ vmlWatermark: true,
29819
+ vmlStyle: style,
29820
+ vmlAttributes: shapeAttrs,
29821
+ vmlImagedata: imagedataAttrs,
29822
+ // Positioning
29823
+ isAnchor: true,
29824
+ inline: false,
29825
+ wrap: {
29826
+ type: "None",
29827
+ attrs: {
29828
+ behindDoc: Number.isFinite(zIndex) ? zIndex < 0 : true
29829
+ }
29830
+ },
29831
+ anchorData: {
29832
+ hRelativeFrom: hRelativeTo,
29833
+ vRelativeFrom: vRelativeTo,
29834
+ alignH: hPosition,
29835
+ alignV: vPosition
29836
+ },
29837
+ // Size
29838
+ size: {
29839
+ width: convertToPixels(width),
29840
+ height: convertToPixels(height)
29841
+ },
29842
+ marginOffset: {
29843
+ horizontal: convertToPixels(position.marginLeft),
29844
+ top: convertToPixels(position.marginTop)
29845
+ },
29846
+ // Image adjustments
29847
+ ...gain && { gain },
29848
+ ...blacklevel && { blacklevel }
29849
+ }
29850
+ };
29851
+ return imageNode;
29852
+ }
29853
+ function normalizeTargetPath(targetPath = "") {
29854
+ if (!targetPath) return targetPath;
29855
+ const trimmed = targetPath.replace(/^\/+/, "");
29856
+ if (trimmed.startsWith("word/")) return trimmed;
29857
+ if (trimmed.startsWith("media/")) return `word/${trimmed}`;
29858
+ return `word/${trimmed}`;
29859
+ }
29860
+ function parseVmlStyle(style) {
29861
+ const result = {};
29862
+ if (!style) return result;
29863
+ const declarations = style.split(";").filter((s) => s.trim());
29864
+ for (const decl of declarations) {
29865
+ const [prop, value] = decl.split(":").map((s) => s.trim());
29866
+ if (prop && value) {
29867
+ result[prop] = value;
29868
+ }
29869
+ }
29870
+ return result;
29871
+ }
29872
+ function convertToPixels(value) {
29873
+ if (typeof value === "number") return value;
29874
+ if (!value || typeof value !== "string") return 0;
29875
+ const match = value.match(/^([\d.]+)([a-z%]+)?$/i);
29876
+ if (!match) return 0;
29877
+ const num = parseFloat(match[1]);
29878
+ const unit = match[2] || "px";
29879
+ switch (unit.toLowerCase()) {
29880
+ case "px":
29881
+ return num;
29882
+ case "pt":
29883
+ return num * (96 / 72);
29884
+ // 1pt = 1/72 inch, 96 DPI
29885
+ case "in":
29886
+ return num * 96;
29887
+ case "cm":
29888
+ return num * (96 / 2.54);
29889
+ case "mm":
29890
+ return num * (96 / 25.4);
29891
+ case "pc":
29892
+ return num * 16;
29893
+ // 1pc = 12pt
29894
+ default:
29895
+ return num;
29896
+ }
29897
+ }
29756
29898
  function pictNodeTypeStrategy(node) {
29757
29899
  const shape = node.elements?.find((el) => el.name === "v:shape");
29758
29900
  const group = node.elements?.find((el) => el.name === "v:group");
@@ -29771,6 +29913,10 @@ function pictNodeTypeStrategy(node) {
29771
29913
  if (textbox) {
29772
29914
  return { type: "shapeContainer", handler: handleShapeTextboxImport };
29773
29915
  }
29916
+ const imagedata = shape.elements?.find((el) => el.name === "v:imagedata");
29917
+ if (imagedata) {
29918
+ return { type: "image", handler: handleShapeImageImport };
29919
+ }
29774
29920
  }
29775
29921
  return { type: "unknown", handler: null };
29776
29922
  }
@@ -29869,8 +30015,116 @@ function translateVRectContentBlock(params) {
29869
30015
  };
29870
30016
  return wrapTextInRun(pict);
29871
30017
  }
30018
+ function translateVmlWatermark(params) {
30019
+ const { node } = params;
30020
+ const { attrs } = node;
30021
+ if (attrs.vmlAttributes && attrs.vmlImagedata) {
30022
+ const shape2 = {
30023
+ name: "v:shape",
30024
+ attributes: attrs.vmlAttributes,
30025
+ elements: [
30026
+ {
30027
+ name: "v:imagedata",
30028
+ attributes: {
30029
+ ...attrs.vmlImagedata,
30030
+ "r:id": attrs.rId
30031
+ }
30032
+ }
30033
+ ]
30034
+ };
30035
+ const pict2 = {
30036
+ name: "w:pict",
30037
+ attributes: {
30038
+ "w14:anchorId": generateRandomSigned32BitIntStrId()
30039
+ },
30040
+ elements: [shape2]
30041
+ };
30042
+ const par2 = {
30043
+ name: "w:p",
30044
+ elements: [wrapTextInRun(pict2)]
30045
+ };
30046
+ return par2;
30047
+ }
30048
+ const style = buildVmlStyle(attrs);
30049
+ const shape = {
30050
+ name: "v:shape",
30051
+ attributes: {
30052
+ id: `WordPictureWatermark${generateRandomSigned32BitIntStrId().replace("-", "")}`,
30053
+ "o:spid": `_x0000_s${Math.floor(Math.random() * 1e4)}`,
30054
+ type: "#_x0000_t75",
30055
+ style,
30056
+ "o:allowincell": "f"
30057
+ },
30058
+ elements: [
30059
+ {
30060
+ name: "v:imagedata",
30061
+ attributes: {
30062
+ "r:id": attrs.rId,
30063
+ "o:title": attrs.title || attrs.alt || "Watermark",
30064
+ ...attrs.gain && { gain: attrs.gain },
30065
+ ...attrs.blacklevel && { blacklevel: attrs.blacklevel }
30066
+ }
30067
+ }
30068
+ ]
30069
+ };
30070
+ const pict = {
30071
+ name: "w:pict",
30072
+ attributes: {
30073
+ "w14:anchorId": generateRandomSigned32BitIntStrId()
30074
+ },
30075
+ elements: [shape]
30076
+ };
30077
+ const par = {
30078
+ name: "w:p",
30079
+ elements: [wrapTextInRun(pict)]
30080
+ };
30081
+ return par;
30082
+ }
30083
+ function buildVmlStyle(attrs) {
30084
+ const styles = [];
30085
+ styles.push("position:absolute");
30086
+ if (attrs.size) {
30087
+ if (attrs.size.width) {
30088
+ styles.push(`width:${convertToPt(attrs.size.width)}pt`);
30089
+ }
30090
+ if (attrs.size.height) {
30091
+ styles.push(`height:${convertToPt(attrs.size.height)}pt`);
30092
+ }
30093
+ }
30094
+ if (attrs.marginOffset) {
30095
+ if (attrs.marginOffset.horizontal !== void 0) {
30096
+ styles.push(`margin-left:${convertToPt(attrs.marginOffset.horizontal)}pt`);
30097
+ }
30098
+ if (attrs.marginOffset.top !== void 0) {
30099
+ styles.push(`margin-top:${convertToPt(attrs.marginOffset.top)}pt`);
30100
+ }
30101
+ }
30102
+ if (attrs.wrap?.attrs?.behindDoc) {
30103
+ styles.push("z-index:-251653120");
30104
+ }
30105
+ if (attrs.anchorData) {
30106
+ if (attrs.anchorData.alignH) {
30107
+ styles.push(`mso-position-horizontal:${attrs.anchorData.alignH}`);
30108
+ }
30109
+ if (attrs.anchorData.alignV) {
30110
+ styles.push(`mso-position-vertical:${attrs.anchorData.alignV}`);
30111
+ }
30112
+ if (attrs.anchorData.hRelativeFrom) {
30113
+ styles.push(`mso-position-horizontal-relative:${attrs.anchorData.hRelativeFrom}`);
30114
+ }
30115
+ if (attrs.anchorData.vRelativeFrom) {
30116
+ styles.push(`mso-position-vertical-relative:${attrs.anchorData.vRelativeFrom}`);
30117
+ }
30118
+ }
30119
+ styles.push("mso-width-percent:0");
30120
+ styles.push("mso-height-percent:0");
30121
+ return styles.join(";");
30122
+ }
30123
+ function convertToPt(pixels) {
30124
+ return pixels * 72 / 96;
30125
+ }
29872
30126
  const XML_NODE_NAME = "w:pict";
29873
- const SD_NODE_NAME = ["shapeContainer", "contentBlock"];
30127
+ const SD_NODE_NAME = ["shapeContainer", "contentBlock", "image"];
29874
30128
  const validXmlAttributes = [];
29875
30129
  function encode(params) {
29876
30130
  const { node, pNode } = params.extraParams;
@@ -29894,6 +30148,12 @@ function decode(params) {
29894
30148
  shapeContainer: () => translateShapeContainer(params),
29895
30149
  shapeTextbox: () => translateShapeTextbox(params),
29896
30150
  contentBlock: () => translateContentBlock(params),
30151
+ image: () => {
30152
+ if (node.attrs?.vmlWatermark) {
30153
+ return translateVmlWatermark(params);
30154
+ }
30155
+ return null;
30156
+ },
29897
30157
  default: () => null
29898
30158
  };
29899
30159
  const decoder = types[node.type] ?? types.default;
@@ -31009,7 +31269,7 @@ class SuperConverter {
31009
31269
  static getStoredSuperdocVersion(docx) {
31010
31270
  return SuperConverter.getStoredCustomProperty(docx, "SuperdocVersion");
31011
31271
  }
31012
- static setStoredSuperdocVersion(docx = this.convertedXml, version = "1.3.1-next.3") {
31272
+ static setStoredSuperdocVersion(docx = this.convertedXml, version = "1.4.0-next.2") {
31013
31273
  return SuperConverter.setStoredCustomProperty(docx, "SuperdocVersion", version, false);
31014
31274
  }
31015
31275
  /**
@@ -1,5 +1,5 @@
1
- import { B as BIT8, M as MAX_SAFE_INTEGER, c as create, a as BITS7, u as utf8TextDecoder, b as create$1, s as setIfUndefined, d as create$2, f as from, e as floor$1, g as equalityDeep, w as writeVarUint, h as writeVarString, t as toUint8Array, i as createEncoder, j as createInjectionKey, k as toString, l as throwError, m as useSsrAdapter, n as configProviderInjectionKey, o as cssrAnchorMetaName, p as globalStyle, q as cB, r as c, v as isMounted, x as commonVariables$2, y as cM, z as cNotM, A as cE, C as derived, D as changeColor, E as insideModal, F as insidePopover, G as resolveWrappedSlot, H as on, I as warnOnce, J as useConfig, K as useMergedState, L as useMemo, N as useTheme, O as useRtl, P as createKey, Q as useThemeClass, R as createId, S as call, T as render, U as messageProviderInjectionKey, V as messageApiInjectionKey, W as fromBase64, X as onChange, Y as varStorage, Z as toBase64, _ as createUint8ArrayFromArrayBuffer, $ as offChange, a0 as writeVarUint8Array, a1 as map, a2 as length, a3 as isNode, a4 as min, a5 as pow, a6 as comments_module_events, a7 as getFileObject, a8 as getTrackChanges, a9 as CommentsPluginKey, aa as TrackChangesBasePluginKey, ab as Editor, ac as getRichTextExtensions, ad as ellipsisVerticalSvg, ae as xmarkIconSvg, af as checkIconSvg, ag as caretDownIconSvg, ah as commentIconSvg, ai as _export_sfc, aj as NDropdown, ak as SuperInput, al as vClickOutside, am as PresentationEditor, an as SuperEditor, ao as AIWriter, ap as NConfigProvider, aq as SuperToolbar } from "./index-CJec1cbb.es.js";
2
- import "./SuperConverter-BQ6PNaJ8.es.js";
1
+ import { B as BIT8, M as MAX_SAFE_INTEGER, c as create, a as BITS7, u as utf8TextDecoder, b as create$1, s as setIfUndefined, d as create$2, f as from, e as floor$1, g as equalityDeep, w as writeVarUint, h as writeVarString, t as toUint8Array, i as createEncoder, j as createInjectionKey, k as toString, l as throwError, m as useSsrAdapter, n as configProviderInjectionKey, o as cssrAnchorMetaName, p as globalStyle, q as cB, r as c, v as isMounted, x as commonVariables$2, y as cM, z as cNotM, A as cE, C as derived, D as changeColor, E as insideModal, F as insidePopover, G as resolveWrappedSlot, H as on, I as warnOnce, J as useConfig, K as useMergedState, L as useMemo, N as useTheme, O as useRtl, P as createKey, Q as useThemeClass, R as createId, S as call, T as render, U as messageProviderInjectionKey, V as messageApiInjectionKey, W as fromBase64, X as onChange, Y as varStorage, Z as toBase64, _ as createUint8ArrayFromArrayBuffer, $ as offChange, a0 as writeVarUint8Array, a1 as map, a2 as length, a3 as isNode, a4 as min, a5 as pow, a6 as comments_module_events, a7 as getFileObject, a8 as getTrackChanges, a9 as CommentsPluginKey, aa as TrackChangesBasePluginKey, ab as Editor, ac as getRichTextExtensions, ad as ellipsisVerticalSvg, ae as xmarkIconSvg, af as checkIconSvg, ag as caretDownIconSvg, ah as commentIconSvg, ai as _export_sfc, aj as NDropdown, ak as SuperInput, al as vClickOutside, am as PresentationEditor, an as SuperEditor, ao as AIWriter, ap as NConfigProvider, aq as SuperToolbar } from "./index-dnQEKI-e.es.js";
2
+ import "./SuperConverter-DxlpZQZQ.es.js";
3
3
  import { B as BlankDOCX } from "./blank-docx-ABm6XYAA.es.js";
4
4
  import { E as EventEmitter } from "./eventemitter3-CwrdEv8r.es.js";
5
5
  import { HocuspocusProvider, HocuspocusProviderWebsocket } from "@hocuspocus/provider";
@@ -5144,6 +5144,11 @@ const useCommentsStore = /* @__PURE__ */ defineStore("comments", () => {
5144
5144
  allowResolve: true,
5145
5145
  showResolved: false
5146
5146
  });
5147
+ const viewingVisibility = reactive({
5148
+ documentMode: "editing",
5149
+ commentsVisible: false,
5150
+ trackChangesVisible: false
5151
+ });
5147
5152
  const isDebugging = false;
5148
5153
  const debounceTimers = {};
5149
5154
  const COMMENT_EVENTS = comments_module_events;
@@ -5170,6 +5175,7 @@ const useCommentsStore = /* @__PURE__ */ defineStore("comments", () => {
5170
5175
  const isFloatingCommentsReady = ref(false);
5171
5176
  const generalCommentIds = ref([]);
5172
5177
  const pendingComment = ref(null);
5178
+ const isViewingMode = computed(() => viewingVisibility.documentMode === "viewing");
5173
5179
  const init = (config = {}) => {
5174
5180
  const updatedConfig = { ...commentsConfig, ...config };
5175
5181
  Object.assign(commentsConfig, updatedConfig);
@@ -5182,6 +5188,17 @@ const useCommentsStore = /* @__PURE__ */ defineStore("comments", () => {
5182
5188
  if (id === void 0 || id === null) return null;
5183
5189
  return commentsList.value.find((c2) => c2.commentId == id || c2.importedId == id);
5184
5190
  };
5191
+ const getThreadParent = (comment) => {
5192
+ if (!comment?.parentCommentId) return comment;
5193
+ return getComment(comment.parentCommentId);
5194
+ };
5195
+ const isThreadVisible = (comment) => {
5196
+ if (!isViewingMode.value) return true;
5197
+ const parent = getThreadParent(comment);
5198
+ if (!parent && comment?.parentCommentId) return false;
5199
+ const isTrackedChange = Boolean(parent?.trackedChange);
5200
+ return isTrackedChange ? viewingVisibility.trackChangesVisible : viewingVisibility.commentsVisible;
5201
+ };
5185
5202
  const setActiveComment = (superdoc, id) => {
5186
5203
  if (id === void 0 || id === null) {
5187
5204
  activeComment.value = null;
@@ -5283,6 +5300,7 @@ const useCommentsStore = /* @__PURE__ */ defineStore("comments", () => {
5283
5300
  const resolvedComments = [];
5284
5301
  const childCommentMap = /* @__PURE__ */ new Map();
5285
5302
  commentsList.value.forEach((comment) => {
5303
+ if (!isThreadVisible(comment)) return;
5286
5304
  if (comment.resolvedTime) {
5287
5305
  resolvedComments.push(comment);
5288
5306
  } else if (!comment.parentCommentId && !comment.resolvedTime) {
@@ -5491,6 +5509,17 @@ const useCommentsStore = /* @__PURE__ */ defineStore("comments", () => {
5491
5509
  });
5492
5510
  return comments;
5493
5511
  });
5512
+ const setViewingVisibility = ({ documentMode, commentsVisible, trackChangesVisible } = {}) => {
5513
+ if (typeof documentMode === "string") {
5514
+ viewingVisibility.documentMode = documentMode;
5515
+ }
5516
+ if (typeof commentsVisible === "boolean") {
5517
+ viewingVisibility.commentsVisible = commentsVisible;
5518
+ }
5519
+ if (typeof trackChangesVisible === "boolean") {
5520
+ viewingVisibility.trackChangesVisible = trackChangesVisible;
5521
+ }
5522
+ };
5494
5523
  const normalizeCommentForEditor = (node) => {
5495
5524
  if (!node || typeof node !== "object") return node;
5496
5525
  const cloneMarks = (marks) => Array.isArray(marks) ? marks.filter(Boolean).map((mark) => ({
@@ -5570,6 +5599,7 @@ const useCommentsStore = /* @__PURE__ */ defineStore("comments", () => {
5570
5599
  getFloatingComments,
5571
5600
  // Actions
5572
5601
  init,
5602
+ setViewingVisibility,
5573
5603
  getComment,
5574
5604
  setActiveComment,
5575
5605
  getCommentLocation,
@@ -6559,7 +6589,7 @@ const _sfc_main$a = {
6559
6589
  const superdocStore = useSuperdocStore();
6560
6590
  const commentsStore = useCommentsStore();
6561
6591
  const { COMMENT_EVENTS } = commentsStore;
6562
- const { documentsWithConverations, activeComment, floatingCommentsOffset, commentsList } = storeToRefs(commentsStore);
6592
+ const { documentsWithConverations, activeComment, floatingCommentsOffset, getGroupedComments } = storeToRefs(commentsStore);
6563
6593
  const { documents, activeZoom } = storeToRefs(superdocStore);
6564
6594
  const { proxy } = getCurrentInstance();
6565
6595
  const emit = __emit;
@@ -6621,7 +6651,7 @@ const _sfc_main$a = {
6621
6651
  emit("highlight-click", comment);
6622
6652
  };
6623
6653
  const getCurrentComments = computed(() => {
6624
- 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");
6654
+ return getGroupedComments.value?.parentComments.filter((c2) => c2.selection && c2.selection.selectionBounds?.top).filter((c2) => !c2.resolvedTime).filter((c2) => c2.selection?.source !== "super-editor");
6625
6655
  });
6626
6656
  watch(activeComment, (newVal) => {
6627
6657
  if (!newVal) return;
@@ -6649,7 +6679,7 @@ const _sfc_main$a = {
6649
6679
  };
6650
6680
  }
6651
6681
  };
6652
- const CommentsLayer = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["__scopeId", "data-v-d019784c"]]);
6682
+ const CommentsLayer = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["__scopeId", "data-v-7d21d613"]]);
6653
6683
  const _hoisted_1$8 = { class: "sidebar-container calculation-container" };
6654
6684
  const _hoisted_2$3 = ["id"];
6655
6685
  const _sfc_main$9 = {
@@ -7449,7 +7479,7 @@ const _sfc_main = {
7449
7479
  __name: "SuperDoc",
7450
7480
  emits: ["selection-update"],
7451
7481
  setup(__props, { emit: __emit }) {
7452
- const PdfViewer = defineAsyncComponent(() => import("./PdfViewer-CPnVLLJm.es.js"));
7482
+ const PdfViewer = defineAsyncComponent(() => import("./PdfViewer-Dnv-LGqI.es.js"));
7453
7483
  const superdocStore = useSuperdocStore();
7454
7484
  const commentsStore = useCommentsStore();
7455
7485
  const {
@@ -7491,6 +7521,16 @@ const _sfc_main = {
7491
7521
  const { isHighContrastMode: isHighContrastMode2 } = useHighContrastMode();
7492
7522
  const { uiFontFamily } = useUiFontFamily();
7493
7523
  const isViewingMode = () => proxy?.$superdoc?.config?.documentMode === "viewing";
7524
+ const isViewingCommentsVisible = computed(
7525
+ () => isViewingMode() && proxy?.$superdoc?.config?.comments?.visible === true
7526
+ );
7527
+ const isViewingTrackChangesVisible = computed(
7528
+ () => isViewingMode() && proxy?.$superdoc?.config?.trackChanges?.visible === true
7529
+ );
7530
+ const shouldRenderCommentsInViewing = computed(() => {
7531
+ if (!isViewingMode()) return true;
7532
+ return isViewingCommentsVisible.value || isViewingTrackChangesVisible.value;
7533
+ });
7494
7534
  const commentsModuleConfig = computed(() => {
7495
7535
  const config = modules.comments;
7496
7536
  if (config === false || config == null) return null;
@@ -7585,7 +7625,7 @@ const _sfc_main = {
7585
7625
  const commentsConfig = proxy.$superdoc.config.modules?.comments;
7586
7626
  if (!commentsConfig || commentsConfig === false) return;
7587
7627
  if (!positions || Object.keys(positions).length === 0) return;
7588
- if (isViewingMode()) {
7628
+ if (!shouldRenderCommentsInViewing.value) {
7589
7629
  commentsStore.clearEditorCommentPositions?.();
7590
7630
  return;
7591
7631
  }
@@ -7780,7 +7820,9 @@ const _sfc_main = {
7780
7820
  layoutEngineOptions: useLayoutEngine ? {
7781
7821
  ...proxy.$superdoc.config.layoutEngineOptions || {},
7782
7822
  debugLabel: proxy.$superdoc.config.layoutEngineOptions?.debugLabel ?? doc.name ?? doc.id,
7783
- zoom: (activeZoom.value ?? 100) / 100
7823
+ zoom: (activeZoom.value ?? 100) / 100,
7824
+ emitCommentPositionsInViewing: isViewingMode() && shouldRenderCommentsInViewing.value,
7825
+ enableCommentsInViewing: isViewingCommentsVisible.value
7784
7826
  } : void 0,
7785
7827
  permissionResolver: (payload = {}) => proxy.$superdoc.canPerformPermission({
7786
7828
  role: proxy.$superdoc.config.role,
@@ -7793,7 +7835,7 @@ const _sfc_main = {
7793
7835
  const onEditorCommentLocationsUpdate = (doc, { allCommentIds: activeThreadId, allCommentPositions } = {}) => {
7794
7836
  const commentsConfig = proxy.$superdoc.config.modules?.comments;
7795
7837
  if (!commentsConfig || commentsConfig === false) return;
7796
- if (isViewingMode()) {
7838
+ if (!shouldRenderCommentsInViewing.value) {
7797
7839
  commentsStore.clearEditorCommentPositions?.();
7798
7840
  return;
7799
7841
  }
@@ -7852,7 +7894,7 @@ const _sfc_main = {
7852
7894
  };
7853
7895
  const isCommentsEnabled = computed(() => Boolean(commentsModuleConfig.value));
7854
7896
  const showCommentsSidebar = computed(() => {
7855
- if (isViewingMode()) return false;
7897
+ if (!shouldRenderCommentsInViewing.value) return false;
7856
7898
  return pendingComment.value || getFloatingComments.value?.length > 0 && isReady.value && layers.value && isCommentsEnabled.value && !isCommentsListVisible.value;
7857
7899
  });
7858
7900
  const showToolsFloatingMenu = computed(() => {
@@ -8194,7 +8236,7 @@ const _sfc_main = {
8194
8236
  };
8195
8237
  }
8196
8238
  };
8197
- const App = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-5196811d"]]);
8239
+ const App = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-78737564"]]);
8198
8240
  const createSuperdocVueApp = () => {
8199
8241
  const app = createApp(App);
8200
8242
  const pinia = createPinia();
@@ -8300,6 +8342,8 @@ class SuperDoc extends EventEmitter {
8300
8342
  title: "SuperDoc",
8301
8343
  conversations: [],
8302
8344
  isInternal: false,
8345
+ comments: { visible: false },
8346
+ trackChanges: { visible: false },
8303
8347
  // toolbar config
8304
8348
  toolbar: null,
8305
8349
  // Optional DOM element to render the toolbar in
@@ -8349,6 +8393,16 @@ class SuperDoc extends EventEmitter {
8349
8393
  ...this.config,
8350
8394
  ...config
8351
8395
  };
8396
+ if (!this.config.comments || typeof this.config.comments !== "object") {
8397
+ this.config.comments = { visible: false };
8398
+ } else if (typeof this.config.comments.visible !== "boolean") {
8399
+ this.config.comments.visible = false;
8400
+ }
8401
+ if (!this.config.trackChanges || typeof this.config.trackChanges !== "object") {
8402
+ this.config.trackChanges = { visible: false };
8403
+ } else if (typeof this.config.trackChanges.visible !== "boolean") {
8404
+ this.config.trackChanges.visible = false;
8405
+ }
8352
8406
  const incomingUser = this.config.user;
8353
8407
  if (!incomingUser || typeof incomingUser !== "object") {
8354
8408
  this.config.user = { ...DEFAULT_USER };
@@ -8366,9 +8420,10 @@ class SuperDoc extends EventEmitter {
8366
8420
  }
8367
8421
  if (!this.config.layoutEngineOptions.trackedChanges) {
8368
8422
  const isViewingMode = this.config.documentMode === "viewing";
8423
+ const viewingTrackedChangesVisible = isViewingMode && this.config.trackChanges?.visible === true;
8369
8424
  this.config.layoutEngineOptions.trackedChanges = {
8370
- mode: isViewingMode ? "final" : "review",
8371
- enabled: !isViewingMode
8425
+ mode: isViewingMode ? viewingTrackedChangesVisible ? "review" : "original" : "review",
8426
+ enabled: true
8372
8427
  };
8373
8428
  }
8374
8429
  this.config.modules = this.config.modules || {};
@@ -8378,7 +8433,7 @@ class SuperDoc extends EventEmitter {
8378
8433
  this.config.colors = shuffleArray(this.config.colors);
8379
8434
  this.userColorMap = /* @__PURE__ */ new Map();
8380
8435
  this.colorIndex = 0;
8381
- this.version = "1.3.1-next.3";
8436
+ this.version = "1.4.0-next.2";
8382
8437
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
8383
8438
  this.superdocId = config.superdocId || v4();
8384
8439
  this.colors = this.config.colors;
@@ -8515,6 +8570,7 @@ class SuperDoc extends EventEmitter {
8515
8570
  this.superdocStore.init(this.config);
8516
8571
  const commentsModuleConfig = this.config.modules.comments;
8517
8572
  this.commentsStore.init(commentsModuleConfig && commentsModuleConfig !== false ? commentsModuleConfig : {});
8573
+ this.#syncViewingVisibility();
8518
8574
  }
8519
8575
  #initListeners() {
8520
8576
  this.on("editorBeforeCreate", this.config.onEditorBeforeCreate);
@@ -8816,6 +8872,7 @@ class SuperDoc extends EventEmitter {
8816
8872
  if (!type) return;
8817
8873
  type = type.toLowerCase();
8818
8874
  this.config.documentMode = type;
8875
+ this.#syncViewingVisibility();
8819
8876
  const types = {
8820
8877
  viewing: () => this.#setModeViewing(),
8821
8878
  editing: () => this.#setModeEditing(),
@@ -8895,10 +8952,20 @@ class SuperDoc extends EventEmitter {
8895
8952
  }
8896
8953
  #setModeViewing() {
8897
8954
  this.toolbar.activeEditor = null;
8898
- this.setTrackedChangesPreferences({ mode: "original", enabled: true });
8899
- this.commentsStore?.clearEditorCommentPositions?.();
8955
+ const commentsVisible = this.config.comments?.visible === true;
8956
+ const trackChangesVisible = this.config.trackChanges?.visible === true;
8957
+ this.setTrackedChangesPreferences(
8958
+ trackChangesVisible ? { mode: "review", enabled: true } : { mode: "original", enabled: true }
8959
+ );
8960
+ if (!commentsVisible && !trackChangesVisible) {
8961
+ this.commentsStore?.clearEditorCommentPositions?.();
8962
+ }
8900
8963
  this.superdocStore.documents.forEach((doc) => {
8901
- doc.removeComments();
8964
+ if (commentsVisible || trackChangesVisible) {
8965
+ doc.restoreComments();
8966
+ } else {
8967
+ doc.removeComments();
8968
+ }
8902
8969
  this.#applyDocumentMode(doc, "viewing");
8903
8970
  });
8904
8971
  if (this.toolbar) {
@@ -8906,6 +8973,31 @@ class SuperDoc extends EventEmitter {
8906
8973
  this.toolbar.updateToolbarState();
8907
8974
  }
8908
8975
  }
8976
+ #syncViewingVisibility() {
8977
+ const commentsVisible = this.config.comments?.visible === true;
8978
+ const trackChangesVisible = this.config.trackChanges?.visible === true;
8979
+ const isViewingMode = this.config.documentMode === "viewing";
8980
+ const shouldRenderCommentsInViewing = commentsVisible || trackChangesVisible;
8981
+ if (this.commentsStore?.setViewingVisibility) {
8982
+ this.commentsStore.setViewingVisibility({
8983
+ documentMode: this.config.documentMode,
8984
+ commentsVisible,
8985
+ trackChangesVisible
8986
+ });
8987
+ }
8988
+ const docs = this.superdocStore?.documents;
8989
+ if (Array.isArray(docs) && docs.length > 0) {
8990
+ docs.forEach((doc) => {
8991
+ const presentationEditor = typeof doc.getPresentationEditor === "function" ? doc.getPresentationEditor() : null;
8992
+ if (presentationEditor?.setViewingCommentOptions) {
8993
+ presentationEditor.setViewingCommentOptions({
8994
+ emitCommentPositionsInViewing: isViewingMode && shouldRenderCommentsInViewing,
8995
+ enableCommentsInViewing: isViewingMode && commentsVisible
8996
+ });
8997
+ }
8998
+ });
8999
+ }
9000
+ }
8909
9001
  /**
8910
9002
  * Search for text or regex in the active editor
8911
9003
  * @param {string | RegExp} text The text or regex to search for