-
Notifications
You must be signed in to change notification settings - Fork 3
Fixes #59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Fixes #59
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -3498,6 +3498,15 @@ function renderTable( | |||||||||||
| const MIN_CONTRAST = 3.0; | ||||||||||||
| const pageBg = style._pageBg || "FFFFFF"; | ||||||||||||
|
|
||||||||||||
| // If headerBg is too similar to pageBg, the header row won't stand out. | ||||||||||||
| // Swap to theme accent1 so the header is visually distinct. | ||||||||||||
| if (style.headerBg) { | ||||||||||||
| const headerVsPage = contrastRatio(style.headerBg, pageBg); | ||||||||||||
| if (headerVsPage < 1.5 && doc.theme.accent1) { | ||||||||||||
| style.headerBg = doc.theme.accent1; | ||||||||||||
| } | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| if (style.bodyFg) { | ||||||||||||
| const bodyRatio = contrastRatio(style.bodyFg, pageBg); | ||||||||||||
| if (bodyRatio < MIN_CONTRAST) { | ||||||||||||
|
|
@@ -3641,16 +3650,12 @@ function renderTable( | |||||||||||
| }); | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| // Alternating row background FIRST | ||||||||||||
| if (style.altRowBg && r % 2 === 1) { | ||||||||||||
| doc.drawRect(x, curY, totalWidth, rowH, { fill: style.altRowBg }); | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| // Auto-contrast body text against effective row background | ||||||||||||
| // EVERY row gets an explicit fill — no transparent rows, no guessing | ||||||||||||
| const isAlt = !!(style.altRowBg && r % 2 === 1); | ||||||||||||
| const rowBg = isAlt | ||||||||||||
| ? style.altRowBg | ||||||||||||
| : (style._pageBg || "FFFFFF"); | ||||||||||||
| const rowBg = isAlt ? style.altRowBg : (style._pageBg || "FFFFFF"); | ||||||||||||
| doc.drawRect(x, curY, totalWidth, rowH, { fill: rowBg }); | ||||||||||||
|
Comment on lines
+3653
to
+3656
|
||||||||||||
|
|
||||||||||||
| // Text color computed against the ACTUAL fill we just drew | ||||||||||||
| const rowFg = autoTextColor(rowBg); | ||||||||||||
|
Comment on lines
+3658
to
3659
|
||||||||||||
| // Text color computed against the ACTUAL fill we just drew | |
| const rowFg = autoTextColor(rowBg); | |
| // Prefer the validated body text color; fall back to an automatic | |
| // contrast color if no explicit body foreground is configured. | |
| const rowFg = style.bodyFg ?? autoTextColor(rowBg); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
renderTablemutates the passedTableStyle(style.headerBghere). When callers use preset styles viaresolveTableStyle, those are shared singletons fromTABLE_STYLES, so this change can leak across tables/documents. Consider computing aneffectiveHeaderBglocal variable (and/or cloning the style object when resolving presets) instead of mutatingstylein-place.