Skip to content

fix: correct OOXML theme color tint/shade resolution#270

Merged
jedrazb merged 3 commits intoeigenpal:mainfrom
sted:fix/theme-colors
Apr 17, 2026
Merged

fix: correct OOXML theme color tint/shade resolution#270
jedrazb merged 3 commits intoeigenpal:mainfrom
sted:fix/theme-colors

Conversation

@sted
Copy link
Copy Markdown
Contributor

@sted sted commented Apr 16, 2026

Summary

  • Fix tint/shade color formulas in colorResolver.ts: replaced HSL-based approach with the OOXML per-channel linear interpolation specified in ECMA-376 §17.3.2.41. The previous formula produced incorrect intermediate colors (e.g., a 20% tint of dark blue produced medium blue instead of very light blue).
  • Resolve theme colors for table cell backgrounds in toProseDoc.ts: table cells using theme fills (e.g., themeFill="accent1" with tint/shade modifiers) were rendering with no background because only the rgb property was checked, ignoring theme color references. Now threads the document theme through the conversion and calls resolveColor().
  • Add regression tests (17 new tests):
    • colorResolver.test.ts — covers resolveColor with real-world tint/shade values (`33`, `99`, `F2`) and edge cases (`FF` = no change, `00` = fully white/black).
    • toProseDoc.test.ts (new) — integration tests verifying that themed cell shading resolves to correct `backgroundColor` attrs on PM nodes.

Before / After

Table header rows and section rows using theme colors (common in Word's built-in table styles) now render with correct backgrounds instead of white.

Test plan

  • `bun run typecheck` passes
  • `bun test` — all 357 tests pass (340 existing + 17 new)
  • `bun run build` succeeds
  • Visual verification with DOCX files using themed table styles

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 16, 2026

@sted is attempting to deploy a commit to the EigenPal Team on Vercel.

A member of the Team first needs to authorize it.

Covers the tint/shade math fix and the theme color threading through
toProseDoc to table cell backgroundColor attrs. Uses real-world tint
values (33, 99, F2) from documents with themed table styles.
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 17, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docx-editor Ready Ready Preview, Comment Apr 17, 2026 6:48am

Request Review

@jedrazb jedrazb merged commit 50a7b02 into eigenpal:main Apr 17, 2026
4 checks passed
jedrazb added a commit that referenced this pull request Apr 17, 2026
Adds `resolveColorToHex` as the single shared helper for converting any
`ColorValue` (rgb or themeColor+tint/shade) to a display-ready hex string,
with consistent handling of transparent/auto and missing-theme cases.

Applies it at every display-side call site so `themeFill`/`themeColor`
with `themeTint`/`themeShade` is honored everywhere, not just on table cells:

- `toProseDoc.ts` — replaces the inline resolution added in #270.
- `toFlowBlocks.ts` — paragraph shading now resolves themed fills (previously
  read `.fill.rgb` directly, silently dropping themed paragraph backgrounds).
- `clipboard.ts` — HTML copy now honors themed text color and shading when
  a theme is threaded through `ClipboardOptions`/`useClipboard` options.

Tests: +20 new pass (357 → 377 total), covering helper edge cases,
paragraph themed-shading end-to-end (Document → PM → flow blocks), and
clipboard HTML with themed runs.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants