@harbour-enterprises/superdoc 0.11.37 → 0.11.39

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 (29) hide show
  1. package/dist/chunks/{super-editor.es-CjnJi9EI.es.js → super-editor.es-CfOoZR7Y.es.js} +3 -3
  2. package/dist/chunks/{super-editor.es-CJ7-KcXD.cjs → super-editor.es-Oav3pft6.cjs} +3 -3
  3. package/dist/components/CommentsLayer/commentsList/super-comments-list.d.ts +1 -2
  4. package/dist/components/CommentsLayer/commentsList/super-comments-list.d.ts.map +1 -1
  5. package/dist/core/SuperDoc.d.ts +262 -40
  6. package/dist/core/SuperDoc.d.ts.map +1 -1
  7. package/dist/stores/superdoc-store.d.ts +6 -744
  8. package/dist/stores/superdoc-store.d.ts.map +1 -1
  9. package/dist/super-editor/ai-writer.es.js +2 -2
  10. package/dist/super-editor/chunks/{converter-DsjQE-ty.js → converter-BaPyRYsP.js} +2 -2
  11. package/dist/super-editor/chunks/{docx-zipper-SxaBdzlS.js → docx-zipper-DWp5ugUc.js} +1 -1
  12. package/dist/super-editor/chunks/{editor-DYLzFO1Q.js → editor-C80oU8zg.js} +3 -3
  13. package/dist/super-editor/chunks/{toolbar-CXKqr_40.js → toolbar-BfR55xSN.js} +2 -2
  14. package/dist/super-editor/components/toolbar/super-toolbar.d.ts +1 -1
  15. package/dist/super-editor/components/toolbar/super-toolbar.d.ts.map +1 -1
  16. package/dist/super-editor/converter.es.js +1 -1
  17. package/dist/super-editor/docx-zipper.es.js +2 -2
  18. package/dist/super-editor/editor.es.js +3 -3
  19. package/dist/super-editor/file-zipper.es.js +1 -1
  20. package/dist/super-editor/super-editor.es.js +6 -6
  21. package/dist/super-editor/toolbar.es.js +2 -2
  22. package/dist/super-editor.cjs +1 -1
  23. package/dist/super-editor.d.ts +3 -0
  24. package/dist/super-editor.es.js +1 -1
  25. package/dist/superdoc.cjs +3 -3
  26. package/dist/superdoc.es.js +111 -9
  27. package/dist/superdoc.umd.js +111 -11
  28. package/dist/superdoc.umd.js.map +1 -1
  29. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
- import { Y as md, g as yd, c as bd, n as jo, F as Wo, H as wd, x as Sd, D as Dd, M as vd, a as Fd } from "./chunks/super-editor.es-CjnJi9EI.es.js";
2
- import { O as Ib, X as Cb, R as fb } from "./chunks/super-editor.es-CjnJi9EI.es.js";
1
+ import { Y as md, g as yd, c as bd, n as jo, F as Wo, H as wd, x as Sd, D as Dd, M as vd, a as Fd } from "./chunks/super-editor.es-CfOoZR7Y.es.js";
2
+ import { O as Ib, X as Cb, R as fb } from "./chunks/super-editor.es-CfOoZR7Y.es.js";
3
3
  import { Y as Vl, r as W, Z as ui, p as Ge, _ as Vn, a as ae, $ as zn, a0 as ua, D as dt, i as ht, q as ji, l as wt, y as Fe, a1 as kd, N as Zt, u as qt, a2 as xd, a3 as Rd, a4 as Xo, g as Ji, K as Us, O as jr, j as Ii, k as Di, h as da, U as Nd, s as Md, A as Wr, F as jt, R as GA, m as Ct, E as mi, I as ms, C as re, V as Ld, S as Gd, W as Td, J as qi, P as Es, G as ar, Q as Ud, H as Hd, T as Pd, b as ye, o as fe, t as yi, x as bi, z as zl, f as We, B as ri, e as Ze, v as hi, w as Qi, n as Xs, a5 as Zl, d as gn, c as $l, X as Od, a6 as Jd } from "./chunks/vue-DKS68Dra.es.js";
4
4
  import { B as qn } from "./chunks/jszip-OpmRHhd4.es.js";
5
5
  import { B as Yd } from "./chunks/blank-docx-BRvkcuiv.es.js";
@@ -32651,9 +32651,14 @@ const yy = ["innerHTML"], by = { class: "superdoc__document document" }, wy = {
32651
32651
  class hb extends eg {
32652
32652
  /** @type {Array<string>} */
32653
32653
  static allowedTypes = [on, Ia, TA];
32654
- /** @type {number} */
32654
+ /** @type {string} */
32655
32655
  version;
32656
+ /** @type {User[]} */
32656
32657
  users;
32658
+ /** @type {import('yjs').Doc | undefined} */
32659
+ ydoc;
32660
+ /** @type {import('@hocuspocus/provider').HocuspocusProvider | undefined} */
32661
+ provider;
32657
32662
  /** @type {Config} */
32658
32663
  config = {
32659
32664
  superdocId: null,
@@ -32673,7 +32678,6 @@ class hb extends eg {
32673
32678
  conversations: [],
32674
32679
  pagination: !1,
32675
32680
  // Optional: Whether to show pagination in SuperEditors
32676
- isCollaborative: !1,
32677
32681
  isInternal: !1,
32678
32682
  // toolbar config
32679
32683
  toolbar: null,
@@ -32713,8 +32717,12 @@ class hb extends eg {
32713
32717
  this.config = {
32714
32718
  ...this.config,
32715
32719
  ...t
32716
- }, this.config.colors = NI(this.config.colors), this.userColorMap = /* @__PURE__ */ new Map(), this.colorIndex = 0, this.version = "0.11.37", console.debug("🦋 [superdoc] Using SuperDoc version:", this.version), this.superdocId = t.superdocId || ig(), this.colors = this.config.colors, this.#t(), await this.#r(this.config.modules), this.#i(), this.#s(), this.user = this.config.user, this.users = this.config.users || [], this.socket = null, this.isDev = this.config.isDev || !1, this.activeEditor = null, this.comments = [], this.app.mount(this.config.selector), this.readyEditors = 0, this.isLocked = this.config.isLocked || !1, this.lockedBy = this.config.lockedBy || null, this.#a(this);
32720
+ }, this.config.colors = NI(this.config.colors), this.userColorMap = /* @__PURE__ */ new Map(), this.colorIndex = 0, this.version = "0.11.39", console.debug("🦋 [superdoc] Using SuperDoc version:", this.version), this.superdocId = t.superdocId || ig(), this.colors = this.config.colors, this.#t(), await this.#r(this.config.modules), this.#i(), this.#s(), this.user = this.config.user, this.users = this.config.users || [], this.socket = null, this.isDev = this.config.isDev || !1, this.activeEditor = null, this.comments = [], this.app.mount(this.config.selector), this.readyEditors = 0, this.isLocked = this.config.isLocked || !1, this.lockedBy = this.config.lockedBy || null, this.#a();
32717
32721
  }
32722
+ /**
32723
+ * Get the number of editors that are required for this superdoc
32724
+ * @returns {number} The number of required editors
32725
+ */
32718
32726
  get requiredNumberOfEditors() {
32719
32727
  return this.superdocStore.documents.filter((t) => t.type === on).length;
32720
32728
  }
@@ -32744,7 +32752,7 @@ class hb extends eg {
32744
32752
  }
32745
32753
  #i() {
32746
32754
  const { app: t, pinia: i, superdocStore: r, commentsStore: A } = Fy();
32747
- this.app = t, this.pinia = i, this.app.config.globalProperties.$config = this.config, this.app.config.globalProperties.$documentMode = this.config.documentMode, this.app.config.globalProperties.$superdoc = this, this.superdocStore = r, this.commentsStore = A, this.version = this.config.version, this.superdocStore.init(this.config), this.commentsStore.init(this.config.modules.comments);
32755
+ this.app = t, this.pinia = i, this.app.config.globalProperties.$config = this.config, this.app.config.globalProperties.$documentMode = this.config.documentMode, this.app.config.globalProperties.$superdoc = this, this.superdocStore = r, this.commentsStore = A, this.superdocStore.init(this.config), this.commentsStore.init(this.config.modules.comments);
32748
32756
  }
32749
32757
  #s() {
32750
32758
  this.on("editorBeforeCreate", this.config.onEditorBeforeCreate), this.on("editorCreate", this.config.onEditorCreate), this.on("editorDestroy", this.config.onEditorDestroy), this.on("ready", this.config.onReady), this.on("comments-update", this.config.onCommentsUpdate), this.on("awareness-update", this.config.onAwarenessUpdate), this.on("locked", this.config.onLocked), this.on("pdf-document-ready", this.config.onPdfDocumentReady), this.on("sidebar-toggle", this.config.onSidebarToggle), this.on("collaboration-ready", this.config.onCollaborationReady), this.on("editor-update", this.config.onEditorUpdate), this.on("content-error", this.onContentError), this.on("exception", this.config.onException);
@@ -32761,7 +32769,6 @@ class hb extends eg {
32761
32769
  }
32762
32770
  /**
32763
32771
  * Add a user to the shared users list
32764
- *
32765
32772
  * @param {Object} user The user to add
32766
32773
  * @returns {void}
32767
32774
  */
@@ -32770,7 +32777,6 @@ class hb extends eg {
32770
32777
  }
32771
32778
  /**
32772
32779
  * Remove a user from the shared users list
32773
- *
32774
32780
  * @param {String} email The email of the user to remove
32775
32781
  * @returns {void}
32776
32782
  */
@@ -32789,31 +32795,68 @@ class hb extends eg {
32789
32795
  superdocVersion: this.version
32790
32796
  });
32791
32797
  }
32798
+ /**
32799
+ * Triggered when there is an error in the content
32800
+ * @param {Object} param0
32801
+ * @param {Error} param0.error The error that occurred
32802
+ * @param {Editor} param0.editor The editor that caused the error
32803
+ */
32792
32804
  onContentError({ error: t, editor: i }) {
32793
32805
  const { documentId: r } = i.options, A = this.superdocStore.documents.find((c) => c.id === r);
32794
32806
  this.config.onContentError({ error: t, editor: i, documentId: A.id, file: A.data });
32795
32807
  }
32808
+ /**
32809
+ * Triggered when the PDF document is ready
32810
+ * @returns {void}
32811
+ */
32796
32812
  broadcastPdfDocumentReady() {
32797
32813
  this.emit("pdf-document-ready");
32798
32814
  }
32815
+ /**
32816
+ * Triggered when the superdoc is ready
32817
+ * @returns {void}
32818
+ */
32799
32819
  broadcastReady() {
32800
32820
  this.readyEditors === this.requiredNumberOfEditors && this.emit("ready", { superdoc: this });
32801
32821
  }
32822
+ /**
32823
+ * Triggered before an editor is created
32824
+ * @param {Editor} editor The editor that is about to be created
32825
+ * @returns {void}
32826
+ */
32802
32827
  broadcastEditorBeforeCreate(t) {
32803
32828
  this.emit("editorBeforeCreate", { editor: t });
32804
32829
  }
32830
+ /**
32831
+ * Triggered when an editor is created
32832
+ * @param {Editor} editor The editor that was created
32833
+ * @returns {void}
32834
+ */
32805
32835
  broadcastEditorCreate(t) {
32806
32836
  this.readyEditors++, this.broadcastReady(), this.emit("editorCreate", { editor: t });
32807
32837
  }
32838
+ /**
32839
+ * Triggered when an editor is destroyed
32840
+ * @returns {void}
32841
+ */
32808
32842
  broadcastEditorDestroy() {
32809
32843
  this.emit("editorDestroy");
32810
32844
  }
32845
+ /**
32846
+ * Triggered when the comments sidebar is toggled
32847
+ * @param {boolean} isOpened
32848
+ */
32811
32849
  broadcastSidebarToggle(t) {
32812
32850
  this.emit("sidebar-toggle", t);
32813
32851
  }
32814
32852
  log(...t) {
32815
32853
  console.debug("🦋 🦸‍♀️ [superdoc]", ...t);
32816
32854
  }
32855
+ /**
32856
+ * Set the active editor
32857
+ * @param {Editor} editor The editor to set as active
32858
+ * @returns {void}
32859
+ */
32817
32860
  setActiveEditor(t) {
32818
32861
  this.activeEditor = t, this.toolbar && this.toolbar.setActiveEditor(t);
32819
32862
  }
@@ -32847,15 +32890,36 @@ class hb extends eg {
32847
32890
  this.emit("ai-highlight", { type: r, data: A });
32848
32891
  }), this.once("editorCreate", () => this.toolbar.updateToolbarState());
32849
32892
  }
32893
+ /**
32894
+ * Add a comments list to the superdoc
32895
+ * Requires the comments module to be enabled
32896
+ * @param {Element} element The DOM element to render the comments list in
32897
+ * @returns {void}
32898
+ */
32850
32899
  addCommentsList(t) {
32851
32900
  !this.config?.modules?.comments || this.config.role === "viewer" || (console.debug("🦋 [superdoc] Adding comments list to:", t), t && (this.config.modules.comments.element = t), this.commentsList = new Em(this.config.modules?.comments, this), this.config.onCommentsListChange && this.config.onCommentsListChange({ isRendered: !0 }));
32852
32901
  }
32902
+ /**
32903
+ * Remove the comments list from the superdoc
32904
+ * @returns {void}
32905
+ */
32853
32906
  removeCommentsList() {
32854
32907
  this.commentsList && (this.commentsList.close(), this.commentsList = null, this.config.onCommentsListChange && this.config.onCommentsListChange({ isRendered: !1 }));
32855
32908
  }
32909
+ /**
32910
+ * Triggered when a toolbar command is executed
32911
+ * @param {Object} param0
32912
+ * @param {Object} param0.item The toolbar item that was clicked
32913
+ * @param {string} param0.argument The argument passed to the command
32914
+ */
32856
32915
  onToolbarCommand({ item: t, argument: i }) {
32857
32916
  t.command === "setDocumentMode" ? this.setDocumentMode(i) : t.command === "setZoom" && (this.superdocStore.activeZoom = i);
32858
32917
  }
32918
+ /**
32919
+ * Set the document mode.
32920
+ * @param {DocumentMode} type
32921
+ * @returns {void}
32922
+ */
32859
32923
  setDocumentMode(t) {
32860
32924
  if (!t) return;
32861
32925
  t = t.toLowerCase(), this.config.documentMode = t;
@@ -32897,9 +32961,19 @@ class hb extends eg {
32897
32961
  i && i.setDocumentMode("viewing");
32898
32962
  }), this.toolbar && (this.toolbar.documentMode = "viewing", this.toolbar.updateToolbarState());
32899
32963
  }
32964
+ /**
32965
+ * Search for text or regex in the active editor
32966
+ * @param {string | RegExp} text The text or regex to search for
32967
+ * @returns {Object[]} The search results
32968
+ */
32900
32969
  search(t) {
32901
32970
  return this.activeEditor?.commands.search(t);
32902
32971
  }
32972
+ /**
32973
+ * Go to the next search result
32974
+ * @param {Object} match The match object
32975
+ * @returns {void}
32976
+ */
32903
32977
  goToSearchResult(t) {
32904
32978
  return this.activeEditor?.commands.goToSearchResult(t);
32905
32979
  }
@@ -32915,6 +32989,10 @@ class hb extends eg {
32915
32989
  });
32916
32990
  });
32917
32991
  }
32992
+ /**
32993
+ * Get the HTML content of all editors
32994
+ * @returns {Array<string>} The HTML content of all editors
32995
+ */
32918
32996
  getHTML() {
32919
32997
  const t = [];
32920
32998
  return this.superdocStore.documents.forEach((i) => {
@@ -32933,6 +33011,17 @@ class hb extends eg {
32933
33011
 
32934
33012
  `), this.emit("locked", { isLocked: t, lockedBy: i });
32935
33013
  }
33014
+ /**
33015
+ * Export the superdoc to a file
33016
+ * @param {Object} params
33017
+ * @param {string[]} [params.exportType]
33018
+ * @param {string} [params.commentsType]
33019
+ * @param {string} [params.exportedName]
33020
+ * @param {Array} [params.additionalFiles]
33021
+ * @param {Array} [params.additionalFileNames]
33022
+ * @param {boolean} [params.isFinalDoc]
33023
+ * @returns {Promise<void>} The exported file
33024
+ */
32936
33025
  async export({
32937
33026
  exportType: t = ["docx"],
32938
33027
  commentsType: i,
@@ -32951,6 +33040,11 @@ class hb extends eg {
32951
33040
  Wl(m, u, "zip");
32952
33041
  }
32953
33042
  }
33043
+ /**
33044
+ * Export editors to DOCX format.
33045
+ * @param {{ commentsType?: string, isFinalDoc?: boolean }} [options]
33046
+ * @returns {Promise<Array<Blob>>}
33047
+ */
32954
33048
  async exportEditorsToDOCX({ commentsType: t, isFinalDoc: i } = {}) {
32955
33049
  const r = [];
32956
33050
  t !== "clean" && r.push(...this.commentsStore?.translateCommentsForExport());
@@ -32977,6 +33071,10 @@ class hb extends eg {
32977
33071
  });
32978
33072
  });
32979
33073
  }
33074
+ /**
33075
+ * Save the superdoc if in collaboration mode
33076
+ * @returns {Promise<void[]>} Resolves when all documents have saved
33077
+ */
32980
33078
  async save() {
32981
33079
  const t = [
32982
33080
  this.#h()
@@ -32986,10 +33084,14 @@ class hb extends eg {
32986
33084
  const i = await Promise.all(t);
32987
33085
  return console.debug("🦋 [superdoc] Save complete:", i), i;
32988
33086
  }
33087
+ /**
33088
+ * Destroy the superdoc instance
33089
+ * @returns {void}
33090
+ */
32989
33091
  destroy() {
32990
33092
  this.app && (this.log("[superdoc] Unmounting app"), this.config.socket?.cancelWebsocketRetry(), this.config.socket?.disconnect(), this.config.socket?.destroy(), this.ydoc?.destroy(), this.provider?.disconnect(), this.provider?.destroy(), this.config.documents.forEach((t) => {
32991
33093
  t.provider && (t.provider.disconnect(), t.provider.destroy()), t.ydoc?.destroy();
32992
- }), this.superdocStore.reset(), this.telemetry?.destroy(), this.app.unmount(), this.removeAllListeners(), delete this.app.config.globalProperties.$config, delete this.app.config.globalProperties.$superdoc);
33094
+ }), this.superdocStore.reset(), this.app.unmount(), this.removeAllListeners(), delete this.app.config.globalProperties.$config, delete this.app.config.globalProperties.$superdoc);
32993
33095
  }
32994
33096
  /**
32995
33097
  * Focus the active editor or the first editor in the superdoc
@@ -24155,7 +24155,7 @@ Actual: ` + p3.attribValue
24155
24155
  return;
24156
24156
  }
24157
24157
  }
24158
- static updateDocumentVersion(e = this.convertedXml, t = "0.11.37") {
24158
+ static updateDocumentVersion(e = this.convertedXml, t = "0.11.39") {
24159
24159
  const n = "docProps/custom.xml";
24160
24160
  e[n] || (e[n] = Fu$2());
24161
24161
  const i3 = e["docProps/custom.xml"];
@@ -24418,7 +24418,7 @@ Actual: ` + p3.attribValue
24418
24418
  function Fu$2() {
24419
24419
  return Gf$1;
24420
24420
  }
24421
- function Bu$2(r22 = 2, e = "0.11.37") {
24421
+ function Bu$2(r22 = 2, e = "0.11.39") {
24422
24422
  return {
24423
24423
  type: "element",
24424
24424
  name: "property",
@@ -37216,7 +37216,7 @@ Actual: ` + p3.attribValue
37216
37216
  * @returns {Object | void} Migration results
37217
37217
  */
37218
37218
  processCollaborationMigrations() {
37219
- if (console.debug("[checkVersionMigrations] Current editor version", "0.11.37"), !this.options.ydoc) return;
37219
+ if (console.debug("[checkVersionMigrations] Current editor version", "0.11.39"), !this.options.ydoc) return;
37220
37220
  let r = this.options.ydoc.getMap("meta").get("version");
37221
37221
  r || (r = "initial"), console.debug("[checkVersionMigrations] Document version", r);
37222
37222
  const o = hl$1(r) || [], s = this.state.plugins.find((c3) => c3.key.startsWith("y-sync"));
@@ -71426,9 +71426,14 @@ ${style2}
71426
71426
  class SuperDoc extends EventEmitter {
71427
71427
  /** @type {Array<string>} */
71428
71428
  static allowedTypes = [DOCX, PDF, HTML];
71429
- /** @type {number} */
71429
+ /** @type {string} */
71430
71430
  version;
71431
+ /** @type {User[]} */
71431
71432
  users;
71433
+ /** @type {import('yjs').Doc | undefined} */
71434
+ ydoc;
71435
+ /** @type {import('@hocuspocus/provider').HocuspocusProvider | undefined} */
71436
+ provider;
71432
71437
  /** @type {Config} */
71433
71438
  config = {
71434
71439
  superdocId: null,
@@ -71448,7 +71453,6 @@ ${style2}
71448
71453
  conversations: [],
71449
71454
  pagination: false,
71450
71455
  // Optional: Whether to show pagination in SuperEditors
71451
- isCollaborative: false,
71452
71456
  isInternal: false,
71453
71457
  // toolbar config
71454
71458
  toolbar: null,
@@ -71493,7 +71497,7 @@ ${style2}
71493
71497
  this.config.colors = shuffleArray(this.config.colors);
71494
71498
  this.userColorMap = /* @__PURE__ */ new Map();
71495
71499
  this.colorIndex = 0;
71496
- this.version = "0.11.37";
71500
+ this.version = "0.11.39";
71497
71501
  console.debug("🦋 [superdoc] Using SuperDoc version:", this.version);
71498
71502
  this.superdocId = config.superdocId || v4();
71499
71503
  this.colors = this.config.colors;
@@ -71511,8 +71515,12 @@ ${style2}
71511
71515
  this.readyEditors = 0;
71512
71516
  this.isLocked = this.config.isLocked || false;
71513
71517
  this.lockedBy = this.config.lockedBy || null;
71514
- this.#addToolbar(this);
71518
+ this.#addToolbar();
71515
71519
  }
71520
+ /**
71521
+ * Get the number of editors that are required for this superdoc
71522
+ * @returns {number} The number of required editors
71523
+ */
71516
71524
  get requiredNumberOfEditors() {
71517
71525
  return this.superdocStore.documents.filter((d) => d.type === DOCX).length;
71518
71526
  }
@@ -71562,7 +71570,6 @@ ${style2}
71562
71570
  this.app.config.globalProperties.$superdoc = this;
71563
71571
  this.superdocStore = superdocStore;
71564
71572
  this.commentsStore = commentsStore;
71565
- this.version = this.config.version;
71566
71573
  this.superdocStore.init(this.config);
71567
71574
  this.commentsStore.init(this.config.modules.comments);
71568
71575
  }
@@ -71598,7 +71605,6 @@ ${style2}
71598
71605
  }
71599
71606
  /**
71600
71607
  * Add a user to the shared users list
71601
- *
71602
71608
  * @param {Object} user The user to add
71603
71609
  * @returns {void}
71604
71610
  */
@@ -71608,7 +71614,6 @@ ${style2}
71608
71614
  }
71609
71615
  /**
71610
71616
  * Remove a user from the shared users list
71611
- *
71612
71617
  * @param {String} email The email of the user to remove
71613
71618
  * @returns {void}
71614
71619
  */
@@ -71627,36 +71632,73 @@ ${style2}
71627
71632
  superdocVersion: this.version
71628
71633
  });
71629
71634
  }
71635
+ /**
71636
+ * Triggered when there is an error in the content
71637
+ * @param {Object} param0
71638
+ * @param {Error} param0.error The error that occurred
71639
+ * @param {Editor} param0.editor The editor that caused the error
71640
+ */
71630
71641
  onContentError({ error, editor }) {
71631
71642
  const { documentId } = editor.options;
71632
71643
  const doc2 = this.superdocStore.documents.find((d) => d.id === documentId);
71633
71644
  this.config.onContentError({ error, editor, documentId: doc2.id, file: doc2.data });
71634
71645
  }
71646
+ /**
71647
+ * Triggered when the PDF document is ready
71648
+ * @returns {void}
71649
+ */
71635
71650
  broadcastPdfDocumentReady() {
71636
71651
  this.emit("pdf-document-ready");
71637
71652
  }
71653
+ /**
71654
+ * Triggered when the superdoc is ready
71655
+ * @returns {void}
71656
+ */
71638
71657
  broadcastReady() {
71639
71658
  if (this.readyEditors === this.requiredNumberOfEditors) {
71640
71659
  this.emit("ready", { superdoc: this });
71641
71660
  }
71642
71661
  }
71662
+ /**
71663
+ * Triggered before an editor is created
71664
+ * @param {Editor} editor The editor that is about to be created
71665
+ * @returns {void}
71666
+ */
71643
71667
  broadcastEditorBeforeCreate(editor) {
71644
71668
  this.emit("editorBeforeCreate", { editor });
71645
71669
  }
71670
+ /**
71671
+ * Triggered when an editor is created
71672
+ * @param {Editor} editor The editor that was created
71673
+ * @returns {void}
71674
+ */
71646
71675
  broadcastEditorCreate(editor) {
71647
71676
  this.readyEditors++;
71648
71677
  this.broadcastReady();
71649
71678
  this.emit("editorCreate", { editor });
71650
71679
  }
71680
+ /**
71681
+ * Triggered when an editor is destroyed
71682
+ * @returns {void}
71683
+ */
71651
71684
  broadcastEditorDestroy() {
71652
71685
  this.emit("editorDestroy");
71653
71686
  }
71687
+ /**
71688
+ * Triggered when the comments sidebar is toggled
71689
+ * @param {boolean} isOpened
71690
+ */
71654
71691
  broadcastSidebarToggle(isOpened) {
71655
71692
  this.emit("sidebar-toggle", isOpened);
71656
71693
  }
71657
71694
  log(...args) {
71658
71695
  console.debug("🦋 🦸‍♀️ [superdoc]", ...args);
71659
71696
  }
71697
+ /**
71698
+ * Set the active editor
71699
+ * @param {Editor} editor The editor to set as active
71700
+ * @returns {void}
71701
+ */
71660
71702
  setActiveEditor(editor) {
71661
71703
  this.activeEditor = editor;
71662
71704
  if (this.toolbar) this.toolbar.setActiveEditor(editor);
@@ -71696,6 +71738,12 @@ ${style2}
71696
71738
  });
71697
71739
  this.once("editorCreate", () => this.toolbar.updateToolbarState());
71698
71740
  }
71741
+ /**
71742
+ * Add a comments list to the superdoc
71743
+ * Requires the comments module to be enabled
71744
+ * @param {Element} element The DOM element to render the comments list in
71745
+ * @returns {void}
71746
+ */
71699
71747
  addCommentsList(element) {
71700
71748
  if (!this.config?.modules?.comments || this.config.role === "viewer") return;
71701
71749
  console.debug("🦋 [superdoc] Adding comments list to:", element);
@@ -71703,6 +71751,10 @@ ${style2}
71703
71751
  this.commentsList = new SuperComments(this.config.modules?.comments, this);
71704
71752
  if (this.config.onCommentsListChange) this.config.onCommentsListChange({ isRendered: true });
71705
71753
  }
71754
+ /**
71755
+ * Remove the comments list from the superdoc
71756
+ * @returns {void}
71757
+ */
71706
71758
  removeCommentsList() {
71707
71759
  if (this.commentsList) {
71708
71760
  this.commentsList.close();
@@ -71710,6 +71762,12 @@ ${style2}
71710
71762
  if (this.config.onCommentsListChange) this.config.onCommentsListChange({ isRendered: false });
71711
71763
  }
71712
71764
  }
71765
+ /**
71766
+ * Triggered when a toolbar command is executed
71767
+ * @param {Object} param0
71768
+ * @param {Object} param0.item The toolbar item that was clicked
71769
+ * @param {string} param0.argument The argument passed to the command
71770
+ */
71713
71771
  onToolbarCommand({ item, argument }) {
71714
71772
  if (item.command === "setDocumentMode") {
71715
71773
  this.setDocumentMode(argument);
@@ -71717,6 +71775,11 @@ ${style2}
71717
71775
  this.superdocStore.activeZoom = argument;
71718
71776
  }
71719
71777
  }
71778
+ /**
71779
+ * Set the document mode.
71780
+ * @param {DocumentMode} type
71781
+ * @returns {void}
71782
+ */
71720
71783
  setDocumentMode(type) {
71721
71784
  if (!type) return;
71722
71785
  type = type.toLowerCase();
@@ -71772,9 +71835,19 @@ ${style2}
71772
71835
  this.toolbar.updateToolbarState();
71773
71836
  }
71774
71837
  }
71838
+ /**
71839
+ * Search for text or regex in the active editor
71840
+ * @param {string | RegExp} text The text or regex to search for
71841
+ * @returns {Object[]} The search results
71842
+ */
71775
71843
  search(text) {
71776
71844
  return this.activeEditor?.commands.search(text);
71777
71845
  }
71846
+ /**
71847
+ * Go to the next search result
71848
+ * @param {Object} match The match object
71849
+ * @returns {void}
71850
+ */
71778
71851
  goToSearchResult(match) {
71779
71852
  return this.activeEditor?.commands.goToSearchResult(match);
71780
71853
  }
@@ -71791,6 +71864,10 @@ ${style2}
71791
71864
  });
71792
71865
  });
71793
71866
  }
71867
+ /**
71868
+ * Get the HTML content of all editors
71869
+ * @returns {Array<string>} The HTML content of all editors
71870
+ */
71794
71871
  getHTML() {
71795
71872
  const editors = [];
71796
71873
  this.superdocStore.documents.forEach((doc2) => {
@@ -71812,6 +71889,17 @@ ${style2}
71812
71889
  console.debug("🦋 [superdoc] Locking superdoc:", isLocked, lockedBy, "\n\n\n");
71813
71890
  this.emit("locked", { isLocked, lockedBy });
71814
71891
  }
71892
+ /**
71893
+ * Export the superdoc to a file
71894
+ * @param {Object} params
71895
+ * @param {string[]} [params.exportType]
71896
+ * @param {string} [params.commentsType]
71897
+ * @param {string} [params.exportedName]
71898
+ * @param {Array} [params.additionalFiles]
71899
+ * @param {Array} [params.additionalFileNames]
71900
+ * @param {boolean} [params.isFinalDoc]
71901
+ * @returns {Promise<void>} The exported file
71902
+ */
71815
71903
  async export({
71816
71904
  exportType = ["docx"],
71817
71905
  commentsType,
@@ -71837,6 +71925,11 @@ ${style2}
71837
71925
  createDownload(zip, baseFileName, "zip");
71838
71926
  }
71839
71927
  }
71928
+ /**
71929
+ * Export editors to DOCX format.
71930
+ * @param {{ commentsType?: string, isFinalDoc?: boolean }} [options]
71931
+ * @returns {Promise<Array<Blob>>}
71932
+ */
71840
71933
  async exportEditorsToDOCX({ commentsType, isFinalDoc } = {}) {
71841
71934
  const comments = [];
71842
71935
  if (commentsType !== "clean") {
@@ -71876,6 +71969,10 @@ ${style2}
71876
71969
  });
71877
71970
  });
71878
71971
  }
71972
+ /**
71973
+ * Save the superdoc if in collaboration mode
71974
+ * @returns {Promise<void[]>} Resolves when all documents have saved
71975
+ */
71879
71976
  async save() {
71880
71977
  const savePromises = [
71881
71978
  this.#triggerCollaborationSaves()
@@ -71886,6 +71983,10 @@ ${style2}
71886
71983
  console.debug("🦋 [superdoc] Save complete:", result);
71887
71984
  return result;
71888
71985
  }
71986
+ /**
71987
+ * Destroy the superdoc instance
71988
+ * @returns {void}
71989
+ */
71889
71990
  destroy() {
71890
71991
  if (!this.app) {
71891
71992
  return;
@@ -71905,7 +72006,6 @@ ${style2}
71905
72006
  doc2.ydoc?.destroy();
71906
72007
  });
71907
72008
  this.superdocStore.reset();
71908
- this.telemetry?.destroy();
71909
72009
  this.app.unmount();
71910
72010
  this.removeAllListeners();
71911
72011
  delete this.app.config.globalProperties.$config;