fix: prevent text overlap when multi-column sections span pages (SD-1869)#2676
Conversation
The tab measurement code hardcoded `maxFontSize: 12` for tab-created lines and tab runs, causing incorrect line height calculations when the surrounding text used a different font size. This also adds `fontSize: '0'` to line styles to eliminate the CSS strut that caused baseline misalignment between normal-flow and absolutely-positioned (tab-aligned) children.
When a multi-column section's content spans multiple pages and columns have unequal heights, the next section's content was positioned at the shorter column's cursor Y instead of below all column content. This caused visible text overlap on page 2. Add maxCursorY to PageState to track the deepest Y reached across all columns. startMidPageRegion now uses this value so the next section begins below all column content.
…l lines Lines with tab stops use absolute positioning for text segments, which bypasses the CSS strut. Normal-flow lines inherit the browser's default 16px font-size, creating a strut that shifts text down ~1px via baseline alignment. This made tab-indented first lines appear shifted up relative to continuation lines. Zero the line container's font-size to remove the strut, and restore explicit font-size on the three child elements that inherit rather than set their own: empty-run caret placeholder (lineHeight), math run wrapper (run height), and field annotation wrapper (16px fallback).
Verifies that mid-page column transitions start below the tallest column when columns have unequal heights. Uses a 3-col → 2-col transition to exercise the maxCursorY tracking without triggering the new-page guard (columnIndexBefore >= newColumns.count).
caio-pizzol
left a comment
There was a problem hiding this comment.
@luccas-harbour the overlap fix works — pushed a regression test for it (e859c96).
side finding: the ECMA spec says continuous section breaks should balance content evenly across columns (like Word does — 6 paragraphs in 2 columns = 3+3). SuperDoc fills column 1 first, which is why multi-column docs look different from Word. this is pre-existing, not on this PR — filed SD-2452 for it.
left one inline comment.
| // matter much: MathML has its own internal scaling, and the plain-text | ||
| // fallback just needs a non-zero size. Don't rely on this for precise | ||
| // typographic sizing. | ||
| wrapper.style.fontSize = `${run.height}px`; |
There was a problem hiding this comment.
run.height can be 80-100px for tall math expressions (fractions, equation arrays). that gets used as the font size here, which would make the plain-text fallback huge. a fixed value like 24px or the paragraph's font size would be safer — worth changing?
caio-pizzol
left a comment
There was a problem hiding this comment.
feel free to merge after addressing last comment
Summary
fontSize: '0'on line containers and restores explicit font sizes on child elements that need them (field annotations, math wrappers, empty-run spans).maxCursorYacross columns and using it as the starting Y for the next region.