Skip to content

fix(editor): email themiing's body background not in editor#3123

Merged
gabrielmfern merged 2 commits intofeat/ai-oss-editorfrom
cursor/ai-editor-product-1696-4db9
Mar 26, 2026
Merged

fix(editor): email themiing's body background not in editor#3123
gabrielmfern merged 2 commits intofeat/ai-oss-editorfrom
cursor/ai-editor-product-1696-4db9

Conversation

@gabrielmfern
Copy link
Copy Markdown
Member

@gabrielmfern gabrielmfern commented Mar 26, 2026

Summary

The EmailTheming plugin applies body background color during serialization (via BaseTemplate), but the same background color was not reflected in the live editor view. This caused a visual mismatch between the editing experience and the final email output.

Raised in PR #3115 review.

Changes

  • In the ProseMirror plugin's sync() function, extract the body backgroundColor from the merged CSS and apply it directly to view.dom.style.backgroundColor
  • Clean up the background color in the plugin's destroy() handler
  • Add 4 new tests covering:
    • Applying body background color to the editor DOM element
    • No background when no backgroundColor is defined
    • Reactive updates when theme styles change
    • Cleanup on editor destroy

Relevant files

  • packages/editor/src/plugins/email-theming/extension.tsx — main implementation
  • packages/editor/src/plugins/email-theming/extension.spec.ts — new tests

Closes PRODUCT-1696

Slack Thread

Open in Web Open in Cursor 

Summary by cubic

Fixes the mismatch between the live editor and the serialized email by applying the theme’s body background color to the editor container. Meets PRODUCT-1696.

  • Bug Fixes
    • Read body backgroundColor from merged theme CSS and set it on view.dom in sync.
    • Clear the background style on plugin destroy.
    • Add tests for applying color, handling no color, reactive updates, and cleanup; bump @react-email/editor to 0.0.0-experimental.37.

Written for commit 1f56b25. Summary will update on new commits.

@vercel
Copy link
Copy Markdown
Contributor

vercel bot commented Mar 26, 2026

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

Project Deployment Actions Updated (UTC)
react-email Ready Ready Preview, Comment Mar 26, 2026 4:30pm
react-email-demo Ready Ready Preview, Comment Mar 26, 2026 4:30pm

Request Review

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 26, 2026

⚠️ No Changeset found

Latest commit: 1f56b25

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@cursor cursor bot changed the title feat(editor): Apply EmailTheming body background color to live editor view feat: apply EmailTheming body background color to live editor view Mar 26, 2026
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Mar 26, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@react-email/editor@3123

commit: 10ec653

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cubic analysis

No issues found across 2 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Linked issue analysis

Linked issue: PRODUCT-1696: Apply EmailTheming body background color to live editor view

Status Acceptance criteria Notes
Apply body background color to the live editor view (editor container) Sets view.dom.style.backgroundColor from merged CSS
Implement change inside the ProseMirror plugin's sync() function Merged CSS read and style applied inside sync() when styles change
Extract body.backgroundColor from merged CSS (getMergedCssJs) and use it Reads mergedCssJs.body?.backgroundColor before applying
Clean up the background color in the plugin's destroy() handler Clears view.dom.style.backgroundColor in destroy()
Reactive updates: background updates when theme/styles change sync() updates on styles change and tests assert new color
Do not set background when no backgroundColor is defined Sets '' when bodyBg not a string; test asserts no background
Add tests covering applying background, no background, reactive updates, and cleanup on destroy Four tests added covering apply, none, reactive, and destroy cleanup
Continue injecting merged theme CSS (injectThemeCss called with merged CSS) injectThemeCss called with mergedCssJs and scope preserved
Prefer applying background to editor container as suggested (alternative approach implemented) Applied background directly to view.dom.style per suggested alt.

@gabrielmfern gabrielmfern changed the title feat: apply EmailTheming body background color to live editor view fix(editor): email body background not being set in editor by EmailTheming Mar 26, 2026
@gabrielmfern gabrielmfern requested a review from joaopcm March 26, 2026 16:01
@gabrielmfern gabrielmfern changed the title fix(editor): email body background not being set in editor by EmailTheming fix(editor): EmailThemiing's body background not in editor Mar 26, 2026
The EmailTheming plugin now applies the body background color from the
theme to the editor's DOM element (view.dom) in the ProseMirror plugin's
sync() function. This ensures the live editing experience matches the
serialized email output.

Changes:
- Extract body backgroundColor from merged CSS and apply it to
  view.dom.style.backgroundColor in the sync() function
- Clean up the background color on plugin destroy
- Add 4 tests covering: applying bg color, no bg when undefined,
  reactive updates on theme change, and cleanup on destroy

Closes PRODUCT-1696

Co-authored-by: Gabriel Miranda <gabrielmfern@outlook.com>
@gabrielmfern gabrielmfern force-pushed the cursor/ai-editor-product-1696-4db9 branch from 8ab979e to b967b14 Compare March 26, 2026 16:14
@gabrielmfern gabrielmfern changed the title fix(editor): EmailThemiing's body background not in editor fix(editor): email themiing's body background not in editor Mar 26, 2026
@gabrielmfern gabrielmfern marked this pull request as ready for review March 26, 2026 16:29
@socket-security
Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedhtml-to-ast@​0.0.6831009980100
Addedhtml-to-text@​9.0.59910010082100

View full report

@gabrielmfern gabrielmfern merged commit 21cb732 into feat/ai-oss-editor Mar 26, 2026
15 checks passed
@gabrielmfern gabrielmfern deleted the cursor/ai-editor-product-1696-4db9 branch March 26, 2026 20:57
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.

3 participants