From 4c8dd006296603448d28c0b05c41883ee5e298b4 Mon Sep 17 00:00:00 2001 From: Steffen Becker Date: Wed, 2 Sep 2026 22:34:30 +0200 Subject: [PATCH] fix: a manual page break keeps the block's space above Only a break the flow had to make swallows it. Probed against the reference, page top at 20.01mm: a block with 6/20mm above lands at 26.00/40.01 after fo:break-before, and at 20.01 for either after an automatic break. Every chapter opening of a book-style document is the manual case. --- src/lib/editor/extensions/pageBreaks.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/lib/editor/extensions/pageBreaks.ts b/src/lib/editor/extensions/pageBreaks.ts index 364c1e4..14d5d73 100644 --- a/src/lib/editor/extensions/pageBreaks.ts +++ b/src/lib/editor/extensions/pageBreaks.ts @@ -1480,11 +1480,14 @@ export const PageBreaks = Extension.create({ } } - // A page break — its own spacer, or one that left it at the top — swallows the - // block's space above, as LibreOffice does. A line split doesn't: there the - // page starts mid-block. `effectiveTop` still excludes this leaf's own push. + // A page break the flow had to make — its own spacer, or one that left it at + // the top — swallows the block's space above; a break the document asks for + // keeps it (probed: a page top is 20.01mm, a manual break with 6/20mm above + // puts the block at 26.00/40.01, an automatic one at 20.01 for either). A line + // split doesn't: there the page starts mid-block. `effectiveTop` still + // excludes this leaf's own push. if ( - i > 0 && !leaf.inTableCell && (leaf.spaceAbove ?? 0) > 0.5 + i > 0 && !leaf.inTableCell && !leaf.forceBreakBefore && (leaf.spaceAbove ?? 0) > 0.5 && (breaks.some((b) => b.reason !== 'line-split') || (breaks.length === 0 && Math.abs(effectiveTop - contentStart) < 0.5)) ) {