fix(editor): emit theme link styles in renderHTML

Merged
JO
6mo ago
+171-3

Summary

  • Link mark renderHTML merges EmailTheming link styles into the emitted <a style="...">. User inline styles still win via CSS cascade (appended last).
  • Exports getEmailTheming so the Link extension can resolve the active theme at render time.
  • RESET_MINIMAL.link now carries color: #0670DB + text-decoration: underline so both themes ship a default link color.
  • No hardcoded colors in link.tsx; all defaults come from getResolvedNodeStyles against the active theme.

Unblocks dropping the DOMParser workaround in the dashboard's generate-json-content.ts (resend/resend#10044).

Bug happening

https://github.com/user-attachments/assets/16daba0c-2a5d-42f1-83e2-642632845cff

After this fix

https://github.com/user-attachments/assets/f16e01c0-46fa-48b9-8225-ed6bf06fc640

Test plan

  • New packages/editor/src/extensions/link.spec.ts (6 cases): basic + minimal themes emit themed style, class="node-link" preserved, user color wins over theme, mark.attrs.style stays empty for plain links (inspector contract), plain <a> setContent round-trip produces themed output.
  • pnpm vitest run --project unit — 434 passed, 1 skipped, no snapshot regressions.
  • pnpm build clean.
  • Manual: dashboard Visual -> HTML -> Visual, add link in Visual mode, confirm blue + underline in editor view and in exported HTML.
  • Manual: switch theme to minimal, confirm link still themed.
  • Manual: set custom link color via inspector, confirm custom color wins in both editor and export.

Summary by cubic

Make link rendering theme-aware by injecting EmailTheming styles into the <a> tag during HTML export. Links render blue and underlined by default, and user inline styles still win.

  • Bug Fixes

    • Merge theme link styles into <a style> in renderHTML; user inline styles are appended last to win.
    • Move default link styles to RESET_BASIC (color: #0670DB, text-decoration: underline); RESET_MINIMAL references them for consistency.
    • Resolve defaults via getResolvedNodeStyles; no hardcoded colors in the link extension.
    • Fixes link styling loss on Visual ↔ HTML round‑trips; enables removing the DOMParser workaround in the dashboard.
  • Dependencies

    • Add changeset for a patch release of @react-email/editor.