@harbour-enterprises/superdoc 0.13.0-next.3 → 0.13.0-next.4

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 (25) hide show
  1. package/dist/chunks/{super-editor.es-CaiAvJmI.es.js → super-editor.es-BLihY9I3.es.js} +33 -10
  2. package/dist/chunks/{super-editor.es-C1r2fKvd.cjs → super-editor.es-C8bnXrNN.cjs} +33 -10
  3. package/dist/stores/comments-store.d.ts.map +1 -1
  4. package/dist/super-editor/ai-writer.es.js +2 -2
  5. package/dist/super-editor/chunks/{converter-DifQiKXL.js → converter-IP9PazoB.js} +2 -2
  6. package/dist/super-editor/chunks/{docx-zipper-0V4s80fa.js → docx-zipper-CesiGAcg.js} +1 -1
  7. package/dist/super-editor/chunks/{editor-Cu6WivrX.js → editor-2jdmUJVn.js} +33 -10
  8. package/dist/super-editor/chunks/{toolbar-VX_23hqe.js → toolbar-BwVRLL78.js} +2 -2
  9. package/dist/super-editor/converter.es.js +1 -1
  10. package/dist/super-editor/docx-zipper.es.js +2 -2
  11. package/dist/super-editor/editor.es.js +3 -3
  12. package/dist/super-editor/extensions/image/imageHelpers/imagePositionPlugin.d.ts.map +1 -1
  13. package/dist/super-editor/extensions/ordered-list/helpers/orderedListSyncPlugin.d.ts.map +1 -1
  14. package/dist/super-editor/extensions/paragraph/paragraph.d.ts.map +1 -1
  15. package/dist/super-editor/extensions/tab/tab.d.ts.map +1 -1
  16. package/dist/super-editor/file-zipper.es.js +1 -1
  17. package/dist/super-editor/super-editor.es.js +6 -6
  18. package/dist/super-editor/toolbar.es.js +2 -2
  19. package/dist/super-editor.cjs +1 -1
  20. package/dist/super-editor.es.js +1 -1
  21. package/dist/superdoc.cjs +23 -7
  22. package/dist/superdoc.es.js +24 -8
  23. package/dist/superdoc.umd.js +55 -16
  24. package/dist/superdoc.umd.js.map +1 -1
  25. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
- import { o as index$1, C as CommentsPluginKey, f as TrackChangesBasePluginKey, E as Editor, l as getRichTextExtensions, d as SuperInput, A as AIWriter, c as SuperEditor, e as SuperToolbar, g as createZip } from "./chunks/super-editor.es-CaiAvJmI.es.js";
2
- import { a, S, i, n } from "./chunks/super-editor.es-CaiAvJmI.es.js";
1
+ import { o as index$1, C as CommentsPluginKey, f as TrackChangesBasePluginKey, E as Editor, l as getRichTextExtensions, d as SuperInput, A as AIWriter, c as SuperEditor, e as SuperToolbar, g as createZip } from "./chunks/super-editor.es-BLihY9I3.es.js";
2
+ import { a, S, i, n } from "./chunks/super-editor.es-BLihY9I3.es.js";
3
3
  import { Y as effectScope, r as ref, Z as markRaw, p as process$1, _ as toRaw, a as computed, $ as isRef, a0 as isReactive, D as toRef, i as inject, q as getCurrentInstance, l as watch, y as unref, a1 as hasInjectionContext, N as reactive, u as nextTick, a2 as getCurrentScope, a3 as onScopeDispose, a4 as toRefs, g as global$1, K as shallowRef, O as readonly, j as onMounted, k as onBeforeUnmount, h as onBeforeMount, U as onActivated, s as onDeactivated, A as createTextVNode, F as Fragment, R as Comment, m as defineComponent, E as provide, I as withDirectives, C as h, V as Teleport, S as renderSlot, W as isVNode, J as watchEffect, P as Transition, G as mergeProps, Q as vShow, H as cloneVNode, T as Text, b as createElementBlock, o as openBlock, t as toDisplayString, x as createVNode, z as withCtx, f as createBaseVNode, B as normalizeStyle, e as createCommentVNode, v as createBlock, w as withModifiers, n as normalizeClass, a5 as resolveDirective, d as renderList, c as createApp, X as onUnmounted, a6 as resolveDynamicComponent } from "./chunks/vue-Bi1uWinj.es.js";
4
4
  import { B as Buffer$2 } from "./chunks/jszip-DckFs3A7.es.js";
5
5
  import { B as BlankDOCX } from "./chunks/blank-docx-iwdyG9RH.es.js";
@@ -4334,14 +4334,29 @@ const useCommentsStore = /* @__PURE__ */ defineStore("comments", () => {
4334
4334
  });
4335
4335
  addComment({ superdoc: superdoc2, comment: newComment });
4336
4336
  });
4337
- const trackedChanges = index$1.getTrackChanges(editor.state);
4338
- trackedChanges.forEach(({ mark }) => {
4337
+ setTimeout(() => {
4338
+ createCommentForTrackChanges(editor);
4339
+ }, 0);
4340
+ };
4341
+ const createCommentForTrackChanges = (editor) => {
4342
+ let trackedChanges = index$1.getTrackChanges(editor.state);
4343
+ let isLargeDoc = editor.state.doc.nodeSize >= 1e5;
4344
+ if (isLargeDoc && trackedChanges.length) {
4345
+ trackedChanges = trackedChanges.slice(0, 100);
4346
+ }
4347
+ trackedChanges.forEach(({ mark }, index2) => {
4348
+ console.debug(`Create comment for track change: ${index2}`);
4349
+ const { dispatch } = editor.view;
4350
+ const { tr } = editor.view.state;
4339
4351
  const foundComment = commentsList.value.find((i2) => i2.commentId === mark.attrs.id);
4352
+ const isLastIteration = trackedChanges.length === index2 + 1;
4340
4353
  if (foundComment) {
4354
+ if (isLastIteration) {
4355
+ tr.setMeta(CommentsPluginKey, { type: "force" });
4356
+ dispatch(tr);
4357
+ }
4341
4358
  return;
4342
4359
  }
4343
- const { dispatch } = editor.view;
4344
- const { tr } = editor.view.state;
4345
4360
  const markMetaKeys = {
4346
4361
  trackInsert: "insertedMark",
4347
4362
  trackDelete: "deletionMark",
@@ -4349,7 +4364,8 @@ const useCommentsStore = /* @__PURE__ */ defineStore("comments", () => {
4349
4364
  };
4350
4365
  const markKeyName = markMetaKeys[mark.type.name];
4351
4366
  if (markKeyName) {
4352
- tr.setMeta(CommentsPluginKey, { type: "force" });
4367
+ if (isLastIteration) tr.setMeta(CommentsPluginKey, { type: "force" });
4368
+ tr.setMeta(CommentsPluginKey, { type: "forceTrackChanges" });
4353
4369
  tr.setMeta(TrackChangesBasePluginKey, { [markKeyName]: mark });
4354
4370
  dispatch(tr);
4355
4371
  }
@@ -47773,7 +47789,7 @@ class SuperDoc extends EventEmitter {
47773
47789
  this.config.colors = shuffleArray(this.config.colors);
47774
47790
  this.userColorMap = /* @__PURE__ */ new Map();
47775
47791
  this.colorIndex = 0;
47776
- this.version = "0.13.0-next.3";
47792
+ this.version = "0.13.0-next.4";
47777
47793
  console.debug("🦋 [superdoc] Using SuperDoc version:", this.version);
47778
47794
  this.superdocId = config.superdocId || v4();
47779
47795
  this.colors = this.config.colors;
@@ -30770,7 +30770,7 @@
30770
30770
  return;
30771
30771
  }
30772
30772
  }
30773
- static updateDocumentVersion(docx = this.convertedXml, version2 = "0.13.0-next.3") {
30773
+ static updateDocumentVersion(docx = this.convertedXml, version2 = "0.13.0-next.4") {
30774
30774
  const customLocation = "docProps/custom.xml";
30775
30775
  if (!docx[customLocation]) {
30776
30776
  docx[customLocation] = generateCustomXml();
@@ -31237,7 +31237,7 @@
31237
31237
  function generateCustomXml() {
31238
31238
  return DEFAULT_CUSTOM_XML;
31239
31239
  }
31240
- function generateSuperdocVersion(pid = 2, version2 = "0.13.0-next.3") {
31240
+ function generateSuperdocVersion(pid = 2, version2 = "0.13.0-next.4") {
31241
31241
  return {
31242
31242
  type: "element",
31243
31243
  name: "property",
@@ -46759,7 +46759,7 @@
46759
46759
  if (isPaginationInit) shouldUpdate = true;
46760
46760
  const meta = tr.getMeta(CommentsPluginKey);
46761
46761
  const { type: type2 } = meta || {};
46762
- if (type2 === "force") shouldUpdate = true;
46762
+ if (type2 === "force" || type2 === "forceTrackChanges") shouldUpdate = true;
46763
46763
  if (!isPaginationInit && !shouldUpdate && meta && meta.decorations) {
46764
46764
  return {
46765
46765
  ...pluginState,
@@ -48614,7 +48614,7 @@
48614
48614
  * @returns {Object | void} Migration results
48615
48615
  */
48616
48616
  processCollaborationMigrations() {
48617
- console.debug("[checkVersionMigrations] Current editor version", "0.13.0-next.3");
48617
+ console.debug("[checkVersionMigrations] Current editor version", "0.13.0-next.4");
48618
48618
  if (!this.options.ydoc) return;
48619
48619
  const metaMap = this.options.ydoc.getMap("meta");
48620
48620
  let docVersion = metaMap.get("version");
@@ -50313,6 +50313,9 @@
50313
50313
  let { doc: doc2, tr } = newState;
50314
50314
  let listsBySyncId = {};
50315
50315
  doc2.descendants((node2, pos) => {
50316
+ if (node2.type.name === "paragraph") {
50317
+ return false;
50318
+ }
50316
50319
  if (node2.type.name === "orderedList" && !!node2.attrs.syncId) {
50317
50320
  let syncId = node2.attrs.syncId;
50318
50321
  if (!listsBySyncId[syncId]) listsBySyncId[syncId] = [];
@@ -50442,6 +50445,9 @@
50442
50445
  let { doc: doc2 } = state2;
50443
50446
  let map2 = /* @__PURE__ */ new Map();
50444
50447
  doc2.descendants((node2, pos) => {
50448
+ if (node2.type.name === "paragraph") {
50449
+ return false;
50450
+ }
50445
50451
  let { attrs } = node2;
50446
50452
  let isListItem = node2.type.name === "listItem";
50447
50453
  let hasListLevel = !!attrs.listLevel?.length;
@@ -50462,6 +50468,9 @@
50462
50468
  let { doc: doc2 } = state2;
50463
50469
  let allItems = [];
50464
50470
  doc2.descendants((node2, pos) => {
50471
+ if (node2.type.name === "paragraph") {
50472
+ return false;
50473
+ }
50465
50474
  let isListItem = node2.type.name === "listItem";
50466
50475
  let $pos = doc2.resolve(pos);
50467
50476
  if (isListItem && $pos.parent === list) {
@@ -50837,7 +50846,15 @@
50837
50846
  let { doc: doc2, storedMarks } = state2;
50838
50847
  let decorations = [];
50839
50848
  if (Array.isArray(storedMarks)) marks.push(...storedMarks);
50840
- let listItems = findChildren$4(doc2, (node2) => node2.type.name === "listItem");
50849
+ let listItems = [];
50850
+ doc2.descendants((node2, pos) => {
50851
+ if (node2.type.name === "paragraph") {
50852
+ return false;
50853
+ }
50854
+ if (node2.type.name === "listItem") {
50855
+ listItems.push({ node: node2, pos });
50856
+ }
50857
+ });
50841
50858
  if (!listItems.length) {
50842
50859
  return decorations;
50843
50860
  }
@@ -51414,6 +51431,7 @@
51414
51431
  return DecorationSet.create(state2.doc, decorations);
51415
51432
  },
51416
51433
  apply(tr, oldDecorationSet, oldState, newState) {
51434
+ if (!tr.docChanged) return oldDecorationSet;
51417
51435
  const decorations = getDropcapDecorations(newState, view);
51418
51436
  return DecorationSet.create(newState.doc, decorations);
51419
51437
  }
@@ -51430,11 +51448,14 @@
51430
51448
  const getDropcapDecorations = (state2, view) => {
51431
51449
  let decorations = [];
51432
51450
  state2.doc.descendants((node2, pos) => {
51433
- if (node2.attrs.dropcap?.type === "margin") {
51434
- const width = getDropcapWidth(view, pos);
51435
- decorations.push(
51436
- Decoration.inline(pos, pos + node2.nodeSize, { style: `margin-left: -${width}px;` })
51437
- );
51451
+ if (node2.type.name === "paragraph") {
51452
+ if (node2.attrs.dropcap?.type === "margin") {
51453
+ const width = getDropcapWidth(view, pos);
51454
+ decorations.push(
51455
+ Decoration.inline(pos, pos + node2.nodeSize, { style: `margin-left: -${width}px;` })
51456
+ );
51457
+ }
51458
+ return false;
51438
51459
  }
51439
51460
  });
51440
51461
  return decorations;
@@ -51670,6 +51691,7 @@
51670
51691
  return DecorationSet.create(state2.doc, decorations);
51671
51692
  },
51672
51693
  apply(tr, oldDecorationSet, oldState, newState) {
51694
+ if (!tr.docChanged) return oldDecorationSet;
51673
51695
  const decorations = getTabDecorations(newState, view);
51674
51696
  return DecorationSet.create(newState.doc, decorations);
51675
51697
  }
@@ -56005,6 +56027,7 @@
56005
56027
  return DecorationSet.empty;
56006
56028
  },
56007
56029
  apply(tr, oldDecorationSet, oldState, newState) {
56030
+ if (!tr.docChanged) return oldDecorationSet;
56008
56031
  const decorations = getImagePositionDecorations(newState, view);
56009
56032
  return DecorationSet.create(newState.doc, decorations);
56010
56033
  }
@@ -80448,14 +80471,29 @@ ${reason}`);
80448
80471
  });
80449
80472
  addComment({ superdoc: superdoc2, comment: newComment });
80450
80473
  });
80451
- const trackedChanges = index$2.getTrackChanges(editor.state);
80452
- trackedChanges.forEach(({ mark }) => {
80474
+ setTimeout(() => {
80475
+ createCommentForTrackChanges(editor);
80476
+ }, 0);
80477
+ };
80478
+ const createCommentForTrackChanges = (editor) => {
80479
+ let trackedChanges = index$2.getTrackChanges(editor.state);
80480
+ let isLargeDoc = editor.state.doc.nodeSize >= 1e5;
80481
+ if (isLargeDoc && trackedChanges.length) {
80482
+ trackedChanges = trackedChanges.slice(0, 100);
80483
+ }
80484
+ trackedChanges.forEach(({ mark }, index2) => {
80485
+ console.debug(`Create comment for track change: ${index2}`);
80486
+ const { dispatch } = editor.view;
80487
+ const { tr } = editor.view.state;
80453
80488
  const foundComment = commentsList.value.find((i2) => i2.commentId === mark.attrs.id);
80489
+ const isLastIteration = trackedChanges.length === index2 + 1;
80454
80490
  if (foundComment) {
80491
+ if (isLastIteration) {
80492
+ tr.setMeta(CommentsPluginKey, { type: "force" });
80493
+ dispatch(tr);
80494
+ }
80455
80495
  return;
80456
80496
  }
80457
- const { dispatch } = editor.view;
80458
- const { tr } = editor.view.state;
80459
80497
  const markMetaKeys = {
80460
80498
  trackInsert: "insertedMark",
80461
80499
  trackDelete: "deletionMark",
@@ -80463,7 +80501,8 @@ ${reason}`);
80463
80501
  };
80464
80502
  const markKeyName = markMetaKeys[mark.type.name];
80465
80503
  if (markKeyName) {
80466
- tr.setMeta(CommentsPluginKey, { type: "force" });
80504
+ if (isLastIteration) tr.setMeta(CommentsPluginKey, { type: "force" });
80505
+ tr.setMeta(CommentsPluginKey, { type: "forceTrackChanges" });
80467
80506
  tr.setMeta(TrackChangesBasePluginKey, { [markKeyName]: mark });
80468
80507
  dispatch(tr);
80469
80508
  }
@@ -93238,7 +93277,7 @@ ${style2}
93238
93277
  this.config.colors = shuffleArray(this.config.colors);
93239
93278
  this.userColorMap = /* @__PURE__ */ new Map();
93240
93279
  this.colorIndex = 0;
93241
- this.version = "0.13.0-next.3";
93280
+ this.version = "0.13.0-next.4";
93242
93281
  console.debug("🦋 [superdoc] Using SuperDoc version:", this.version);
93243
93282
  this.superdocId = config.superdocId || v4();
93244
93283
  this.colors = this.config.colors;