@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
@@ -1,5 +1,5 @@
1
1
  import { m as defineComponent, y as h, O as Transition, $ as process$1, J as watchEffect, a as computed, r as ref, j as onMounted, W as onUnmounted, b as createElementBlock, o as openBlock, f as createBaseVNode, e as createCommentVNode, v as createVNode, x as unref } from "./vue-CKmzTNVs.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-tHw-DC34.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-cSTBvMaB.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-Cwv-wUpm.cjs");
4
- const superdoc = require("./index-myYbO6wO.cjs");
4
+ const superdoc = require("./index-2Tp2kFsl.cjs");
5
5
  function self(vars) {
6
6
  const {
7
7
  opacityDisabled,
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- const superEditor_es = require("./super-editor.es-Cs1TKdep.cjs");
2
+ const superEditor_es = require("./super-editor.es-CyHF2Y6u.cjs");
3
3
  const blankDocx = require("./blank-docx-DfW3Eeh2.cjs");
4
4
  const eventemitter3 = require("./eventemitter3-DmHNHvFX.cjs");
5
5
  const provider = require("@hocuspocus/provider");
@@ -3249,6 +3249,9 @@ function awarenessHandler(context, { changes = {}, states }) {
3249
3249
  context.emit("awareness-update", payload);
3250
3250
  }
3251
3251
  function createProvider({ config, user, documentId, socket, superdocInstance }) {
3252
+ console.warn(
3253
+ "[superdoc] Internal provider creation is deprecated. Pass { ydoc, provider } to modules.collaboration instead."
3254
+ );
3252
3255
  if (!config.providerType) config.providerType = "superdoc";
3253
3256
  const providers = {
3254
3257
  hocuspocus: () => createHocuspocusProvider({ config, user, documentId, socket, superdocInstance }),
@@ -3305,6 +3308,22 @@ const onDisconnect = (superdocInstance, documentId) => {
3305
3308
  const onDestroy = (superdocInstance, documentId) => {
3306
3309
  console.warn("🔌 [superdoc] Destroyed", documentId);
3307
3310
  };
3311
+ function setupAwarenessHandler(provider2, superdocInstance, user) {
3312
+ const awareness = provider2.awareness;
3313
+ if (!awareness) {
3314
+ console.warn("[superdoc] External provider missing awareness property");
3315
+ return;
3316
+ }
3317
+ if (user && awareness.setLocalStateField) {
3318
+ awareness.setLocalStateField("user", user);
3319
+ }
3320
+ awareness.on("change", (changes = {}) => {
3321
+ awarenessHandler(superdocInstance, {
3322
+ changes,
3323
+ states: awareness.getStates()
3324
+ });
3325
+ });
3326
+ }
3308
3327
  const addYComment = (yArray, ydoc, event) => {
3309
3328
  const { comment } = event;
3310
3329
  const yComment = new Y.Map(Object.entries(comment));
@@ -3663,8 +3682,8 @@ function useDocument(params2, superdocConfig) {
3663
3682
  const getEditor = () => editorRef.value;
3664
3683
  function initDocumentType({ type: type2, data: data2 }) {
3665
3684
  if (data2?.type) return data2.type;
3666
- if (type2) return type2 in documentTypes ? documentTypes[type2] : null;
3667
- throw new Error("Document type not specified for doc:", params2);
3685
+ if (type2) return documentTypes[type2] || type2;
3686
+ throw new Error("Document type not specified");
3668
3687
  }
3669
3688
  const removeComments = () => {
3670
3689
  conversationsBackup.value = conversations.value;
@@ -17219,7 +17238,7 @@ const _sfc_main = {
17219
17238
  __name: "SuperDoc",
17220
17239
  emits: ["selection-update"],
17221
17240
  setup(__props, { emit: __emit }) {
17222
- const PdfViewer = vue.defineAsyncComponent(() => Promise.resolve().then(() => require("./PdfViewer-DE24U_pv.cjs")));
17241
+ const PdfViewer = vue.defineAsyncComponent(() => Promise.resolve().then(() => require("./PdfViewer-CjZkPY58.cjs")));
17223
17242
  const superdocStore = useSuperdocStore();
17224
17243
  const commentsStore = useCommentsStore();
17225
17244
  const {
@@ -17983,7 +18002,7 @@ class SuperDoc extends eventemitter3.EventEmitter {
17983
18002
  this.config.colors = shuffleArray(this.config.colors);
17984
18003
  this.userColorMap = /* @__PURE__ */ new Map();
17985
18004
  this.colorIndex = 0;
17986
- this.version = "0.34.9";
18005
+ this.version = "0.35.2";
17987
18006
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
17988
18007
  this.superdocId = config.superdocId || uuid.v4();
17989
18008
  this.colors = this.config.colors;
@@ -18144,6 +18163,28 @@ class SuperDoc extends eventemitter3.EventEmitter {
18144
18163
  async #initCollaboration({ collaboration: collaborationModuleConfig, comments: commentsConfig = {} } = {}) {
18145
18164
  if (!collaborationModuleConfig) return this.config.documents;
18146
18165
  this.isCollaborative = true;
18166
+ const { ydoc: externalYdoc, provider: externalProvider } = collaborationModuleConfig;
18167
+ if (externalYdoc && externalProvider) {
18168
+ this.ydoc = externalYdoc;
18169
+ this.provider = externalProvider;
18170
+ setupAwarenessHandler(externalProvider, this, this.config.user);
18171
+ if (!this.config.documents || this.config.documents.length === 0) {
18172
+ this.config.documents = [
18173
+ {
18174
+ id: uuid.v4(),
18175
+ type: DOCX,
18176
+ name: "document.docx"
18177
+ }
18178
+ ];
18179
+ }
18180
+ this.config.documents.forEach((doc) => {
18181
+ doc.ydoc = externalYdoc;
18182
+ doc.provider = externalProvider;
18183
+ doc.role = this.config.role;
18184
+ });
18185
+ initCollaborationComments(this);
18186
+ return this.config.documents;
18187
+ }
18147
18188
  if (collaborationModuleConfig.providerType === "hocuspocus") {
18148
18189
  this.config.socket = new provider.HocuspocusProviderWebsocket({
18149
18190
  url: collaborationModuleConfig.url
@@ -1,4 +1,4 @@
1
- import { s as getDefaultExportFromCjs$2 } from "./super-editor.es-C8J_Vybd.es.js";
1
+ import { s as getDefaultExportFromCjs$2 } from "./super-editor.es-DgptwjrT.es.js";
2
2
  import { V as VFile } from "./index-CvBqQJbG-CvBqQJbG.es.js";
3
3
  function bail(error) {
4
4
  if (error) {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const superEditor_es = require("./super-editor.es-Cs1TKdep.cjs");
3
+ const superEditor_es = require("./super-editor.es-CyHF2Y6u.cjs");
4
4
  const indexCvBqQJbG = require("./index-CvBqQJbG-Dwm0THD7.cjs");
5
5
  function bail(error) {
6
6
  if (error) {
@@ -1,4 +1,4 @@
1
- import { q as index, 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-C8J_Vybd.es.js";
1
+ import { q as index, 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-DgptwjrT.es.js";
2
2
  import { B as BlankDOCX } from "./blank-docx-ABm6XYAA.es.js";
3
3
  import { E as EventEmitter } from "./eventemitter3-hYlnBzSA.es.js";
4
4
  import { HocuspocusProvider, HocuspocusProviderWebsocket } from "@hocuspocus/provider";
@@ -3232,6 +3232,9 @@ function awarenessHandler(context, { changes = {}, states }) {
3232
3232
  context.emit("awareness-update", payload);
3233
3233
  }
3234
3234
  function createProvider({ config, user, documentId, socket, superdocInstance }) {
3235
+ console.warn(
3236
+ "[superdoc] Internal provider creation is deprecated. Pass { ydoc, provider } to modules.collaboration instead."
3237
+ );
3235
3238
  if (!config.providerType) config.providerType = "superdoc";
3236
3239
  const providers = {
3237
3240
  hocuspocus: () => createHocuspocusProvider({ config, user, documentId, socket, superdocInstance }),
@@ -3288,6 +3291,22 @@ const onDisconnect = (superdocInstance, documentId) => {
3288
3291
  const onDestroy = (superdocInstance, documentId) => {
3289
3292
  console.warn("🔌 [superdoc] Destroyed", documentId);
3290
3293
  };
3294
+ function setupAwarenessHandler(provider, superdocInstance, user) {
3295
+ const awareness = provider.awareness;
3296
+ if (!awareness) {
3297
+ console.warn("[superdoc] External provider missing awareness property");
3298
+ return;
3299
+ }
3300
+ if (user && awareness.setLocalStateField) {
3301
+ awareness.setLocalStateField("user", user);
3302
+ }
3303
+ awareness.on("change", (changes = {}) => {
3304
+ awarenessHandler(superdocInstance, {
3305
+ changes,
3306
+ states: awareness.getStates()
3307
+ });
3308
+ });
3309
+ }
3291
3310
  const addYComment = (yArray, ydoc, event) => {
3292
3311
  const { comment } = event;
3293
3312
  const yComment = new Map$2(Object.entries(comment));
@@ -3646,8 +3665,8 @@ function useDocument(params2, superdocConfig) {
3646
3665
  const getEditor = () => editorRef.value;
3647
3666
  function initDocumentType({ type: type2, data: data2 }) {
3648
3667
  if (data2?.type) return data2.type;
3649
- if (type2) return type2 in documentTypes ? documentTypes[type2] : null;
3650
- throw new Error("Document type not specified for doc:", params2);
3668
+ if (type2) return documentTypes[type2] || type2;
3669
+ throw new Error("Document type not specified");
3651
3670
  }
3652
3671
  const removeComments = () => {
3653
3672
  conversationsBackup.value = conversations.value;
@@ -17202,7 +17221,7 @@ const _sfc_main = {
17202
17221
  __name: "SuperDoc",
17203
17222
  emits: ["selection-update"],
17204
17223
  setup(__props, { emit: __emit }) {
17205
- const PdfViewer = defineAsyncComponent(() => import("./PdfViewer-C2rB3UFf.es.js"));
17224
+ const PdfViewer = defineAsyncComponent(() => import("./PdfViewer-BFtgOHmf.es.js"));
17206
17225
  const superdocStore = useSuperdocStore();
17207
17226
  const commentsStore = useCommentsStore();
17208
17227
  const {
@@ -17966,7 +17985,7 @@ class SuperDoc extends EventEmitter {
17966
17985
  this.config.colors = shuffleArray(this.config.colors);
17967
17986
  this.userColorMap = /* @__PURE__ */ new Map();
17968
17987
  this.colorIndex = 0;
17969
- this.version = "0.34.9";
17988
+ this.version = "0.35.2";
17970
17989
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
17971
17990
  this.superdocId = config.superdocId || v4();
17972
17991
  this.colors = this.config.colors;
@@ -18127,6 +18146,28 @@ class SuperDoc extends EventEmitter {
18127
18146
  async #initCollaboration({ collaboration: collaborationModuleConfig, comments: commentsConfig = {} } = {}) {
18128
18147
  if (!collaborationModuleConfig) return this.config.documents;
18129
18148
  this.isCollaborative = true;
18149
+ const { ydoc: externalYdoc, provider: externalProvider } = collaborationModuleConfig;
18150
+ if (externalYdoc && externalProvider) {
18151
+ this.ydoc = externalYdoc;
18152
+ this.provider = externalProvider;
18153
+ setupAwarenessHandler(externalProvider, this, this.config.user);
18154
+ if (!this.config.documents || this.config.documents.length === 0) {
18155
+ this.config.documents = [
18156
+ {
18157
+ id: v4(),
18158
+ type: DOCX,
18159
+ name: "document.docx"
18160
+ }
18161
+ ];
18162
+ }
18163
+ this.config.documents.forEach((doc) => {
18164
+ doc.ydoc = externalYdoc;
18165
+ doc.provider = externalProvider;
18166
+ doc.role = this.config.role;
18167
+ });
18168
+ initCollaborationComments(this);
18169
+ return this.config.documents;
18170
+ }
18130
18171
  if (collaborationModuleConfig.providerType === "hocuspocus") {
18131
18172
  this.config.socket = new HocuspocusProviderWebsocket({
18132
18173
  url: collaborationModuleConfig.url
@@ -33139,7 +33139,7 @@ function importCommentData({ docx, editor, converter }) {
33139
33139
  const trackedDeletedText = attributes["custom:trackedDeletedText"] !== "null" ? attributes["custom:trackedDeletedText"] : null;
33140
33140
  const date = new Date(createdDate);
33141
33141
  const unixTimestampMs = date.getTime();
33142
- const parsedComment = nodeListHandler.handler({
33142
+ const parsedElements = nodeListHandler.handler({
33143
33143
  nodes: el.elements,
33144
33144
  nodeListHandler,
33145
33145
  docx,
@@ -33147,7 +33147,7 @@ function importCommentData({ docx, editor, converter }) {
33147
33147
  converter,
33148
33148
  path: [el]
33149
33149
  });
33150
- const { attrs } = parsedComment[0];
33150
+ const { attrs } = parsedElements[0];
33151
33151
  const paraId = attrs["w14:paraId"];
33152
33152
  return {
33153
33153
  commentId: internalId || v4(),
@@ -33155,7 +33155,8 @@ function importCommentData({ docx, editor, converter }) {
33155
33155
  creatorName: authorName,
33156
33156
  creatorEmail: authorEmail,
33157
33157
  createdTime: unixTimestampMs,
33158
- textJson: parsedComment[0],
33158
+ textJson: parsedElements[0],
33159
+ elements: parsedElements,
33159
33160
  initials,
33160
33161
  paraId,
33161
33162
  trackedChange,
@@ -33177,7 +33178,12 @@ const generateCommentsWithExtendedData = ({ docx, comments }) => {
33177
33178
  const { elements = [] } = initialElements[0] ?? {};
33178
33179
  const commentEx = elements.filter((el) => el.name === "w15:commentEx");
33179
33180
  return comments.map((comment) => {
33180
- const extendedDef = commentEx.find((ce2) => ce2.attributes["w15:paraId"] === comment.paraId);
33181
+ const extendedDef = commentEx.find((ce2) => {
33182
+ const isIncludedInCommentElements = comment.elements.some(
33183
+ (el) => el.attrs["w14:paraId"] === ce2.attributes["w15:paraId"]
33184
+ );
33185
+ return isIncludedInCommentElements;
33186
+ });
33181
33187
  if (!extendedDef) return { ...comment, isDone: comment.isDone ?? false };
33182
33188
  const { isDone, paraIdParent } = getExtendedDetails(extendedDef);
33183
33189
  let parentComment;
@@ -35797,7 +35803,7 @@ const _SuperConverter = class _SuperConverter2 {
35797
35803
  static getStoredSuperdocVersion(docx) {
35798
35804
  return _SuperConverter2.getStoredCustomProperty(docx, "SuperdocVersion");
35799
35805
  }
35800
- static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "0.34.9") {
35806
+ static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "0.35.2") {
35801
35807
  return _SuperConverter2.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
35802
35808
  }
35803
35809
  /**
@@ -47956,6 +47962,12 @@ const toggleNode = (typeOrName, toggleTypeOrName, attrs = {}) => ({ state: state
47956
47962
  const selectAll = () => ({ state: state2, dispatch }) => selectAll$1(state2, dispatch);
47957
47963
  const deleteSelection = () => ({ state: state2, tr, dispatch }) => {
47958
47964
  const { from: from2, to, empty: empty2 } = state2.selection;
47965
+ if (document && document.getSelection) {
47966
+ const currentDomSelection = document.getSelection();
47967
+ if (currentDomSelection?.baseNode?.data?.length == 1) {
47968
+ return false;
47969
+ }
47970
+ }
47959
47971
  if (empty2) {
47960
47972
  return deleteSelection$1(state2, dispatch);
47961
47973
  }
@@ -49526,12 +49538,41 @@ const Keymap = Extension.create({
49526
49538
  const Editable = Extension.create({
49527
49539
  name: "editable",
49528
49540
  addPmPlugins() {
49541
+ const editor = this.editor;
49529
49542
  const editablePlugin = new Plugin({
49530
49543
  key: new PluginKey("editable"),
49531
49544
  props: {
49532
- editable: () => {
49533
- return this.editor.options.editable;
49534
- }
49545
+ editable: () => editor.options.editable,
49546
+ handleDOMEvents: {
49547
+ beforeinput: (_view, event) => {
49548
+ if (!editor.options.editable) {
49549
+ event.preventDefault();
49550
+ return true;
49551
+ }
49552
+ return false;
49553
+ },
49554
+ mousedown: (_view, event) => {
49555
+ if (!editor.options.editable) {
49556
+ event.preventDefault();
49557
+ return true;
49558
+ }
49559
+ return false;
49560
+ },
49561
+ focus: (view, event) => {
49562
+ if (!editor.options.editable) {
49563
+ event.preventDefault();
49564
+ view.dom.blur();
49565
+ return true;
49566
+ }
49567
+ return false;
49568
+ }
49569
+ },
49570
+ handleClick: () => !editor.options.editable,
49571
+ handleDoubleClick: () => !editor.options.editable,
49572
+ handleTripleClick: () => !editor.options.editable,
49573
+ handleKeyDown: () => !editor.options.editable,
49574
+ handlePaste: () => !editor.options.editable,
49575
+ handleDrop: () => !editor.options.editable
49535
49576
  }
49536
49577
  });
49537
49578
  return [editablePlugin];
@@ -50542,12 +50583,14 @@ const prepareCommentsForImport = (doc2, tr, schema, converter) => {
50542
50583
  importedId: node.attrs["w:id"]
50543
50584
  });
50544
50585
  if (type2.name === "commentRangeStart") {
50545
- toMark.push({
50546
- commentId: resolvedCommentId,
50547
- importedId,
50548
- internal,
50549
- start: pos
50550
- });
50586
+ if (!matchingImportedComment.isDone) {
50587
+ toMark.push({
50588
+ commentId: resolvedCommentId,
50589
+ importedId,
50590
+ internal,
50591
+ start: pos
50592
+ });
50593
+ }
50551
50594
  ensureFallbackComment({
50552
50595
  converter,
50553
50596
  matchingImportedComment,
@@ -54106,7 +54149,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
54106
54149
  { default: remarkStringify },
54107
54150
  { default: remarkGfm }
54108
54151
  ] = await Promise.all([
54109
- Promise.resolve().then(() => require("./index-CHtB4uAl-D-zQo-Zr.cjs")),
54152
+ Promise.resolve().then(() => require("./index-CzChRmiA-Db3kkVxc.cjs")),
54110
54153
  Promise.resolve().then(() => require("./index-DRCvimau-H4Ck3S9a.cjs")),
54111
54154
  Promise.resolve().then(() => require("./index-C_x_N6Uh-Db3CUJMX.cjs")),
54112
54155
  Promise.resolve().then(() => require("./index-D_sWOSiG-BtDZzJ6I.cjs")),
@@ -54216,7 +54259,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
54216
54259
  Object.entries(this.converter.convertedXml).forEach(([name, json2]) => {
54217
54260
  if (name.includes("header") || name.includes("footer")) {
54218
54261
  const resultXml = this.converter.schemaToXml(json2.elements[0]);
54219
- updatedHeadersFooters[name] = String(resultXml);
54262
+ updatedHeadersFooters[name] = String(resultXml.replace(/\[\[sdspace\]\]/g, ""));
54220
54263
  }
54221
54264
  });
54222
54265
  const numberingData = this.converter.convertedXml["word/numbering.xml"];
@@ -54324,7 +54367,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
54324
54367
  * @returns {Object | void} Migration results
54325
54368
  */
54326
54369
  processCollaborationMigrations() {
54327
- console.debug("[checkVersionMigrations] Current editor version", "0.34.9");
54370
+ console.debug("[checkVersionMigrations] Current editor version", "0.35.2");
54328
54371
  if (!this.options.ydoc) return;
54329
54372
  const metaMap = this.options.ydoc.getMap("meta");
54330
54373
  let docVersion = metaMap.get("version");
@@ -72113,11 +72156,11 @@ const getChangesByIdToResolve = (state2, id) => {
72113
72156
  break;
72114
72157
  }
72115
72158
  const [left2, right2] = direction < 0 ? [neighbor, currentChange] : [currentChange, neighbor];
72116
- if (!areDirectlyConnected(left2, right2)) {
72117
- break;
72118
- }
72119
72159
  const sharesId = neighbor.mark.attrs.id === matchingId;
72120
72160
  const complementary = isComplementaryPair(currentChange.mark.type.name, neighbor.mark.type.name);
72161
+ if (!sharesId && !areDirectlyConnected(left2, right2)) {
72162
+ break;
72163
+ }
72121
72164
  if (!sharesId && !complementary) {
72122
72165
  break;
72123
72166
  }
@@ -93217,11 +93260,29 @@ const _sfc_main$1 = {
93217
93260
  delete props.options.content;
93218
93261
  const ydoc = props.options.ydoc;
93219
93262
  const provider = props.options.collaborationProvider;
93220
- const handleSynced = () => {
93221
- pollForMetaMapData(ydoc);
93222
- provider.off("synced", handleSynced);
93263
+ const waitForSync = () => {
93264
+ if (provider.isSynced || provider.synced) return Promise.resolve();
93265
+ return new Promise((resolve) => {
93266
+ const onSync = (synced) => {
93267
+ if (synced === false) return;
93268
+ provider.off("synced", onSync);
93269
+ provider.off("sync", onSync);
93270
+ resolve();
93271
+ };
93272
+ provider.on("synced", onSync);
93273
+ provider.on("sync", onSync);
93274
+ });
93223
93275
  };
93224
- provider.on("synced", handleSynced);
93276
+ waitForSync().then(async () => {
93277
+ const metaMap = ydoc.getMap("meta");
93278
+ if (metaMap.has("docx")) {
93279
+ pollForMetaMapData(ydoc);
93280
+ } else {
93281
+ props.options.isNewFile = true;
93282
+ const fileData = await loadNewFileData();
93283
+ if (fileData) initEditor(fileData);
93284
+ }
93285
+ });
93225
93286
  }
93226
93287
  };
93227
93288
  const getExtensions = () => {
@@ -93405,7 +93466,7 @@ const _sfc_main$1 = {
93405
93466
  };
93406
93467
  }
93407
93468
  };
93408
- const SuperEditor = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-cd3558fe"]]);
93469
+ const SuperEditor = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-86fdd359"]]);
93409
93470
  const _hoisted_1 = ["innerHTML"];
93410
93471
  const _sfc_main = {
93411
93472
  __name: "SuperInput",
@@ -33122,7 +33122,7 @@ function importCommentData({ docx, editor, converter }) {
33122
33122
  const trackedDeletedText = attributes["custom:trackedDeletedText"] !== "null" ? attributes["custom:trackedDeletedText"] : null;
33123
33123
  const date = new Date(createdDate);
33124
33124
  const unixTimestampMs = date.getTime();
33125
- const parsedComment = nodeListHandler.handler({
33125
+ const parsedElements = nodeListHandler.handler({
33126
33126
  nodes: el.elements,
33127
33127
  nodeListHandler,
33128
33128
  docx,
@@ -33130,7 +33130,7 @@ function importCommentData({ docx, editor, converter }) {
33130
33130
  converter,
33131
33131
  path: [el]
33132
33132
  });
33133
- const { attrs } = parsedComment[0];
33133
+ const { attrs } = parsedElements[0];
33134
33134
  const paraId = attrs["w14:paraId"];
33135
33135
  return {
33136
33136
  commentId: internalId || v4(),
@@ -33138,7 +33138,8 @@ function importCommentData({ docx, editor, converter }) {
33138
33138
  creatorName: authorName,
33139
33139
  creatorEmail: authorEmail,
33140
33140
  createdTime: unixTimestampMs,
33141
- textJson: parsedComment[0],
33141
+ textJson: parsedElements[0],
33142
+ elements: parsedElements,
33142
33143
  initials,
33143
33144
  paraId,
33144
33145
  trackedChange,
@@ -33160,7 +33161,12 @@ const generateCommentsWithExtendedData = ({ docx, comments }) => {
33160
33161
  const { elements = [] } = initialElements[0] ?? {};
33161
33162
  const commentEx = elements.filter((el) => el.name === "w15:commentEx");
33162
33163
  return comments.map((comment) => {
33163
- const extendedDef = commentEx.find((ce2) => ce2.attributes["w15:paraId"] === comment.paraId);
33164
+ const extendedDef = commentEx.find((ce2) => {
33165
+ const isIncludedInCommentElements = comment.elements.some(
33166
+ (el) => el.attrs["w14:paraId"] === ce2.attributes["w15:paraId"]
33167
+ );
33168
+ return isIncludedInCommentElements;
33169
+ });
33164
33170
  if (!extendedDef) return { ...comment, isDone: comment.isDone ?? false };
33165
33171
  const { isDone, paraIdParent } = getExtendedDetails(extendedDef);
33166
33172
  let parentComment;
@@ -35780,7 +35786,7 @@ const _SuperConverter = class _SuperConverter2 {
35780
35786
  static getStoredSuperdocVersion(docx) {
35781
35787
  return _SuperConverter2.getStoredCustomProperty(docx, "SuperdocVersion");
35782
35788
  }
35783
- static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "0.34.9") {
35789
+ static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "0.35.2") {
35784
35790
  return _SuperConverter2.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
35785
35791
  }
35786
35792
  /**
@@ -47939,6 +47945,12 @@ const toggleNode = (typeOrName, toggleTypeOrName, attrs = {}) => ({ state: state
47939
47945
  const selectAll = () => ({ state: state2, dispatch }) => selectAll$1(state2, dispatch);
47940
47946
  const deleteSelection = () => ({ state: state2, tr, dispatch }) => {
47941
47947
  const { from: from2, to, empty: empty2 } = state2.selection;
47948
+ if (document && document.getSelection) {
47949
+ const currentDomSelection = document.getSelection();
47950
+ if (currentDomSelection?.baseNode?.data?.length == 1) {
47951
+ return false;
47952
+ }
47953
+ }
47942
47954
  if (empty2) {
47943
47955
  return deleteSelection$1(state2, dispatch);
47944
47956
  }
@@ -49509,12 +49521,41 @@ const Keymap = Extension.create({
49509
49521
  const Editable = Extension.create({
49510
49522
  name: "editable",
49511
49523
  addPmPlugins() {
49524
+ const editor = this.editor;
49512
49525
  const editablePlugin = new Plugin({
49513
49526
  key: new PluginKey("editable"),
49514
49527
  props: {
49515
- editable: () => {
49516
- return this.editor.options.editable;
49517
- }
49528
+ editable: () => editor.options.editable,
49529
+ handleDOMEvents: {
49530
+ beforeinput: (_view, event) => {
49531
+ if (!editor.options.editable) {
49532
+ event.preventDefault();
49533
+ return true;
49534
+ }
49535
+ return false;
49536
+ },
49537
+ mousedown: (_view, event) => {
49538
+ if (!editor.options.editable) {
49539
+ event.preventDefault();
49540
+ return true;
49541
+ }
49542
+ return false;
49543
+ },
49544
+ focus: (view, event) => {
49545
+ if (!editor.options.editable) {
49546
+ event.preventDefault();
49547
+ view.dom.blur();
49548
+ return true;
49549
+ }
49550
+ return false;
49551
+ }
49552
+ },
49553
+ handleClick: () => !editor.options.editable,
49554
+ handleDoubleClick: () => !editor.options.editable,
49555
+ handleTripleClick: () => !editor.options.editable,
49556
+ handleKeyDown: () => !editor.options.editable,
49557
+ handlePaste: () => !editor.options.editable,
49558
+ handleDrop: () => !editor.options.editable
49518
49559
  }
49519
49560
  });
49520
49561
  return [editablePlugin];
@@ -50525,12 +50566,14 @@ const prepareCommentsForImport = (doc2, tr, schema, converter) => {
50525
50566
  importedId: node.attrs["w:id"]
50526
50567
  });
50527
50568
  if (type2.name === "commentRangeStart") {
50528
- toMark.push({
50529
- commentId: resolvedCommentId,
50530
- importedId,
50531
- internal,
50532
- start: pos
50533
- });
50569
+ if (!matchingImportedComment.isDone) {
50570
+ toMark.push({
50571
+ commentId: resolvedCommentId,
50572
+ importedId,
50573
+ internal,
50574
+ start: pos
50575
+ });
50576
+ }
50534
50577
  ensureFallbackComment({
50535
50578
  converter,
50536
50579
  matchingImportedComment,
@@ -54089,7 +54132,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
54089
54132
  { default: remarkStringify },
54090
54133
  { default: remarkGfm }
54091
54134
  ] = await Promise.all([
54092
- import("./index-CHtB4uAl-BS8u99OE.es.js"),
54135
+ import("./index-CzChRmiA-C73DMMSu.es.js"),
54093
54136
  import("./index-DRCvimau-Cw339678.es.js"),
54094
54137
  import("./index-C_x_N6Uh-DJn8hIEt.es.js"),
54095
54138
  import("./index-D_sWOSiG-DE96TaT5.es.js"),
@@ -54199,7 +54242,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
54199
54242
  Object.entries(this.converter.convertedXml).forEach(([name, json2]) => {
54200
54243
  if (name.includes("header") || name.includes("footer")) {
54201
54244
  const resultXml = this.converter.schemaToXml(json2.elements[0]);
54202
- updatedHeadersFooters[name] = String(resultXml);
54245
+ updatedHeadersFooters[name] = String(resultXml.replace(/\[\[sdspace\]\]/g, ""));
54203
54246
  }
54204
54247
  });
54205
54248
  const numberingData = this.converter.convertedXml["word/numbering.xml"];
@@ -54307,7 +54350,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
54307
54350
  * @returns {Object | void} Migration results
54308
54351
  */
54309
54352
  processCollaborationMigrations() {
54310
- console.debug("[checkVersionMigrations] Current editor version", "0.34.9");
54353
+ console.debug("[checkVersionMigrations] Current editor version", "0.35.2");
54311
54354
  if (!this.options.ydoc) return;
54312
54355
  const metaMap = this.options.ydoc.getMap("meta");
54313
54356
  let docVersion = metaMap.get("version");
@@ -72096,11 +72139,11 @@ const getChangesByIdToResolve = (state2, id) => {
72096
72139
  break;
72097
72140
  }
72098
72141
  const [left2, right2] = direction < 0 ? [neighbor, currentChange] : [currentChange, neighbor];
72099
- if (!areDirectlyConnected(left2, right2)) {
72100
- break;
72101
- }
72102
72142
  const sharesId = neighbor.mark.attrs.id === matchingId;
72103
72143
  const complementary = isComplementaryPair(currentChange.mark.type.name, neighbor.mark.type.name);
72144
+ if (!sharesId && !areDirectlyConnected(left2, right2)) {
72145
+ break;
72146
+ }
72104
72147
  if (!sharesId && !complementary) {
72105
72148
  break;
72106
72149
  }
@@ -93200,11 +93243,29 @@ const _sfc_main$1 = {
93200
93243
  delete props.options.content;
93201
93244
  const ydoc = props.options.ydoc;
93202
93245
  const provider = props.options.collaborationProvider;
93203
- const handleSynced = () => {
93204
- pollForMetaMapData(ydoc);
93205
- provider.off("synced", handleSynced);
93246
+ const waitForSync = () => {
93247
+ if (provider.isSynced || provider.synced) return Promise.resolve();
93248
+ return new Promise((resolve) => {
93249
+ const onSync = (synced) => {
93250
+ if (synced === false) return;
93251
+ provider.off("synced", onSync);
93252
+ provider.off("sync", onSync);
93253
+ resolve();
93254
+ };
93255
+ provider.on("synced", onSync);
93256
+ provider.on("sync", onSync);
93257
+ });
93206
93258
  };
93207
- provider.on("synced", handleSynced);
93259
+ waitForSync().then(async () => {
93260
+ const metaMap = ydoc.getMap("meta");
93261
+ if (metaMap.has("docx")) {
93262
+ pollForMetaMapData(ydoc);
93263
+ } else {
93264
+ props.options.isNewFile = true;
93265
+ const fileData = await loadNewFileData();
93266
+ if (fileData) initEditor(fileData);
93267
+ }
93268
+ });
93208
93269
  }
93209
93270
  };
93210
93271
  const getExtensions = () => {
@@ -93388,7 +93449,7 @@ const _sfc_main$1 = {
93388
93449
  };
93389
93450
  }
93390
93451
  };
93391
- const SuperEditor = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-cd3558fe"]]);
93452
+ const SuperEditor = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-86fdd359"]]);
93392
93453
  const _hoisted_1 = ["innerHTML"];
93393
93454
  const _sfc_main = {
93394
93455
  __name: "SuperInput",
@@ -1 +1 @@
1
- {"version":3,"file":"use-document.d.ts","sourceRoot":"","sources":["../../../../../src/composables/use-document.js"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4GC"}
1
+ {"version":3,"file":"use-document.d.ts","sourceRoot":"","sources":["../../../../../src/composables/use-document.js"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6GC"}