From 970ad3776acecf94485ff7c66f34409a48030d78 Mon Sep 17 00:00:00 2001 From: Steffen Becker Date: Mon, 10 Aug 2026 20:46:43 +0000 Subject: [PATCH] fix: space below a block need not fit on its page LibreOffice drops it at the page bottom, as it drops space above at a page top (probed: a paragraph 8mm clear of the bottom keeps its 2cm below and stays). Counting it pushed the last block of a page down a page too early. --- src/lib/editor/extensions/pageBreaks.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/lib/editor/extensions/pageBreaks.ts b/src/lib/editor/extensions/pageBreaks.ts index 9a5e0b2..b32e000 100644 --- a/src/lib/editor/extensions/pageBreaks.ts +++ b/src/lib/editor/extensions/pageBreaks.ts @@ -1084,7 +1084,10 @@ export const PageBreaks = Extension.create({ bandOpenY: target, reason: 'leaf-jump-to-next-page', }); - } else if (effectiveBottom + (leaf.spaceAfter ?? 0) > contentEnd) { + // Space below is not part of what has to fit: a block whose last line ends + // on the page keeps it and the gap is dropped at the page bottom, the way + // space above is at a page top (probed: 2cm below a line 8mm short of it). + } else if (effectiveBottom > contentEnd) { if (leaf.kind === 'atomic') { const cf = leaf.columnsFragment; if (cf && cf.blockCount > 1 && cf.firstBlockNeededPx + COLUMNS_FIT_MARGIN_PX <= contentEnd - effectiveTop) {