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

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-CEDW4NYV.cjs");
5
+ const index = require("./index-C4RVDXKX.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-9qGjdWOS.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-CqbujvlE.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.6") {
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.6") {
30942
30942
  return SuperConverter.setStoredCustomProperty(docx, "SuperdocVersion", version, false);
30943
30943
  }
30944
30944
  /**
@@ -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-CqbujvlE.es.js";
2
+ import "./SuperConverter-S9b1fFw5.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-oYYAvC47.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.6";
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,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-tcg6NQjY.cjs");
4
+ const superEditor_converter = require("./SuperConverter-BdOf8skU.cjs");
5
5
  const vue = require("./vue-De9wkgLl.cjs");
6
6
  require("./jszip.min-BPh2MMAa.cjs");
7
7
  const eventemitter3 = require("./eventemitter3-BQuRcMPI.cjs");
@@ -15351,7 +15351,7 @@ const canUseDOM = () => {
15351
15351
  return false;
15352
15352
  }
15353
15353
  };
15354
- const summaryVersion = "1.3.0-next.5";
15354
+ const summaryVersion = "1.3.0-next.6";
15355
15355
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
15356
15356
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
15357
15357
  function mapAttributes(attrs) {
@@ -17984,7 +17984,7 @@ class Editor extends EventEmitter {
17984
17984
  * Process collaboration migrations
17985
17985
  */
17986
17986
  processCollaborationMigrations() {
17987
- console.debug("[checkVersionMigrations] Current editor version", "1.3.0-next.5");
17987
+ console.debug("[checkVersionMigrations] Current editor version", "1.3.0-next.6");
17988
17988
  if (!this.options.ydoc) return;
17989
17989
  const metaMap = this.options.ydoc.getMap("meta");
17990
17990
  let docVersion = metaMap.get("version");
@@ -30859,8 +30859,7 @@ function getHeaderFooterTypeForSection(pageNumber, sectionIndex, identifier, opt
30859
30859
  const titlePgEnabled = sectionTitlePg === true;
30860
30860
  const isFirstPageOfSection = sectionPageNumber === 1;
30861
30861
  if (isFirstPageOfSection && titlePgEnabled) {
30862
- if (hasFirst) return "first";
30863
- if (!hasDefault && !hasEven && !hasOdd) return null;
30862
+ if (hasFirst || hasDefault || hasEven || hasOdd) return "first";
30864
30863
  return null;
30865
30864
  }
30866
30865
  if (identifier.alternateHeaders) {
@@ -32916,6 +32915,45 @@ function layoutDocument(blocks, measures, options = {}) {
32916
32915
  return height;
32917
32916
  };
32918
32917
  const headerContentHeights = options.headerContentHeights;
32918
+ const footerContentHeights = options.footerContentHeights;
32919
+ const headerContentHeightsByRId = options.headerContentHeightsByRId;
32920
+ const footerContentHeightsByRId = options.footerContentHeightsByRId;
32921
+ const getVariantTypeForPage = (sectionPageNumber, titlePgEnabled, alternateHeaders) => {
32922
+ if (sectionPageNumber === 1 && titlePgEnabled) {
32923
+ return "first";
32924
+ }
32925
+ return "default";
32926
+ };
32927
+ const getHeaderHeightForPage = (variantType, headerRef) => {
32928
+ if (headerRef && headerContentHeightsByRId?.has(headerRef)) {
32929
+ return validateContentHeight(headerContentHeightsByRId.get(headerRef));
32930
+ }
32931
+ if (headerContentHeights) {
32932
+ return validateContentHeight(headerContentHeights[variantType]);
32933
+ }
32934
+ return 0;
32935
+ };
32936
+ const getFooterHeightForPage = (variantType, footerRef) => {
32937
+ if (footerRef && footerContentHeightsByRId?.has(footerRef)) {
32938
+ return validateContentHeight(footerContentHeightsByRId.get(footerRef));
32939
+ }
32940
+ if (footerContentHeights) {
32941
+ return validateContentHeight(footerContentHeights[variantType]);
32942
+ }
32943
+ return 0;
32944
+ };
32945
+ const calculateEffectiveTopMargin = (headerContentHeight, currentHeaderDistance, baseTopMargin) => {
32946
+ if (headerContentHeight > 0) {
32947
+ return Math.max(baseTopMargin, currentHeaderDistance + headerContentHeight);
32948
+ }
32949
+ return baseTopMargin;
32950
+ };
32951
+ const calculateEffectiveBottomMargin = (footerContentHeight, currentFooterDistance, baseBottomMargin) => {
32952
+ if (footerContentHeight > 0) {
32953
+ return Math.max(baseBottomMargin, currentFooterDistance + footerContentHeight);
32954
+ }
32955
+ return baseBottomMargin;
32956
+ };
32919
32957
  const maxHeaderContentHeight = headerContentHeights ? Math.max(
32920
32958
  0,
32921
32959
  validateContentHeight(headerContentHeights.default),
@@ -32923,9 +32961,6 @@ function layoutDocument(blocks, measures, options = {}) {
32923
32961
  validateContentHeight(headerContentHeights.even),
32924
32962
  validateContentHeight(headerContentHeights.odd)
32925
32963
  ) : 0;
32926
- const headerDistance = margins.header ?? margins.top;
32927
- const effectiveTopMargin = maxHeaderContentHeight > 0 ? Math.max(margins.top, headerDistance + maxHeaderContentHeight) : margins.top;
32928
- const footerContentHeights = options.footerContentHeights;
32929
32964
  const maxFooterContentHeight = footerContentHeights ? Math.max(
32930
32965
  0,
32931
32966
  validateContentHeight(footerContentHeights.default),
@@ -32933,8 +32968,12 @@ function layoutDocument(blocks, measures, options = {}) {
32933
32968
  validateContentHeight(footerContentHeights.even),
32934
32969
  validateContentHeight(footerContentHeights.odd)
32935
32970
  ) : 0;
32971
+ const headerDistance = margins.header ?? margins.top;
32936
32972
  const footerDistance = margins.footer ?? margins.bottom;
32937
- const effectiveBottomMargin = maxFooterContentHeight > 0 ? Math.max(margins.bottom, footerDistance + maxFooterContentHeight) : margins.bottom;
32973
+ const defaultHeaderHeight = getHeaderHeightForPage("default", void 0);
32974
+ const defaultFooterHeight = getFooterHeightForPage("default", void 0);
32975
+ const effectiveTopMargin = calculateEffectiveTopMargin(defaultHeaderHeight, headerDistance, margins.top);
32976
+ const effectiveBottomMargin = calculateEffectiveBottomMargin(defaultFooterHeight, footerDistance, margins.bottom);
32938
32977
  let activeTopMargin = effectiveTopMargin;
32939
32978
  let activeBottomMargin = effectiveBottomMargin;
32940
32979
  let activeLeftMargin = margins.left;
@@ -32943,6 +32982,10 @@ function layoutDocument(blocks, measures, options = {}) {
32943
32982
  let pendingBottomMargin = null;
32944
32983
  let pendingLeftMargin = null;
32945
32984
  let pendingRightMargin = null;
32985
+ let activeSectionBaseTopMargin = margins.top;
32986
+ let activeSectionBaseBottomMargin = margins.bottom;
32987
+ let pendingSectionBaseTopMargin = null;
32988
+ let pendingSectionBaseBottomMargin = null;
32946
32989
  let activeHeaderDistance = margins.header ?? margins.top;
32947
32990
  let pendingHeaderDistance = null;
32948
32991
  let activeFooterDistance = margins.footer ?? margins.bottom;
@@ -33148,6 +33191,7 @@ function layoutDocument(blocks, measures, options = {}) {
33148
33191
  }
33149
33192
  let activeSectionIndex = initialSectionMetadata?.sectionIndex ?? 0;
33150
33193
  let pendingSectionIndex = null;
33194
+ const sectionFirstPageNumbers = /* @__PURE__ */ new Map();
33151
33195
  const paginator = createPaginator({
33152
33196
  margins: paginatorMargins,
33153
33197
  getActiveTopMargin: () => activeTopMargin,
@@ -33161,6 +33205,7 @@ function layoutDocument(blocks, measures, options = {}) {
33161
33205
  createPage,
33162
33206
  onNewPage: (state) => {
33163
33207
  if (!state) {
33208
+ const isEnteringNewSection = pendingSectionIndex !== null;
33164
33209
  const applied = applyPendingToActive({
33165
33210
  activeTopMargin,
33166
33211
  activeBottomMargin,
@@ -33228,7 +33273,69 @@ function layoutDocument(blocks, measures, options = {}) {
33228
33273
  activeVAlign = pendingVAlign;
33229
33274
  pendingVAlign = null;
33230
33275
  }
33276
+ if (pendingSectionBaseTopMargin !== null) {
33277
+ activeSectionBaseTopMargin = pendingSectionBaseTopMargin;
33278
+ pendingSectionBaseTopMargin = null;
33279
+ }
33280
+ if (pendingSectionBaseBottomMargin !== null) {
33281
+ activeSectionBaseBottomMargin = pendingSectionBaseBottomMargin;
33282
+ pendingSectionBaseBottomMargin = null;
33283
+ }
33231
33284
  pageCount += 1;
33285
+ const newPageNumber = pageCount;
33286
+ if (isEnteringNewSection || !sectionFirstPageNumbers.has(activeSectionIndex)) {
33287
+ sectionFirstPageNumbers.set(activeSectionIndex, newPageNumber);
33288
+ }
33289
+ const firstPageInSection = sectionFirstPageNumbers.get(activeSectionIndex) ?? newPageNumber;
33290
+ const sectionPageNumber = newPageNumber - firstPageInSection + 1;
33291
+ const sectionMetadata = sectionMetadataList[activeSectionIndex];
33292
+ const titlePgEnabled = sectionMetadata?.titlePg ?? false;
33293
+ const variantType = getVariantTypeForPage(sectionPageNumber, titlePgEnabled);
33294
+ let headerRef = activeSectionRefs?.headerRefs?.[variantType];
33295
+ let footerRef = activeSectionRefs?.footerRefs?.[variantType];
33296
+ let effectiveVariantType = variantType;
33297
+ if (!headerRef && variantType !== "default" && activeSectionIndex > 0) {
33298
+ const prevSectionMetadata = sectionMetadataList[activeSectionIndex - 1];
33299
+ if (prevSectionMetadata?.headerRefs?.[variantType]) {
33300
+ headerRef = prevSectionMetadata.headerRefs[variantType];
33301
+ layoutLog(
33302
+ `[Layout] Page ${newPageNumber}: Inheriting header '${variantType}' from section ${activeSectionIndex - 1}: ${headerRef}`
33303
+ );
33304
+ }
33305
+ }
33306
+ if (!footerRef && variantType !== "default" && activeSectionIndex > 0) {
33307
+ const prevSectionMetadata = sectionMetadataList[activeSectionIndex - 1];
33308
+ if (prevSectionMetadata?.footerRefs?.[variantType]) {
33309
+ footerRef = prevSectionMetadata.footerRefs[variantType];
33310
+ layoutLog(
33311
+ `[Layout] Page ${newPageNumber}: Inheriting footer '${variantType}' from section ${activeSectionIndex - 1}: ${footerRef}`
33312
+ );
33313
+ }
33314
+ }
33315
+ if (!headerRef && variantType !== "default" && activeSectionRefs?.headerRefs?.default) {
33316
+ headerRef = activeSectionRefs.headerRefs.default;
33317
+ effectiveVariantType = "default";
33318
+ }
33319
+ if (!footerRef && variantType !== "default" && activeSectionRefs?.footerRefs?.default) {
33320
+ footerRef = activeSectionRefs.footerRefs.default;
33321
+ }
33322
+ const headerHeight = getHeaderHeightForPage(effectiveVariantType, headerRef);
33323
+ const footerHeight = getFooterHeightForPage(
33324
+ variantType !== "default" && !activeSectionRefs?.footerRefs?.[variantType] ? "default" : variantType,
33325
+ footerRef
33326
+ );
33327
+ activeTopMargin = calculateEffectiveTopMargin(headerHeight, activeHeaderDistance, activeSectionBaseTopMargin);
33328
+ activeBottomMargin = calculateEffectiveBottomMargin(
33329
+ footerHeight,
33330
+ activeFooterDistance,
33331
+ activeSectionBaseBottomMargin
33332
+ );
33333
+ layoutLog(
33334
+ `[Layout] Page ${newPageNumber}: Using variant '${variantType}' - headerHeight: ${headerHeight}, footerHeight: ${footerHeight}`
33335
+ );
33336
+ layoutLog(
33337
+ `[Layout] Page ${newPageNumber}: Adjusted margins - top: ${activeTopMargin}, bottom: ${activeBottomMargin} (base: ${activeSectionBaseTopMargin}, ${activeSectionBaseBottomMargin})`
33338
+ );
33232
33339
  return;
33233
33340
  }
33234
33341
  if (state?.page) {
@@ -33434,6 +33541,20 @@ function layoutDocument(blocks, measures, options = {}) {
33434
33541
  pendingColumns = updatedState.pendingColumns;
33435
33542
  activeOrientation = updatedState.activeOrientation;
33436
33543
  pendingOrientation = updatedState.pendingOrientation;
33544
+ const isFirstSection = effectiveBlock.attrs?.isFirstSection && states.length === 0;
33545
+ const blockTopMargin = effectiveBlock.margins?.top;
33546
+ const blockBottomMargin = effectiveBlock.margins?.bottom;
33547
+ if (isFirstSection) {
33548
+ activeSectionBaseTopMargin = typeof blockTopMargin === "number" ? blockTopMargin : margins.top;
33549
+ activeSectionBaseBottomMargin = typeof blockBottomMargin === "number" ? blockBottomMargin : margins.bottom;
33550
+ } else if (blockTopMargin !== void 0 || blockBottomMargin !== void 0) {
33551
+ if (blockTopMargin !== void 0) {
33552
+ pendingSectionBaseTopMargin = typeof blockTopMargin === "number" ? blockTopMargin : margins.top;
33553
+ }
33554
+ if (blockBottomMargin !== void 0) {
33555
+ pendingSectionBaseBottomMargin = typeof blockBottomMargin === "number" ? blockBottomMargin : margins.bottom;
33556
+ }
33557
+ }
33437
33558
  if (effectiveBlock.vAlign) {
33438
33559
  const isFirstSection2 = effectiveBlock.attrs?.isFirstSection && states.length === 0;
33439
33560
  if (isFirstSection2) {
@@ -33452,7 +33573,6 @@ function layoutDocument(blocks, measures, options = {}) {
33452
33573
  }
33453
33574
  const sectionIndexRaw = effectiveBlock.attrs?.sectionIndex;
33454
33575
  const metadataIndex = typeof sectionIndexRaw === "number" ? sectionIndexRaw : Number(sectionIndexRaw ?? NaN);
33455
- const isFirstSection = effectiveBlock.attrs?.isFirstSection && states.length === 0;
33456
33576
  if (Number.isFinite(metadataIndex)) {
33457
33577
  if (isFirstSection) {
33458
33578
  activeSectionIndex = metadataIndex;
@@ -35640,6 +35760,7 @@ async function incrementalLayout(previousBlocks, _previousLayout, nextBlocks, op
35640
35760
  `[Perf] 4.1 Measure all blocks: ${(measureEnd - measureStart).toFixed(2)}ms (${cacheMisses} measured, ${cacheHits} cached)`
35641
35761
  );
35642
35762
  let headerContentHeights;
35763
+ let headerContentHeightsByRId;
35643
35764
  const hasHeaderBlocks = headerFooter?.headerBlocks && Object.keys(headerFooter.headerBlocks).length > 0;
35644
35765
  const hasHeaderBlocksByRId = headerFooter?.headerBlocksByRId && headerFooter.headerBlocksByRId.size > 0;
35645
35766
  if (headerFooter?.constraints && (hasHeaderBlocks || hasHeaderBlocksByRId)) {
@@ -35679,7 +35800,8 @@ async function incrementalLayout(previousBlocks, _previousLayout, nextBlocks, op
35679
35800
  }
35680
35801
  }
35681
35802
  if (hasHeaderBlocksByRId && headerFooter.headerBlocksByRId) {
35682
- for (const [_rId, blocks] of headerFooter.headerBlocksByRId) {
35803
+ headerContentHeightsByRId = /* @__PURE__ */ new Map();
35804
+ for (const [rId, blocks] of headerFooter.headerBlocksByRId) {
35683
35805
  if (!blocks || blocks.length === 0) continue;
35684
35806
  const measureConstraints = {
35685
35807
  maxWidth: headerFooter.constraints.width,
@@ -35691,8 +35813,7 @@ async function incrementalLayout(previousBlocks, _previousLayout, nextBlocks, op
35691
35813
  height: headerFooter.constraints.height
35692
35814
  });
35693
35815
  if (layout2.height > 0) {
35694
- const currentDefault = headerContentHeights.default ?? 0;
35695
- headerContentHeights.default = Math.max(currentDefault, layout2.height);
35816
+ headerContentHeightsByRId.set(rId, layout2.height);
35696
35817
  }
35697
35818
  }
35698
35819
  }
@@ -35700,6 +35821,7 @@ async function incrementalLayout(previousBlocks, _previousLayout, nextBlocks, op
35700
35821
  perfLog(`[Perf] 4.1.5 Pre-layout headers for height: ${(hfPreEnd - hfPreStart).toFixed(2)}ms`);
35701
35822
  }
35702
35823
  let footerContentHeights;
35824
+ let footerContentHeightsByRId;
35703
35825
  const hasFooterBlocks = headerFooter?.footerBlocks && Object.keys(headerFooter.footerBlocks).length > 0;
35704
35826
  const hasFooterBlocksByRId = headerFooter?.footerBlocksByRId && headerFooter.footerBlocksByRId.size > 0;
35705
35827
  if (headerFooter?.constraints && (hasFooterBlocks || hasFooterBlocksByRId)) {
@@ -35742,7 +35864,8 @@ async function incrementalLayout(previousBlocks, _previousLayout, nextBlocks, op
35742
35864
  }
35743
35865
  }
35744
35866
  if (hasFooterBlocksByRId && headerFooter.footerBlocksByRId) {
35745
- for (const [_rId, blocks] of headerFooter.footerBlocksByRId) {
35867
+ footerContentHeightsByRId = /* @__PURE__ */ new Map();
35868
+ for (const [rId, blocks] of headerFooter.footerBlocksByRId) {
35746
35869
  if (!blocks || blocks.length === 0) continue;
35747
35870
  const measureConstraints = {
35748
35871
  maxWidth: headerFooter.constraints.width,
@@ -35754,8 +35877,7 @@ async function incrementalLayout(previousBlocks, _previousLayout, nextBlocks, op
35754
35877
  height: headerFooter.constraints.height
35755
35878
  });
35756
35879
  if (layout2.height > 0) {
35757
- const currentDefault = footerContentHeights.default ?? 0;
35758
- footerContentHeights.default = Math.max(currentDefault, layout2.height);
35880
+ footerContentHeightsByRId.set(rId, layout2.height);
35759
35881
  }
35760
35882
  }
35761
35883
  }
@@ -35770,9 +35892,13 @@ async function incrementalLayout(previousBlocks, _previousLayout, nextBlocks, op
35770
35892
  let layout = layoutDocument(nextBlocks, measures, {
35771
35893
  ...options,
35772
35894
  headerContentHeights,
35773
- // Pass header heights to prevent overlap
35895
+ // Pass header heights to prevent overlap (per-variant)
35774
35896
  footerContentHeights,
35775
- // 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
35776
35902
  remeasureParagraph: (block, maxWidth, firstLineIndent) => remeasureParagraph(block, maxWidth, firstLineIndent)
35777
35903
  });
35778
35904
  const layoutEnd = performance.now();
@@ -35820,9 +35946,13 @@ async function incrementalLayout(previousBlocks, _previousLayout, nextBlocks, op
35820
35946
  layout = layoutDocument(currentBlocks, currentMeasures, {
35821
35947
  ...options,
35822
35948
  headerContentHeights,
35823
- // Pass header heights to prevent overlap
35949
+ // Pass header heights to prevent overlap (per-variant)
35824
35950
  footerContentHeights,
35825
- // 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
35826
35956
  remeasureParagraph: (block, maxWidth, firstLineIndent) => remeasureParagraph(block, maxWidth, firstLineIndent)
35827
35957
  });
35828
35958
  const relayoutEnd = performance.now();
@@ -53403,7 +53533,26 @@ class PresentationEditor extends EventEmitter {
53403
53533
  const firstPageInSection = sectionFirstPageNumbers.get(sectionIndex);
53404
53534
  const sectionPageNumber = typeof firstPageInSection === "number" ? pageNumber - firstPageInSection + 1 : pageNumber;
53405
53535
  const headerFooterType = multiSectionId ? getHeaderFooterTypeForSection(pageNumber, sectionIndex, multiSectionId, { kind, sectionPageNumber }) : getHeaderFooterType(pageNumber, legacyIdentifier, { kind });
53406
- 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
+ }
53407
53556
  if (!headerFooterType) {
53408
53557
  return null;
53409
53558
  }
@@ -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-C4RVDXKX.cjs");
3
+ require("./SuperConverter-BdOf8skU.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-0pJuKd1x.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.6";
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;