fix: table phantom lines at pagebreak

This commit is contained in:
Steffen Becker committed 2026-06-25 16:23:49 +02:00
1 parent 8acae13b9a
commit a5a38eb33a
2 files changed
+21 -9

No files matched your search

+4 -2
View File
@@ -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 @@
<!-- Dedicated mount point that TipTap fully owns — keeping it free of Svelte
content avoids Svelte and ProseMirror fighting over the same parent's DOM. -->
<div bind:this={element} class="tiptap-host"></div>
{#if bandStyles.length}
{#if gapStripeStyles.length}
<div class="band-layer">
{#each bandStyles as b}
<div
+17 -7
View File
@@ -96,6 +96,10 @@ export type TableBreakBand = {
key: number;
closeY: number; // content-end of the closing page (band/mask top)
height: number; // bandSpan = marginBottom + gap + marginTop
// True when the break falls between whole table rows: the rows' own cell borders
// already cap the table at the gap, so only the gap stripe is painted (no mask /
// close-open lines, which would double the real borders). False for in-cell splits.
rowBreak: boolean;
left: number; // content-area left (mask left)
width: number; // content-area width (mask width)
marginBottom: number;
@@ -710,10 +714,10 @@ export const PageBreaks = Extension.create({
height: number;
row: { columns: number } | null;
}[] = [];
// Close/open bands for in-cell table breaks. Keyed by the rounded openY (the
// grouping id) → mapped to the unrounded openY so the band lands on the exact
// page-cycle position (a rounded value would show a ~0.5px seam at the edges).
const tableBands = new Map<number, number>();
// 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<number, { openY: number; rowBreak: boolean }>();
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,