@harbour-enterprises/superdoc 0.22.0-next.1 → 0.22.0-next.11

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 (75) hide show
  1. package/dist/chunks/{PdfViewer-BpwMPbUj.es.js → PdfViewer-CS3pY_UR.es.js} +1 -1
  2. package/dist/chunks/{PdfViewer-B3KmcDup.cjs → PdfViewer-Cz3fT1qt.cjs} +1 -1
  3. package/dist/chunks/{index-Cw4YywoD.es.js → index-Bbqhu9ev.es.js} +53 -26
  4. package/dist/chunks/{index-BOf6E2I4.cjs → index-p73XAt11.cjs} +53 -26
  5. package/dist/chunks/{super-editor.es-DHDx2fsy.cjs → super-editor.es-CFD0lcOY.cjs} +3201 -2009
  6. package/dist/chunks/{super-editor.es-vfoWxyZL.es.js → super-editor.es-DK3l03fz.es.js} +3201 -2009
  7. package/dist/core/SuperDoc.d.ts +5 -0
  8. package/dist/core/SuperDoc.d.ts.map +1 -1
  9. package/dist/core/types/index.d.ts +4 -4
  10. package/dist/core/types/index.d.ts.map +1 -1
  11. package/dist/stores/comments-store.d.ts +4 -1
  12. package/dist/stores/comments-store.d.ts.map +1 -1
  13. package/dist/style.css +51 -44
  14. package/dist/super-editor/ai-writer.es.js +2 -2
  15. package/dist/super-editor/chunks/{converter-BcqEfCTg.js → converter-DFDRdFEB.js} +1880 -1169
  16. package/dist/super-editor/chunks/{docx-zipper-DZ9ph0iQ.js → docx-zipper-CplUdgI9.js} +73 -12
  17. package/dist/super-editor/chunks/{editor-BC2sSIVa.js → editor-BnpIdTLI.js} +1492 -1061
  18. package/dist/super-editor/chunks/{toolbar-DNTo5DDf.js → toolbar-5h-ljJ_h.js} +2 -2
  19. package/dist/super-editor/converter.es.js +1 -1
  20. package/dist/super-editor/docx-zipper.es.js +2 -2
  21. package/dist/super-editor/editor.es.js +3 -3
  22. package/dist/super-editor/file-zipper.es.js +1 -1
  23. package/dist/super-editor/src/core/DocxZipper.d.ts +1 -1
  24. package/dist/super-editor/src/core/helpers/generateDocxRandomId.d.ts +5 -0
  25. package/dist/super-editor/src/core/super-converter/SuperConverter.d.ts +1 -13
  26. package/dist/super-editor/src/core/super-converter/exporter.d.ts +5 -4
  27. package/dist/super-editor/src/core/super-converter/field-references/fld-preprocessors/hyperlink-preprocessor.d.ts +9 -0
  28. package/dist/super-editor/src/core/super-converter/field-references/fld-preprocessors/index.d.ts +2 -0
  29. package/dist/super-editor/src/core/super-converter/field-references/fld-preprocessors/num-pages-preprocessor.d.ts +9 -0
  30. package/dist/super-editor/src/core/super-converter/field-references/fld-preprocessors/page-preprocessor.d.ts +9 -0
  31. package/dist/super-editor/src/core/super-converter/field-references/fld-preprocessors/page-ref-preprocessor.d.ts +9 -0
  32. package/dist/super-editor/src/core/super-converter/field-references/fld-preprocessors/toc-preprocessor.d.ts +8 -0
  33. package/dist/super-editor/src/core/super-converter/field-references/index.d.ts +1 -0
  34. package/dist/super-editor/src/core/super-converter/field-references/preProcessNodesForFldChar.d.ts +21 -0
  35. package/dist/super-editor/src/core/super-converter/helpers/tableFallbackHelpers.d.ts +24 -0
  36. package/dist/super-editor/src/core/super-converter/v2/exporter/helpers/translateChildNodes.d.ts +3 -3
  37. package/dist/super-editor/src/core/super-converter/v2/importer/pageReferenceImporter.d.ts +4 -0
  38. package/dist/super-editor/src/core/super-converter/v2/importer/tableOfContentsImporter.d.ts +4 -0
  39. package/dist/super-editor/src/core/super-converter/v2/types/index.d.ts +7 -1
  40. package/dist/super-editor/src/core/super-converter/v3/handlers/sd/pageReference/index.d.ts +1 -0
  41. package/dist/super-editor/src/core/super-converter/v3/handlers/sd/pageReference/pageReference-translator.d.ts +7 -0
  42. package/dist/super-editor/src/core/super-converter/v3/handlers/sd/tableOfContents/index.d.ts +1 -0
  43. package/dist/super-editor/src/core/super-converter/v3/handlers/sd/tableOfContents/tableOfContents-translator.d.ts +10 -0
  44. package/dist/super-editor/src/core/super-converter/v3/handlers/w/caps/caps-translator.d.ts +7 -0
  45. package/dist/super-editor/src/core/super-converter/v3/handlers/w/p/helpers/w-p-helpers.d.ts +0 -2
  46. package/dist/super-editor/src/core/super-converter/v3/handlers/w/sdt/helpers/handle-doc-part-obj.d.ts +9 -1
  47. package/dist/super-editor/src/core/super-converter/v3/handlers/w/sdt/helpers/translate-document-part-obj.d.ts +6 -0
  48. package/dist/super-editor/src/core/super-converter/v3/node-translator/node-translator.d.ts +2 -2
  49. package/dist/super-editor/src/extensions/custom-selection/custom-selection.d.ts +5 -1
  50. package/dist/super-editor/src/extensions/index.d.ts +2 -1
  51. package/dist/super-editor/src/extensions/page-reference/index.d.ts +1 -0
  52. package/dist/super-editor/src/extensions/page-reference/page-reference.d.ts +2 -0
  53. package/dist/super-editor/src/extensions/structured-content/document-part-object.d.ts +2 -0
  54. package/dist/super-editor/src/extensions/structured-content/index.d.ts +2 -0
  55. package/dist/super-editor/src/extensions/structured-content/structured-content-commands.d.ts +67 -0
  56. package/dist/super-editor/src/extensions/structured-content/structuredContentHelpers/getStructuredContentBlockTags.d.ts +6 -0
  57. package/dist/super-editor/src/extensions/structured-content/structuredContentHelpers/getStructuredContentInlineTags.d.ts +6 -0
  58. package/dist/super-editor/src/extensions/structured-content/structuredContentHelpers/getStructuredContentTags.d.ts +6 -0
  59. package/dist/super-editor/src/extensions/structured-content/structuredContentHelpers/getStructuredContentTagsById.d.ts +7 -0
  60. package/dist/super-editor/src/extensions/structured-content/structuredContentHelpers/index.d.ts +4 -0
  61. package/dist/super-editor/src/extensions/tab/helpers/tabDecorations.d.ts +2 -2
  62. package/dist/super-editor/src/extensions/table-of-contents/index.d.ts +1 -0
  63. package/dist/super-editor/src/extensions/table-of-contents/table-of-contents.d.ts +2 -0
  64. package/dist/super-editor/src/utils/contextmenu-helpers.d.ts +24 -0
  65. package/dist/super-editor/style.css +7 -0
  66. package/dist/super-editor/super-editor.es.js +11 -17
  67. package/dist/super-editor/toolbar.es.js +2 -2
  68. package/dist/super-editor.cjs +1 -1
  69. package/dist/super-editor.es.js +1 -1
  70. package/dist/superdoc.cjs +2 -2
  71. package/dist/superdoc.es.js +2 -2
  72. package/dist/superdoc.umd.js +3245 -2026
  73. package/dist/superdoc.umd.js.map +1 -1
  74. package/package.json +1 -1
  75. package/dist/super-editor/src/components/slash-menu/contextmenu-helpers.d.ts +0 -1
@@ -1,5 +1,5 @@
1
1
  import { m as defineComponent, B as h, O as Transition, $ as process$1, I as watchEffect, d as computed, r as ref, j as onMounted, W as onUnmounted, c as createElementBlock, o as openBlock, a as createBaseVNode, f as createCommentVNode, v as createVNode, x as unref } from "./vue-CXxsqYcP.es.js";
2
- import { d as derived, c, a as cB, f as fadeInTransition, b as cM, N as NBaseLoading, w as warnOnce, u as useConfig, e as useTheme, p as pxfy, g as createKey, h as useThemeClass, i as useCompitable, _ as _export_sfc, j as useSuperdocStore, s as storeToRefs, k as useSelection } from "./index-Cw4YywoD.es.js";
2
+ import { d as derived, c, a as cB, f as fadeInTransition, b as cM, N as NBaseLoading, w as warnOnce, u as useConfig, e as useTheme, p as pxfy, g as createKey, h as useThemeClass, i as useCompitable, _ as _export_sfc, j as useSuperdocStore, s as storeToRefs, k as useSelection } from "./index-Bbqhu9ev.es.js";
3
3
  function self(vars) {
4
4
  const {
5
5
  opacityDisabled,
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const vue = require("./vue-DWle4Cai.cjs");
4
- const superdoc = require("./index-BOf6E2I4.cjs");
4
+ const superdoc = require("./index-p73XAt11.cjs");
5
5
  function self(vars) {
6
6
  const {
7
7
  opacityDisabled,
@@ -1,4 +1,4 @@
1
- import { q as index$1, C as CommentsPluginKey, h as TrackChangesBasePluginKey, E as Editor, n as getRichTextExtensions, f as SuperInput, e as SuperEditor, A as AIWriter, g as SuperToolbar, i as createZip } from "./super-editor.es-vfoWxyZL.es.js";
1
+ import { q as index$1, C as CommentsPluginKey, h as TrackChangesBasePluginKey, E as Editor, n as getRichTextExtensions, f as SuperInput, e as SuperEditor, A as AIWriter, g as SuperToolbar, i as createZip } from "./super-editor.es-DK3l03fz.es.js";
2
2
  import { a0 as effectScope, r as ref, _ as markRaw, $ as process$1, a1 as toRaw, d as computed, a2 as isRef, a3 as isReactive, C as toRef, i as inject, p as getCurrentInstance, l as watch, x as unref, a4 as hasInjectionContext, M as reactive, s as nextTick, a5 as getCurrentScope, a6 as onScopeDispose, a7 as toRefs, g as global$1, J as shallowRef, N as readonly, j as onMounted, k as onBeforeUnmount, h as onBeforeMount, S as onActivated, q as onDeactivated, z as createTextVNode, F as Fragment, Q as Comment, m as defineComponent, D as provide, H as withDirectives, B as h, U as Teleport, R as renderSlot, V as isVNode, I as watchEffect, O as Transition, a8 as TransitionGroup, E as mergeProps, P as vShow, G as cloneVNode, T as Text, c as createElementBlock, o as openBlock, t as toDisplayString, v as createVNode, y as withCtx, a as createBaseVNode, A as normalizeStyle, f as createCommentVNode, u as createBlock, w as withModifiers, n as normalizeClass, a9 as resolveDirective, e as renderList, b as createApp, X as resolveDynamicComponent, aa as defineAsyncComponent } from "./vue-CXxsqYcP.es.js";
3
3
  import { B as Buffer$2 } from "./jszip-B8KIZSNe.es.js";
4
4
  import { B as BlankDOCX } from "./blank-docx-iwdyG9RH.es.js";
@@ -4161,7 +4161,7 @@ const groupChanges = (changes) => {
4161
4161
  const c1 = changes[i];
4162
4162
  const c2 = changes[i + 1];
4163
4163
  const c1Key = markMetaKeys[c1.mark.type.name];
4164
- if (c1 && c2 && c1.to === c2.from) {
4164
+ if (c1 && c2 && c1.to === c2.from && c1.mark.attrs.id === c2.mark.attrs.id) {
4165
4165
  const c2Key = markMetaKeys[c2.mark.type.name];
4166
4166
  grouped.push({
4167
4167
  from: c1.from,
@@ -4206,6 +4206,7 @@ const useCommentsStore = /* @__PURE__ */ defineStore("comments", () => {
4206
4206
  const isCommentsListVisible = ref(false);
4207
4207
  const editorCommentIds = ref([]);
4208
4208
  const editorCommentPositions = ref({});
4209
+ const isCommentHighlighted = ref(false);
4209
4210
  const floatingCommentsOffset = ref(0);
4210
4211
  const sortedConversations = ref([]);
4211
4212
  const visibleConversations = ref([]);
@@ -4484,8 +4485,8 @@ const useCommentsStore = /* @__PURE__ */ defineStore("comments", () => {
4484
4485
  tr.setMeta(CommentsPluginKey, { type: "forceTrackChanges" });
4485
4486
  tr.setMeta(TrackChangesBasePluginKey, trackChangesPayload);
4486
4487
  }
4488
+ dispatch(tr);
4487
4489
  });
4488
- dispatch(tr);
4489
4490
  };
4490
4491
  const translateCommentsForExport = () => {
4491
4492
  const processedComments = [];
@@ -4555,6 +4556,7 @@ const useCommentsStore = /* @__PURE__ */ defineStore("comments", () => {
4555
4556
  try {
4556
4557
  const normalizedContent = normalizeCommentForEditor(commentTextJson);
4557
4558
  const schemaContent = Array.isArray(normalizedContent) ? normalizedContent[0] : normalizedContent;
4559
+ if (!schemaContent.content.length) return null;
4558
4560
  const editor = new Editor({
4559
4561
  mode: "text",
4560
4562
  isHeadless: true,
@@ -4588,6 +4590,7 @@ const useCommentsStore = /* @__PURE__ */ defineStore("comments", () => {
4588
4590
  commentsParentElement,
4589
4591
  editorCommentPositions,
4590
4592
  hasInitializedLocations,
4593
+ isCommentHighlighted,
4591
4594
  // Floating comments
4592
4595
  floatingCommentsOffset,
4593
4596
  sortedConversations,
@@ -16114,7 +16117,8 @@ const _sfc_main$c = {
16114
16117
  currentCommentText,
16115
16118
  isDebugging,
16116
16119
  editingCommentId,
16117
- editorCommentPositions
16120
+ editorCommentPositions,
16121
+ isCommentHighlighted
16118
16122
  } = storeToRefs(commentsStore);
16119
16123
  const { activeZoom } = storeToRefs(superdocStore);
16120
16124
  const isInternal = ref(true);
@@ -16176,13 +16180,14 @@ const _sfc_main$c = {
16176
16180
  "track-format",
16177
16181
  "track-format-dec"
16178
16182
  ];
16179
- if (excludedClasses.some((className) => e.target.classList.contains(className))) return;
16183
+ if (excludedClasses.some((className) => e.target.classList.contains(className)) || isCommentHighlighted.value) return;
16180
16184
  if (activeComment.value === props.comment.commentId) {
16181
16185
  floatingCommentsOffset.value = 0;
16182
16186
  emit("dialog-exit");
16183
16187
  }
16184
16188
  activeComment.value = null;
16185
16189
  commentsStore.setActiveComment(proxy.$superdoc, activeComment.value);
16190
+ isCommentHighlighted.value = false;
16186
16191
  };
16187
16192
  const handleAddComment = () => {
16188
16193
  const options = {
@@ -16395,7 +16400,7 @@ const _sfc_main$c = {
16395
16400
  };
16396
16401
  }
16397
16402
  };
16398
- const CommentDialog = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["__scopeId", "data-v-dc5e6675"]]);
16403
+ const CommentDialog = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["__scopeId", "data-v-e07f3426"]]);
16399
16404
  const _hoisted_1$a = { class: "comments-list" };
16400
16405
  const _hoisted_2$5 = { key: 0 };
16401
16406
  const _hoisted_3$3 = { class: "comment-item" };
@@ -17392,7 +17397,7 @@ const _sfc_main = {
17392
17397
  __name: "SuperDoc",
17393
17398
  emits: ["selection-update"],
17394
17399
  setup(__props, { emit: __emit }) {
17395
- const PdfViewer = defineAsyncComponent(() => import("./PdfViewer-BpwMPbUj.es.js"));
17400
+ const PdfViewer = defineAsyncComponent(() => import("./PdfViewer-CS3pY_UR.es.js"));
17396
17401
  const superdocStore = useSuperdocStore();
17397
17402
  const commentsStore = useCommentsStore();
17398
17403
  const {
@@ -17418,7 +17423,8 @@ const _sfc_main = {
17418
17423
  getFloatingComments,
17419
17424
  hasSyncedCollaborationComments,
17420
17425
  editorCommentPositions,
17421
- hasInitializedLocations
17426
+ hasInitializedLocations,
17427
+ isCommentHighlighted
17422
17428
  } = storeToRefs(commentsStore);
17423
17429
  const { showAddComment, handleEditorLocationsUpdate, handleTrackedChangeUpdate } = commentsStore;
17424
17430
  const { proxy } = getCurrentInstance();
@@ -17613,6 +17619,7 @@ const _sfc_main = {
17613
17619
  nextTick(() => {
17614
17620
  if (pendingComment.value) return;
17615
17621
  commentsStore.setActiveComment(proxy.$superdoc, activeCommentId);
17622
+ isCommentHighlighted.value = true;
17616
17623
  });
17617
17624
  if (typeof proxy.$superdoc.config.onCommentsUpdate === "function") {
17618
17625
  proxy.$superdoc.config.onCommentsUpdate(params2);
@@ -17935,7 +17942,7 @@ const _sfc_main = {
17935
17942
  };
17936
17943
  }
17937
17944
  };
17938
- const App = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-dbfba5b9"]]);
17945
+ const App = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-3f71b1bf"]]);
17939
17946
  const createSuperdocVueApp = () => {
17940
17947
  const app = createApp(App);
17941
17948
  const pinia = createPinia();
@@ -18052,6 +18059,9 @@ class SuperDoc extends EventEmitter {
18052
18059
  this.isDev = this.config.isDev || false;
18053
18060
  this.activeEditor = null;
18054
18061
  this.comments = [];
18062
+ if (!this.config.selector) {
18063
+ throw new Error("SuperDoc: selector is required");
18064
+ }
18055
18065
  this.app.mount(this.config.selector);
18056
18066
  this.readyEditors = 0;
18057
18067
  this.isLocked = this.config.isLocked || false;
@@ -18071,6 +18081,16 @@ class SuperDoc extends EventEmitter {
18071
18081
  users: this.users
18072
18082
  };
18073
18083
  }
18084
+ /**
18085
+ * Get the SuperDoc container element
18086
+ * @returns {HTMLElement | null}
18087
+ */
18088
+ get element() {
18089
+ if (typeof this.config.selector === "string") {
18090
+ return document.querySelector(this.config.selector);
18091
+ }
18092
+ return this.config.selector;
18093
+ }
18074
18094
  #patchNaiveUIStyles() {
18075
18095
  const cspNonce = this.config.cspNonce;
18076
18096
  const originalCreateElement = document.createElement;
@@ -18094,10 +18114,16 @@ class SuperDoc extends EventEmitter {
18094
18114
  }
18095
18115
  if (hasDocumentConfig) {
18096
18116
  const normalized = normalizeDocumentEntry(this.config.document);
18097
- this.config.documents = [normalized];
18117
+ this.config.documents = [
18118
+ {
18119
+ id: v4(),
18120
+ ...normalized
18121
+ }
18122
+ ];
18098
18123
  } else if (hasDocumentUrl) {
18099
18124
  this.config.documents = [
18100
18125
  {
18126
+ id: v4(),
18101
18127
  type: DOCX,
18102
18128
  url: this.config.document,
18103
18129
  name: "document.docx",
@@ -18105,33 +18131,34 @@ class SuperDoc extends EventEmitter {
18105
18131
  }
18106
18132
  ];
18107
18133
  } else if (hasDocumentFile) {
18134
+ const normalized = normalizeDocumentEntry(this.config.document);
18108
18135
  this.config.documents = [
18109
18136
  {
18110
- type: this.config.document.type,
18111
- data: this.config.document,
18112
- name: this.config.document.name,
18113
- isNewFile: true
18137
+ id: v4(),
18138
+ ...normalized
18114
18139
  }
18115
18140
  ];
18116
18141
  } else if (hasDocumentBlob) {
18117
- const docType = this.config.document.type || DOCX;
18118
- let extension = ".docx";
18119
- if (docType === PDF) {
18120
- extension = ".pdf";
18121
- } else if (docType === HTML) {
18122
- extension = ".html";
18123
- }
18142
+ const normalized = normalizeDocumentEntry(this.config.document);
18124
18143
  this.config.documents = [
18125
18144
  {
18126
- type: docType,
18127
- data: this.config.document,
18128
- name: `document${extension}`,
18129
- isNewFile: true
18145
+ id: v4(),
18146
+ ...normalized
18130
18147
  }
18131
18148
  ];
18132
18149
  }
18133
18150
  if (Array.isArray(this.config.documents) && this.config.documents.length > 0) {
18134
- this.config.documents = this.config.documents.map((d) => normalizeDocumentEntry(d));
18151
+ this.config.documents = this.config.documents.map((d) => {
18152
+ const normalized = normalizeDocumentEntry(d);
18153
+ if (!normalized || typeof normalized !== "object") {
18154
+ return normalized;
18155
+ }
18156
+ const existingId = typeof normalized === "object" && "id" in normalized && normalized.id || d && typeof d === "object" && "id" in d && d.id;
18157
+ return {
18158
+ ...normalized,
18159
+ id: existingId || v4()
18160
+ };
18161
+ });
18135
18162
  }
18136
18163
  }
18137
18164
  #initVueApp() {
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- const superEditor_es = require("./super-editor.es-DHDx2fsy.cjs");
2
+ const superEditor_es = require("./super-editor.es-CFD0lcOY.cjs");
3
3
  const vue = require("./vue-DWle4Cai.cjs");
4
4
  const jszip = require("./jszip-b7l8QkfH.cjs");
5
5
  const blankDocx = require("./blank-docx-CPqX9RF5.cjs");
@@ -4178,7 +4178,7 @@ const groupChanges = (changes) => {
4178
4178
  const c1 = changes[i];
4179
4179
  const c2 = changes[i + 1];
4180
4180
  const c1Key = markMetaKeys[c1.mark.type.name];
4181
- if (c1 && c2 && c1.to === c2.from) {
4181
+ if (c1 && c2 && c1.to === c2.from && c1.mark.attrs.id === c2.mark.attrs.id) {
4182
4182
  const c2Key = markMetaKeys[c2.mark.type.name];
4183
4183
  grouped.push({
4184
4184
  from: c1.from,
@@ -4223,6 +4223,7 @@ const useCommentsStore = /* @__PURE__ */ defineStore("comments", () => {
4223
4223
  const isCommentsListVisible = vue.ref(false);
4224
4224
  const editorCommentIds = vue.ref([]);
4225
4225
  const editorCommentPositions = vue.ref({});
4226
+ const isCommentHighlighted = vue.ref(false);
4226
4227
  const floatingCommentsOffset = vue.ref(0);
4227
4228
  const sortedConversations = vue.ref([]);
4228
4229
  const visibleConversations = vue.ref([]);
@@ -4501,8 +4502,8 @@ const useCommentsStore = /* @__PURE__ */ defineStore("comments", () => {
4501
4502
  tr.setMeta(superEditor_es.CommentsPluginKey, { type: "forceTrackChanges" });
4502
4503
  tr.setMeta(superEditor_es.TrackChangesBasePluginKey, trackChangesPayload);
4503
4504
  }
4505
+ dispatch(tr);
4504
4506
  });
4505
- dispatch(tr);
4506
4507
  };
4507
4508
  const translateCommentsForExport = () => {
4508
4509
  const processedComments = [];
@@ -4572,6 +4573,7 @@ const useCommentsStore = /* @__PURE__ */ defineStore("comments", () => {
4572
4573
  try {
4573
4574
  const normalizedContent = normalizeCommentForEditor(commentTextJson);
4574
4575
  const schemaContent = Array.isArray(normalizedContent) ? normalizedContent[0] : normalizedContent;
4576
+ if (!schemaContent.content.length) return null;
4575
4577
  const editor = new superEditor_es.Editor({
4576
4578
  mode: "text",
4577
4579
  isHeadless: true,
@@ -4605,6 +4607,7 @@ const useCommentsStore = /* @__PURE__ */ defineStore("comments", () => {
4605
4607
  commentsParentElement,
4606
4608
  editorCommentPositions,
4607
4609
  hasInitializedLocations,
4610
+ isCommentHighlighted,
4608
4611
  // Floating comments
4609
4612
  floatingCommentsOffset,
4610
4613
  sortedConversations,
@@ -16131,7 +16134,8 @@ const _sfc_main$c = {
16131
16134
  currentCommentText,
16132
16135
  isDebugging,
16133
16136
  editingCommentId,
16134
- editorCommentPositions
16137
+ editorCommentPositions,
16138
+ isCommentHighlighted
16135
16139
  } = storeToRefs(commentsStore);
16136
16140
  const { activeZoom } = storeToRefs(superdocStore);
16137
16141
  const isInternal = vue.ref(true);
@@ -16193,13 +16197,14 @@ const _sfc_main$c = {
16193
16197
  "track-format",
16194
16198
  "track-format-dec"
16195
16199
  ];
16196
- if (excludedClasses.some((className) => e.target.classList.contains(className))) return;
16200
+ if (excludedClasses.some((className) => e.target.classList.contains(className)) || isCommentHighlighted.value) return;
16197
16201
  if (activeComment.value === props.comment.commentId) {
16198
16202
  floatingCommentsOffset.value = 0;
16199
16203
  emit("dialog-exit");
16200
16204
  }
16201
16205
  activeComment.value = null;
16202
16206
  commentsStore.setActiveComment(proxy.$superdoc, activeComment.value);
16207
+ isCommentHighlighted.value = false;
16203
16208
  };
16204
16209
  const handleAddComment = () => {
16205
16210
  const options = {
@@ -16412,7 +16417,7 @@ const _sfc_main$c = {
16412
16417
  };
16413
16418
  }
16414
16419
  };
16415
- const CommentDialog = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["__scopeId", "data-v-dc5e6675"]]);
16420
+ const CommentDialog = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["__scopeId", "data-v-e07f3426"]]);
16416
16421
  const _hoisted_1$a = { class: "comments-list" };
16417
16422
  const _hoisted_2$5 = { key: 0 };
16418
16423
  const _hoisted_3$3 = { class: "comment-item" };
@@ -17409,7 +17414,7 @@ const _sfc_main = {
17409
17414
  __name: "SuperDoc",
17410
17415
  emits: ["selection-update"],
17411
17416
  setup(__props, { emit: __emit }) {
17412
- const PdfViewer = vue.defineAsyncComponent(() => Promise.resolve().then(() => require("./PdfViewer-B3KmcDup.cjs")));
17417
+ const PdfViewer = vue.defineAsyncComponent(() => Promise.resolve().then(() => require("./PdfViewer-Cz3fT1qt.cjs")));
17413
17418
  const superdocStore = useSuperdocStore();
17414
17419
  const commentsStore = useCommentsStore();
17415
17420
  const {
@@ -17435,7 +17440,8 @@ const _sfc_main = {
17435
17440
  getFloatingComments,
17436
17441
  hasSyncedCollaborationComments,
17437
17442
  editorCommentPositions,
17438
- hasInitializedLocations
17443
+ hasInitializedLocations,
17444
+ isCommentHighlighted
17439
17445
  } = storeToRefs(commentsStore);
17440
17446
  const { showAddComment, handleEditorLocationsUpdate, handleTrackedChangeUpdate } = commentsStore;
17441
17447
  const { proxy } = vue.getCurrentInstance();
@@ -17630,6 +17636,7 @@ const _sfc_main = {
17630
17636
  vue.nextTick(() => {
17631
17637
  if (pendingComment.value) return;
17632
17638
  commentsStore.setActiveComment(proxy.$superdoc, activeCommentId);
17639
+ isCommentHighlighted.value = true;
17633
17640
  });
17634
17641
  if (typeof proxy.$superdoc.config.onCommentsUpdate === "function") {
17635
17642
  proxy.$superdoc.config.onCommentsUpdate(params2);
@@ -17952,7 +17959,7 @@ const _sfc_main = {
17952
17959
  };
17953
17960
  }
17954
17961
  };
17955
- const App = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-dbfba5b9"]]);
17962
+ const App = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-3f71b1bf"]]);
17956
17963
  const createSuperdocVueApp = () => {
17957
17964
  const app = vue.createApp(App);
17958
17965
  const pinia = createPinia();
@@ -18069,6 +18076,9 @@ class SuperDoc extends eventemitter3.EventEmitter {
18069
18076
  this.isDev = this.config.isDev || false;
18070
18077
  this.activeEditor = null;
18071
18078
  this.comments = [];
18079
+ if (!this.config.selector) {
18080
+ throw new Error("SuperDoc: selector is required");
18081
+ }
18072
18082
  this.app.mount(this.config.selector);
18073
18083
  this.readyEditors = 0;
18074
18084
  this.isLocked = this.config.isLocked || false;
@@ -18088,6 +18098,16 @@ class SuperDoc extends eventemitter3.EventEmitter {
18088
18098
  users: this.users
18089
18099
  };
18090
18100
  }
18101
+ /**
18102
+ * Get the SuperDoc container element
18103
+ * @returns {HTMLElement | null}
18104
+ */
18105
+ get element() {
18106
+ if (typeof this.config.selector === "string") {
18107
+ return document.querySelector(this.config.selector);
18108
+ }
18109
+ return this.config.selector;
18110
+ }
18091
18111
  #patchNaiveUIStyles() {
18092
18112
  const cspNonce = this.config.cspNonce;
18093
18113
  const originalCreateElement = document.createElement;
@@ -18111,10 +18131,16 @@ class SuperDoc extends eventemitter3.EventEmitter {
18111
18131
  }
18112
18132
  if (hasDocumentConfig) {
18113
18133
  const normalized = normalizeDocumentEntry(this.config.document);
18114
- this.config.documents = [normalized];
18134
+ this.config.documents = [
18135
+ {
18136
+ id: uuid.v4(),
18137
+ ...normalized
18138
+ }
18139
+ ];
18115
18140
  } else if (hasDocumentUrl) {
18116
18141
  this.config.documents = [
18117
18142
  {
18143
+ id: uuid.v4(),
18118
18144
  type: DOCX,
18119
18145
  url: this.config.document,
18120
18146
  name: "document.docx",
@@ -18122,33 +18148,34 @@ class SuperDoc extends eventemitter3.EventEmitter {
18122
18148
  }
18123
18149
  ];
18124
18150
  } else if (hasDocumentFile) {
18151
+ const normalized = normalizeDocumentEntry(this.config.document);
18125
18152
  this.config.documents = [
18126
18153
  {
18127
- type: this.config.document.type,
18128
- data: this.config.document,
18129
- name: this.config.document.name,
18130
- isNewFile: true
18154
+ id: uuid.v4(),
18155
+ ...normalized
18131
18156
  }
18132
18157
  ];
18133
18158
  } else if (hasDocumentBlob) {
18134
- const docType = this.config.document.type || DOCX;
18135
- let extension = ".docx";
18136
- if (docType === PDF) {
18137
- extension = ".pdf";
18138
- } else if (docType === HTML) {
18139
- extension = ".html";
18140
- }
18159
+ const normalized = normalizeDocumentEntry(this.config.document);
18141
18160
  this.config.documents = [
18142
18161
  {
18143
- type: docType,
18144
- data: this.config.document,
18145
- name: `document${extension}`,
18146
- isNewFile: true
18162
+ id: uuid.v4(),
18163
+ ...normalized
18147
18164
  }
18148
18165
  ];
18149
18166
  }
18150
18167
  if (Array.isArray(this.config.documents) && this.config.documents.length > 0) {
18151
- this.config.documents = this.config.documents.map((d) => normalizeDocumentEntry(d));
18168
+ this.config.documents = this.config.documents.map((d) => {
18169
+ const normalized = normalizeDocumentEntry(d);
18170
+ if (!normalized || typeof normalized !== "object") {
18171
+ return normalized;
18172
+ }
18173
+ const existingId = typeof normalized === "object" && "id" in normalized && normalized.id || d && typeof d === "object" && "id" in d && d.id;
18174
+ return {
18175
+ ...normalized,
18176
+ id: existingId || uuid.v4()
18177
+ };
18178
+ });
18152
18179
  }
18153
18180
  }
18154
18181
  #initVueApp() {