@harbour-enterprises/superdoc 0.21.0 → 0.21.1

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 (49) hide show
  1. package/dist/chunks/{PdfViewer-OZDJ7gwT.cjs → PdfViewer-B507M2sz.cjs} +1 -1
  2. package/dist/chunks/{PdfViewer-D3zo7tPo.es.js → PdfViewer-DCKxnML6.es.js} +1 -1
  3. package/dist/chunks/{index-MzW5BVNd.es.js → index-DWR8syta.es.js} +42 -21
  4. package/dist/chunks/{index-CfYf4T_z.cjs → index-djqw1MEc.cjs} +42 -21
  5. package/dist/chunks/{super-editor.es-Bntob7Wd.es.js → super-editor.es-D__G4K0i.es.js} +1595 -866
  6. package/dist/chunks/{super-editor.es-U-GVCd_F.cjs → super-editor.es-HekVJogH.cjs} +1595 -866
  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 +12 -4
  10. package/dist/core/types/index.d.ts.map +1 -1
  11. package/dist/style.css +32 -27
  12. package/dist/super-editor/ai-writer.es.js +2 -2
  13. package/dist/super-editor/chunks/{converter-3xnF_NHq.js → converter-B_pO-5Ls.js} +1064 -710
  14. package/dist/super-editor/chunks/{docx-zipper-CZdELYi-.js → docx-zipper-WaO3WaIz.js} +73 -12
  15. package/dist/super-editor/chunks/{editor-BqYH4kDD.js → editor-DInvq7gF.js} +80 -26
  16. package/dist/super-editor/chunks/{toolbar-TkaE2kKM.js → toolbar-C15EomPB.js} +2 -2
  17. package/dist/super-editor/converter.es.js +1 -1
  18. package/dist/super-editor/docx-zipper.es.js +2 -2
  19. package/dist/super-editor/editor.es.js +3 -3
  20. package/dist/super-editor/file-zipper.es.js +1 -1
  21. package/dist/super-editor/src/components/slash-menu/menuItems.d.ts +5 -1
  22. package/dist/super-editor/src/components/slash-menu/tests/testHelpers.d.ts +466 -0
  23. package/dist/super-editor/src/components/slash-menu/utils.d.ts +9 -2
  24. package/dist/super-editor/src/core/DocxZipper.d.ts +1 -1
  25. package/dist/super-editor/src/core/commands/__tests__/schemaWithLists.d.ts +2 -0
  26. package/dist/super-editor/src/core/commands/__tests__/testHelpers.d.ts +4 -0
  27. package/dist/super-editor/src/core/commands/__tests__/testSchema.d.ts +2 -0
  28. package/dist/super-editor/src/core/commands/tests/commandTestUtils.d.ts +7 -0
  29. package/dist/super-editor/src/core/commands/tests/test-schema.d.ts +2 -0
  30. package/dist/super-editor/src/core/super-converter/SuperConverter.d.ts +1 -13
  31. package/dist/super-editor/src/core/super-converter/exporter.d.ts +1 -0
  32. package/dist/super-editor/src/core/super-converter/helpers/tableFallbackHelpers.d.ts +24 -0
  33. package/dist/super-editor/src/core/super-converter/v3/handlers/mc/altermateContent/alternate-content-translator.d.ts +6 -0
  34. package/dist/super-editor/src/core/super-converter/v3/handlers/mc/altermateContent/index.d.ts +1 -0
  35. package/dist/super-editor/src/extensions/custom-selection/custom-selection.d.ts +5 -0
  36. package/dist/super-editor/src/tests/helpers/helpers.d.ts +1 -0
  37. package/dist/super-editor/src/utils/contextmenu-helpers.d.ts +24 -0
  38. package/dist/super-editor/style.css +5 -0
  39. package/dist/super-editor/super-editor.es.js +454 -154
  40. package/dist/super-editor/toolbar.es.js +2 -2
  41. package/dist/super-editor.cjs +1 -1
  42. package/dist/super-editor.es.js +1 -1
  43. package/dist/superdoc.cjs +2 -2
  44. package/dist/superdoc.es.js +2 -2
  45. package/dist/superdoc.umd.js +1635 -885
  46. package/dist/superdoc.umd.js.map +1 -1
  47. package/package.json +2 -5
  48. package/dist/super-editor/src/extensions/run-item/index.d.ts +0 -1
  49. package/dist/super-editor/src/extensions/run-item/run-item.d.ts +0 -26
@@ -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-CfYf4T_z.cjs");
4
+ const superdoc = require("./index-djqw1MEc.cjs");
5
5
  function self(vars) {
6
6
  const {
7
7
  opacityDisabled,
@@ -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-MzW5BVNd.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-DWR8syta.es.js";
3
3
  function self(vars) {
4
4
  const {
5
5
  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-Bntob7Wd.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-D__G4K0i.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";
@@ -17392,7 +17392,7 @@ const _sfc_main = {
17392
17392
  __name: "SuperDoc",
17393
17393
  emits: ["selection-update"],
17394
17394
  setup(__props, { emit: __emit }) {
17395
- const PdfViewer = defineAsyncComponent(() => import("./PdfViewer-D3zo7tPo.es.js"));
17395
+ const PdfViewer = defineAsyncComponent(() => import("./PdfViewer-DCKxnML6.es.js"));
17396
17396
  const superdocStore = useSuperdocStore();
17397
17397
  const commentsStore = useCommentsStore();
17398
17398
  const {
@@ -17573,6 +17573,7 @@ const _sfc_main = {
17573
17573
  annotations: proxy.$superdoc.config.annotations,
17574
17574
  isCommentsEnabled: proxy.$superdoc.config.modules?.comments,
17575
17575
  isAiEnabled: proxy.$superdoc.config.modules?.ai,
17576
+ slashMenuConfig: proxy.$superdoc.config.modules?.slashMenu,
17576
17577
  onBeforeCreate: onEditorBeforeCreate,
17577
17578
  onCreate: onEditorCreate,
17578
17579
  onDestroy: onEditorDestroy,
@@ -17934,7 +17935,7 @@ const _sfc_main = {
17934
17935
  };
17935
17936
  }
17936
17937
  };
17937
- const App = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-07532c12"]]);
17938
+ const App = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-dbfba5b9"]]);
17938
17939
  const createSuperdocVueApp = () => {
17939
17940
  const app = createApp(App);
17940
17941
  const pinia = createPinia();
@@ -18036,7 +18037,7 @@ class SuperDoc extends EventEmitter {
18036
18037
  this.config.colors = shuffleArray(this.config.colors);
18037
18038
  this.userColorMap = /* @__PURE__ */ new Map();
18038
18039
  this.colorIndex = 0;
18039
- this.version = "0.20.2";
18040
+ this.version = "0.21.1";
18040
18041
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
18041
18042
  this.superdocId = config.superdocId || v4();
18042
18043
  this.colors = this.config.colors;
@@ -18051,6 +18052,9 @@ class SuperDoc extends EventEmitter {
18051
18052
  this.isDev = this.config.isDev || false;
18052
18053
  this.activeEditor = null;
18053
18054
  this.comments = [];
18055
+ if (!this.config.selector) {
18056
+ throw new Error("SuperDoc: selector is required");
18057
+ }
18054
18058
  this.app.mount(this.config.selector);
18055
18059
  this.readyEditors = 0;
18056
18060
  this.isLocked = this.config.isLocked || false;
@@ -18070,6 +18074,16 @@ class SuperDoc extends EventEmitter {
18070
18074
  users: this.users
18071
18075
  };
18072
18076
  }
18077
+ /**
18078
+ * Get the SuperDoc container element
18079
+ * @returns {HTMLElement | null}
18080
+ */
18081
+ get element() {
18082
+ if (typeof this.config.selector === "string") {
18083
+ return document.querySelector(this.config.selector);
18084
+ }
18085
+ return this.config.selector;
18086
+ }
18073
18087
  #patchNaiveUIStyles() {
18074
18088
  const cspNonce = this.config.cspNonce;
18075
18089
  const originalCreateElement = document.createElement;
@@ -18093,10 +18107,16 @@ class SuperDoc extends EventEmitter {
18093
18107
  }
18094
18108
  if (hasDocumentConfig) {
18095
18109
  const normalized = normalizeDocumentEntry(this.config.document);
18096
- this.config.documents = [normalized];
18110
+ this.config.documents = [
18111
+ {
18112
+ id: v4(),
18113
+ ...normalized
18114
+ }
18115
+ ];
18097
18116
  } else if (hasDocumentUrl) {
18098
18117
  this.config.documents = [
18099
18118
  {
18119
+ id: v4(),
18100
18120
  type: DOCX,
18101
18121
  url: this.config.document,
18102
18122
  name: "document.docx",
@@ -18104,33 +18124,34 @@ class SuperDoc extends EventEmitter {
18104
18124
  }
18105
18125
  ];
18106
18126
  } else if (hasDocumentFile) {
18127
+ const normalized = normalizeDocumentEntry(this.config.document);
18107
18128
  this.config.documents = [
18108
18129
  {
18109
- type: this.config.document.type,
18110
- data: this.config.document,
18111
- name: this.config.document.name,
18112
- isNewFile: true
18130
+ id: v4(),
18131
+ ...normalized
18113
18132
  }
18114
18133
  ];
18115
18134
  } else if (hasDocumentBlob) {
18116
- const docType = this.config.document.type || DOCX;
18117
- let extension = ".docx";
18118
- if (docType === PDF) {
18119
- extension = ".pdf";
18120
- } else if (docType === HTML) {
18121
- extension = ".html";
18122
- }
18135
+ const normalized = normalizeDocumentEntry(this.config.document);
18123
18136
  this.config.documents = [
18124
18137
  {
18125
- type: docType,
18126
- data: this.config.document,
18127
- name: `document${extension}`,
18128
- isNewFile: true
18138
+ id: v4(),
18139
+ ...normalized
18129
18140
  }
18130
18141
  ];
18131
18142
  }
18132
18143
  if (Array.isArray(this.config.documents) && this.config.documents.length > 0) {
18133
- this.config.documents = this.config.documents.map((d) => normalizeDocumentEntry(d));
18144
+ this.config.documents = this.config.documents.map((d) => {
18145
+ const normalized = normalizeDocumentEntry(d);
18146
+ if (!normalized || typeof normalized !== "object") {
18147
+ return normalized;
18148
+ }
18149
+ const existingId = typeof normalized === "object" && "id" in normalized && normalized.id || d && typeof d === "object" && "id" in d && d.id;
18150
+ return {
18151
+ ...normalized,
18152
+ id: existingId || v4()
18153
+ };
18154
+ });
18134
18155
  }
18135
18156
  }
18136
18157
  #initVueApp() {
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- const superEditor_es = require("./super-editor.es-U-GVCd_F.cjs");
2
+ const superEditor_es = require("./super-editor.es-HekVJogH.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");
@@ -17409,7 +17409,7 @@ const _sfc_main = {
17409
17409
  __name: "SuperDoc",
17410
17410
  emits: ["selection-update"],
17411
17411
  setup(__props, { emit: __emit }) {
17412
- const PdfViewer = vue.defineAsyncComponent(() => Promise.resolve().then(() => require("./PdfViewer-OZDJ7gwT.cjs")));
17412
+ const PdfViewer = vue.defineAsyncComponent(() => Promise.resolve().then(() => require("./PdfViewer-B507M2sz.cjs")));
17413
17413
  const superdocStore = useSuperdocStore();
17414
17414
  const commentsStore = useCommentsStore();
17415
17415
  const {
@@ -17590,6 +17590,7 @@ const _sfc_main = {
17590
17590
  annotations: proxy.$superdoc.config.annotations,
17591
17591
  isCommentsEnabled: proxy.$superdoc.config.modules?.comments,
17592
17592
  isAiEnabled: proxy.$superdoc.config.modules?.ai,
17593
+ slashMenuConfig: proxy.$superdoc.config.modules?.slashMenu,
17593
17594
  onBeforeCreate: onEditorBeforeCreate,
17594
17595
  onCreate: onEditorCreate,
17595
17596
  onDestroy: onEditorDestroy,
@@ -17951,7 +17952,7 @@ const _sfc_main = {
17951
17952
  };
17952
17953
  }
17953
17954
  };
17954
- const App = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-07532c12"]]);
17955
+ const App = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-dbfba5b9"]]);
17955
17956
  const createSuperdocVueApp = () => {
17956
17957
  const app = vue.createApp(App);
17957
17958
  const pinia = createPinia();
@@ -18053,7 +18054,7 @@ class SuperDoc extends eventemitter3.EventEmitter {
18053
18054
  this.config.colors = shuffleArray(this.config.colors);
18054
18055
  this.userColorMap = /* @__PURE__ */ new Map();
18055
18056
  this.colorIndex = 0;
18056
- this.version = "0.20.2";
18057
+ this.version = "0.21.1";
18057
18058
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
18058
18059
  this.superdocId = config.superdocId || uuid.v4();
18059
18060
  this.colors = this.config.colors;
@@ -18068,6 +18069,9 @@ class SuperDoc extends eventemitter3.EventEmitter {
18068
18069
  this.isDev = this.config.isDev || false;
18069
18070
  this.activeEditor = null;
18070
18071
  this.comments = [];
18072
+ if (!this.config.selector) {
18073
+ throw new Error("SuperDoc: selector is required");
18074
+ }
18071
18075
  this.app.mount(this.config.selector);
18072
18076
  this.readyEditors = 0;
18073
18077
  this.isLocked = this.config.isLocked || false;
@@ -18087,6 +18091,16 @@ class SuperDoc extends eventemitter3.EventEmitter {
18087
18091
  users: this.users
18088
18092
  };
18089
18093
  }
18094
+ /**
18095
+ * Get the SuperDoc container element
18096
+ * @returns {HTMLElement | null}
18097
+ */
18098
+ get element() {
18099
+ if (typeof this.config.selector === "string") {
18100
+ return document.querySelector(this.config.selector);
18101
+ }
18102
+ return this.config.selector;
18103
+ }
18090
18104
  #patchNaiveUIStyles() {
18091
18105
  const cspNonce = this.config.cspNonce;
18092
18106
  const originalCreateElement = document.createElement;
@@ -18110,10 +18124,16 @@ class SuperDoc extends eventemitter3.EventEmitter {
18110
18124
  }
18111
18125
  if (hasDocumentConfig) {
18112
18126
  const normalized = normalizeDocumentEntry(this.config.document);
18113
- this.config.documents = [normalized];
18127
+ this.config.documents = [
18128
+ {
18129
+ id: uuid.v4(),
18130
+ ...normalized
18131
+ }
18132
+ ];
18114
18133
  } else if (hasDocumentUrl) {
18115
18134
  this.config.documents = [
18116
18135
  {
18136
+ id: uuid.v4(),
18117
18137
  type: DOCX,
18118
18138
  url: this.config.document,
18119
18139
  name: "document.docx",
@@ -18121,33 +18141,34 @@ class SuperDoc extends eventemitter3.EventEmitter {
18121
18141
  }
18122
18142
  ];
18123
18143
  } else if (hasDocumentFile) {
18144
+ const normalized = normalizeDocumentEntry(this.config.document);
18124
18145
  this.config.documents = [
18125
18146
  {
18126
- type: this.config.document.type,
18127
- data: this.config.document,
18128
- name: this.config.document.name,
18129
- isNewFile: true
18147
+ id: uuid.v4(),
18148
+ ...normalized
18130
18149
  }
18131
18150
  ];
18132
18151
  } else if (hasDocumentBlob) {
18133
- const docType = this.config.document.type || DOCX;
18134
- let extension = ".docx";
18135
- if (docType === PDF) {
18136
- extension = ".pdf";
18137
- } else if (docType === HTML) {
18138
- extension = ".html";
18139
- }
18152
+ const normalized = normalizeDocumentEntry(this.config.document);
18140
18153
  this.config.documents = [
18141
18154
  {
18142
- type: docType,
18143
- data: this.config.document,
18144
- name: `document${extension}`,
18145
- isNewFile: true
18155
+ id: uuid.v4(),
18156
+ ...normalized
18146
18157
  }
18147
18158
  ];
18148
18159
  }
18149
18160
  if (Array.isArray(this.config.documents) && this.config.documents.length > 0) {
18150
- this.config.documents = this.config.documents.map((d) => normalizeDocumentEntry(d));
18161
+ this.config.documents = this.config.documents.map((d) => {
18162
+ const normalized = normalizeDocumentEntry(d);
18163
+ if (!normalized || typeof normalized !== "object") {
18164
+ return normalized;
18165
+ }
18166
+ const existingId = typeof normalized === "object" && "id" in normalized && normalized.id || d && typeof d === "object" && "id" in d && d.id;
18167
+ return {
18168
+ ...normalized,
18169
+ id: existingId || uuid.v4()
18170
+ };
18171
+ });
18151
18172
  }
18152
18173
  }
18153
18174
  #initVueApp() {