fix: keep-with-next reserves a successor that cannot split
A paragraph with fewer lines than orphan and widow control demand together has no legal break point, so it moves to the next page whole — and the heading kept with it has to follow. Measuring only its first two lines left the heading stranded at the page foot.
This commit is contained in:
1 parent
06bee1d3f1
commit
80e935145b
1 file changed
+4
-2
@@ -511,8 +511,10 @@ export const PageBreaks = Extension.create({
|
||||
function firstLinesHeight(el: HTMLElement, scale: number, want: number): number {
|
||||
const lines = getLineRects(el);
|
||||
if (!lines.length) return el.offsetHeight;
|
||||
const last = lines[Math.min(want, lines.length) - 1];
|
||||
return (last.bottom - lines[0].top) / scale;
|
||||
// A block with fewer lines than orphan and widow control demand together has
|
||||
// no legal split point at all, so the pair needs room for the whole of it.
|
||||
const keep = lines.length < want * 2 ? lines.length : want;
|
||||
return (lines[keep - 1].bottom - lines[0].top) / scale;
|
||||
}
|
||||
|
||||
function findLineSplit(
|
||||
|
||||
Reference in new issue
Block a user