superdoc 1.7.0-next.9 → 1.7.0

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.
@@ -1,6 +1,6 @@
1
1
  import { d as defineComponent, h, T as Transition, p as process$1, w as watchEffect, c as computed, r as ref, f as onMounted, X as onUnmounted, E as createElementBlock, G as openBlock, K as createBaseVNode, M as createCommentVNode, I as createVNode, v as unref } from "./vue-BnBKJwCW.es.js";
2
- import { N as NBaseLoading, u as useSuperdocStore, s as storeToRefs, a as useSelection } from "./index-Dho4ex7D.es.js";
3
- import { C as derived, r as c, q as cB, aF as fadeInTransition, y as cM, I as warnOnce, J as useConfig, N as useTheme, aG as pxfy, P as createKey, Q as useThemeClass, aH as useCompitable, ai as _export_sfc } from "./index-C070FBOz.es.js";
2
+ import { N as NBaseLoading, u as useSuperdocStore, s as storeToRefs, a as useSelection } from "./index-ugS0fOdR.es.js";
3
+ import { C as derived, r as c, q as cB, aF as fadeInTransition, y as cM, I as warnOnce, J as useConfig, N as useTheme, aG as pxfy, P as createKey, Q as useThemeClass, aH as useCompitable, ai as _export_sfc } from "./index-i1HR2Dcb.es.js";
4
4
  function self(vars) {
5
5
  const {
6
6
  opacityDisabled,
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const vue = require("./vue-De9wkgLl.cjs");
4
- const superdoc = require("./index-CDRAe8oj.cjs");
5
- const index = require("./index-nEA2vtLH.cjs");
4
+ const superdoc = require("./index-D85x_K2T.cjs");
5
+ const index = require("./index-CRVcSemy.cjs");
6
6
  function self(vars) {
7
7
  const {
8
8
  opacityDisabled,
@@ -33200,7 +33200,7 @@ class SuperConverter {
33200
33200
  static getStoredSuperdocVersion(docx) {
33201
33201
  return SuperConverter.getStoredCustomProperty(docx, "SuperdocVersion");
33202
33202
  }
33203
- static setStoredSuperdocVersion(docx = this.convertedXml, version = "1.7.0-next.9") {
33203
+ static setStoredSuperdocVersion(docx = this.convertedXml, version = "1.7.0") {
33204
33204
  return SuperConverter.setStoredCustomProperty(docx, "SuperdocVersion", version, false);
33205
33205
  }
33206
33206
  /**
@@ -33199,7 +33199,7 @@ class SuperConverter {
33199
33199
  static getStoredSuperdocVersion(docx) {
33200
33200
  return SuperConverter.getStoredCustomProperty(docx, "SuperdocVersion");
33201
33201
  }
33202
- static setStoredSuperdocVersion(docx = this.convertedXml, version = "1.7.0-next.9") {
33202
+ static setStoredSuperdocVersion(docx = this.convertedXml, version = "1.7.0") {
33203
33203
  return SuperConverter.setStoredCustomProperty(docx, "SuperdocVersion", version, false);
33204
33204
  }
33205
33205
  /**
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  const jszip = require("./jszip-C8_CqJxM.cjs");
3
3
  const helpers$1 = require("./helpers-nOdwpmwb.cjs");
4
- const superEditor_converter = require("./SuperConverter-PbxPQOyI.cjs");
4
+ const superEditor_converter = require("./SuperConverter-DLjFfhUV.cjs");
5
5
  const vue = require("./vue-De9wkgLl.cjs");
6
6
  require("./jszip.min-BPh2MMAa.cjs");
7
7
  const eventemitter3 = require("./eventemitter3-BQuRcMPI.cjs");
@@ -15861,7 +15861,7 @@ const canUseDOM = () => {
15861
15861
  return false;
15862
15862
  }
15863
15863
  };
15864
- const summaryVersion = "1.7.0-next.9";
15864
+ const summaryVersion = "1.7.0";
15865
15865
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
15866
15866
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
15867
15867
  function mapAttributes(attrs) {
@@ -18531,7 +18531,7 @@ class Editor extends EventEmitter {
18531
18531
  * Process collaboration migrations
18532
18532
  */
18533
18533
  processCollaborationMigrations() {
18534
- console.debug("[checkVersionMigrations] Current editor version", "1.7.0-next.9");
18534
+ console.debug("[checkVersionMigrations] Current editor version", "1.7.0");
18535
18535
  if (!this.options.ydoc) return;
18536
18536
  const metaMap = this.options.ydoc.getMap("meta");
18537
18537
  let docVersion = metaMap.get("version");
@@ -34834,6 +34834,115 @@ function getMeasureHeight(block, measure) {
34834
34834
  }
34835
34835
  }
34836
34836
  }
34837
+ function computeKeepNextChains(blocks) {
34838
+ const chains = /* @__PURE__ */ new Map();
34839
+ const processedIndices = /* @__PURE__ */ new Set();
34840
+ for (let i = 0; i < blocks.length; i++) {
34841
+ if (processedIndices.has(i)) continue;
34842
+ const block = blocks[i];
34843
+ if (block.kind !== "paragraph") continue;
34844
+ const paraBlock = block;
34845
+ if (paraBlock.attrs?.keepNext !== true) continue;
34846
+ const memberIndices = [i];
34847
+ let endIndex = i;
34848
+ for (let j = i + 1; j < blocks.length; j++) {
34849
+ const nextBlock = blocks[j];
34850
+ if (nextBlock.kind === "sectionBreak" || nextBlock.kind === "pageBreak" || nextBlock.kind === "columnBreak") {
34851
+ break;
34852
+ }
34853
+ if (nextBlock.kind !== "paragraph") {
34854
+ break;
34855
+ }
34856
+ const nextPara = nextBlock;
34857
+ if (nextPara.attrs?.keepNext === true) {
34858
+ memberIndices.push(j);
34859
+ endIndex = j;
34860
+ processedIndices.add(j);
34861
+ } else {
34862
+ break;
34863
+ }
34864
+ }
34865
+ const anchorIndex = endIndex + 1 < blocks.length ? endIndex + 1 : -1;
34866
+ if (anchorIndex !== -1) {
34867
+ const anchorBlock = blocks[anchorIndex];
34868
+ if (anchorBlock.kind === "sectionBreak" || anchorBlock.kind === "pageBreak" || anchorBlock.kind === "columnBreak") {
34869
+ if (memberIndices.length > 1) {
34870
+ chains.set(i, {
34871
+ startIndex: i,
34872
+ endIndex,
34873
+ memberIndices,
34874
+ anchorIndex: -1
34875
+ });
34876
+ }
34877
+ continue;
34878
+ }
34879
+ }
34880
+ chains.set(i, {
34881
+ startIndex: i,
34882
+ endIndex,
34883
+ memberIndices,
34884
+ anchorIndex
34885
+ });
34886
+ }
34887
+ return chains;
34888
+ }
34889
+ function calculateChainHeight(chain, blocks, measures, state) {
34890
+ let totalHeight = 0;
34891
+ let prevStyleId;
34892
+ let prevSpacingAfter = 0;
34893
+ let prevContextualSpacing = false;
34894
+ let isFirstMember = true;
34895
+ for (const memberIndex of chain.memberIndices) {
34896
+ const block = blocks[memberIndex];
34897
+ const measure = measures[memberIndex];
34898
+ if (!measure) continue;
34899
+ const spacingBefore = getParagraphSpacingBefore(block);
34900
+ const spacingAfter = getParagraphSpacingAfter$1(block);
34901
+ const styleId = typeof block.attrs?.styleId === "string" ? block.attrs?.styleId : void 0;
34902
+ const contextualSpacing = block.attrs?.contextualSpacing === true;
34903
+ if (isFirstMember) {
34904
+ const prevTrailing = Number.isFinite(state.trailingSpacing) && state.trailingSpacing > 0 ? state.trailingSpacing : 0;
34905
+ const sameAsLastOnPage = styleId && state.lastParagraphStyleId === styleId;
34906
+ const effectiveSpacingBefore = contextualSpacing && sameAsLastOnPage ? 0 : Math.max(spacingBefore - prevTrailing, 0);
34907
+ totalHeight += effectiveSpacingBefore;
34908
+ isFirstMember = false;
34909
+ } else {
34910
+ const sameStyle = styleId && prevStyleId && styleId === prevStyleId;
34911
+ const effectiveSpacingAfterPrev = prevContextualSpacing && sameStyle ? 0 : prevSpacingAfter;
34912
+ const effectiveSpacingBefore = contextualSpacing && sameStyle ? 0 : spacingBefore;
34913
+ const interParagraphSpacing = Math.max(effectiveSpacingAfterPrev, effectiveSpacingBefore);
34914
+ totalHeight += interParagraphSpacing;
34915
+ }
34916
+ totalHeight += getMeasureHeight(block, measure);
34917
+ prevStyleId = styleId;
34918
+ prevSpacingAfter = spacingAfter;
34919
+ prevContextualSpacing = contextualSpacing;
34920
+ }
34921
+ if (chain.anchorIndex !== -1) {
34922
+ const anchorBlock = blocks[chain.anchorIndex];
34923
+ const anchorMeasure = measures[chain.anchorIndex];
34924
+ if (anchorBlock && anchorMeasure) {
34925
+ if (anchorBlock.kind === "paragraph" && anchorMeasure.kind === "paragraph") {
34926
+ const anchorSpacingBefore = getParagraphSpacingBefore(anchorBlock);
34927
+ const anchorStyleId = typeof anchorBlock.attrs?.styleId === "string" ? anchorBlock.attrs?.styleId : void 0;
34928
+ const anchorContextualSpacing = anchorBlock.attrs?.contextualSpacing === true;
34929
+ const sameStyle = anchorStyleId && prevStyleId && anchorStyleId === prevStyleId;
34930
+ const effectiveSpacingAfterPrev = prevContextualSpacing && sameStyle ? 0 : prevSpacingAfter;
34931
+ const effectiveAnchorSpacingBefore = anchorContextualSpacing && sameStyle ? 0 : anchorSpacingBefore;
34932
+ const interParagraphSpacing = Math.max(effectiveSpacingAfterPrev, effectiveAnchorSpacingBefore);
34933
+ const firstLineHeight = anchorMeasure.lines[0]?.lineHeight;
34934
+ const anchorHeight = typeof firstLineHeight === "number" && Number.isFinite(firstLineHeight) && firstLineHeight > 0 ? firstLineHeight : getMeasureHeight(anchorBlock, anchorMeasure);
34935
+ totalHeight += interParagraphSpacing + anchorHeight;
34936
+ } else {
34937
+ const isAnchoredTable = anchorBlock.kind === "table" && anchorBlock.anchor?.isAnchored === true;
34938
+ if (!isAnchoredTable) {
34939
+ totalHeight += prevSpacingAfter + getMeasureHeight(anchorBlock, anchorMeasure);
34940
+ }
34941
+ }
34942
+ }
34943
+ }
34944
+ return totalHeight;
34945
+ }
34837
34946
  const DEFAULT_PAGE_SIZE$2 = { w: 612, h: 792 };
34838
34947
  const DEFAULT_MARGINS$2 = { top: 72, right: 72, bottom: 72, left: 72 };
34839
34948
  const COLUMN_EPSILON$1 = 1e-4;
@@ -35445,6 +35554,13 @@ function layoutDocument(blocks, measures, options = {}) {
35445
35554
  floatManager.registerDrawing(entry.block, entry.measure, anchorY, state.columnIndex, state.page.number);
35446
35555
  preRegisteredPositions.set(entry.block.id, { anchorX, anchorY, pageNumber: state.page.number });
35447
35556
  }
35557
+ const keepNextChains = computeKeepNextChains(blocks);
35558
+ const midChainIndices = /* @__PURE__ */ new Set();
35559
+ for (const chain of keepNextChains.values()) {
35560
+ for (let i = 1; i < chain.memberIndices.length; i++) {
35561
+ midChainIndices.add(chain.memberIndices[i]);
35562
+ }
35563
+ }
35448
35564
  for (let index2 = 0; index2 < blocks.length; index2 += 1) {
35449
35565
  const block = blocks[index2];
35450
35566
  const measure = measures[index2];
@@ -35661,7 +35777,24 @@ function layoutDocument(blocks, measures, options = {}) {
35661
35777
  placedAnchoredTableIds.add(tableBlock.id);
35662
35778
  }
35663
35779
  }
35664
- if (paraBlock.attrs?.keepNext === true) {
35780
+ const chain = keepNextChains.get(index2);
35781
+ if (midChainIndices.has(index2)) ;
35782
+ else if (chain) {
35783
+ let state = paginator.ensurePage();
35784
+ const availableHeight = state.contentBottom - state.cursorY;
35785
+ const firstMemberBlock = blocks[chain.startIndex];
35786
+ const firstMemberStyleId = typeof firstMemberBlock.attrs?.styleId === "string" ? firstMemberBlock.attrs?.styleId : void 0;
35787
+ const firstMemberContextualSpacing = firstMemberBlock.attrs?.contextualSpacing === true;
35788
+ const contextualSpacingApplies = firstMemberContextualSpacing && firstMemberStyleId && state.lastParagraphStyleId === firstMemberStyleId;
35789
+ const prevTrailing = Number.isFinite(state.trailingSpacing) && state.trailingSpacing > 0 ? state.trailingSpacing : 0;
35790
+ const effectiveAvailableHeight = contextualSpacingApplies ? availableHeight + prevTrailing : availableHeight;
35791
+ const chainHeight = calculateChainHeight(chain, blocks, measures, state);
35792
+ const pageContentHeight = state.contentBottom - state.topMargin;
35793
+ const chainFitsOnBlankPage = chainHeight <= pageContentHeight;
35794
+ if (chainFitsOnBlankPage && chainHeight > effectiveAvailableHeight && state.page.fragments.length > 0) {
35795
+ state = paginator.advanceColumn(state);
35796
+ }
35797
+ } else if (paraBlock.attrs?.keepNext === true) {
35665
35798
  const nextBlock = blocks[index2 + 1];
35666
35799
  const nextMeasure = measures[index2 + 1];
35667
35800
  if (nextBlock && nextMeasure && nextBlock.kind !== "sectionBreak" && nextBlock.kind !== "pageBreak" && nextBlock.kind !== "columnBreak") {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
- const index = require("./index-nEA2vtLH.cjs");
3
- require("./SuperConverter-PbxPQOyI.cjs");
2
+ const index = require("./index-CRVcSemy.cjs");
3
+ require("./SuperConverter-DLjFfhUV.cjs");
4
4
  const blankDocx = require("./blank-docx-DfW3Eeh2.cjs");
5
5
  const eventemitter3 = require("./eventemitter3-BQuRcMPI.cjs");
6
6
  const provider = require("@hocuspocus/provider");
@@ -7552,7 +7552,7 @@ const _sfc_main = {
7552
7552
  __name: "SuperDoc",
7553
7553
  emits: ["selection-update"],
7554
7554
  setup(__props, { emit: __emit }) {
7555
- const PdfViewer = vue.defineAsyncComponent(() => Promise.resolve().then(() => require("./PdfViewer-Vnsmg2cv.cjs")));
7555
+ const PdfViewer = vue.defineAsyncComponent(() => Promise.resolve().then(() => require("./PdfViewer-CwPJ8YYJ.cjs")));
7556
7556
  const superdocStore = useSuperdocStore();
7557
7557
  const commentsStore = useCommentsStore();
7558
7558
  const {
@@ -8506,7 +8506,7 @@ class SuperDoc extends eventemitter3.EventEmitter {
8506
8506
  this.config.colors = shuffleArray(this.config.colors);
8507
8507
  this.userColorMap = /* @__PURE__ */ new Map();
8508
8508
  this.colorIndex = 0;
8509
- this.version = "1.7.0-next.9";
8509
+ this.version = "1.7.0";
8510
8510
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
8511
8511
  this.superdocId = config.superdocId || uuid.v4();
8512
8512
  this.colors = this.config.colors;
@@ -1,6 +1,6 @@
1
1
  import { B as Buffer$2 } from "./jszip-B1fkPkPJ.es.js";
2
2
  import { t as twipsToInches, i as inchesToTwips, p as ptToTwips, l as linesToTwips, a as twipsToLines, b as pixelsToTwips, h as halfPointToPoints, c as twipsToPixels$2, d as convertSizeToCSS, e as inchesToPixels } from "./helpers-C8e9wR5l.es.js";
3
- import { g as generateDocxRandomId, T as TextSelection$1, o as objectIncludes, w as wrapTextsInRuns, D as DOMParser$1, c as createDocFromMarkdown, a as createDocFromHTML, b as chainableEditorState, d as convertMarkdownToHTML, f as findParentNode, e as findParentNodeClosestToPos, h as generateRandom32BitHex, i as generateRandomSigned32BitIntStrId, P as PluginKey, j as Plugin, M as Mapping, N as NodeSelection, k as Selection, l as Slice, m as DOMSerializer, F as Fragment, n as Mark$1, p as dropPoint, A as AllSelection, q as Schema$1, s as canSplit, t as resolveRunProperties, u as encodeMarksFromRPr, v as liftTarget, x as canJoin, y as joinPoint, z as replaceStep$1, R as ReplaceAroundStep$1, B as htmlHandler, C as ReplaceStep, E as getResolvedParagraphProperties, G as changeListLevel, H as isList$1, I as updateNumberingProperties, L as ListHelpers, J as inputRulesPlugin, K as TrackDeleteMarkName$1, O as TrackInsertMarkName$1, Q as TrackFormatMarkName$1, U as AddMarkStep, V as RemoveMarkStep, W as CommandService, S as SuperConverter, X as EditorState, Y as unflattenListsInHtml, Z as SelectionRange, _ as Transform, $ as createOoxmlResolver, a0 as translator, a1 as translator$1, a2 as resolveDocxFontFamily, a3 as combineIndentProperties, a4 as _getReferencedTableStyles, a5 as decodeRPrFromMarks, a6 as calculateResolvedParagraphProperties, a7 as encodeCSSFromPPr, a8 as encodeCSSFromRPr, a9 as generateOrderedListIndex, aa as docxNumberingHelpers, ab as InputRule, ac as insertNewRelationship, ad as kebabCase$1, ae as getUnderlineCssString } from "./SuperConverter-B0zMkLdc.es.js";
3
+ import { g as generateDocxRandomId, T as TextSelection$1, o as objectIncludes, w as wrapTextsInRuns, D as DOMParser$1, c as createDocFromMarkdown, a as createDocFromHTML, b as chainableEditorState, d as convertMarkdownToHTML, f as findParentNode, e as findParentNodeClosestToPos, h as generateRandom32BitHex, i as generateRandomSigned32BitIntStrId, P as PluginKey, j as Plugin, M as Mapping, N as NodeSelection, k as Selection, l as Slice, m as DOMSerializer, F as Fragment, n as Mark$1, p as dropPoint, A as AllSelection, q as Schema$1, s as canSplit, t as resolveRunProperties, u as encodeMarksFromRPr, v as liftTarget, x as canJoin, y as joinPoint, z as replaceStep$1, R as ReplaceAroundStep$1, B as htmlHandler, C as ReplaceStep, E as getResolvedParagraphProperties, G as changeListLevel, H as isList$1, I as updateNumberingProperties, L as ListHelpers, J as inputRulesPlugin, K as TrackDeleteMarkName$1, O as TrackInsertMarkName$1, Q as TrackFormatMarkName$1, U as AddMarkStep, V as RemoveMarkStep, W as CommandService, S as SuperConverter, X as EditorState, Y as unflattenListsInHtml, Z as SelectionRange, _ as Transform, $ as createOoxmlResolver, a0 as translator, a1 as translator$1, a2 as resolveDocxFontFamily, a3 as combineIndentProperties, a4 as _getReferencedTableStyles, a5 as decodeRPrFromMarks, a6 as calculateResolvedParagraphProperties, a7 as encodeCSSFromPPr, a8 as encodeCSSFromRPr, a9 as generateOrderedListIndex, aa as docxNumberingHelpers, ab as InputRule, ac as insertNewRelationship, ad as kebabCase$1, ae as getUnderlineCssString } from "./SuperConverter-exxhgRGz.es.js";
4
4
  import { p as process$1, r as ref, C as global$1, c as computed, E as createElementBlock, F as Fragment$1, S as renderList, O as withModifiers, G as openBlock, P as normalizeClass, M as createCommentVNode, H as toDisplayString, K as createBaseVNode, U as createApp, f as onMounted, X as onUnmounted, R as withDirectives, v as unref, Y as vModelText, y as nextTick, L as normalizeStyle, u as watch, Z as withKeys, _ as createTextVNode, I as createVNode, h as h$1, $ as readonly, s as getCurrentInstance, o as onBeforeUnmount, j as reactive, b as onBeforeMount, i as inject, a0 as onActivated, a1 as onDeactivated, a2 as Comment, d as defineComponent, a as provide, g as Teleport, t as toRef, a3 as renderSlot, a4 as isVNode, D as shallowRef, w as watchEffect, T as Transition, a5 as mergeProps, a6 as vShow, a7 as cloneVNode, a8 as Text$2, m as markRaw, N as createBlock, J as withCtx, a9 as useCssVars, V as resolveDynamicComponent, aa as normalizeProps, ab as guardReactiveProps } from "./vue-BnBKJwCW.es.js";
5
5
  import "./jszip.min-DCl8qkFO.es.js";
6
6
  import { E as EventEmitter$1 } from "./eventemitter3-CwrdEv8r.es.js";
@@ -15844,7 +15844,7 @@ const canUseDOM = () => {
15844
15844
  return false;
15845
15845
  }
15846
15846
  };
15847
- const summaryVersion = "1.7.0-next.9";
15847
+ const summaryVersion = "1.7.0";
15848
15848
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
15849
15849
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
15850
15850
  function mapAttributes(attrs) {
@@ -18514,7 +18514,7 @@ class Editor extends EventEmitter {
18514
18514
  * Process collaboration migrations
18515
18515
  */
18516
18516
  processCollaborationMigrations() {
18517
- console.debug("[checkVersionMigrations] Current editor version", "1.7.0-next.9");
18517
+ console.debug("[checkVersionMigrations] Current editor version", "1.7.0");
18518
18518
  if (!this.options.ydoc) return;
18519
18519
  const metaMap = this.options.ydoc.getMap("meta");
18520
18520
  let docVersion = metaMap.get("version");
@@ -34817,6 +34817,115 @@ function getMeasureHeight(block, measure) {
34817
34817
  }
34818
34818
  }
34819
34819
  }
34820
+ function computeKeepNextChains(blocks) {
34821
+ const chains = /* @__PURE__ */ new Map();
34822
+ const processedIndices = /* @__PURE__ */ new Set();
34823
+ for (let i = 0; i < blocks.length; i++) {
34824
+ if (processedIndices.has(i)) continue;
34825
+ const block = blocks[i];
34826
+ if (block.kind !== "paragraph") continue;
34827
+ const paraBlock = block;
34828
+ if (paraBlock.attrs?.keepNext !== true) continue;
34829
+ const memberIndices = [i];
34830
+ let endIndex = i;
34831
+ for (let j = i + 1; j < blocks.length; j++) {
34832
+ const nextBlock = blocks[j];
34833
+ if (nextBlock.kind === "sectionBreak" || nextBlock.kind === "pageBreak" || nextBlock.kind === "columnBreak") {
34834
+ break;
34835
+ }
34836
+ if (nextBlock.kind !== "paragraph") {
34837
+ break;
34838
+ }
34839
+ const nextPara = nextBlock;
34840
+ if (nextPara.attrs?.keepNext === true) {
34841
+ memberIndices.push(j);
34842
+ endIndex = j;
34843
+ processedIndices.add(j);
34844
+ } else {
34845
+ break;
34846
+ }
34847
+ }
34848
+ const anchorIndex = endIndex + 1 < blocks.length ? endIndex + 1 : -1;
34849
+ if (anchorIndex !== -1) {
34850
+ const anchorBlock = blocks[anchorIndex];
34851
+ if (anchorBlock.kind === "sectionBreak" || anchorBlock.kind === "pageBreak" || anchorBlock.kind === "columnBreak") {
34852
+ if (memberIndices.length > 1) {
34853
+ chains.set(i, {
34854
+ startIndex: i,
34855
+ endIndex,
34856
+ memberIndices,
34857
+ anchorIndex: -1
34858
+ });
34859
+ }
34860
+ continue;
34861
+ }
34862
+ }
34863
+ chains.set(i, {
34864
+ startIndex: i,
34865
+ endIndex,
34866
+ memberIndices,
34867
+ anchorIndex
34868
+ });
34869
+ }
34870
+ return chains;
34871
+ }
34872
+ function calculateChainHeight(chain, blocks, measures, state) {
34873
+ let totalHeight = 0;
34874
+ let prevStyleId;
34875
+ let prevSpacingAfter = 0;
34876
+ let prevContextualSpacing = false;
34877
+ let isFirstMember = true;
34878
+ for (const memberIndex of chain.memberIndices) {
34879
+ const block = blocks[memberIndex];
34880
+ const measure = measures[memberIndex];
34881
+ if (!measure) continue;
34882
+ const spacingBefore = getParagraphSpacingBefore(block);
34883
+ const spacingAfter = getParagraphSpacingAfter$1(block);
34884
+ const styleId = typeof block.attrs?.styleId === "string" ? block.attrs?.styleId : void 0;
34885
+ const contextualSpacing = block.attrs?.contextualSpacing === true;
34886
+ if (isFirstMember) {
34887
+ const prevTrailing = Number.isFinite(state.trailingSpacing) && state.trailingSpacing > 0 ? state.trailingSpacing : 0;
34888
+ const sameAsLastOnPage = styleId && state.lastParagraphStyleId === styleId;
34889
+ const effectiveSpacingBefore = contextualSpacing && sameAsLastOnPage ? 0 : Math.max(spacingBefore - prevTrailing, 0);
34890
+ totalHeight += effectiveSpacingBefore;
34891
+ isFirstMember = false;
34892
+ } else {
34893
+ const sameStyle = styleId && prevStyleId && styleId === prevStyleId;
34894
+ const effectiveSpacingAfterPrev = prevContextualSpacing && sameStyle ? 0 : prevSpacingAfter;
34895
+ const effectiveSpacingBefore = contextualSpacing && sameStyle ? 0 : spacingBefore;
34896
+ const interParagraphSpacing = Math.max(effectiveSpacingAfterPrev, effectiveSpacingBefore);
34897
+ totalHeight += interParagraphSpacing;
34898
+ }
34899
+ totalHeight += getMeasureHeight(block, measure);
34900
+ prevStyleId = styleId;
34901
+ prevSpacingAfter = spacingAfter;
34902
+ prevContextualSpacing = contextualSpacing;
34903
+ }
34904
+ if (chain.anchorIndex !== -1) {
34905
+ const anchorBlock = blocks[chain.anchorIndex];
34906
+ const anchorMeasure = measures[chain.anchorIndex];
34907
+ if (anchorBlock && anchorMeasure) {
34908
+ if (anchorBlock.kind === "paragraph" && anchorMeasure.kind === "paragraph") {
34909
+ const anchorSpacingBefore = getParagraphSpacingBefore(anchorBlock);
34910
+ const anchorStyleId = typeof anchorBlock.attrs?.styleId === "string" ? anchorBlock.attrs?.styleId : void 0;
34911
+ const anchorContextualSpacing = anchorBlock.attrs?.contextualSpacing === true;
34912
+ const sameStyle = anchorStyleId && prevStyleId && anchorStyleId === prevStyleId;
34913
+ const effectiveSpacingAfterPrev = prevContextualSpacing && sameStyle ? 0 : prevSpacingAfter;
34914
+ const effectiveAnchorSpacingBefore = anchorContextualSpacing && sameStyle ? 0 : anchorSpacingBefore;
34915
+ const interParagraphSpacing = Math.max(effectiveSpacingAfterPrev, effectiveAnchorSpacingBefore);
34916
+ const firstLineHeight = anchorMeasure.lines[0]?.lineHeight;
34917
+ const anchorHeight = typeof firstLineHeight === "number" && Number.isFinite(firstLineHeight) && firstLineHeight > 0 ? firstLineHeight : getMeasureHeight(anchorBlock, anchorMeasure);
34918
+ totalHeight += interParagraphSpacing + anchorHeight;
34919
+ } else {
34920
+ const isAnchoredTable = anchorBlock.kind === "table" && anchorBlock.anchor?.isAnchored === true;
34921
+ if (!isAnchoredTable) {
34922
+ totalHeight += prevSpacingAfter + getMeasureHeight(anchorBlock, anchorMeasure);
34923
+ }
34924
+ }
34925
+ }
34926
+ }
34927
+ return totalHeight;
34928
+ }
34820
34929
  const DEFAULT_PAGE_SIZE$2 = { w: 612, h: 792 };
34821
34930
  const DEFAULT_MARGINS$2 = { top: 72, right: 72, bottom: 72, left: 72 };
34822
34931
  const COLUMN_EPSILON$1 = 1e-4;
@@ -35428,6 +35537,13 @@ function layoutDocument(blocks, measures, options = {}) {
35428
35537
  floatManager.registerDrawing(entry.block, entry.measure, anchorY, state.columnIndex, state.page.number);
35429
35538
  preRegisteredPositions.set(entry.block.id, { anchorX, anchorY, pageNumber: state.page.number });
35430
35539
  }
35540
+ const keepNextChains = computeKeepNextChains(blocks);
35541
+ const midChainIndices = /* @__PURE__ */ new Set();
35542
+ for (const chain of keepNextChains.values()) {
35543
+ for (let i = 1; i < chain.memberIndices.length; i++) {
35544
+ midChainIndices.add(chain.memberIndices[i]);
35545
+ }
35546
+ }
35431
35547
  for (let index2 = 0; index2 < blocks.length; index2 += 1) {
35432
35548
  const block = blocks[index2];
35433
35549
  const measure = measures[index2];
@@ -35644,7 +35760,24 @@ function layoutDocument(blocks, measures, options = {}) {
35644
35760
  placedAnchoredTableIds.add(tableBlock.id);
35645
35761
  }
35646
35762
  }
35647
- if (paraBlock.attrs?.keepNext === true) {
35763
+ const chain = keepNextChains.get(index2);
35764
+ if (midChainIndices.has(index2)) ;
35765
+ else if (chain) {
35766
+ let state = paginator.ensurePage();
35767
+ const availableHeight = state.contentBottom - state.cursorY;
35768
+ const firstMemberBlock = blocks[chain.startIndex];
35769
+ const firstMemberStyleId = typeof firstMemberBlock.attrs?.styleId === "string" ? firstMemberBlock.attrs?.styleId : void 0;
35770
+ const firstMemberContextualSpacing = firstMemberBlock.attrs?.contextualSpacing === true;
35771
+ const contextualSpacingApplies = firstMemberContextualSpacing && firstMemberStyleId && state.lastParagraphStyleId === firstMemberStyleId;
35772
+ const prevTrailing = Number.isFinite(state.trailingSpacing) && state.trailingSpacing > 0 ? state.trailingSpacing : 0;
35773
+ const effectiveAvailableHeight = contextualSpacingApplies ? availableHeight + prevTrailing : availableHeight;
35774
+ const chainHeight = calculateChainHeight(chain, blocks, measures, state);
35775
+ const pageContentHeight = state.contentBottom - state.topMargin;
35776
+ const chainFitsOnBlankPage = chainHeight <= pageContentHeight;
35777
+ if (chainFitsOnBlankPage && chainHeight > effectiveAvailableHeight && state.page.fragments.length > 0) {
35778
+ state = paginator.advanceColumn(state);
35779
+ }
35780
+ } else if (paraBlock.attrs?.keepNext === true) {
35648
35781
  const nextBlock = blocks[index2 + 1];
35649
35782
  const nextMeasure = measures[index2 + 1];
35650
35783
  if (nextBlock && nextMeasure && nextBlock.kind !== "sectionBreak" && nextBlock.kind !== "pageBreak" && nextBlock.kind !== "columnBreak") {
@@ -1,5 +1,5 @@
1
- import { B as BIT8, M as MAX_SAFE_INTEGER, c as create, a as BITS7, u as utf8TextDecoder, b as create$1, s as setIfUndefined, d as create$2, f as from, e as floor$1, g as equalityDeep, w as writeVarUint, h as writeVarString, t as toUint8Array, i as createEncoder, j as createInjectionKey, k as toString, l as throwError, m as useSsrAdapter, n as configProviderInjectionKey, o as cssrAnchorMetaName, p as globalStyle, q as cB, r as c, v as isMounted, x as commonVariables$2, y as cM, z as cNotM, A as cE, C as derived, D as changeColor, E as insideModal, F as insidePopover, G as resolveWrappedSlot, H as on, I as warnOnce, J as useConfig, K as useMergedState, L as useMemo, N as useTheme, O as useRtl, P as createKey, Q as useThemeClass, R as createId, S as call, T as render, U as messageProviderInjectionKey, V as messageApiInjectionKey, W as fromBase64, X as onChange, Y as varStorage, Z as toBase64, _ as createUint8ArrayFromArrayBuffer, $ as offChange, a0 as writeVarUint8Array, a1 as map, a2 as length, a3 as isNode, a4 as min, a5 as pow, a6 as comments_module_events, a7 as getFileObject, a8 as getTrackChanges, a9 as CommentsPluginKey, aa as TrackChangesBasePluginKey, ab as Editor, ac as getRichTextExtensions, ad as ellipsisVerticalSvg, ae as xmarkIconSvg, af as checkIconSvg, ag as caretDownIconSvg, ah as commentIconSvg, ai as _export_sfc, aj as NDropdown, ak as SuperInput, al as vClickOutside, am as PresentationEditor, an as SuperEditor, ao as AIWriter, ap as NConfigProvider, aq as SuperToolbar } from "./index-C070FBOz.es.js";
2
- import "./SuperConverter-B0zMkLdc.es.js";
1
+ import { B as BIT8, M as MAX_SAFE_INTEGER, c as create, a as BITS7, u as utf8TextDecoder, b as create$1, s as setIfUndefined, d as create$2, f as from, e as floor$1, g as equalityDeep, w as writeVarUint, h as writeVarString, t as toUint8Array, i as createEncoder, j as createInjectionKey, k as toString, l as throwError, m as useSsrAdapter, n as configProviderInjectionKey, o as cssrAnchorMetaName, p as globalStyle, q as cB, r as c, v as isMounted, x as commonVariables$2, y as cM, z as cNotM, A as cE, C as derived, D as changeColor, E as insideModal, F as insidePopover, G as resolveWrappedSlot, H as on, I as warnOnce, J as useConfig, K as useMergedState, L as useMemo, N as useTheme, O as useRtl, P as createKey, Q as useThemeClass, R as createId, S as call, T as render, U as messageProviderInjectionKey, V as messageApiInjectionKey, W as fromBase64, X as onChange, Y as varStorage, Z as toBase64, _ as createUint8ArrayFromArrayBuffer, $ as offChange, a0 as writeVarUint8Array, a1 as map, a2 as length, a3 as isNode, a4 as min, a5 as pow, a6 as comments_module_events, a7 as getFileObject, a8 as getTrackChanges, a9 as CommentsPluginKey, aa as TrackChangesBasePluginKey, ab as Editor, ac as getRichTextExtensions, ad as ellipsisVerticalSvg, ae as xmarkIconSvg, af as checkIconSvg, ag as caretDownIconSvg, ah as commentIconSvg, ai as _export_sfc, aj as NDropdown, ak as SuperInput, al as vClickOutside, am as PresentationEditor, an as SuperEditor, ao as AIWriter, ap as NConfigProvider, aq as SuperToolbar } from "./index-i1HR2Dcb.es.js";
2
+ import "./SuperConverter-exxhgRGz.es.js";
3
3
  import { B as BlankDOCX } from "./blank-docx-ABm6XYAA.es.js";
4
4
  import { E as EventEmitter } from "./eventemitter3-CwrdEv8r.es.js";
5
5
  import { HocuspocusProvider, HocuspocusProviderWebsocket } from "@hocuspocus/provider";
@@ -7535,7 +7535,7 @@ const _sfc_main = {
7535
7535
  __name: "SuperDoc",
7536
7536
  emits: ["selection-update"],
7537
7537
  setup(__props, { emit: __emit }) {
7538
- const PdfViewer = defineAsyncComponent(() => import("./PdfViewer-W0haUdLl.es.js"));
7538
+ const PdfViewer = defineAsyncComponent(() => import("./PdfViewer-Bl6LYo6A.es.js"));
7539
7539
  const superdocStore = useSuperdocStore();
7540
7540
  const commentsStore = useCommentsStore();
7541
7541
  const {
@@ -8489,7 +8489,7 @@ class SuperDoc extends EventEmitter {
8489
8489
  this.config.colors = shuffleArray(this.config.colors);
8490
8490
  this.userColorMap = /* @__PURE__ */ new Map();
8491
8491
  this.colorIndex = 0;
8492
- this.version = "1.7.0-next.9";
8492
+ this.version = "1.7.0";
8493
8493
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
8494
8494
  this.superdocId = config.superdocId || v4();
8495
8495
  this.colors = this.config.colors;
@@ -2,6 +2,6 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  require("../chunks/jszip-C8_CqJxM.cjs");
4
4
  require("../chunks/helpers-nOdwpmwb.cjs");
5
- const superEditor_converter = require("../chunks/SuperConverter-PbxPQOyI.cjs");
5
+ const superEditor_converter = require("../chunks/SuperConverter-DLjFfhUV.cjs");
6
6
  require("../chunks/uuid-R7L08bOx.cjs");
7
7
  exports.SuperConverter = superEditor_converter.SuperConverter;
@@ -1,6 +1,6 @@
1
1
  import "../chunks/jszip-B1fkPkPJ.es.js";
2
2
  import "../chunks/helpers-C8e9wR5l.es.js";
3
- import { S } from "../chunks/SuperConverter-B0zMkLdc.es.js";
3
+ import { S } from "../chunks/SuperConverter-exxhgRGz.es.js";
4
4
  import "../chunks/uuid-CjlX8hrF.es.js";
5
5
  export {
6
6
  S as SuperConverter
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const index = require("./chunks/index-nEA2vtLH.cjs");
3
+ const index = require("./chunks/index-CRVcSemy.cjs");
4
4
  const superEditor_docxZipper = require("./super-editor/docx-zipper.cjs");
5
5
  const superEditor_fileZipper = require("./super-editor/file-zipper.cjs");
6
6
  const vue = require("./chunks/vue-De9wkgLl.cjs");
7
- const superEditor_converter = require("./chunks/SuperConverter-PbxPQOyI.cjs");
7
+ const superEditor_converter = require("./chunks/SuperConverter-DLjFfhUV.cjs");
8
8
  function isNodeType(node, name) {
9
9
  return node.type.name === name;
10
10
  }
@@ -1,9 +1,9 @@
1
- import { ax as Node, ay as Mark } from "./chunks/index-C070FBOz.es.js";
2
- import { ao, au, a9, ab, aw, am, av, aA, an, ak, aq, az, aa, as, aC, aE, aB, ac, aD, ar, at } from "./chunks/index-C070FBOz.es.js";
1
+ import { ax as Node, ay as Mark } from "./chunks/index-i1HR2Dcb.es.js";
2
+ import { ao, au, a9, ab, aw, am, av, aA, an, ak, aq, az, aa, as, aC, aE, aB, ac, aD, ar, at } from "./chunks/index-i1HR2Dcb.es.js";
3
3
  import { default as default2 } from "./super-editor/docx-zipper.es.js";
4
4
  import { createZip } from "./super-editor/file-zipper.es.js";
5
5
  import { d as defineComponent, E as createElementBlock, G as openBlock, K as createBaseVNode } from "./chunks/vue-BnBKJwCW.es.js";
6
- import { S, r } from "./chunks/SuperConverter-B0zMkLdc.es.js";
6
+ import { S, r } from "./chunks/SuperConverter-exxhgRGz.es.js";
7
7
  function isNodeType(node, name) {
8
8
  return node.type.name === name;
9
9
  }
package/dist/superdoc.cjs CHANGED
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const index = require("./chunks/index-nEA2vtLH.cjs");
4
- const superdoc = require("./chunks/index-CDRAe8oj.cjs");
5
- const superEditor_converter = require("./chunks/SuperConverter-PbxPQOyI.cjs");
3
+ const index = require("./chunks/index-CRVcSemy.cjs");
4
+ const superdoc = require("./chunks/index-D85x_K2T.cjs");
5
+ const superEditor_converter = require("./chunks/SuperConverter-DLjFfhUV.cjs");
6
6
  const blankDocx = require("./chunks/blank-docx-DfW3Eeh2.cjs");
7
7
  require("./chunks/jszip-C8_CqJxM.cjs");
8
8
  require("./chunks/helpers-nOdwpmwb.cjs");
@@ -1,6 +1,6 @@
1
- import { au, ab, aw, av, as, a7, ac, ar, at } from "./chunks/index-C070FBOz.es.js";
2
- import { D, H, P, S, c } from "./chunks/index-Dho4ex7D.es.js";
3
- import { S as S2, r } from "./chunks/SuperConverter-B0zMkLdc.es.js";
1
+ import { au, ab, aw, av, as, a7, ac, ar, at } from "./chunks/index-i1HR2Dcb.es.js";
2
+ import { D, H, P, S, c } from "./chunks/index-ugS0fOdR.es.js";
3
+ import { S as S2, r } from "./chunks/SuperConverter-exxhgRGz.es.js";
4
4
  import { B } from "./chunks/blank-docx-ABm6XYAA.es.js";
5
5
  import "./chunks/jszip-B1fkPkPJ.es.js";
6
6
  import "./chunks/helpers-C8e9wR5l.es.js";