@harbour-enterprises/superdoc 1.3.0-next.5 → 1.3.0-next.7

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,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-79lZpkMi.cjs");
5
- const index = require("./index-BHIGTNEQ.cjs");
4
+ const superdoc = require("./index-CKi-JNoY.cjs");
5
+ const index = require("./index-CmmcvSxn.cjs");
6
6
  function self(vars) {
7
7
  const {
8
8
  opacityDisabled,
@@ -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-B697vddF.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-BSxlafD_.es.js";
2
+ import { N as NBaseLoading, u as useSuperdocStore, s as storeToRefs, a as useSelection } from "./index-C0irsRkX.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-BuT4cwmK.es.js";
4
4
  function self(vars) {
5
5
  const {
6
6
  opacityDisabled,
@@ -30939,7 +30939,7 @@ class SuperConverter {
30939
30939
  static getStoredSuperdocVersion(docx) {
30940
30940
  return SuperConverter.getStoredCustomProperty(docx, "SuperdocVersion");
30941
30941
  }
30942
- static setStoredSuperdocVersion(docx = this.convertedXml, version = "1.3.0-next.5") {
30942
+ static setStoredSuperdocVersion(docx = this.convertedXml, version = "1.3.0-next.7") {
30943
30943
  return SuperConverter.setStoredCustomProperty(docx, "SuperdocVersion", version, false);
30944
30944
  }
30945
30945
  /**
@@ -30938,7 +30938,7 @@ class SuperConverter {
30938
30938
  static getStoredSuperdocVersion(docx) {
30939
30939
  return SuperConverter.getStoredCustomProperty(docx, "SuperdocVersion");
30940
30940
  }
30941
- static setStoredSuperdocVersion(docx = this.convertedXml, version = "1.3.0-next.5") {
30941
+ static setStoredSuperdocVersion(docx = this.convertedXml, version = "1.3.0-next.7") {
30942
30942
  return SuperConverter.setStoredCustomProperty(docx, "SuperdocVersion", version, false);
30943
30943
  }
30944
30944
  /**
@@ -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 _getReferencedTableStyles, a4 as decodeRPrFromMarks, a5 as calculateResolvedParagraphProperties, a6 as encodeCSSFromPPr, a7 as encodeCSSFromRPr, a8 as generateOrderedListIndex, a9 as docxNumberingHelpers, aa as InputRule, ab as insertNewRelationship, ac as kebabCase$1, ad as getUnderlineCssString } from "./SuperConverter-DMbipzpl.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 _getReferencedTableStyles, a4 as decodeRPrFromMarks, a5 as calculateResolvedParagraphProperties, a6 as encodeCSSFromPPr, a7 as encodeCSSFromRPr, a8 as generateOrderedListIndex, a9 as docxNumberingHelpers, aa as InputRule, ab as insertNewRelationship, ac as kebabCase$1, ad as getUnderlineCssString } from "./SuperConverter-Bc9dM-qO.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 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";
@@ -15334,7 +15334,7 @@ const canUseDOM = () => {
15334
15334
  return false;
15335
15335
  }
15336
15336
  };
15337
- const summaryVersion = "1.3.0-next.5";
15337
+ const summaryVersion = "1.3.0-next.7";
15338
15338
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
15339
15339
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
15340
15340
  function mapAttributes(attrs) {
@@ -17967,7 +17967,7 @@ class Editor extends EventEmitter {
17967
17967
  * Process collaboration migrations
17968
17968
  */
17969
17969
  processCollaborationMigrations() {
17970
- console.debug("[checkVersionMigrations] Current editor version", "1.3.0-next.5");
17970
+ console.debug("[checkVersionMigrations] Current editor version", "1.3.0-next.7");
17971
17971
  if (!this.options.ydoc) return;
17972
17972
  const metaMap = this.options.ydoc.getMap("meta");
17973
17973
  let docVersion = metaMap.get("version");
@@ -25551,7 +25551,28 @@ class DomPainter {
25551
25551
  section: kind,
25552
25552
  pageNumberText: page.numberText
25553
25553
  };
25554
- data.fragments.forEach((fragment) => {
25554
+ const behindDocFragments = [];
25555
+ const normalFragments = [];
25556
+ for (const fragment of data.fragments) {
25557
+ const isBehindDoc = (fragment.kind === "image" || fragment.kind === "drawing") && "zIndex" in fragment && fragment.zIndex === 0;
25558
+ if (isBehindDoc) {
25559
+ behindDocFragments.push(fragment);
25560
+ } else {
25561
+ normalFragments.push(fragment);
25562
+ }
25563
+ }
25564
+ const behindDocSelector = `[data-behind-doc-section="${kind}"]`;
25565
+ pageEl.querySelectorAll(behindDocSelector).forEach((el) => el.remove());
25566
+ behindDocFragments.forEach((fragment) => {
25567
+ const fragEl = this.renderFragment(fragment, context);
25568
+ const pageY = effectiveOffset + fragment.y + (kind === "footer" ? footerYOffset : 0);
25569
+ fragEl.style.top = `${pageY}px`;
25570
+ fragEl.style.left = `${marginLeft + fragment.x}px`;
25571
+ fragEl.style.zIndex = "0";
25572
+ fragEl.dataset.behindDocSection = kind;
25573
+ pageEl.insertBefore(fragEl, pageEl.firstChild);
25574
+ });
25575
+ normalFragments.forEach((fragment) => {
25555
25576
  const fragEl = this.renderFragment(fragment, context);
25556
25577
  if (footerYOffset > 0) {
25557
25578
  const currentTop = parseFloat(fragEl.style.top) || fragment.y;
@@ -30842,8 +30863,7 @@ function getHeaderFooterTypeForSection(pageNumber, sectionIndex, identifier, opt
30842
30863
  const titlePgEnabled = sectionTitlePg === true;
30843
30864
  const isFirstPageOfSection = sectionPageNumber === 1;
30844
30865
  if (isFirstPageOfSection && titlePgEnabled) {
30845
- if (hasFirst) return "first";
30846
- if (!hasDefault && !hasEven && !hasOdd) return null;
30866
+ if (hasFirst || hasDefault || hasEven || hasOdd) return "first";
30847
30867
  return null;
30848
30868
  }
30849
30869
  if (identifier.alternateHeaders) {
@@ -32899,6 +32919,45 @@ function layoutDocument(blocks, measures, options = {}) {
32899
32919
  return height;
32900
32920
  };
32901
32921
  const headerContentHeights = options.headerContentHeights;
32922
+ const footerContentHeights = options.footerContentHeights;
32923
+ const headerContentHeightsByRId = options.headerContentHeightsByRId;
32924
+ const footerContentHeightsByRId = options.footerContentHeightsByRId;
32925
+ const getVariantTypeForPage = (sectionPageNumber, titlePgEnabled, alternateHeaders) => {
32926
+ if (sectionPageNumber === 1 && titlePgEnabled) {
32927
+ return "first";
32928
+ }
32929
+ return "default";
32930
+ };
32931
+ const getHeaderHeightForPage = (variantType, headerRef) => {
32932
+ if (headerRef && headerContentHeightsByRId?.has(headerRef)) {
32933
+ return validateContentHeight(headerContentHeightsByRId.get(headerRef));
32934
+ }
32935
+ if (headerContentHeights) {
32936
+ return validateContentHeight(headerContentHeights[variantType]);
32937
+ }
32938
+ return 0;
32939
+ };
32940
+ const getFooterHeightForPage = (variantType, footerRef) => {
32941
+ if (footerRef && footerContentHeightsByRId?.has(footerRef)) {
32942
+ return validateContentHeight(footerContentHeightsByRId.get(footerRef));
32943
+ }
32944
+ if (footerContentHeights) {
32945
+ return validateContentHeight(footerContentHeights[variantType]);
32946
+ }
32947
+ return 0;
32948
+ };
32949
+ const calculateEffectiveTopMargin = (headerContentHeight, currentHeaderDistance, baseTopMargin) => {
32950
+ if (headerContentHeight > 0) {
32951
+ return Math.max(baseTopMargin, currentHeaderDistance + headerContentHeight);
32952
+ }
32953
+ return baseTopMargin;
32954
+ };
32955
+ const calculateEffectiveBottomMargin = (footerContentHeight, currentFooterDistance, baseBottomMargin) => {
32956
+ if (footerContentHeight > 0) {
32957
+ return Math.max(baseBottomMargin, currentFooterDistance + footerContentHeight);
32958
+ }
32959
+ return baseBottomMargin;
32960
+ };
32902
32961
  const maxHeaderContentHeight = headerContentHeights ? Math.max(
32903
32962
  0,
32904
32963
  validateContentHeight(headerContentHeights.default),
@@ -32906,9 +32965,6 @@ function layoutDocument(blocks, measures, options = {}) {
32906
32965
  validateContentHeight(headerContentHeights.even),
32907
32966
  validateContentHeight(headerContentHeights.odd)
32908
32967
  ) : 0;
32909
- const headerDistance = margins.header ?? margins.top;
32910
- const effectiveTopMargin = maxHeaderContentHeight > 0 ? Math.max(margins.top, headerDistance + maxHeaderContentHeight) : margins.top;
32911
- const footerContentHeights = options.footerContentHeights;
32912
32968
  const maxFooterContentHeight = footerContentHeights ? Math.max(
32913
32969
  0,
32914
32970
  validateContentHeight(footerContentHeights.default),
@@ -32916,8 +32972,12 @@ function layoutDocument(blocks, measures, options = {}) {
32916
32972
  validateContentHeight(footerContentHeights.even),
32917
32973
  validateContentHeight(footerContentHeights.odd)
32918
32974
  ) : 0;
32975
+ const headerDistance = margins.header ?? margins.top;
32919
32976
  const footerDistance = margins.footer ?? margins.bottom;
32920
- const effectiveBottomMargin = maxFooterContentHeight > 0 ? Math.max(margins.bottom, footerDistance + maxFooterContentHeight) : margins.bottom;
32977
+ const defaultHeaderHeight = getHeaderHeightForPage("default", void 0);
32978
+ const defaultFooterHeight = getFooterHeightForPage("default", void 0);
32979
+ const effectiveTopMargin = calculateEffectiveTopMargin(defaultHeaderHeight, headerDistance, margins.top);
32980
+ const effectiveBottomMargin = calculateEffectiveBottomMargin(defaultFooterHeight, footerDistance, margins.bottom);
32921
32981
  let activeTopMargin = effectiveTopMargin;
32922
32982
  let activeBottomMargin = effectiveBottomMargin;
32923
32983
  let activeLeftMargin = margins.left;
@@ -32926,6 +32986,10 @@ function layoutDocument(blocks, measures, options = {}) {
32926
32986
  let pendingBottomMargin = null;
32927
32987
  let pendingLeftMargin = null;
32928
32988
  let pendingRightMargin = null;
32989
+ let activeSectionBaseTopMargin = margins.top;
32990
+ let activeSectionBaseBottomMargin = margins.bottom;
32991
+ let pendingSectionBaseTopMargin = null;
32992
+ let pendingSectionBaseBottomMargin = null;
32929
32993
  let activeHeaderDistance = margins.header ?? margins.top;
32930
32994
  let pendingHeaderDistance = null;
32931
32995
  let activeFooterDistance = margins.footer ?? margins.bottom;
@@ -33131,6 +33195,7 @@ function layoutDocument(blocks, measures, options = {}) {
33131
33195
  }
33132
33196
  let activeSectionIndex = initialSectionMetadata?.sectionIndex ?? 0;
33133
33197
  let pendingSectionIndex = null;
33198
+ const sectionFirstPageNumbers = /* @__PURE__ */ new Map();
33134
33199
  const paginator = createPaginator({
33135
33200
  margins: paginatorMargins,
33136
33201
  getActiveTopMargin: () => activeTopMargin,
@@ -33144,6 +33209,7 @@ function layoutDocument(blocks, measures, options = {}) {
33144
33209
  createPage,
33145
33210
  onNewPage: (state) => {
33146
33211
  if (!state) {
33212
+ const isEnteringNewSection = pendingSectionIndex !== null;
33147
33213
  const applied = applyPendingToActive({
33148
33214
  activeTopMargin,
33149
33215
  activeBottomMargin,
@@ -33211,7 +33277,69 @@ function layoutDocument(blocks, measures, options = {}) {
33211
33277
  activeVAlign = pendingVAlign;
33212
33278
  pendingVAlign = null;
33213
33279
  }
33280
+ if (pendingSectionBaseTopMargin !== null) {
33281
+ activeSectionBaseTopMargin = pendingSectionBaseTopMargin;
33282
+ pendingSectionBaseTopMargin = null;
33283
+ }
33284
+ if (pendingSectionBaseBottomMargin !== null) {
33285
+ activeSectionBaseBottomMargin = pendingSectionBaseBottomMargin;
33286
+ pendingSectionBaseBottomMargin = null;
33287
+ }
33214
33288
  pageCount += 1;
33289
+ const newPageNumber = pageCount;
33290
+ if (isEnteringNewSection || !sectionFirstPageNumbers.has(activeSectionIndex)) {
33291
+ sectionFirstPageNumbers.set(activeSectionIndex, newPageNumber);
33292
+ }
33293
+ const firstPageInSection = sectionFirstPageNumbers.get(activeSectionIndex) ?? newPageNumber;
33294
+ const sectionPageNumber = newPageNumber - firstPageInSection + 1;
33295
+ const sectionMetadata = sectionMetadataList[activeSectionIndex];
33296
+ const titlePgEnabled = sectionMetadata?.titlePg ?? false;
33297
+ const variantType = getVariantTypeForPage(sectionPageNumber, titlePgEnabled);
33298
+ let headerRef = activeSectionRefs?.headerRefs?.[variantType];
33299
+ let footerRef = activeSectionRefs?.footerRefs?.[variantType];
33300
+ let effectiveVariantType = variantType;
33301
+ if (!headerRef && variantType !== "default" && activeSectionIndex > 0) {
33302
+ const prevSectionMetadata = sectionMetadataList[activeSectionIndex - 1];
33303
+ if (prevSectionMetadata?.headerRefs?.[variantType]) {
33304
+ headerRef = prevSectionMetadata.headerRefs[variantType];
33305
+ layoutLog(
33306
+ `[Layout] Page ${newPageNumber}: Inheriting header '${variantType}' from section ${activeSectionIndex - 1}: ${headerRef}`
33307
+ );
33308
+ }
33309
+ }
33310
+ if (!footerRef && variantType !== "default" && activeSectionIndex > 0) {
33311
+ const prevSectionMetadata = sectionMetadataList[activeSectionIndex - 1];
33312
+ if (prevSectionMetadata?.footerRefs?.[variantType]) {
33313
+ footerRef = prevSectionMetadata.footerRefs[variantType];
33314
+ layoutLog(
33315
+ `[Layout] Page ${newPageNumber}: Inheriting footer '${variantType}' from section ${activeSectionIndex - 1}: ${footerRef}`
33316
+ );
33317
+ }
33318
+ }
33319
+ if (!headerRef && variantType !== "default" && activeSectionRefs?.headerRefs?.default) {
33320
+ headerRef = activeSectionRefs.headerRefs.default;
33321
+ effectiveVariantType = "default";
33322
+ }
33323
+ if (!footerRef && variantType !== "default" && activeSectionRefs?.footerRefs?.default) {
33324
+ footerRef = activeSectionRefs.footerRefs.default;
33325
+ }
33326
+ const headerHeight = getHeaderHeightForPage(effectiveVariantType, headerRef);
33327
+ const footerHeight = getFooterHeightForPage(
33328
+ variantType !== "default" && !activeSectionRefs?.footerRefs?.[variantType] ? "default" : variantType,
33329
+ footerRef
33330
+ );
33331
+ activeTopMargin = calculateEffectiveTopMargin(headerHeight, activeHeaderDistance, activeSectionBaseTopMargin);
33332
+ activeBottomMargin = calculateEffectiveBottomMargin(
33333
+ footerHeight,
33334
+ activeFooterDistance,
33335
+ activeSectionBaseBottomMargin
33336
+ );
33337
+ layoutLog(
33338
+ `[Layout] Page ${newPageNumber}: Using variant '${variantType}' - headerHeight: ${headerHeight}, footerHeight: ${footerHeight}`
33339
+ );
33340
+ layoutLog(
33341
+ `[Layout] Page ${newPageNumber}: Adjusted margins - top: ${activeTopMargin}, bottom: ${activeBottomMargin} (base: ${activeSectionBaseTopMargin}, ${activeSectionBaseBottomMargin})`
33342
+ );
33215
33343
  return;
33216
33344
  }
33217
33345
  if (state?.page) {
@@ -33417,6 +33545,20 @@ function layoutDocument(blocks, measures, options = {}) {
33417
33545
  pendingColumns = updatedState.pendingColumns;
33418
33546
  activeOrientation = updatedState.activeOrientation;
33419
33547
  pendingOrientation = updatedState.pendingOrientation;
33548
+ const isFirstSection = effectiveBlock.attrs?.isFirstSection && states.length === 0;
33549
+ const blockTopMargin = effectiveBlock.margins?.top;
33550
+ const blockBottomMargin = effectiveBlock.margins?.bottom;
33551
+ if (isFirstSection) {
33552
+ activeSectionBaseTopMargin = typeof blockTopMargin === "number" ? blockTopMargin : margins.top;
33553
+ activeSectionBaseBottomMargin = typeof blockBottomMargin === "number" ? blockBottomMargin : margins.bottom;
33554
+ } else if (blockTopMargin !== void 0 || blockBottomMargin !== void 0) {
33555
+ if (blockTopMargin !== void 0) {
33556
+ pendingSectionBaseTopMargin = typeof blockTopMargin === "number" ? blockTopMargin : margins.top;
33557
+ }
33558
+ if (blockBottomMargin !== void 0) {
33559
+ pendingSectionBaseBottomMargin = typeof blockBottomMargin === "number" ? blockBottomMargin : margins.bottom;
33560
+ }
33561
+ }
33420
33562
  if (effectiveBlock.vAlign) {
33421
33563
  const isFirstSection2 = effectiveBlock.attrs?.isFirstSection && states.length === 0;
33422
33564
  if (isFirstSection2) {
@@ -33435,7 +33577,6 @@ function layoutDocument(blocks, measures, options = {}) {
33435
33577
  }
33436
33578
  const sectionIndexRaw = effectiveBlock.attrs?.sectionIndex;
33437
33579
  const metadataIndex = typeof sectionIndexRaw === "number" ? sectionIndexRaw : Number(sectionIndexRaw ?? NaN);
33438
- const isFirstSection = effectiveBlock.attrs?.isFirstSection && states.length === 0;
33439
33580
  if (Number.isFinite(metadataIndex)) {
33440
33581
  if (isFirstSection) {
33441
33582
  activeSectionIndex = metadataIndex;
@@ -33759,10 +33900,6 @@ function layoutHeaderFooter(blocks, measures, constraints) {
33759
33900
  if (!Number.isFinite(height) || height <= 0) {
33760
33901
  return { pages: [], height: 0 };
33761
33902
  }
33762
- const overflowBase = typeof constraints.overflowBaseHeight === "number" && Number.isFinite(constraints.overflowBaseHeight) && constraints.overflowBaseHeight > 0 ? constraints.overflowBaseHeight : height;
33763
- const maxBehindDocOverflow = Math.max(192, overflowBase * 4);
33764
- const minBehindDocY = -maxBehindDocOverflow;
33765
- const maxBehindDocY = height + maxBehindDocOverflow;
33766
33903
  const marginLeft = constraints.margins?.left ?? 0;
33767
33904
  const transformedBlocks = marginLeft > 0 ? blocks.map((block) => {
33768
33905
  const hasPageRelativeAnchor = (block.kind === "image" || block.kind === "drawing") && block.anchor?.hRelativeFrom === "page" && block.anchor.offsetH != null;
@@ -33801,7 +33938,7 @@ function layoutHeaderFooter(blocks, measures, constraints) {
33801
33938
  );
33802
33939
  }
33803
33940
  const anchoredBlock = block;
33804
- if (anchoredBlock.anchor?.behindDoc && (fragment.y < minBehindDocY || fragment.y > maxBehindDocY)) {
33941
+ if (anchoredBlock.anchor?.behindDoc) {
33805
33942
  continue;
33806
33943
  }
33807
33944
  }
@@ -35623,6 +35760,7 @@ async function incrementalLayout(previousBlocks, _previousLayout, nextBlocks, op
35623
35760
  `[Perf] 4.1 Measure all blocks: ${(measureEnd - measureStart).toFixed(2)}ms (${cacheMisses} measured, ${cacheHits} cached)`
35624
35761
  );
35625
35762
  let headerContentHeights;
35763
+ let headerContentHeightsByRId;
35626
35764
  const hasHeaderBlocks = headerFooter?.headerBlocks && Object.keys(headerFooter.headerBlocks).length > 0;
35627
35765
  const hasHeaderBlocksByRId = headerFooter?.headerBlocksByRId && headerFooter.headerBlocksByRId.size > 0;
35628
35766
  if (headerFooter?.constraints && (hasHeaderBlocks || hasHeaderBlocksByRId)) {
@@ -35662,7 +35800,8 @@ async function incrementalLayout(previousBlocks, _previousLayout, nextBlocks, op
35662
35800
  }
35663
35801
  }
35664
35802
  if (hasHeaderBlocksByRId && headerFooter.headerBlocksByRId) {
35665
- for (const [_rId, blocks] of headerFooter.headerBlocksByRId) {
35803
+ headerContentHeightsByRId = /* @__PURE__ */ new Map();
35804
+ for (const [rId, blocks] of headerFooter.headerBlocksByRId) {
35666
35805
  if (!blocks || blocks.length === 0) continue;
35667
35806
  const measureConstraints = {
35668
35807
  maxWidth: headerFooter.constraints.width,
@@ -35674,8 +35813,7 @@ async function incrementalLayout(previousBlocks, _previousLayout, nextBlocks, op
35674
35813
  height: headerFooter.constraints.height
35675
35814
  });
35676
35815
  if (layout2.height > 0) {
35677
- const currentDefault = headerContentHeights.default ?? 0;
35678
- headerContentHeights.default = Math.max(currentDefault, layout2.height);
35816
+ headerContentHeightsByRId.set(rId, layout2.height);
35679
35817
  }
35680
35818
  }
35681
35819
  }
@@ -35683,6 +35821,7 @@ async function incrementalLayout(previousBlocks, _previousLayout, nextBlocks, op
35683
35821
  perfLog(`[Perf] 4.1.5 Pre-layout headers for height: ${(hfPreEnd - hfPreStart).toFixed(2)}ms`);
35684
35822
  }
35685
35823
  let footerContentHeights;
35824
+ let footerContentHeightsByRId;
35686
35825
  const hasFooterBlocks = headerFooter?.footerBlocks && Object.keys(headerFooter.footerBlocks).length > 0;
35687
35826
  const hasFooterBlocksByRId = headerFooter?.footerBlocksByRId && headerFooter.footerBlocksByRId.size > 0;
35688
35827
  if (headerFooter?.constraints && (hasFooterBlocks || hasFooterBlocksByRId)) {
@@ -35725,7 +35864,8 @@ async function incrementalLayout(previousBlocks, _previousLayout, nextBlocks, op
35725
35864
  }
35726
35865
  }
35727
35866
  if (hasFooterBlocksByRId && headerFooter.footerBlocksByRId) {
35728
- for (const [_rId, blocks] of headerFooter.footerBlocksByRId) {
35867
+ footerContentHeightsByRId = /* @__PURE__ */ new Map();
35868
+ for (const [rId, blocks] of headerFooter.footerBlocksByRId) {
35729
35869
  if (!blocks || blocks.length === 0) continue;
35730
35870
  const measureConstraints = {
35731
35871
  maxWidth: headerFooter.constraints.width,
@@ -35737,8 +35877,7 @@ async function incrementalLayout(previousBlocks, _previousLayout, nextBlocks, op
35737
35877
  height: headerFooter.constraints.height
35738
35878
  });
35739
35879
  if (layout2.height > 0) {
35740
- const currentDefault = footerContentHeights.default ?? 0;
35741
- footerContentHeights.default = Math.max(currentDefault, layout2.height);
35880
+ footerContentHeightsByRId.set(rId, layout2.height);
35742
35881
  }
35743
35882
  }
35744
35883
  }
@@ -35753,9 +35892,13 @@ async function incrementalLayout(previousBlocks, _previousLayout, nextBlocks, op
35753
35892
  let layout = layoutDocument(nextBlocks, measures, {
35754
35893
  ...options,
35755
35894
  headerContentHeights,
35756
- // Pass header heights to prevent overlap
35895
+ // Pass header heights to prevent overlap (per-variant)
35757
35896
  footerContentHeights,
35758
- // Pass footer heights to prevent overlap
35897
+ // Pass footer heights to prevent overlap (per-variant)
35898
+ headerContentHeightsByRId,
35899
+ // Pass header heights by rId for per-page margin calculation
35900
+ footerContentHeightsByRId,
35901
+ // Pass footer heights by rId for per-page margin calculation
35759
35902
  remeasureParagraph: (block, maxWidth, firstLineIndent) => remeasureParagraph(block, maxWidth, firstLineIndent)
35760
35903
  });
35761
35904
  const layoutEnd = performance.now();
@@ -35803,9 +35946,13 @@ async function incrementalLayout(previousBlocks, _previousLayout, nextBlocks, op
35803
35946
  layout = layoutDocument(currentBlocks, currentMeasures, {
35804
35947
  ...options,
35805
35948
  headerContentHeights,
35806
- // Pass header heights to prevent overlap
35949
+ // Pass header heights to prevent overlap (per-variant)
35807
35950
  footerContentHeights,
35808
- // Pass footer heights to prevent overlap
35951
+ // Pass footer heights to prevent overlap (per-variant)
35952
+ headerContentHeightsByRId,
35953
+ // Pass header heights by rId for per-page margin calculation
35954
+ footerContentHeightsByRId,
35955
+ // Pass footer heights by rId for per-page margin calculation
35809
35956
  remeasureParagraph: (block, maxWidth, firstLineIndent) => remeasureParagraph(block, maxWidth, firstLineIndent)
35810
35957
  });
35811
35958
  const relayoutEnd = performance.now();
@@ -53386,7 +53533,26 @@ class PresentationEditor extends EventEmitter {
53386
53533
  const firstPageInSection = sectionFirstPageNumbers.get(sectionIndex);
53387
53534
  const sectionPageNumber = typeof firstPageInSection === "number" ? pageNumber - firstPageInSection + 1 : pageNumber;
53388
53535
  const headerFooterType = multiSectionId ? getHeaderFooterTypeForSection(pageNumber, sectionIndex, multiSectionId, { kind, sectionPageNumber }) : getHeaderFooterType(pageNumber, legacyIdentifier, { kind });
53389
- const sectionRId = page?.sectionRefs && kind === "header" ? page.sectionRefs.headerRefs?.[headerFooterType] ?? void 0 : page?.sectionRefs && kind === "footer" ? page.sectionRefs.footerRefs?.[headerFooterType] ?? void 0 : void 0;
53536
+ let sectionRId;
53537
+ if (page?.sectionRefs && kind === "header") {
53538
+ sectionRId = page.sectionRefs.headerRefs?.[headerFooterType];
53539
+ if (!sectionRId && headerFooterType && headerFooterType !== "default" && sectionIndex > 0 && multiSectionId) {
53540
+ const prevSectionIds = multiSectionId.sectionHeaderIds.get(sectionIndex - 1);
53541
+ sectionRId = prevSectionIds?.[headerFooterType] ?? void 0;
53542
+ }
53543
+ if (!sectionRId && headerFooterType !== "default") {
53544
+ sectionRId = page.sectionRefs.headerRefs?.default;
53545
+ }
53546
+ } else if (page?.sectionRefs && kind === "footer") {
53547
+ sectionRId = page.sectionRefs.footerRefs?.[headerFooterType];
53548
+ if (!sectionRId && headerFooterType && headerFooterType !== "default" && sectionIndex > 0 && multiSectionId) {
53549
+ const prevSectionIds = multiSectionId.sectionFooterIds.get(sectionIndex - 1);
53550
+ sectionRId = prevSectionIds?.[headerFooterType] ?? void 0;
53551
+ }
53552
+ if (!sectionRId && headerFooterType !== "default") {
53553
+ sectionRId = page.sectionRefs.footerRefs?.default;
53554
+ }
53555
+ }
53390
53556
  if (!headerFooterType) {
53391
53557
  return null;
53392
53558
  }
@@ -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-BSxlafD_.es.js";
2
- import "./SuperConverter-DMbipzpl.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-BuT4cwmK.es.js";
2
+ import "./SuperConverter-Bc9dM-qO.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";
@@ -7444,7 +7444,7 @@ const _sfc_main = {
7444
7444
  __name: "SuperDoc",
7445
7445
  emits: ["selection-update"],
7446
7446
  setup(__props, { emit: __emit }) {
7447
- const PdfViewer = defineAsyncComponent(() => import("./PdfViewer-Dbc_J_1L.es.js"));
7447
+ const PdfViewer = defineAsyncComponent(() => import("./PdfViewer-CnKGOFjP.es.js"));
7448
7448
  const superdocStore = useSuperdocStore();
7449
7449
  const commentsStore = useCommentsStore();
7450
7450
  const {
@@ -8350,7 +8350,7 @@ class SuperDoc extends EventEmitter {
8350
8350
  this.config.colors = shuffleArray(this.config.colors);
8351
8351
  this.userColorMap = /* @__PURE__ */ new Map();
8352
8352
  this.colorIndex = 0;
8353
- this.version = "1.3.0-next.5";
8353
+ this.version = "1.3.0-next.7";
8354
8354
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
8355
8355
  this.superdocId = config.superdocId || v4();
8356
8356
  this.colors = this.config.colors;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
- const index = require("./index-BHIGTNEQ.cjs");
3
- require("./SuperConverter-tcg6NQjY.cjs");
2
+ const index = require("./index-CmmcvSxn.cjs");
3
+ require("./SuperConverter-BIrkxV37.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");
@@ -7461,7 +7461,7 @@ const _sfc_main = {
7461
7461
  __name: "SuperDoc",
7462
7462
  emits: ["selection-update"],
7463
7463
  setup(__props, { emit: __emit }) {
7464
- const PdfViewer = vue.defineAsyncComponent(() => Promise.resolve().then(() => require("./PdfViewer-CvoctNPw.cjs")));
7464
+ const PdfViewer = vue.defineAsyncComponent(() => Promise.resolve().then(() => require("./PdfViewer-BolWPjJ9.cjs")));
7465
7465
  const superdocStore = useSuperdocStore();
7466
7466
  const commentsStore = useCommentsStore();
7467
7467
  const {
@@ -8367,7 +8367,7 @@ class SuperDoc extends eventemitter3.EventEmitter {
8367
8367
  this.config.colors = shuffleArray(this.config.colors);
8368
8368
  this.userColorMap = /* @__PURE__ */ new Map();
8369
8369
  this.colorIndex = 0;
8370
- this.version = "1.3.0-next.5";
8370
+ this.version = "1.3.0-next.7";
8371
8371
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
8372
8372
  this.superdocId = config.superdocId || uuid.v4();
8373
8373
  this.colors = this.config.colors;