@harbour-enterprises/superdoc 2.0.0-next.20 → 2.0.0-next.21

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 (27) hide show
  1. package/dist/chunks/{PdfViewer-Y5Q3KpNr.cjs → PdfViewer-B4os0dhm.cjs} +1 -1
  2. package/dist/chunks/{PdfViewer-ag_ZFG_a.es.js → PdfViewer-CvJZenVo.es.js} +1 -1
  3. package/dist/chunks/{index-XnRj2biz-DiLIwrZX.cjs → index--w_Fk0WX-Bd420t19.cjs} +1 -1
  4. package/dist/chunks/{index-XnRj2biz-CWqMvtJZ.es.js → index--w_Fk0WX-D_kNY98j.es.js} +1 -1
  5. package/dist/chunks/{index-CWNzyoyI.cjs → index-BaspZNUO.cjs} +3 -3
  6. package/dist/chunks/{index-Dymes5hN.es.js → index-bocgaXi5.es.js} +3 -3
  7. package/dist/chunks/{super-editor.es-BBUBeVVw.es.js → super-editor.es-CHiYj0m5.es.js} +105 -48
  8. package/dist/chunks/{super-editor.es-DwEkOdPH.cjs → super-editor.es-KouCN1a9.cjs} +105 -48
  9. package/dist/super-editor/ai-writer.es.js +2 -2
  10. package/dist/super-editor/chunks/{converter-CFpzAUl1.js → converter-De_h0rq-.js} +1 -1
  11. package/dist/super-editor/chunks/{docx-zipper-B4U-khNy.js → docx-zipper-CKQFze2s.js} +1 -1
  12. package/dist/super-editor/chunks/{editor-CUCVDSiG.js → editor-BJljVUQD.js} +106 -49
  13. package/dist/super-editor/chunks/{index-XnRj2biz.js → index--w_Fk0WX.js} +1 -1
  14. package/dist/super-editor/chunks/{toolbar-DXUz-ZeU.js → toolbar-Br3J_GSc.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.es.js +6 -6
  20. package/dist/super-editor/toolbar.es.js +2 -2
  21. package/dist/super-editor.cjs +1 -1
  22. package/dist/super-editor.es.js +1 -1
  23. package/dist/superdoc.cjs +2 -2
  24. package/dist/superdoc.es.js +2 -2
  25. package/dist/superdoc.umd.js +107 -50
  26. package/dist/superdoc.umd.js.map +1 -1
  27. package/package.json +1 -1
@@ -42468,7 +42468,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
42468
42468
  static getStoredSuperdocVersion(docx) {
42469
42469
  return _SuperConverter2.getStoredCustomProperty(docx, "SuperdocVersion");
42470
42470
  }
42471
- static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "2.0.0-next.20") {
42471
+ static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "2.0.0-next.21") {
42472
42472
  return _SuperConverter2.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
42473
42473
  }
42474
42474
  /**
@@ -68530,7 +68530,7 @@ ${err.toString()}`);
68530
68530
  const shouldSkipNodeView = (editor) => {
68531
68531
  return isHeadless(editor);
68532
68532
  };
68533
- const summaryVersion = "2.0.0-next.20";
68533
+ const summaryVersion = "2.0.0-next.21";
68534
68534
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
68535
68535
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
68536
68536
  function mapAttributes(attrs) {
@@ -69319,7 +69319,7 @@ ${err.toString()}`);
69319
69319
  { default: remarkStringify2 },
69320
69320
  { default: remarkGfm2 }
69321
69321
  ] = await Promise.all([
69322
- Promise.resolve().then(() => indexXnRj2biz),
69322
+ Promise.resolve().then(() => index_W_Fk0WX),
69323
69323
  Promise.resolve().then(() => indexDRCvimau),
69324
69324
  Promise.resolve().then(() => indexC_x_N6Uh),
69325
69325
  Promise.resolve().then(() => indexD_sWOSiG),
@@ -69524,7 +69524,7 @@ ${err.toString()}`);
69524
69524
  * Process collaboration migrations
69525
69525
  */
69526
69526
  processCollaborationMigrations() {
69527
- console.debug("[checkVersionMigrations] Current editor version", "2.0.0-next.20");
69527
+ console.debug("[checkVersionMigrations] Current editor version", "2.0.0-next.21");
69528
69528
  if (!this.options.ydoc) return;
69529
69529
  const metaMap = this.options.ydoc.getMap("meta");
69530
69530
  let docVersion = metaMap.get("version");
@@ -83083,13 +83083,13 @@ ${l}
83083
83083
  if (maxHeaderContentHeight > 0) {
83084
83084
  return Math.max(baseTop, headerDistance + maxHeaderContentHeight);
83085
83085
  }
83086
- return Math.max(baseTop, headerDistance);
83086
+ return baseTop;
83087
83087
  };
83088
83088
  const calcRequiredBottomMargin = (footerDistance, baseBottom) => {
83089
83089
  if (maxFooterContentHeight > 0) {
83090
83090
  return Math.max(baseBottom, footerDistance + maxFooterContentHeight);
83091
83091
  }
83092
- return Math.max(baseBottom, footerDistance);
83092
+ return baseBottom;
83093
83093
  };
83094
83094
  if (block.attrs?.isFirstSection && !next2.hasAnyPages) {
83095
83095
  if (block.pageSize) {
@@ -83590,6 +83590,11 @@ ${l}
83590
83590
  const prevTrailing = state2.trailingSpacing ?? 0;
83591
83591
  const neededSpacingBefore = Math.max(spacingBefore - prevTrailing, 0);
83592
83592
  if (state2.cursorY + neededSpacingBefore > state2.contentBottom) {
83593
+ if (state2.cursorY <= state2.topMargin) {
83594
+ state2.trailingSpacing = 0;
83595
+ appliedSpacingBefore = true;
83596
+ break;
83597
+ }
83593
83598
  state2 = advanceColumn(state2);
83594
83599
  if (state2.trailingSpacing == null) state2.trailingSpacing = 0;
83595
83600
  continue;
@@ -84905,12 +84910,12 @@ ${l}
84905
84910
  next2.pendingFooterDistance = footerDistance2;
84906
84911
  }
84907
84912
  if (block.margins?.top !== void 0 || block.margins?.header !== void 0) {
84908
- const requiredTop = maxHeaderContentHeight > 0 ? headerDistance2 + maxHeaderContentHeight : headerDistance2;
84913
+ const requiredTop = maxHeaderContentHeight > 0 ? headerDistance2 + maxHeaderContentHeight : 0;
84909
84914
  next2.activeTopMargin = Math.max(sectionTop, requiredTop);
84910
84915
  next2.pendingTopMargin = next2.activeTopMargin;
84911
84916
  }
84912
84917
  if (block.margins?.bottom !== void 0 || block.margins?.footer !== void 0) {
84913
- const requiredBottom = maxFooterContentHeight > 0 ? footerDistance2 + maxFooterContentHeight : footerDistance2;
84918
+ const requiredBottom = maxFooterContentHeight > 0 ? footerDistance2 + maxFooterContentHeight : 0;
84914
84919
  next2.activeBottomMargin = Math.max(sectionBottom, requiredBottom);
84915
84920
  next2.pendingBottomMargin = next2.activeBottomMargin;
84916
84921
  }
@@ -85660,7 +85665,7 @@ ${l}
85660
85665
  throw new Error("layoutHeaderFooter: width must be positive");
85661
85666
  }
85662
85667
  if (!Number.isFinite(height) || height <= 0) {
85663
- throw new Error("layoutHeaderFooter: height must be positive");
85668
+ return { pages: [], height: 0 };
85664
85669
  }
85665
85670
  const maxBehindDocOverflow = Math.max(192, height * 4);
85666
85671
  const minBehindDocY = -maxBehindDocOverflow;
@@ -87506,7 +87511,9 @@ ${l}
87506
87511
  `[Perf] 4.1 Measure all blocks: ${(measureEnd - measureStart).toFixed(2)}ms (${cacheMisses} measured, ${cacheHits} cached)`
87507
87512
  );
87508
87513
  let headerContentHeights;
87509
- if (headerFooter?.constraints && headerFooter.headerBlocks) {
87514
+ const hasHeaderBlocks = headerFooter?.headerBlocks && Object.keys(headerFooter.headerBlocks).length > 0;
87515
+ const hasHeaderBlocksByRId = headerFooter?.headerBlocksByRId && headerFooter.headerBlocksByRId.size > 0;
87516
+ if (headerFooter?.constraints && (hasHeaderBlocks || hasHeaderBlocksByRId)) {
87510
87517
  const hfPreStart = performance.now();
87511
87518
  const measureFn = headerFooter.measure ?? measureBlock2;
87512
87519
  invalidateHeaderFooterCache(
@@ -87518,25 +87525,45 @@ ${l}
87518
87525
  options.sectionMetadata
87519
87526
  );
87520
87527
  const HEADER_PRELAYOUT_PLACEHOLDER_PAGE_COUNT = 1;
87521
- const preHeaderLayouts = await layoutHeaderFooterWithCache(
87522
- headerFooter.headerBlocks,
87523
- headerFooter.constraints,
87524
- measureFn,
87525
- headerMeasureCache,
87526
- HEADER_PRELAYOUT_PLACEHOLDER_PAGE_COUNT,
87527
- void 0
87528
- // No page resolver needed for height calculation
87529
- );
87530
87528
  const isValidHeaderType = (key2) => {
87531
87529
  return ["default", "first", "even", "odd"].includes(key2);
87532
87530
  };
87533
87531
  headerContentHeights = {};
87534
- for (const [type2, value] of Object.entries(preHeaderLayouts)) {
87535
- if (!isValidHeaderType(type2)) continue;
87536
- if (value?.layout && typeof value.layout.height === "number") {
87537
- const height = value.layout.height;
87538
- if (Number.isFinite(height) && height >= 0) {
87539
- headerContentHeights[type2] = height;
87532
+ if (hasHeaderBlocks && headerFooter.headerBlocks) {
87533
+ const preHeaderLayouts = await layoutHeaderFooterWithCache(
87534
+ headerFooter.headerBlocks,
87535
+ headerFooter.constraints,
87536
+ measureFn,
87537
+ headerMeasureCache,
87538
+ HEADER_PRELAYOUT_PLACEHOLDER_PAGE_COUNT,
87539
+ void 0
87540
+ // No page resolver needed for height calculation
87541
+ );
87542
+ for (const [type2, value] of Object.entries(preHeaderLayouts)) {
87543
+ if (!isValidHeaderType(type2)) continue;
87544
+ if (value?.layout && typeof value.layout.height === "number") {
87545
+ const height = value.layout.height;
87546
+ if (Number.isFinite(height) && height >= 0) {
87547
+ headerContentHeights[type2] = height;
87548
+ }
87549
+ }
87550
+ }
87551
+ }
87552
+ if (hasHeaderBlocksByRId && headerFooter.headerBlocksByRId) {
87553
+ for (const [_rId, blocks2] of headerFooter.headerBlocksByRId) {
87554
+ if (!blocks2 || blocks2.length === 0) continue;
87555
+ const measureConstraints = {
87556
+ maxWidth: headerFooter.constraints.width,
87557
+ maxHeight: headerFooter.constraints.height
87558
+ };
87559
+ const measures2 = await Promise.all(blocks2.map((block) => measureFn(block, measureConstraints)));
87560
+ const layout2 = layoutHeaderFooter(blocks2, measures2, {
87561
+ width: headerFooter.constraints.width,
87562
+ height: headerFooter.constraints.height
87563
+ });
87564
+ if (layout2.height > 0) {
87565
+ const currentDefault = headerContentHeights.default ?? 0;
87566
+ headerContentHeights.default = Math.max(currentDefault, layout2.height);
87540
87567
  }
87541
87568
  }
87542
87569
  }
@@ -87544,10 +87571,12 @@ ${l}
87544
87571
  perfLog(`[Perf] 4.1.5 Pre-layout headers for height: ${(hfPreEnd - hfPreStart).toFixed(2)}ms`);
87545
87572
  }
87546
87573
  let footerContentHeights;
87547
- if (headerFooter?.constraints && headerFooter.footerBlocks) {
87574
+ const hasFooterBlocks = headerFooter?.footerBlocks && Object.keys(headerFooter.footerBlocks).length > 0;
87575
+ const hasFooterBlocksByRId = headerFooter?.footerBlocksByRId && headerFooter.footerBlocksByRId.size > 0;
87576
+ if (headerFooter?.constraints && (hasFooterBlocks || hasFooterBlocksByRId)) {
87548
87577
  const footerPreStart = performance.now();
87549
87578
  const measureFn = headerFooter.measure ?? measureBlock2;
87550
- if (!headerFooter.headerBlocks) {
87579
+ if (!hasHeaderBlocks && !hasHeaderBlocksByRId) {
87551
87580
  invalidateHeaderFooterCache(
87552
87581
  headerMeasureCache,
87553
87582
  headerFooterCacheState,
@@ -87558,26 +87587,46 @@ ${l}
87558
87587
  );
87559
87588
  }
87560
87589
  const FOOTER_PRELAYOUT_PLACEHOLDER_PAGE_COUNT = 1;
87590
+ const isValidFooterType = (key2) => {
87591
+ return ["default", "first", "even", "odd"].includes(key2);
87592
+ };
87593
+ footerContentHeights = {};
87561
87594
  try {
87562
- const preFooterLayouts = await layoutHeaderFooterWithCache(
87563
- headerFooter.footerBlocks,
87564
- headerFooter.constraints,
87565
- measureFn,
87566
- headerMeasureCache,
87567
- FOOTER_PRELAYOUT_PLACEHOLDER_PAGE_COUNT,
87568
- void 0
87569
- // No page resolver needed for height calculation
87570
- );
87571
- const isValidFooterType = (key2) => {
87572
- return ["default", "first", "even", "odd"].includes(key2);
87573
- };
87574
- footerContentHeights = {};
87575
- for (const [type2, value] of Object.entries(preFooterLayouts)) {
87576
- if (!isValidFooterType(type2)) continue;
87577
- if (value?.layout && typeof value.layout.height === "number") {
87578
- const height = value.layout.height;
87579
- if (Number.isFinite(height) && height >= 0) {
87580
- footerContentHeights[type2] = height;
87595
+ if (hasFooterBlocks && headerFooter.footerBlocks) {
87596
+ const preFooterLayouts = await layoutHeaderFooterWithCache(
87597
+ headerFooter.footerBlocks,
87598
+ headerFooter.constraints,
87599
+ measureFn,
87600
+ headerMeasureCache,
87601
+ FOOTER_PRELAYOUT_PLACEHOLDER_PAGE_COUNT,
87602
+ void 0
87603
+ // No page resolver needed for height calculation
87604
+ );
87605
+ for (const [type2, value] of Object.entries(preFooterLayouts)) {
87606
+ if (!isValidFooterType(type2)) continue;
87607
+ if (value?.layout && typeof value.layout.height === "number") {
87608
+ const height = value.layout.height;
87609
+ if (Number.isFinite(height) && height >= 0) {
87610
+ footerContentHeights[type2] = height;
87611
+ }
87612
+ }
87613
+ }
87614
+ }
87615
+ if (hasFooterBlocksByRId && headerFooter.footerBlocksByRId) {
87616
+ for (const [_rId, blocks2] of headerFooter.footerBlocksByRId) {
87617
+ if (!blocks2 || blocks2.length === 0) continue;
87618
+ const measureConstraints = {
87619
+ maxWidth: headerFooter.constraints.width,
87620
+ maxHeight: headerFooter.constraints.height
87621
+ };
87622
+ const measures2 = await Promise.all(blocks2.map((block) => measureFn(block, measureConstraints)));
87623
+ const layout2 = layoutHeaderFooter(blocks2, measures2, {
87624
+ width: headerFooter.constraints.width,
87625
+ height: headerFooter.constraints.height
87626
+ });
87627
+ if (layout2.height > 0) {
87628
+ const currentDefault = footerContentHeights.default ?? 0;
87629
+ footerContentHeights.default = Math.max(currentDefault, layout2.height);
87581
87630
  }
87582
87631
  }
87583
87632
  }
@@ -104537,7 +104586,14 @@ ${l}
104537
104586
  const footerMargin = margins.footer ?? 0;
104538
104587
  const headerContentSpace = Math.max(marginTop - headerMargin, 0);
104539
104588
  const footerContentSpace = Math.max(marginBottom - footerMargin, 0);
104540
- const height = Math.max(headerContentSpace, footerContentSpace, 1);
104589
+ const height = Math.max(
104590
+ headerContentSpace,
104591
+ footerContentSpace,
104592
+ headerMargin,
104593
+ footerMargin,
104594
+ marginTop,
104595
+ marginBottom
104596
+ );
104541
104597
  return {
104542
104598
  width: measurementWidth,
104543
104599
  height,
@@ -104687,7 +104743,8 @@ ${l}
104687
104743
  const headerMargin = margins.header ?? 0;
104688
104744
  const topMargin = margins.top ?? DEFAULT_MARGINS.top ?? 0;
104689
104745
  const height = Math.max(topMargin - headerMargin, 1);
104690
- return { x: left2, width, height, offset: headerMargin };
104746
+ const offset2 = headerMargin;
104747
+ return { x: left2, width, height, offset: offset2 };
104691
104748
  } else {
104692
104749
  const footerMargin = margins.footer ?? 0;
104693
104750
  const bottomMargin = margins.bottom ?? DEFAULT_MARGINS.bottom ?? 0;
@@ -158004,7 +158061,7 @@ ${style2}
158004
158061
  this.config.colors = shuffleArray(this.config.colors);
158005
158062
  this.userColorMap = /* @__PURE__ */ new Map();
158006
158063
  this.colorIndex = 0;
158007
- this.version = "2.0.0-next.20";
158064
+ this.version = "2.0.0-next.21";
158008
158065
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
158009
158066
  this.superdocId = config2.superdocId || v4();
158010
158067
  this.colors = this.config.colors;
@@ -160477,7 +160534,7 @@ ${style2}
160477
160534
  value && typeof value === "object" && "byteLength" in value && "byteOffset" in value
160478
160535
  );
160479
160536
  }
160480
- const indexXnRj2biz = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
160537
+ const index_W_Fk0WX = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
160481
160538
  __proto__: null,
160482
160539
  unified
160483
160540
  }, Symbol.toStringTag, { value: "Module" }));