Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/code-mark-inline-styles.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@react-email/editor": patch
---

fix: apply inline styles stored on the `code` mark when composing the email

The `code` mark's serializer only read styles from the text node's attrs, so inline CSS captured on the mark itself (e.g. background, padding, or font styles imported from existing HTML) was dropped from the composed email. The mark's `style` attr is now merged into the rendered `<code>` element.
19 changes: 14 additions & 5 deletions packages/editor/src/extensions/code.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,17 @@ import CodeBase from '@tiptap/extension-code';
import { EmailMark } from '../core/serializer/email-mark';
import { inlineCssToJs } from '../utils/styles';

export const Code = EmailMark.from(CodeBase, ({ children, node, style }) => (
<code style={{ ...style, ...inlineCssToJs(node.attrs?.style) }}>
{children}
</code>
));
export const Code = EmailMark.from(
CodeBase,
({ children, node, style, mark }) => (
<code
style={{
...style,
...inlineCssToJs(node.attrs?.style),
...inlineCssToJs(mark?.attrs?.style),
}}
>
{children}
</code>
),
);
Loading