From a5a38eb33ab28a27781a9e683723e3e8f0a8bc05 Mon Sep 17 00:00:00 2001 From: Steffen Becker Date: Thu, 25 Jun 2026 16:23:49 +0200 Subject: [PATCH] fix: table phantom lines at pagebreak --- src/lib/components/Editor.svelte | 6 ++++-- src/lib/editor/extensions/pageBreaks.ts | 24 +++++++++++++++++------- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/lib/components/Editor.svelte b/src/lib/components/Editor.svelte index 7032b56..fb81f51 100644 --- a/src/lib/components/Editor.svelte +++ b/src/lib/components/Editor.svelte @@ -258,7 +258,9 @@ // Everything below is in document px (relative to .tiptap's top). The .band-layer // lives inside the scaled .paper, so the transform applies the scaling — no `* z`. const border = 1; // 1px page-edge line, like the CSS .tiptap background - bandStyles = tableBandsDoc.map((b) => { + // Only in-cell breaks get the white mask + close/open lines; between-rows breaks + // are capped by the rows' own cell borders, so a band there would double them. + bandStyles = tableBandsDoc.filter((b) => !b.rowBreak).map((b) => { // The band spans the inter-page region (closeY through margin/gap/margin to the // next content-top), where pagination guarantees no content, so the mask can't eat // content. Matched to the table's content box (b.left/b.width) so the lines align. @@ -550,7 +552,7 @@
- {#if bandStyles.length} + {#if gapStripeStyles.length}
{#each bandStyles as b}
(); + // Close/open bands for in-cell + between-rows table breaks. Keyed by the + // rounded openY (the grouping id) → the unrounded openY (so the band lands + // exactly on the page cycle) plus whether it's a between-rows break. + const tableBands = new Map(); const leavesDebug: PageBreakDebugSnapshot['leaves'] = []; const placementsDebug: PageBreakDebugSnapshot['placements'] = []; @@ -858,7 +862,12 @@ export const PageBreaks = Extension.create({ const inBand = !!leaf.inTableCell || br.row !== null; if (inBand && br.bandOpenY !== null) { const key = Math.round(br.bandOpenY); - if (!tableBands.has(key)) tableBands.set(key, br.bandOpenY); + const rowBreak = br.row !== null; + const existing = tableBands.get(key); + if (!existing) tableBands.set(key, { openY: br.bandOpenY, rowBreak }); + // An in-cell break sharing the boundary needs the full mask, so a + // band stays rowBreak only if every break at this key is one. + else if (!rowBreak) existing.rowBreak = false; } placements.push({ docPos: br.docPos, height: h, row: br.row }); placementsDebug.push({ @@ -948,10 +957,11 @@ export const PageBreaks = Extension.create({ // In-cell table breaks (all values in unscaled document px relative to // .tiptap's top). Editor.svelte renders the mask + gap overlay from these. const bandSpan = vm.bottom + PAGE_GAP + vm.top; - const tableBreakBands = Array.from(tableBands, ([key, openY]) => ({ + const tableBreakBands = Array.from(tableBands, ([key, info]) => ({ key, - closeY: openY - bandSpan, + closeY: info.openY - bandSpan, height: bandSpan, + rowBreak: info.rowBreak, left: marginLeft, width: contentWidth, marginBottom: vm.bottom,