@harbour-enterprises/superdoc 0.28.0-next.11 → 0.28.0-next.12

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 (28) hide show
  1. package/dist/chunks/{PdfViewer-CLpN99Rl.es.js → PdfViewer-BsJq49rR.es.js} +1 -1
  2. package/dist/chunks/{PdfViewer-CvsrAT4c.cjs → PdfViewer-D8L8mpOs.cjs} +1 -1
  3. package/dist/chunks/{index-DL9bff78-Cf4UBVvQ.cjs → index-BNr0wgOU-Bg5kSvF0.cjs} +1 -1
  4. package/dist/chunks/{index-DL9bff78-8izww2lB.es.js → index-BNr0wgOU-j0xGZdr7.es.js} +1 -1
  5. package/dist/chunks/{index-CNPV5EVY.es.js → index-ByV1n--x.es.js} +3 -3
  6. package/dist/chunks/{index-sLveeSfi.cjs → index-x4srxOl3.cjs} +3 -3
  7. package/dist/chunks/{super-editor.es-0SXIzzbj.es.js → super-editor.es-C0LbO3l0.es.js} +103 -45
  8. package/dist/chunks/{super-editor.es-Dy32MdYk.cjs → super-editor.es-CANt5-KH.cjs} +103 -45
  9. package/dist/super-editor/ai-writer.es.js +2 -2
  10. package/dist/super-editor/chunks/{converter-DMwo26F4.js → converter-AHcrZseN.js} +1 -1
  11. package/dist/super-editor/chunks/{docx-zipper-CuoYR_fZ.js → docx-zipper-BAc8o9wi.js} +1 -1
  12. package/dist/super-editor/chunks/{editor-BQ9mPcm5.js → editor-BwNyV6ke.js} +104 -46
  13. package/dist/super-editor/chunks/{index-DL9bff78.js → index-BNr0wgOU.js} +1 -1
  14. package/dist/super-editor/chunks/{toolbar-D59d-aMm.js → toolbar-Bx1rJX7n.js} +2 -2
  15. package/dist/super-editor/converter.es.js +1 -1
  16. package/dist/super-editor/docx-zipper.es.js +2 -2
  17. package/dist/super-editor/editor.es.js +3 -3
  18. package/dist/super-editor/file-zipper.es.js +1 -1
  19. package/dist/super-editor/super-editor/src/extensions/tab/helpers/tabDecorations.d.ts +4 -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.es.js +1 -1
  24. package/dist/superdoc.cjs +2 -2
  25. package/dist/superdoc.es.js +2 -2
  26. package/dist/superdoc.umd.js +105 -47
  27. package/dist/superdoc.umd.js.map +1 -1
  28. package/package.json +1 -1
@@ -43212,7 +43212,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
43212
43212
  static getStoredSuperdocVersion(docx) {
43213
43213
  return _SuperConverter2.getStoredCustomProperty(docx, "SuperdocVersion");
43214
43214
  }
43215
- static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "0.27.2") {
43215
+ static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "0.28.1") {
43216
43216
  return _SuperConverter2.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
43217
43217
  }
43218
43218
  /**
@@ -61347,7 +61347,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
61347
61347
  { default: remarkStringify2 },
61348
61348
  { default: remarkGfm2 }
61349
61349
  ] = await Promise.all([
61350
- Promise.resolve().then(() => indexDL9bff78),
61350
+ Promise.resolve().then(() => indexBNr0wgOU),
61351
61351
  Promise.resolve().then(() => indexDRCvimau),
61352
61352
  Promise.resolve().then(() => indexC_x_N6Uh),
61353
61353
  Promise.resolve().then(() => indexD_sWOSiG),
@@ -61565,7 +61565,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
61565
61565
  * @returns {Object | void} Migration results
61566
61566
  */
61567
61567
  processCollaborationMigrations() {
61568
- console.debug("[checkVersionMigrations] Current editor version", "0.27.2");
61568
+ console.debug("[checkVersionMigrations] Current editor version", "0.28.1");
61569
61569
  if (!this.options.ydoc) return;
61570
61570
  const metaMap = this.options.ydoc.getMap("meta");
61571
61571
  let docVersion = metaMap.get("version");
@@ -67196,10 +67196,16 @@ Please report this to https://github.com/markedjs/marked.`, e) {
67196
67196
  const paragraphContext = getParagraphContext($pos, paragraphCache, helpers2);
67197
67197
  if (!paragraphContext) return;
67198
67198
  try {
67199
- const { tabStops, flattened, startPos } = paragraphContext;
67200
- const entryIndex = flattened.findIndex((entry) => entry.pos === pos);
67201
- if (entryIndex === -1) return;
67202
- const indentWidth = getIndentWidth(view, startPos, paragraphContext.indent, coordCache, domPosCache);
67199
+ const { tabStops, flattened, positionMap: positionMap2, startPos } = paragraphContext;
67200
+ const entryIndex = positionMap2.get(pos);
67201
+ if (entryIndex === void 0) return;
67202
+ if (paragraphContext.indentWidth === void 0) {
67203
+ paragraphContext.indentWidth = getIndentWidth(view, startPos, paragraphContext.indent, coordCache, domPosCache);
67204
+ }
67205
+ if (paragraphContext.tabHeight === void 0) {
67206
+ paragraphContext.tabHeight = calcTabHeight($pos);
67207
+ }
67208
+ const indentWidth = paragraphContext.indentWidth;
67203
67209
  const accumulatedTabWidth = paragraphContext.accumulatedTabWidth || 0;
67204
67210
  const currentWidth = indentWidth + measureRangeWidth(view, startPos + 1, pos, coordCache, domPosCache) + accumulatedTabWidth;
67205
67211
  let tabWidth;
@@ -67241,7 +67247,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
67241
67247
  tabWidth = defaultTabDistance - currentWidth % defaultLineLength % defaultTabDistance;
67242
67248
  if (tabWidth === 0) tabWidth = defaultTabDistance;
67243
67249
  }
67244
- const tabHeight = calcTabHeight($pos);
67250
+ const tabHeight = paragraphContext.tabHeight;
67245
67251
  decorations.push(
67246
67252
  Decoration.node(pos, pos + node2.nodeSize, {
67247
67253
  style: `width: ${tabWidth}px; height: ${tabHeight};${extraStyles}`
@@ -67269,13 +67275,16 @@ Please report this to https://github.com/markedjs/marked.`, e) {
67269
67275
  tabStops = style2.definition.styles.tabStops;
67270
67276
  }
67271
67277
  }
67278
+ const { entries, positionMap: positionMap2 } = flattenParagraph(node2, startPos);
67272
67279
  cache2.set(startPos, {
67273
67280
  paragraph: node2,
67274
67281
  paragraphDepth: depth,
67275
67282
  startPos,
67276
67283
  indent: node2.attrs?.indent || {},
67277
67284
  tabStops,
67278
- flattened: flattenParagraph(node2, startPos),
67285
+ flattened: entries,
67286
+ positionMap: positionMap2,
67287
+ // Store position map for O(1) lookups
67279
67288
  accumulatedTabWidth: 0
67280
67289
  });
67281
67290
  }
@@ -67286,6 +67295,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
67286
67295
  }
67287
67296
  function flattenParagraph(paragraph2, paragraphStartPos) {
67288
67297
  const entries = [];
67298
+ const positionMap2 = /* @__PURE__ */ new Map();
67289
67299
  const walk = (node2, basePos) => {
67290
67300
  if (!node2) return;
67291
67301
  if (node2.type?.name === "run") {
@@ -67295,13 +67305,16 @@ Please report this to https://github.com/markedjs/marked.`, e) {
67295
67305
  });
67296
67306
  return;
67297
67307
  }
67298
- entries.push({ node: node2, pos: basePos - 1 });
67308
+ const pos = basePos - 1;
67309
+ const index2 = entries.length;
67310
+ entries.push({ node: node2, pos });
67311
+ positionMap2.set(pos, index2);
67299
67312
  };
67300
67313
  paragraph2.forEach((child, offset2) => {
67301
67314
  const childPos = paragraphStartPos + offset2 + 1;
67302
67315
  walk(child, childPos);
67303
67316
  });
67304
- return entries;
67317
+ return { entries, positionMap: positionMap2 };
67305
67318
  }
67306
67319
  function findNextTabIndex(flattened, fromIndex) {
67307
67320
  for (let i2 = fromIndex; i2 < flattened.length; i2++) {
@@ -67459,6 +67472,21 @@ Please report this to https://github.com/markedjs/marked.`, e) {
67459
67472
  },
67460
67473
  addPmPlugins() {
67461
67474
  const { view, helpers: helpers2 } = this.editor;
67475
+ const mergeRanges = (ranges) => {
67476
+ if (ranges.length === 0) return [];
67477
+ const sorted = ranges.slice().sort((a2, b2) => a2[0] - b2[0]);
67478
+ const merged = [sorted[0]];
67479
+ for (let i2 = 1; i2 < sorted.length; i2++) {
67480
+ const [start2, end2] = sorted[i2];
67481
+ const last = merged[merged.length - 1];
67482
+ if (start2 <= last[1]) {
67483
+ last[1] = Math.max(last[1], end2);
67484
+ } else {
67485
+ merged.push([start2, end2]);
67486
+ }
67487
+ }
67488
+ return merged;
67489
+ };
67462
67490
  const tabPlugin = new Plugin({
67463
67491
  name: "tabPlugin",
67464
67492
  key: new PluginKey("tabPlugin"),
@@ -67469,43 +67497,56 @@ Please report this to https://github.com/markedjs/marked.`, e) {
67469
67497
  apply(tr, { decorations }, _oldState, newState) {
67470
67498
  if (!decorations) {
67471
67499
  decorations = DecorationSet.create(newState.doc, getTabDecorations(newState.doc, view, helpers2));
67500
+ return { decorations };
67472
67501
  }
67473
- if (!tr.docChanged || tr.getMeta("blockNodeInitialUpdate") === true) {
67502
+ if (!tr.docChanged || tr.getMeta("blockNodeInitialUpdate")) {
67474
67503
  return { decorations };
67475
67504
  }
67476
67505
  decorations = decorations.map(tr.mapping, tr.doc);
67477
- let rangesToRecalculate = [];
67506
+ const rangesToRecalculate = [];
67507
+ const containsTab = (node2) => node2.type.name === "tab";
67478
67508
  tr.steps.forEach((step, index2) => {
67479
- const stepMap = step.getMap();
67480
- if (step instanceof ReplaceStep || step instanceof ReplaceAroundStep$1) {
67481
- const $from = tr.docs[index2].resolve(step.from);
67482
- const $to = tr.docs[index2].resolve(step.to);
67483
- const start2 = $from.start(Math.min($from.depth, 1));
67484
- const end2 = $to.end(Math.min($to.depth, 1));
67485
- let addRange2 = false;
67486
- tr.docs[index2].nodesBetween(start2, end2, (node2) => {
67487
- if (node2.type.name === "tab") {
67488
- addRange2 = true;
67509
+ if (!(step instanceof ReplaceStep || step instanceof ReplaceAroundStep$1)) {
67510
+ return;
67511
+ }
67512
+ let hasTabInRange = false;
67513
+ if (step.slice?.content) {
67514
+ step.slice.content.descendants((node2) => {
67515
+ if (containsTab(node2)) {
67516
+ hasTabInRange = true;
67517
+ return false;
67489
67518
  }
67490
67519
  });
67491
- if (!addRange2 && step.slice?.content) {
67492
- step.slice.content.descendants((node2) => {
67493
- if (node2.type.name === "tab") {
67494
- addRange2 = true;
67495
- }
67496
- });
67497
- }
67498
- if (addRange2) {
67499
- rangesToRecalculate.push([start2, end2]);
67500
- }
67501
67520
  }
67502
- rangesToRecalculate = rangesToRecalculate.map(([from2, to]) => {
67503
- const mappedFrom = stepMap.map(from2, -1);
67504
- const mappedTo = stepMap.map(to, 1);
67505
- return [mappedFrom, mappedTo];
67506
- });
67521
+ if (!hasTabInRange) {
67522
+ tr.docs[index2].nodesBetween(step.from, step.to, (node2) => {
67523
+ if (containsTab(node2)) {
67524
+ hasTabInRange = true;
67525
+ return false;
67526
+ }
67527
+ });
67528
+ }
67529
+ if (!hasTabInRange) {
67530
+ return;
67531
+ }
67532
+ let fromPos = step.from;
67533
+ let toPos = step.to;
67534
+ for (let i2 = index2; i2 < tr.steps.length; i2++) {
67535
+ const stepMap = tr.steps[i2].getMap();
67536
+ fromPos = stepMap.map(fromPos, -1);
67537
+ toPos = stepMap.map(toPos, 1);
67538
+ }
67539
+ const $from = newState.doc.resolve(fromPos);
67540
+ const $to = newState.doc.resolve(toPos);
67541
+ const start2 = $from.start(Math.min($from.depth, 1));
67542
+ const end2 = $to.end(Math.min($to.depth, 1));
67543
+ rangesToRecalculate.push([start2, end2]);
67507
67544
  });
67508
- rangesToRecalculate.forEach(([start2, end2]) => {
67545
+ if (rangesToRecalculate.length === 0) {
67546
+ return { decorations };
67547
+ }
67548
+ const mergedRanges = mergeRanges(rangesToRecalculate);
67549
+ mergedRanges.forEach(([start2, end2]) => {
67509
67550
  const oldDecorations = decorations.find(start2, end2);
67510
67551
  decorations = decorations.remove(oldDecorations);
67511
67552
  const newDecorations = getTabDecorations(newState.doc, view, helpers2, start2, end2);
@@ -73669,15 +73710,15 @@ Please report this to https://github.com/markedjs/marked.`, e) {
73669
73710
  style2 += "float: right;";
73670
73711
  floatRight = true;
73671
73712
  } else if (["largest", "bothSides"].includes(attrs.wrapText)) {
73672
- const pageStylesData2 = getDataFromPageStyles({
73713
+ const pageStylesData = getDataFromPageStyles({
73673
73714
  editor: this.editor,
73674
73715
  marginOffset,
73675
73716
  size: size2,
73676
73717
  attrs
73677
73718
  });
73678
- style2 += pageStylesData2.style;
73679
- floatRight = pageStylesData2.floatRight;
73680
- baseHorizontal = pageStylesData2.baseHorizontal;
73719
+ style2 += pageStylesData.style;
73720
+ floatRight = pageStylesData.floatRight;
73721
+ baseHorizontal = pageStylesData.baseHorizontal;
73681
73722
  }
73682
73723
  if (attrs.distTop) margin.top += attrs.distTop;
73683
73724
  if (attrs.distBottom) margin.bottom += attrs.distBottom;
@@ -73685,7 +73726,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
73685
73726
  if (attrs.distRight) margin.right += attrs.distRight;
73686
73727
  break;
73687
73728
  case "Through":
73688
- case "Tight":
73729
+ case "Tight": {
73689
73730
  style2 += "clear: both;";
73690
73731
  const pageStylesData = getDataFromPageStyles({
73691
73732
  editor: this.editor,
@@ -73722,11 +73763,14 @@ Please report this to https://github.com/markedjs/marked.`, e) {
73722
73763
  style2 += `shape-outside: polygon(${points});`;
73723
73764
  }
73724
73765
  break;
73766
+ }
73725
73767
  case "TopAndBottom":
73726
73768
  style2 += "display: block; clear: both;";
73769
+ if (!anchorData) {
73770
+ centered = true;
73771
+ }
73727
73772
  if (attrs.distTop) margin.top += attrs.distTop;
73728
73773
  if (attrs.distBottom) margin.bottom += attrs.distBottom;
73729
- centered = true;
73730
73774
  break;
73731
73775
  }
73732
73776
  }
@@ -73746,6 +73790,20 @@ Please report this to https://github.com/markedjs/marked.`, e) {
73746
73790
  style2 += `position: absolute; ${anchorData.alignH}: 0;`;
73747
73791
  }
73748
73792
  break;
73793
+ case "column":
73794
+ if (anchorData.alignH === "center") {
73795
+ centered = true;
73796
+ } else if (anchorData.alignH === "right") {
73797
+ floatRight = true;
73798
+ if (!style2.includes("float: right;")) {
73799
+ style2 += "float: right;";
73800
+ }
73801
+ } else if (anchorData.alignH === "left") {
73802
+ if (!style2.includes("float: left;")) {
73803
+ style2 += "float: left;";
73804
+ }
73805
+ }
73806
+ break;
73749
73807
  }
73750
73808
  }
73751
73809
  if (hasAnchorData || hasMarginOffsets) {
@@ -117031,7 +117089,7 @@ ${style2}
117031
117089
  this.config.colors = shuffleArray(this.config.colors);
117032
117090
  this.userColorMap = /* @__PURE__ */ new Map();
117033
117091
  this.colorIndex = 0;
117034
- this.version = "0.27.2";
117092
+ this.version = "0.28.1";
117035
117093
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
117036
117094
  this.superdocId = config2.superdocId || v4();
117037
117095
  this.colors = this.config.colors;
@@ -119431,7 +119489,7 @@ ${style2}
119431
119489
  value && typeof value === "object" && "byteLength" in value && "byteOffset" in value
119432
119490
  );
119433
119491
  }
119434
- const indexDL9bff78 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
119492
+ const indexBNr0wgOU = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
119435
119493
  __proto__: null,
119436
119494
  unified
119437
119495
  }, Symbol.toStringTag, { value: "Module" }));