fix: correct OOXML theme color tint/shade resolution#270
Merged
jedrazb merged 3 commits intoeigenpal:mainfrom Apr 17, 2026
Merged
fix: correct OOXML theme color tint/shade resolution#270jedrazb merged 3 commits intoeigenpal:mainfrom
jedrazb merged 3 commits intoeigenpal:mainfrom
Conversation
|
@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.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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>
4 tasks
jedrazb
added a commit
that referenced
this pull request
Apr 17, 2026
* refactor: unify theme color resolution across display paths 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> * refactor(color): fix round-trip + simplify helper + unify toolbar swatches Addresses review feedback on #272. **fromProseDoc round-trip fix** — themed cells (`themeFill` + `themeFillTint`/`themeFillShade`) no longer lose their theme refs on save. Stores the parse-time resolved hex in a new `_originalResolvedFill` attr; if it still matches `attrs.backgroundColor` at save time, the user hasn't changed the color so `orig.shading` is preserved intact. If they have changed it, we write plain `{ fill: { rgb } }` as before. **Helper simplification** — `resolveColorToHex` now uses `slice(1)` instead of a second `.replace(/^#/, '')` in the themed-color branch (`resolveColor` already guarantees the `#` prefix). Dedups the rgb-without-theme fallback by folding it into the single `rgb` branch below. Trims the docstring. **Unify remaining sites** — three sites were hand-rolling the same `resolveColor(...).replace(/^#/, '')` pattern; all now use the helper: - `DocxEditor.tsx:1474` (cell border color) - `FormattingBar.tsx:597` (table border color picker value) - `AdvancedColorPicker.tsx:222` (selected-cell hex comparison) Plus two sites that read `.color?.rgb` directly and dropped themed text colors: - `DocxEditor.tsx` text-color swatch readout - `toolbarUtils.ts` `getSelectionFormatting` (new optional `theme` param) **Tests** — 3 new round-trip tests in `toProseDoc.test.ts` proving themed `tint`/`shade` survive toProseDoc → fromProseDoc unchanged, and that user-initiated color changes still override theme refs with plain rgb. 380 pass (was 377), typecheck clean. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
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).toProseDoc.ts: table cells using theme fills (e.g.,themeFill="accent1"with tint/shade modifiers) were rendering with no background because only thergbproperty was checked, ignoring theme color references. Now threads the document theme through the conversion and callsresolveColor().colorResolver.test.ts— coversresolveColorwith 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