@harbour-enterprises/superdoc 0.34.9 → 0.35.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/dist/chunks/{PdfViewer-C2rB3UFf.es.js → PdfViewer-BFtgOHmf.es.js} +1 -1
  2. package/dist/chunks/{PdfViewer-DE24U_pv.cjs → PdfViewer-CjZkPY58.cjs} +1 -1
  3. package/dist/chunks/{index-myYbO6wO.cjs → index-2Tp2kFsl.cjs} +46 -5
  4. package/dist/chunks/{index-CHtB4uAl-BS8u99OE.es.js → index-CzChRmiA-C73DMMSu.es.js} +1 -1
  5. package/dist/chunks/{index-CHtB4uAl-D-zQo-Zr.cjs → index-CzChRmiA-Db3kkVxc.cjs} +1 -1
  6. package/dist/chunks/{index-tHw-DC34.es.js → index-cSTBvMaB.es.js} +46 -5
  7. package/dist/chunks/{super-editor.es-Cs1TKdep.cjs → super-editor.es-CyHF2Y6u.cjs} +86 -25
  8. package/dist/chunks/{super-editor.es-C8J_Vybd.es.js → super-editor.es-DgptwjrT.es.js} +86 -25
  9. package/dist/packages/superdoc/src/composables/use-document.d.ts.map +1 -1
  10. package/dist/packages/superdoc/src/core/SuperDoc.d.ts.map +1 -1
  11. package/dist/packages/superdoc/src/core/collaboration/collaboration.d.ts +11 -0
  12. package/dist/packages/superdoc/src/core/collaboration/collaboration.d.ts.map +1 -1
  13. package/dist/packages/superdoc/src/core/types/index.d.ts +64 -1
  14. package/dist/packages/superdoc/src/core/types/index.d.ts.map +1 -1
  15. package/dist/style.css +6 -6
  16. package/dist/super-editor/ai-writer.es.js +2 -2
  17. package/dist/super-editor/chunks/{converter-9FsB3Hi4.js → converter-CNQW31Bb.js} +11 -5
  18. package/dist/super-editor/chunks/{docx-zipper-C_3Ejzf5.js → docx-zipper-WzK7I7n3.js} +1 -1
  19. package/dist/super-editor/chunks/{editor-BMv3Pr_v.js → editor-tmuPz5Wb.js} +54 -17
  20. package/dist/super-editor/chunks/{index-CHtB4uAl.js → index-CzChRmiA.js} +1 -1
  21. package/dist/super-editor/chunks/{toolbar-B9ZfgQpl.js → toolbar-BVEErXhc.js} +2 -2
  22. package/dist/super-editor/converter.es.js +1 -1
  23. package/dist/super-editor/docx-zipper.es.js +2 -2
  24. package/dist/super-editor/editor.es.js +3 -3
  25. package/dist/super-editor/file-zipper.es.js +1 -1
  26. package/dist/super-editor/style.css +6 -6
  27. package/dist/super-editor/super-editor/src/core/commands/deleteSelection.d.ts.map +1 -1
  28. package/dist/super-editor/super-editor/src/core/extensions/editable.d.ts +11 -0
  29. package/dist/super-editor/super-editor/src/core/extensions/editable.d.ts.map +1 -1
  30. package/dist/super-editor/super-editor/src/core/super-converter/v2/importer/documentCommentsImporter.d.ts.map +1 -1
  31. package/dist/super-editor/super-editor/src/extensions/comment/comments-helpers.d.ts.map +1 -1
  32. package/dist/super-editor/super-editor/src/extensions/track-changes/permission-helpers.d.ts.map +1 -1
  33. package/dist/super-editor/super-editor.es.js +29 -11
  34. package/dist/super-editor/toolbar.es.js +2 -2
  35. package/dist/super-editor.cjs +1 -1
  36. package/dist/super-editor.es.js +1 -1
  37. package/dist/superdoc.cjs +2 -2
  38. package/dist/superdoc.es.js +2 -2
  39. package/dist/superdoc.umd.js +131 -29
  40. package/dist/superdoc.umd.js.map +1 -1
  41. package/package.json +1 -1
package/dist/superdoc.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const superEditor_es = require("./chunks/super-editor.es-Cs1TKdep.cjs");
4
- const superdoc = require("./chunks/index-myYbO6wO.cjs");
3
+ const superEditor_es = require("./chunks/super-editor.es-CyHF2Y6u.cjs");
4
+ const superdoc = require("./chunks/index-2Tp2kFsl.cjs");
5
5
  const blankDocx = require("./chunks/blank-docx-DfW3Eeh2.cjs");
6
6
  exports.AnnotatorHelpers = superEditor_es.AnnotatorHelpers;
7
7
  exports.Editor = superEditor_es.Editor;
@@ -1,5 +1,5 @@
1
- import { a, E, b, S, d, i, j, n, r, p, q } from "./chunks/super-editor.es-C8J_Vybd.es.js";
2
- import { D, H, P, S as S2, m, l } from "./chunks/index-tHw-DC34.es.js";
1
+ import { a, E, b, S, d, i, j, n, r, p, q } from "./chunks/super-editor.es-DgptwjrT.es.js";
2
+ import { D, H, P, S as S2, m, l } from "./chunks/index-cSTBvMaB.es.js";
3
3
  import { B } from "./chunks/blank-docx-ABm6XYAA.es.js";
4
4
  export {
5
5
  a as AnnotatorHelpers,
@@ -33140,7 +33140,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
33140
33140
  const trackedDeletedText = attributes["custom:trackedDeletedText"] !== "null" ? attributes["custom:trackedDeletedText"] : null;
33141
33141
  const date = new Date(createdDate);
33142
33142
  const unixTimestampMs = date.getTime();
33143
- const parsedComment = nodeListHandler.handler({
33143
+ const parsedElements = nodeListHandler.handler({
33144
33144
  nodes: el.elements,
33145
33145
  nodeListHandler,
33146
33146
  docx,
@@ -33148,7 +33148,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
33148
33148
  converter,
33149
33149
  path: [el]
33150
33150
  });
33151
- const { attrs } = parsedComment[0];
33151
+ const { attrs } = parsedElements[0];
33152
33152
  const paraId = attrs["w14:paraId"];
33153
33153
  return {
33154
33154
  commentId: internalId || v4$1(),
@@ -33156,7 +33156,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
33156
33156
  creatorName: authorName,
33157
33157
  creatorEmail: authorEmail,
33158
33158
  createdTime: unixTimestampMs,
33159
- textJson: parsedComment[0],
33159
+ textJson: parsedElements[0],
33160
+ elements: parsedElements,
33160
33161
  initials,
33161
33162
  paraId,
33162
33163
  trackedChange,
@@ -33178,7 +33179,12 @@ Please report this to https://github.com/markedjs/marked.`, e) {
33178
33179
  const { elements = [] } = initialElements[0] ?? {};
33179
33180
  const commentEx = elements.filter((el) => el.name === "w15:commentEx");
33180
33181
  return comments.map((comment2) => {
33181
- const extendedDef = commentEx.find((ce2) => ce2.attributes["w15:paraId"] === comment2.paraId);
33182
+ const extendedDef = commentEx.find((ce2) => {
33183
+ const isIncludedInCommentElements = comment2.elements.some(
33184
+ (el) => el.attrs["w14:paraId"] === ce2.attributes["w15:paraId"]
33185
+ );
33186
+ return isIncludedInCommentElements;
33187
+ });
33182
33188
  if (!extendedDef) return { ...comment2, isDone: comment2.isDone ?? false };
33183
33189
  const { isDone, paraIdParent } = getExtendedDetails(extendedDef);
33184
33190
  let parentComment;
@@ -35798,7 +35804,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
35798
35804
  static getStoredSuperdocVersion(docx) {
35799
35805
  return _SuperConverter2.getStoredCustomProperty(docx, "SuperdocVersion");
35800
35806
  }
35801
- static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "0.34.9") {
35807
+ static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "0.35.2") {
35802
35808
  return _SuperConverter2.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
35803
35809
  }
35804
35810
  /**
@@ -55698,6 +55704,12 @@ Please report this to https://github.com/markedjs/marked.`, e) {
55698
55704
  const selectAll = () => ({ state: state2, dispatch }) => selectAll$1(state2, dispatch);
55699
55705
  const deleteSelection = () => ({ state: state2, tr, dispatch }) => {
55700
55706
  const { from: from2, to, empty: empty2 } = state2.selection;
55707
+ if (document && document.getSelection) {
55708
+ const currentDomSelection = document.getSelection();
55709
+ if (currentDomSelection?.baseNode?.data?.length == 1) {
55710
+ return false;
55711
+ }
55712
+ }
55701
55713
  if (empty2) {
55702
55714
  return deleteSelection$1(state2, dispatch);
55703
55715
  }
@@ -57268,12 +57280,41 @@ Please report this to https://github.com/markedjs/marked.`, e) {
57268
57280
  const Editable = Extension.create({
57269
57281
  name: "editable",
57270
57282
  addPmPlugins() {
57283
+ const editor = this.editor;
57271
57284
  const editablePlugin = new Plugin({
57272
57285
  key: new PluginKey("editable"),
57273
57286
  props: {
57274
- editable: () => {
57275
- return this.editor.options.editable;
57276
- }
57287
+ editable: () => editor.options.editable,
57288
+ handleDOMEvents: {
57289
+ beforeinput: (_view, event) => {
57290
+ if (!editor.options.editable) {
57291
+ event.preventDefault();
57292
+ return true;
57293
+ }
57294
+ return false;
57295
+ },
57296
+ mousedown: (_view, event) => {
57297
+ if (!editor.options.editable) {
57298
+ event.preventDefault();
57299
+ return true;
57300
+ }
57301
+ return false;
57302
+ },
57303
+ focus: (view, event) => {
57304
+ if (!editor.options.editable) {
57305
+ event.preventDefault();
57306
+ view.dom.blur();
57307
+ return true;
57308
+ }
57309
+ return false;
57310
+ }
57311
+ },
57312
+ handleClick: () => !editor.options.editable,
57313
+ handleDoubleClick: () => !editor.options.editable,
57314
+ handleTripleClick: () => !editor.options.editable,
57315
+ handleKeyDown: () => !editor.options.editable,
57316
+ handlePaste: () => !editor.options.editable,
57317
+ handleDrop: () => !editor.options.editable
57277
57318
  }
57278
57319
  });
57279
57320
  return [editablePlugin];
@@ -58284,12 +58325,14 @@ Please report this to https://github.com/markedjs/marked.`, e) {
58284
58325
  importedId: node2.attrs["w:id"]
58285
58326
  });
58286
58327
  if (type2.name === "commentRangeStart") {
58287
- toMark.push({
58288
- commentId: resolvedCommentId,
58289
- importedId,
58290
- internal,
58291
- start: pos
58292
- });
58328
+ if (!matchingImportedComment.isDone) {
58329
+ toMark.push({
58330
+ commentId: resolvedCommentId,
58331
+ importedId,
58332
+ internal,
58333
+ start: pos
58334
+ });
58335
+ }
58293
58336
  ensureFallbackComment({
58294
58337
  converter,
58295
58338
  matchingImportedComment,
@@ -61848,7 +61891,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
61848
61891
  { default: remarkStringify2 },
61849
61892
  { default: remarkGfm2 }
61850
61893
  ] = await Promise.all([
61851
- Promise.resolve().then(() => indexCHtB4uAl),
61894
+ Promise.resolve().then(() => indexCzChRmiA),
61852
61895
  Promise.resolve().then(() => indexDRCvimau),
61853
61896
  Promise.resolve().then(() => indexC_x_N6Uh),
61854
61897
  Promise.resolve().then(() => indexD_sWOSiG),
@@ -61958,7 +62001,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
61958
62001
  Object.entries(this.converter.convertedXml).forEach(([name, json2]) => {
61959
62002
  if (name.includes("header") || name.includes("footer")) {
61960
62003
  const resultXml = this.converter.schemaToXml(json2.elements[0]);
61961
- updatedHeadersFooters[name] = String(resultXml);
62004
+ updatedHeadersFooters[name] = String(resultXml.replace(/\[\[sdspace\]\]/g, ""));
61962
62005
  }
61963
62006
  });
61964
62007
  const numberingData = this.converter.convertedXml["word/numbering.xml"];
@@ -62066,7 +62109,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
62066
62109
  * @returns {Object | void} Migration results
62067
62110
  */
62068
62111
  processCollaborationMigrations() {
62069
- console.debug("[checkVersionMigrations] Current editor version", "0.34.9");
62112
+ console.debug("[checkVersionMigrations] Current editor version", "0.35.2");
62070
62113
  if (!this.options.ydoc) return;
62071
62114
  const metaMap = this.options.ydoc.getMap("meta");
62072
62115
  let docVersion = metaMap.get("version");
@@ -79855,11 +79898,11 @@ ${l}
79855
79898
  break;
79856
79899
  }
79857
79900
  const [left2, right2] = direction < 0 ? [neighbor, currentChange] : [currentChange, neighbor];
79858
- if (!areDirectlyConnected(left2, right2)) {
79859
- break;
79860
- }
79861
79901
  const sharesId = neighbor.mark.attrs.id === matchingId;
79862
79902
  const complementary = isComplementaryPair(currentChange.mark.type.name, neighbor.mark.type.name);
79903
+ if (!sharesId && !areDirectlyConnected(left2, right2)) {
79904
+ break;
79905
+ }
79863
79906
  if (!sharesId && !complementary) {
79864
79907
  break;
79865
79908
  }
@@ -100932,11 +100975,29 @@ ${style2}
100932
100975
  delete props.options.content;
100933
100976
  const ydoc = props.options.ydoc;
100934
100977
  const provider2 = props.options.collaborationProvider;
100935
- const handleSynced = () => {
100936
- pollForMetaMapData(ydoc);
100937
- provider2.off("synced", handleSynced);
100978
+ const waitForSync = () => {
100979
+ if (provider2.isSynced || provider2.synced) return Promise.resolve();
100980
+ return new Promise((resolve2) => {
100981
+ const onSync = (synced) => {
100982
+ if (synced === false) return;
100983
+ provider2.off("synced", onSync);
100984
+ provider2.off("sync", onSync);
100985
+ resolve2();
100986
+ };
100987
+ provider2.on("synced", onSync);
100988
+ provider2.on("sync", onSync);
100989
+ });
100938
100990
  };
100939
- provider2.on("synced", handleSynced);
100991
+ waitForSync().then(async () => {
100992
+ const metaMap = ydoc.getMap("meta");
100993
+ if (metaMap.has("docx")) {
100994
+ pollForMetaMapData(ydoc);
100995
+ } else {
100996
+ props.options.isNewFile = true;
100997
+ const fileData = await loadNewFileData();
100998
+ if (fileData) initEditor(fileData);
100999
+ }
101000
+ });
100940
101001
  }
100941
101002
  };
100942
101003
  const getExtensions = () => {
@@ -101120,7 +101181,7 @@ ${style2}
101120
101181
  };
101121
101182
  }
101122
101183
  };
101123
- const SuperEditor = /* @__PURE__ */ _export_sfc$1(_sfc_main$1$1, [["__scopeId", "data-v-cd3558fe"]]);
101184
+ const SuperEditor = /* @__PURE__ */ _export_sfc$1(_sfc_main$1$1, [["__scopeId", "data-v-86fdd359"]]);
101124
101185
  const _hoisted_1$h = ["innerHTML"];
101125
101186
  const _sfc_main$i = {
101126
101187
  __name: "SuperInput",
@@ -103633,6 +103694,9 @@ ${reason}`);
103633
103694
  context.emit("awareness-update", payload);
103634
103695
  }
103635
103696
  function createProvider({ config: config2, user, documentId, socket, superdocInstance }) {
103697
+ console.warn(
103698
+ "[superdoc] Internal provider creation is deprecated. Pass { ydoc, provider } to modules.collaboration instead."
103699
+ );
103636
103700
  if (!config2.providerType) config2.providerType = "superdoc";
103637
103701
  const providers = {
103638
103702
  hocuspocus: () => createHocuspocusProvider({ config: config2, user, documentId, socket, superdocInstance }),
@@ -103689,6 +103753,22 @@ ${reason}`);
103689
103753
  const onDestroy = (superdocInstance, documentId) => {
103690
103754
  console.warn("🔌 [superdoc] Destroyed", documentId);
103691
103755
  };
103756
+ function setupAwarenessHandler(provider2, superdocInstance, user) {
103757
+ const awareness = provider2.awareness;
103758
+ if (!awareness) {
103759
+ console.warn("[superdoc] External provider missing awareness property");
103760
+ return;
103761
+ }
103762
+ if (user && awareness.setLocalStateField) {
103763
+ awareness.setLocalStateField("user", user);
103764
+ }
103765
+ awareness.on("change", (changes = {}) => {
103766
+ awarenessHandler(superdocInstance, {
103767
+ changes,
103768
+ states: awareness.getStates()
103769
+ });
103770
+ });
103771
+ }
103692
103772
  const addYComment = (yArray, ydoc, event) => {
103693
103773
  const { comment: comment2 } = event;
103694
103774
  const yComment = new Y.Map(Object.entries(comment2));
@@ -104047,8 +104127,8 @@ ${reason}`);
104047
104127
  const getEditor = () => editorRef.value;
104048
104128
  function initDocumentType({ type: type3, data: data2 }) {
104049
104129
  if (data2?.type) return data2.type;
104050
- if (type3) return type3 in documentTypes ? documentTypes[type3] : null;
104051
- throw new Error("Document type not specified for doc:", params2);
104130
+ if (type3) return documentTypes[type3] || type3;
104131
+ throw new Error("Document type not specified");
104052
104132
  }
104053
104133
  const removeComments = () => {
104054
104134
  conversationsBackup.value = conversations.value;
@@ -118535,7 +118615,7 @@ ${style2}
118535
118615
  this.config.colors = shuffleArray(this.config.colors);
118536
118616
  this.userColorMap = /* @__PURE__ */ new Map();
118537
118617
  this.colorIndex = 0;
118538
- this.version = "0.34.9";
118618
+ this.version = "0.35.2";
118539
118619
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
118540
118620
  this.superdocId = config2.superdocId || v4();
118541
118621
  this.colors = this.config.colors;
@@ -118696,6 +118776,28 @@ ${style2}
118696
118776
  async #initCollaboration({ collaboration: collaborationModuleConfig, comments: commentsConfig = {} } = {}) {
118697
118777
  if (!collaborationModuleConfig) return this.config.documents;
118698
118778
  this.isCollaborative = true;
118779
+ const { ydoc: externalYdoc, provider: externalProvider } = collaborationModuleConfig;
118780
+ if (externalYdoc && externalProvider) {
118781
+ this.ydoc = externalYdoc;
118782
+ this.provider = externalProvider;
118783
+ setupAwarenessHandler(externalProvider, this, this.config.user);
118784
+ if (!this.config.documents || this.config.documents.length === 0) {
118785
+ this.config.documents = [
118786
+ {
118787
+ id: v4(),
118788
+ type: DOCX,
118789
+ name: "document.docx"
118790
+ }
118791
+ ];
118792
+ }
118793
+ this.config.documents.forEach((doc2) => {
118794
+ doc2.ydoc = externalYdoc;
118795
+ doc2.provider = externalProvider;
118796
+ doc2.role = this.config.role;
118797
+ });
118798
+ initCollaborationComments(this);
118799
+ return this.config.documents;
118800
+ }
118699
118801
  if (collaborationModuleConfig.providerType === "hocuspocus") {
118700
118802
  this.config.socket = new provider.HocuspocusProviderWebsocket({
118701
118803
  url: collaborationModuleConfig.url
@@ -120935,7 +121037,7 @@ ${style2}
120935
121037
  value && typeof value === "object" && "byteLength" in value && "byteOffset" in value
120936
121038
  );
120937
121039
  }
120938
- const indexCHtB4uAl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
121040
+ const indexCzChRmiA = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
120939
121041
  __proto__: null,
120940
121042
  unified
120941
121043
  }, Symbol.toStringTag, { value: "Module" }));