@harbour-enterprises/superdoc 0.23.0-next.1 → 0.23.0-next.10

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 (48) hide show
  1. package/dist/chunks/{PdfViewer-C9SGNZr6.cjs → PdfViewer-BsnSIYxD.cjs} +2 -2
  2. package/dist/chunks/{PdfViewer-D9atA783.es.js → PdfViewer-CPZ7QD5u.es.js} +2 -2
  3. package/dist/chunks/{eventemitter3-CZv6vEhA.es.js → eventemitter3-CR2eBWft.es.js} +1 -1
  4. package/dist/chunks/{eventemitter3-B_kO1Pxm.cjs → eventemitter3-DSRogsNq.cjs} +1 -1
  5. package/dist/chunks/{index-C8q6lenv.es.js → index-Cd9h9gMj.es.js} +32 -22
  6. package/dist/chunks/{index-CIbe1VMu.cjs → index-DOd9uvCv.cjs} +32 -22
  7. package/dist/chunks/{jszip-b7l8QkfH.cjs → jszip-B4LDL19y.cjs} +1 -1
  8. package/dist/chunks/{jszip-B8KIZSNe.es.js → jszip-DAXEPCUv.es.js} +1 -1
  9. package/dist/chunks/{super-editor.es-DxScE0ep.cjs → super-editor.es-DAS3_Nt9.cjs} +180 -54
  10. package/dist/chunks/{super-editor.es-Dj6Sxtr7.es.js → super-editor.es-l3dTZlZX.es.js} +180 -54
  11. package/dist/chunks/{vue-DWle4Cai.cjs → vue-DKMj1I9B.cjs} +39 -42
  12. package/dist/chunks/{vue-CXxsqYcP.es.js → vue-ZWZLQtoU.es.js} +39 -42
  13. package/dist/chunks/xml-js-Bbc0NeKa.es.js +2 -0
  14. package/dist/chunks/xml-js-CWV8R-ek.cjs +3 -0
  15. package/dist/core/SuperDoc.d.ts +5 -18
  16. package/dist/core/SuperDoc.d.ts.map +1 -1
  17. package/dist/core/types/index.d.ts +29 -1
  18. package/dist/core/types/index.d.ts.map +1 -1
  19. package/dist/stores/superdoc-store.d.ts.map +1 -1
  20. package/dist/style.css +73 -54
  21. package/dist/super-editor/ai-writer.es.js +2 -2
  22. package/dist/super-editor/chunks/{converter-C08GQjNi.js → converter-ClnqoStR.js} +18 -19
  23. package/dist/super-editor/chunks/{docx-zipper-C3-uf2tI.js → docx-zipper-DC28ucAi.js} +1 -1
  24. package/dist/super-editor/chunks/{editor-C2IwVkIp.js → editor-B2aHhS9B.js} +161 -34
  25. package/dist/super-editor/chunks/{toolbar-De8G_9NV.js → toolbar-Cgyf_4bW.js} +4 -4
  26. package/dist/super-editor/converter.es.js +1 -1
  27. package/dist/super-editor/docx-zipper.es.js +2 -2
  28. package/dist/super-editor/editor.es.js +3 -3
  29. package/dist/super-editor/file-zipper.es.js +1 -1
  30. package/dist/super-editor/src/core/Attribute.d.ts +2 -2
  31. package/dist/super-editor/src/core/Schema.d.ts +2 -2
  32. package/dist/super-editor/src/extensions/image/imageHelpers/handleBase64.d.ts +4 -0
  33. package/dist/super-editor/src/extensions/image/imageHelpers/imageRegistrationPlugin.d.ts +1 -0
  34. package/dist/super-editor/src/extensions/image/imageHelpers/startImageUpload.d.ts +5 -0
  35. package/dist/super-editor/src/extensions/structured-content/structuredContentHelpers/getStructuredContentTagsByAlias.d.ts +8 -0
  36. package/dist/super-editor/src/extensions/structured-content/structuredContentHelpers/index.d.ts +1 -0
  37. package/dist/super-editor/style.css +46 -27
  38. package/dist/super-editor/super-editor.es.js +6 -6
  39. package/dist/super-editor/toolbar.es.js +2 -2
  40. package/dist/super-editor.cjs +2 -2
  41. package/dist/super-editor.es.js +2 -2
  42. package/dist/superdoc.cjs +4 -4
  43. package/dist/superdoc.es.js +4 -4
  44. package/dist/superdoc.umd.js +240 -104
  45. package/dist/superdoc.umd.js.map +1 -1
  46. package/package.json +1 -1
  47. package/dist/chunks/xml-js-CX8FH0He.cjs +0 -3
  48. package/dist/chunks/xml-js-D0tLGmKu.es.js +0 -2
@@ -20,7 +20,7 @@
20
20
  }
21
21
  const Y__namespace = /* @__PURE__ */ _interopNamespaceDefault(Y);
22
22
  /**
23
- * @vue/shared v3.5.21
23
+ * @vue/shared v3.5.22
24
24
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
25
25
  * @license MIT
26
26
  **/
@@ -915,7 +915,7 @@
915
915
  iter._next = iter.next;
916
916
  iter.next = () => {
917
917
  const result = iter._next();
918
- if (result.value) {
918
+ if (!result.done) {
919
919
  result.value = wrapValue(result.value);
920
920
  }
921
921
  return result;
@@ -1041,7 +1041,8 @@
1041
1041
  return res;
1042
1042
  }
1043
1043
  if (isRef(res)) {
1044
- return targetIsArray && isIntegerKey(key2) ? res : res.value;
1044
+ const value = targetIsArray && isIntegerKey(key2) ? res : res.value;
1045
+ return isReadonly2 && isObject$3(value) ? readonly(value) : value;
1045
1046
  }
1046
1047
  if (isObject$3(res)) {
1047
1048
  return isReadonly2 ? readonly(res) : reactive(res);
@@ -2214,9 +2215,6 @@
2214
2215
  insert(mainAnchor, container, anchor);
2215
2216
  const mount2 = (container2, anchor2) => {
2216
2217
  if (shapeFlag & 16) {
2217
- if (parentComponent && parentComponent.isCE) {
2218
- parentComponent.ce._teleportTarget = container2;
2219
- }
2220
2218
  mountChildren(
2221
2219
  children,
2222
2220
  container2,
@@ -2238,6 +2236,9 @@
2238
2236
  } else if (namespace2 !== "mathml" && isTargetMathML(target)) {
2239
2237
  namespace2 = "mathml";
2240
2238
  }
2239
+ if (parentComponent && parentComponent.isCE) {
2240
+ (parentComponent.ce._teleportTargets || (parentComponent.ce._teleportTargets = /* @__PURE__ */ new Set())).add(target);
2241
+ }
2241
2242
  if (!disabled) {
2242
2243
  mount2(target, targetAnchor);
2243
2244
  updateCssVars(n2, false);
@@ -3326,11 +3327,12 @@
3326
3327
  }
3327
3328
  function renderSlot(slots, name, props = {}, fallback, noSlotted) {
3328
3329
  if (currentRenderingInstance.ce || currentRenderingInstance.parent && isAsyncWrapper(currentRenderingInstance.parent) && currentRenderingInstance.parent.ce) {
3330
+ const hasProps = Object.keys(props).length > 0;
3329
3331
  return openBlock(), createBlock(
3330
3332
  Fragment$1,
3331
3333
  null,
3332
3334
  [createVNode("slot", props, fallback)],
3333
- 64
3335
+ hasProps ? -2 : 64
3334
3336
  );
3335
3337
  }
3336
3338
  let slot = slots[name];
@@ -6720,34 +6722,31 @@
6720
6722
  return c2;
6721
6723
  };
6722
6724
  function h$1(type2, propsOrChildren, children) {
6723
- const doCreateVNode = (type22, props, children2) => {
6725
+ try {
6724
6726
  setBlockTracking(-1);
6725
- try {
6726
- return createVNode(type22, props, children2);
6727
- } finally {
6728
- setBlockTracking(1);
6729
- }
6730
- };
6731
- const l = arguments.length;
6732
- if (l === 2) {
6733
- if (isObject$3(propsOrChildren) && !isArray$3(propsOrChildren)) {
6734
- if (isVNode(propsOrChildren)) {
6735
- return doCreateVNode(type2, null, [propsOrChildren]);
6727
+ const l = arguments.length;
6728
+ if (l === 2) {
6729
+ if (isObject$3(propsOrChildren) && !isArray$3(propsOrChildren)) {
6730
+ if (isVNode(propsOrChildren)) {
6731
+ return createVNode(type2, null, [propsOrChildren]);
6732
+ }
6733
+ return createVNode(type2, propsOrChildren);
6734
+ } else {
6735
+ return createVNode(type2, null, propsOrChildren);
6736
6736
  }
6737
- return doCreateVNode(type2, propsOrChildren);
6738
6737
  } else {
6739
- return doCreateVNode(type2, null, propsOrChildren);
6740
- }
6741
- } else {
6742
- if (l > 3) {
6743
- children = Array.prototype.slice.call(arguments, 2);
6744
- } else if (l === 3 && isVNode(children)) {
6745
- children = [children];
6738
+ if (l > 3) {
6739
+ children = Array.prototype.slice.call(arguments, 2);
6740
+ } else if (l === 3 && isVNode(children)) {
6741
+ children = [children];
6742
+ }
6743
+ return createVNode(type2, propsOrChildren, children);
6746
6744
  }
6747
- return doCreateVNode(type2, propsOrChildren, children);
6745
+ } finally {
6746
+ setBlockTracking(1);
6748
6747
  }
6749
6748
  }
6750
- const version$1 = "3.5.21";
6749
+ const version$1 = "3.5.22";
6751
6750
  let policy = void 0;
6752
6751
  const tt = typeof window !== "undefined" && window.trustedTypes;
6753
6752
  if (tt) {
@@ -6953,11 +6952,11 @@
6953
6952
  const resolve2 = () => finishLeave(el, done);
6954
6953
  addTransitionClass(el, leaveFromClass);
6955
6954
  if (!el._enterCancelled) {
6956
- forceReflow();
6955
+ forceReflow(el);
6957
6956
  addTransitionClass(el, leaveActiveClass);
6958
6957
  } else {
6959
6958
  addTransitionClass(el, leaveActiveClass);
6960
- forceReflow();
6959
+ forceReflow(el);
6961
6960
  }
6962
6961
  nextFrame(() => {
6963
6962
  if (!el._isLeaving) {
@@ -7100,8 +7099,9 @@
7100
7099
  if (s === "auto") return 0;
7101
7100
  return Number(s.slice(0, -1).replace(",", ".")) * 1e3;
7102
7101
  }
7103
- function forceReflow() {
7104
- return document.body.offsetHeight;
7102
+ function forceReflow(el) {
7103
+ const targetDocument = el ? el.ownerDocument : document;
7104
+ return targetDocument.body.offsetHeight;
7105
7105
  }
7106
7106
  function patchClass(el, value, isSVG2) {
7107
7107
  const transitionClasses = el[vtcKey];
@@ -7487,7 +7487,7 @@
7487
7487
  prevChildren.forEach(callPendingCbs);
7488
7488
  prevChildren.forEach(recordPosition);
7489
7489
  const movedChildren = prevChildren.filter(applyTranslation);
7490
- forceReflow();
7490
+ forceReflow(instance.vnode.el);
7491
7491
  movedChildren.forEach((c2) => {
7492
7492
  const el = c2.el;
7493
7493
  const style2 = el.style;
@@ -12836,6 +12836,19 @@
12836
12836
  };
12837
12837
  return safeRegexTest;
12838
12838
  }
12839
+ var generatorFunction;
12840
+ var hasRequiredGeneratorFunction;
12841
+ function requireGeneratorFunction() {
12842
+ if (hasRequiredGeneratorFunction) return generatorFunction;
12843
+ hasRequiredGeneratorFunction = 1;
12844
+ const cached = (
12845
+ /** @type {GeneratorFunctionConstructor} */
12846
+ function* () {
12847
+ }.constructor
12848
+ );
12849
+ generatorFunction = () => cached;
12850
+ return generatorFunction;
12851
+ }
12839
12852
  var isGeneratorFunction;
12840
12853
  var hasRequiredIsGeneratorFunction;
12841
12854
  function requireIsGeneratorFunction() {
@@ -12848,16 +12861,7 @@
12848
12861
  var getProto2 = requireGetProto();
12849
12862
  var toStr = callBound2("Object.prototype.toString");
12850
12863
  var fnToStr = callBound2("Function.prototype.toString");
12851
- var getGeneratorFunc = function() {
12852
- if (!hasToStringTag) {
12853
- return false;
12854
- }
12855
- try {
12856
- return Function("return function*() {}")();
12857
- } catch (e) {
12858
- }
12859
- };
12860
- var GeneratorFunction;
12864
+ var getGeneratorFunction = /* @__PURE__ */ requireGeneratorFunction();
12861
12865
  isGeneratorFunction = function isGeneratorFunction2(fn) {
12862
12866
  if (typeof fn !== "function") {
12863
12867
  return false;
@@ -12872,14 +12876,8 @@
12872
12876
  if (!getProto2) {
12873
12877
  return false;
12874
12878
  }
12875
- if (typeof GeneratorFunction === "undefined") {
12876
- var generatorFunc = getGeneratorFunc();
12877
- GeneratorFunction = generatorFunc ? (
12878
- /** @type {GeneratorFunctionConstructor} */
12879
- getProto2(generatorFunc)
12880
- ) : false;
12881
- }
12882
- return getProto2(fn) === GeneratorFunction;
12879
+ var GeneratorFunction = getGeneratorFunction();
12880
+ return GeneratorFunction && getProto2(fn) === GeneratorFunction.prototype;
12883
12881
  };
12884
12882
  return isGeneratorFunction;
12885
12883
  }
@@ -39620,7 +39618,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
39620
39618
  }
39621
39619
  if (elements) {
39622
39620
  if (name === "w:instrText") {
39623
- tags.push(elements[0].text);
39621
+ const textContent2 = (elements || []).map((child) => typeof child?.text === "string" ? child.text : "").join("");
39622
+ tags.push(__privateMethod$2(this, _DocxExporter_instances, replaceSpecialCharacters_fn).call(this, textContent2));
39624
39623
  } else if (name === "w:t" || name === "w:delText" || name === "wp:posOffset") {
39625
39624
  try {
39626
39625
  let text = String(elements[0].text);
@@ -49789,8 +49788,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
49789
49788
  let $to = parse.doc.resolveNoCache(change.endB - parse.from);
49790
49789
  let $fromA = doc2.resolve(change.start);
49791
49790
  let inlineChange = $from.sameParent($to) && $from.parent.inlineContent && $fromA.end() >= change.endA;
49792
- let nextSel;
49793
- if ((ios && view.input.lastIOSEnter > Date.now() - 225 && (!inlineChange || addedNodes.some((n) => n.nodeName == "DIV" || n.nodeName == "P")) || !inlineChange && $from.pos < parse.doc.content.size && (!$from.sameParent($to) || !$from.parent.inlineContent) && !/\S/.test(parse.doc.textBetween($from.pos, $to.pos, "", "")) && (nextSel = Selection.findFrom(parse.doc.resolve($from.pos + 1), 1, true)) && nextSel.head > $from.pos) && view.someProp("handleKeyDown", (f) => f(view, keyEvent(13, "Enter")))) {
49791
+ if ((ios && view.input.lastIOSEnter > Date.now() - 225 && (!inlineChange || addedNodes.some((n) => n.nodeName == "DIV" || n.nodeName == "P")) || !inlineChange && $from.pos < parse.doc.content.size && (!$from.sameParent($to) || !$from.parent.inlineContent) && $from.pos < $to.pos && !/\S/.test(parse.doc.textBetween($from.pos, $to.pos, "", ""))) && view.someProp("handleKeyDown", (f) => f(view, keyEvent(13, "Enter")))) {
49794
49792
  view.input.lastIOSEnter = 0;
49795
49793
  return;
49796
49794
  }
@@ -61934,6 +61932,17 @@ Please report this to https://github.com/markedjs/marked.`, e) {
61934
61932
  });
61935
61933
  return result;
61936
61934
  }
61935
+ function getStructuredContentTagsByAlias(aliasOrAliases, state2) {
61936
+ const result = findChildren$5(state2.doc, (node) => {
61937
+ const isStructuredContent = ["structuredContent", "structuredContentBlock"].includes(node.type.name);
61938
+ if (Array.isArray(aliasOrAliases)) {
61939
+ return isStructuredContent && aliasOrAliases.includes(node.attrs.alias);
61940
+ } else {
61941
+ return isStructuredContent && node.attrs.alias === aliasOrAliases;
61942
+ }
61943
+ });
61944
+ return result;
61945
+ }
61937
61946
  function getStructuredContentTags(state2) {
61938
61947
  const result = findChildren$5(state2.doc, (node) => {
61939
61948
  return node.type.name === "structuredContent" || node.type.name === "structuredContentBlock";
@@ -61953,6 +61962,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
61953
61962
  getStructuredContentBlockTags,
61954
61963
  getStructuredContentInlineTags,
61955
61964
  getStructuredContentTags,
61965
+ getStructuredContentTagsByAlias,
61956
61966
  getStructuredContentTagsById
61957
61967
  }, Symbol.toStringTag, { value: "Module" }));
61958
61968
  const STRUCTURED_CONTENT_NAMES = ["structuredContent", "structuredContentBlock"];
@@ -62041,10 +62051,11 @@ Please report this to https://github.com/markedjs/marked.`, e) {
62041
62051
  return true;
62042
62052
  },
62043
62053
  /**
62044
- * Updates a structured content attributes or content.
62054
+ * Updates a single structured content field by its unique ID.
62055
+ * IDs are unique identifiers, so this will update at most one field.
62045
62056
  * If the updated node does not match the schema, it will not be updated.
62046
62057
  * @category Command
62047
- * @param {string} id
62058
+ * @param {string} id - Unique identifier of the field
62048
62059
  * @param {StructuredContentUpdate} options
62049
62060
  */
62050
62061
  updateStructuredContentById: (id, options = {}) => ({ editor, dispatch, state: state2, tr }) => {
@@ -62084,6 +62095,58 @@ Please report this to https://github.com/markedjs/marked.`, e) {
62084
62095
  }
62085
62096
  return true;
62086
62097
  },
62098
+ /**
62099
+ * Updates all structured content fields with the same alias.
62100
+ * Unlike IDs (which are unique), aliases can be shared across multiple fields.
62101
+ * This will update every field that matches the given alias.
62102
+ * If any updated node does not match the schema, no updates will be applied.
62103
+ * @category Command
62104
+ * @param {string | string[]} alias - Shared identifier for fields (e.g., "customer_name")
62105
+ * @param {StructuredContentUpdate} options
62106
+ */
62107
+ updateStructuredContentByAlias: (alias, options = {}) => ({ editor, dispatch, state: state2, tr }) => {
62108
+ const structuredContentTags = getStructuredContentTagsByAlias(alias, state2);
62109
+ if (!structuredContentTags.length) {
62110
+ return true;
62111
+ }
62112
+ const { schema } = editor;
62113
+ const createContent = (node) => {
62114
+ if (options.text) {
62115
+ return schema.text(options.text);
62116
+ }
62117
+ if (options.html) {
62118
+ const html = htmlHandler(options.html, editor);
62119
+ const doc2 = DOMParser$1.fromSchema(schema).parse(html);
62120
+ return doc2.content;
62121
+ }
62122
+ if (options.json) {
62123
+ return schema.nodeFromJSON(options.json);
62124
+ }
62125
+ return node.content;
62126
+ };
62127
+ for (const { node } of structuredContentTags) {
62128
+ const content = createContent(node);
62129
+ const updatedNode = node.type.create({ ...node.attrs, ...options.attrs }, content, node.marks);
62130
+ try {
62131
+ updatedNode.check();
62132
+ } catch {
62133
+ console.error("Updated node does not conform to the schema");
62134
+ return false;
62135
+ }
62136
+ }
62137
+ if (dispatch) {
62138
+ structuredContentTags.forEach(({ pos, node }) => {
62139
+ const mappedPos = tr.mapping.map(pos);
62140
+ const currentNode = tr.doc.nodeAt(mappedPos);
62141
+ if (currentNode && node.eq(currentNode)) {
62142
+ const content = createContent(node);
62143
+ const updatedNode = node.type.create({ ...node.attrs, ...options.attrs }, content, node.marks);
62144
+ tr.replaceWith(mappedPos, mappedPos + node.nodeSize, updatedNode);
62145
+ }
62146
+ });
62147
+ }
62148
+ return true;
62149
+ },
62087
62150
  /**
62088
62151
  * Removes a structured content.
62089
62152
  * @category Command
@@ -70225,6 +70288,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
70225
70288
  }
70226
70289
  return formatAttrs;
70227
70290
  }
70291
+ const DEFAULT_MIME_TYPE = "application/octet-stream";
70228
70292
  const simpleHash = (str) => {
70229
70293
  let hash2 = 0;
70230
70294
  for (let i2 = 0; i2 < str.length; i2++) {
@@ -70234,21 +70298,40 @@ Please report this to https://github.com/markedjs/marked.`, e) {
70234
70298
  }
70235
70299
  return Math.abs(hash2).toString();
70236
70300
  };
70237
- const base64ToFile = (base64String) => {
70238
- const arr = base64String.split(",");
70239
- const mimeMatch = arr[0].match(/:(.*?);/);
70240
- const mimeType = mimeMatch ? mimeMatch[1] : "";
70241
- const data = arr[1];
70242
- const binaryString = atob(data);
70301
+ const decodeBase64ToBinaryString = (data) => {
70302
+ if (!data) return "";
70303
+ if (typeof atob === "function") {
70304
+ return atob(data);
70305
+ }
70306
+ if (typeof Buffer2 !== "undefined" && typeof Buffer2.from === "function") {
70307
+ return Buffer2.from(data, "base64").toString("binary");
70308
+ }
70309
+ throw new Error("Unable to decode base64 payload in the current environment.");
70310
+ };
70311
+ const extractBase64Meta = (base64String) => {
70312
+ const [meta = "", payload = ""] = base64String.split(",");
70313
+ const mimeMatch = meta.match(/:(.*?);/);
70314
+ const rawMimeType = mimeMatch ? mimeMatch[1] : "";
70315
+ const mimeType = rawMimeType || DEFAULT_MIME_TYPE;
70316
+ const binaryString = decodeBase64ToBinaryString(payload);
70243
70317
  const hash2 = simpleHash(binaryString);
70244
70318
  const extension = mimeType.split("/")[1] || "bin";
70245
70319
  const filename = `image-${hash2}.${extension}`;
70320
+ return { mimeType, binaryString, filename };
70321
+ };
70322
+ const getBase64FileMeta = (base64String) => {
70323
+ const { mimeType, filename } = extractBase64Meta(base64String);
70324
+ return { mimeType, filename };
70325
+ };
70326
+ const base64ToFile = (base64String) => {
70327
+ const { mimeType, binaryString, filename } = extractBase64Meta(base64String);
70328
+ const fileType = mimeType || DEFAULT_MIME_TYPE;
70246
70329
  const bytes = new Uint8Array(binaryString.length);
70247
70330
  for (let i2 = 0; i2 < binaryString.length; i2++) {
70248
70331
  bytes[i2] = binaryString.charCodeAt(i2);
70249
70332
  }
70250
- const blob = new Blob([bytes], { type: mimeType });
70251
- return new File([blob], filename, { type: mimeType });
70333
+ const blob = new Blob([bytes], { type: fileType });
70334
+ return new File([blob], filename, { type: fileType });
70252
70335
  };
70253
70336
  const urlToFile = async (url, filename, mimeType) => {
70254
70337
  try {
@@ -70624,6 +70707,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
70624
70707
  }
70625
70708
  }
70626
70709
  const key = new PluginKey("ImageRegistration");
70710
+ const WORD_MEDIA_PREFIX = "word/";
70627
70711
  const ImageRegistrationPlugin = ({ editor }) => {
70628
70712
  const { view } = editor;
70629
70713
  return new Plugin({
@@ -70644,16 +70728,16 @@ Please report this to https://github.com/markedjs/marked.`, e) {
70644
70728
  },
70645
70729
  appendTransaction: (trs, _oldState, state2) => {
70646
70730
  let foundImages = [];
70647
- trs.forEach((tr2) => {
70648
- if (tr2.docChanged) {
70649
- tr2.steps.forEach((step, index2) => {
70731
+ trs.forEach((tr) => {
70732
+ if (tr.docChanged) {
70733
+ tr.steps.forEach((step, index2) => {
70650
70734
  const stepMap = step.getMap();
70651
70735
  foundImages = foundImages.map(({ node, pos, id }) => {
70652
70736
  const mappedPos = stepMap.map(pos, -1);
70653
70737
  return { node, pos: mappedPos, id };
70654
70738
  });
70655
70739
  if (step instanceof ReplaceStep || step instanceof ReplaceAroundStep$1) {
70656
- (tr2.docs[index2 + 1] || tr2.doc).nodesBetween(
70740
+ (tr.docs[index2 + 1] || tr.doc).nodesBetween(
70657
70741
  stepMap.map(step.from, -1),
70658
70742
  stepMap.map(step.to, 1),
70659
70743
  (node, pos) => {
@@ -70672,22 +70756,10 @@ Please report this to https://github.com/markedjs/marked.`, e) {
70672
70756
  if (!foundImages || foundImages.length === 0) {
70673
70757
  return null;
70674
70758
  }
70675
- registerImages(foundImages, editor, view);
70676
- const tr = state2.tr;
70677
- let { set } = key.getState(state2);
70678
- foundImages.slice().sort((a, b2) => a.pos - b2.pos).forEach(({ pos, id }) => {
70679
- let deco = Decoration.widget(pos, () => document.createElement("placeholder"), {
70680
- side: -1,
70681
- id
70682
- });
70683
- set = set.add(tr.doc, [deco]);
70684
- });
70685
- foundImages.slice().sort((a, b2) => b2.pos - a.pos).forEach(({ node, pos }) => {
70686
- tr.delete(pos, pos + node.nodeSize);
70687
- });
70688
- set = set.map(tr.mapping, tr.doc);
70689
- tr.setMeta(key, { set });
70690
- return tr;
70759
+ if (editor.options.isHeadless) {
70760
+ return handleNodePath(foundImages, editor, state2);
70761
+ }
70762
+ return handleBrowserPath(foundImages, editor, view, state2);
70691
70763
  },
70692
70764
  props: {
70693
70765
  decorations(state2) {
@@ -70697,6 +70769,59 @@ Please report this to https://github.com/markedjs/marked.`, e) {
70697
70769
  }
70698
70770
  });
70699
70771
  };
70772
+ const derivePreferredFileName = (src) => {
70773
+ if (typeof src !== "string" || src.length === 0) {
70774
+ return "image.bin";
70775
+ }
70776
+ if (src.startsWith("data:")) {
70777
+ return getBase64FileMeta(src).filename;
70778
+ }
70779
+ const lastSegment = src.split("/").pop() ?? "";
70780
+ const trimmed = lastSegment.split(/[?#]/)[0];
70781
+ return trimmed || "image.bin";
70782
+ };
70783
+ const handleNodePath = (foundImages, editor, state2) => {
70784
+ const { tr } = state2;
70785
+ const mediaStore = editor.storage.image.media ?? {};
70786
+ if (!editor.storage.image.media) {
70787
+ editor.storage.image.media = mediaStore;
70788
+ }
70789
+ const existingFileNames = new Set(Object.keys(mediaStore).map((key2) => key2.split("/").pop()));
70790
+ foundImages.forEach(({ node, pos }) => {
70791
+ const { src } = node.attrs;
70792
+ const preferredFileName = derivePreferredFileName(src);
70793
+ const uniqueFileName = ensureUniqueFileName(preferredFileName, existingFileNames);
70794
+ existingFileNames.add(uniqueFileName);
70795
+ const mediaPath = buildMediaPath(uniqueFileName);
70796
+ mediaStore[mediaPath] = src;
70797
+ const path = mediaPath.startsWith(WORD_MEDIA_PREFIX) ? mediaPath.slice(WORD_MEDIA_PREFIX.length) : mediaPath;
70798
+ const rId = addImageRelationship({ editor, path });
70799
+ tr.setNodeMarkup(pos, void 0, {
70800
+ ...node.attrs,
70801
+ src: mediaPath,
70802
+ rId
70803
+ });
70804
+ });
70805
+ return tr;
70806
+ };
70807
+ const handleBrowserPath = (foundImages, editor, view, state2) => {
70808
+ registerImages(foundImages, editor, view);
70809
+ const tr = state2.tr;
70810
+ let { set } = key.getState(state2);
70811
+ foundImages.slice().sort((a, b2) => a.pos - b2.pos).forEach(({ pos, id }) => {
70812
+ let deco = Decoration.widget(pos, () => document.createElement("placeholder"), {
70813
+ side: -1,
70814
+ id
70815
+ });
70816
+ set = set.add(tr.doc, [deco]);
70817
+ });
70818
+ foundImages.slice().sort((a, b2) => b2.pos - a.pos).forEach(({ node, pos }) => {
70819
+ tr.delete(pos, pos + node.nodeSize);
70820
+ });
70821
+ set = set.map(tr.mapping, tr.doc);
70822
+ tr.setMeta(key, { set });
70823
+ return tr;
70824
+ };
70700
70825
  const findPlaceholder = (state2, id) => {
70701
70826
  let { set } = key.getState(state2);
70702
70827
  let found2 = set?.find(null, null, (spec) => spec.id === id);
@@ -77814,6 +77939,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
77814
77939
  return actualBreak;
77815
77940
  }
77816
77941
  const onImageLoad = (editor) => {
77942
+ if (typeof requestAnimationFrame !== "function") return;
77817
77943
  requestAnimationFrame(() => {
77818
77944
  const newTr = editor.view.state.tr;
77819
77945
  newTr.setMeta("forceUpdatePagination", true);
@@ -79025,7 +79151,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
79025
79151
  };
79026
79152
  const handleInputSubmit = () => {
79027
79153
  const value = inlineTextInput.value;
79028
- const cleanValue = value.replace(/[^0-9]/g, "");
79154
+ const cleanValue = value.match(/^\d+(\.5)?$/) ? value : Math.floor(parseFloat(value)).toString();
79029
79155
  emit2("textSubmit", cleanValue);
79030
79156
  inlineTextInput.value = cleanValue;
79031
79157
  };
@@ -79107,7 +79233,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
79107
79233
  };
79108
79234
  }
79109
79235
  };
79110
- const ToolbarButton = /* @__PURE__ */ _export_sfc$1(_sfc_main$4$2, [["__scopeId", "data-v-303b3245"]]);
79236
+ const ToolbarButton = /* @__PURE__ */ _export_sfc$1(_sfc_main$4$2, [["__scopeId", "data-v-cea02a58"]]);
79111
79237
  const _hoisted_1$2$2 = {
79112
79238
  class: "toolbar-separator",
79113
79239
  role: "separator",
@@ -97456,6 +97582,9 @@ ${reason}`);
97456
97582
  documentUsers.value = configUsers || [];
97457
97583
  Object.assign(user, configUser);
97458
97584
  Object.assign(modules, configModules);
97585
+ if (!Object.prototype.hasOwnProperty.call(modules, "comments")) {
97586
+ modules.comments = {};
97587
+ }
97459
97588
  if (!configDocs?.length && !config2.modules.collaboration) {
97460
97589
  const newDoc = await getFileObject(BlankDOCX, "blank.docx", DOCX);
97461
97590
  const newDocConfig = {
@@ -111046,6 +111175,11 @@ ${style2}
111046
111175
  const { proxy } = getCurrentInstance();
111047
111176
  commentsStore.proxy = proxy;
111048
111177
  const { isHighContrastMode: isHighContrastMode2 } = useHighContrastMode();
111178
+ const commentsModuleConfig = computed(() => {
111179
+ const config2 = modules.comments;
111180
+ if (config2 === false || config2 == null) return null;
111181
+ return config2;
111182
+ });
111049
111183
  const layers = ref$1(null);
111050
111184
  const commentsLayer = ref$1(null);
111051
111185
  const toolsMenuPosition = reactive({ top: null, right: "-25px", zIndex: 101 });
@@ -111193,7 +111327,7 @@ ${style2}
111193
111327
  rulers: doc2.rulers,
111194
111328
  isInternal: proxy.$superdoc.config.isInternal,
111195
111329
  annotations: proxy.$superdoc.config.annotations,
111196
- isCommentsEnabled: proxy.$superdoc.config.modules?.comments,
111330
+ isCommentsEnabled: Boolean(commentsModuleConfig.value),
111197
111331
  isAiEnabled: proxy.$superdoc.config.modules?.ai,
111198
111332
  slashMenuConfig: proxy.$superdoc.config.modules?.slashMenu,
111199
111333
  onBeforeCreate: onEditorBeforeCreate,
@@ -111224,7 +111358,8 @@ ${style2}
111224
111358
  return options;
111225
111359
  };
111226
111360
  const onEditorCommentLocationsUpdate = ({ allCommentIds: activeThreadId, allCommentPositions }) => {
111227
- if (!proxy.$superdoc.config.modules?.comments) return;
111361
+ const commentsConfig = proxy.$superdoc.config.modules?.comments;
111362
+ if (!commentsConfig || commentsConfig === false) return;
111228
111363
  handleEditorLocationsUpdate(allCommentPositions, activeThreadId);
111229
111364
  };
111230
111365
  const onEditorCommentsUpdate = (params2 = {}) => {
@@ -111246,7 +111381,7 @@ ${style2}
111246
111381
  proxy.$superdoc.config.onTransaction({ editor, transaction, duration: duration2 });
111247
111382
  }
111248
111383
  };
111249
- const isCommentsEnabled = computed(() => "comments" in modules);
111384
+ const isCommentsEnabled = computed(() => Boolean(commentsModuleConfig.value));
111250
111385
  const showCommentsSidebar = computed(() => {
111251
111386
  return pendingComment.value || getFloatingComments.value?.length > 0 && isReady.value && layers.value && isCommentsEnabled.value && !isCommentsListVisible.value;
111252
111387
  });
@@ -111256,13 +111391,14 @@ ${style2}
111256
111391
  });
111257
111392
  computed(() => {
111258
111393
  if (!isCommentsEnabled.value) return false;
111259
- !getConfig?.readOnly && selectionPosition.value;
111394
+ return !getConfig.value?.readOnly && selectionPosition.value;
111260
111395
  });
111261
111396
  watch(showCommentsSidebar, (value) => {
111262
111397
  proxy.$superdoc.broadcastSidebarToggle(value);
111263
111398
  });
111264
111399
  const scrollToComment = (commentId) => {
111265
- if (!proxy.$superdoc.config?.modules?.comments) return;
111400
+ const commentsConfig = proxy.$superdoc.config?.modules?.comments;
111401
+ if (!commentsConfig || commentsConfig === false) return;
111266
111402
  const element = document.querySelector(`[data-thread-id=${commentId}]`);
111267
111403
  if (element) {
111268
111404
  element.scrollIntoView({ behavior: "smooth", block: "start" });
@@ -111270,7 +111406,8 @@ ${style2}
111270
111406
  }
111271
111407
  };
111272
111408
  onMounted(() => {
111273
- if (isCommentsEnabled.value && !modules.comments.readOnly) {
111409
+ const config2 = commentsModuleConfig.value;
111410
+ if (config2 && !config2.readOnly) {
111274
111411
  document.addEventListener("mousedown", handleDocumentMouseDown);
111275
111412
  }
111276
111413
  });
@@ -111392,6 +111529,7 @@ ${style2}
111392
111529
  };
111393
111530
  const shouldShowSelection = computed(() => {
111394
111531
  const config2 = proxy.$superdoc.config.modules?.comments;
111532
+ if (!config2 || config2 === false) return false;
111395
111533
  return !config2.readOnly;
111396
111534
  });
111397
111535
  const handleSuperEditorPageMarginsChange = (doc2, params2) => {
@@ -111558,7 +111696,7 @@ ${style2}
111558
111696
  };
111559
111697
  }
111560
111698
  };
111561
- const App = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-3f71b1bf"]]);
111699
+ const App = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-45f44b6e"]]);
111562
111700
  const createSuperdocVueApp = () => {
111563
111701
  const app = createApp(App);
111564
111702
  const pinia = createPinia();
@@ -111657,6 +111795,10 @@ ${style2}
111657
111795
  ...this.config,
111658
111796
  ...config2
111659
111797
  };
111798
+ this.config.modules = this.config.modules || {};
111799
+ if (!Object.prototype.hasOwnProperty.call(this.config.modules, "comments")) {
111800
+ this.config.modules.comments = {};
111801
+ }
111660
111802
  this.config.colors = shuffleArray(this.config.colors);
111661
111803
  this.userColorMap = /* @__PURE__ */ new Map();
111662
111804
  this.colorIndex = 0;
@@ -111791,7 +111933,8 @@ ${style2}
111791
111933
  this.superdocStore.setExceptionHandler((payload) => this.emit("exception", payload));
111792
111934
  }
111793
111935
  this.superdocStore.init(this.config);
111794
- this.commentsStore.init(this.config.modules.comments);
111936
+ const commentsModuleConfig = this.config.modules.comments;
111937
+ this.commentsStore.init(commentsModuleConfig && commentsModuleConfig !== false ? commentsModuleConfig : {});
111795
111938
  }
111796
111939
  #initListeners() {
111797
111940
  this.on("editorBeforeCreate", this.config.onEditorBeforeCreate);
@@ -112141,15 +112284,8 @@ ${style2}
112141
112284
  }
112142
112285
  /**
112143
112286
  * Export the superdoc to a file
112144
- * @param {Object} params
112145
- * @param {string[]} [params.exportType]
112146
- * @param {string} [params.commentsType]
112147
- * @param {string} [params.exportedName]
112148
- * @param {Array} [params.additionalFiles]
112149
- * @param {Array} [params.additionalFileNames]
112150
- * @param {boolean} [params.isFinalDoc]
112151
- * @param {boolean} [params.triggerDownload] Whether to trigger the download of the exported file
112152
- * @returns {Promise<void | Blob>} Returns void if triggerDownload is false, otherwise returns the exported file
112287
+ * @param {ExportParams} params - Export configuration
112288
+ * @returns {Promise<void | Blob>}
112153
112289
  */
112154
112290
  async export({
112155
112291
  exportType = ["docx"],