Skip to content

fix(editor): restore this context in EmailNode/EmailMark.create() callbacks#3062

Merged
joaopcm merged 2 commits intofeat/ai-oss-editorfrom
feature/oss-430-fix-emailnodecreate-type-regression-this-context-lost-in
Mar 13, 2026
Merged

fix(editor): restore this context in EmailNode/EmailMark.create() callbacks#3062
joaopcm merged 2 commits intofeat/ai-oss-editorfrom
feature/oss-430-fix-emailnodecreate-type-regression-this-context-lost-in

Conversation

@joaopcm
Copy link
Member

@joaopcm joaopcm commented Mar 13, 2026

Summary

Fixes type regression in @react-email/editor@0.0.0-experimental.17 where EmailNode.create() and EmailMark.create() lost this context in config callbacks.

The ConfigParameter type was wrapping the config in Partial<Omit<...>>, stripping the ThisType intersection that TipTap's base implementation provides. Added ThisType<{name, options, storage, editor, type, parent}> to ConfigParameter in both email-node.ts and email-mark.ts to restore access to this.name, this.options, etc. inside callbacks like renderHTML, addCommands, addAttributes.

Bumped version to 0.0.0-experimental.18.

Testing steps

  • Verify EmailNode.create() and EmailMark.create() accept config callbacks with this.name and this.options without TS errors
  • Check renderHTML, addCommands, and addAttributes callbacks have proper this typing
  • Confirm typecheck passes: pnpm --filter @react-email/editor typecheck
  • Run lint: pnpm lint:fix

Summary by cubic

Restores the this context in EmailNode.create() and EmailMark.create() config callbacks in @react-email/editor, and fixes DTS import issues by using explicit types on extension wrappers. Addresses PRODUCT-1612.

  • Bug Fixes

    • Added ThisType to ConfigParameter for nodes and marks to type this in renderHTML, addCommands, and addAttributes, fixing TS errors with this.name/this.options.
    • Annotated all .from() extension wrappers and defined StarterKitOptions explicitly to prevent import * in .d.ts; exported Heading, Divider, and Link plus their option types.
  • Dependencies

    • Bump @react-email/editor to 0.0.0-experimental.18.

Written for commit 01fc68a. Summary will update on new commits.

…onfig callbacks

Add ThisType intersection to ConfigParameter type to preserve 'this' context
(name, options, storage, editor, type, parent) in callbacks like renderHTML,
addCommands, addAttributes. Fixes TS2353/TS2339 errors when using this.options
or this.name inside config callbacks. Bump version to 0.0.0-experimental.18.
@vercel
Copy link

vercel bot commented Mar 13, 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 13, 2026 6:37pm
react-email-demo Ready Ready Preview, Comment Mar 13, 2026 6:37pm

Request Review

@changeset-bot
Copy link

changeset-bot bot commented Mar 13, 2026

⚠️ No Changeset found

Latest commit: 01fc68a

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

@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 13, 2026

Open in StackBlitz

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

commit: 1b380dc

Copy link
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 3 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-1612: fix: EmailNode.create() type regression — this context lost in config callbacks

Status Acceptance criteria Notes
Restore ThisType in EmailNode.create() config parameter so `this` has name/options/storage/editor/type/parent Added ThisType in packages/editor/src/core/serializer/email-node.ts
Restore ThisType in EmailMark.create() config parameter so `this` has name/options/storage/editor/type/parent Added ThisType in packages/editor/src/core/serializer/email-mark.ts
Keep renderToReactEmail required while making other config fields partial ConfigParameter still uses Pick<..., 'renderToReactEmail'>
Ensure callbacks (renderHTML, addCommands, addAttributes) regain typed `this` (this.name, this.options, etc.) ThisType addition restores callback `this` context
Fix implicit any on callback params (e.g. renderHTML({ node, HTMLAttributes })) by restoring typing ConfigParameter types preserved and ThisType restored
Apply same fix to EmailMark if it has the same issue EmailMark file updated with identical ThisType fix
Bump @react-email/editor version to 0.0.0-experimental.18 package.json version updated
⚠️ Verify EmailNode.create() and EmailMark.create() accept config callbacks with this.name and this.options without TS errors ThisType added (likely fixes), but no typecheck run shown
Confirm typecheck passes: pnpm --filter @react-email/editor typecheck No typecheck output or CI evidence in diffs
Run lint: pnpm lint:fix No lint changes or results shown in diffs

Replace inferred types with explicit type annotations on all .from()
extension wrappers to prevent tsdown from emitting import * for each
@tiptap/extension-* package in the DTS. Replace typeof-derived
StarterKitOptions with explicit type definition.

Add missing export * for heading, divider, and link extensions.
Export HeadingOptions, DividerOptions, and LinkOptions types.
@joaopcm joaopcm merged commit 0827cbd into feat/ai-oss-editor Mar 13, 2026
15 checks passed
@joaopcm joaopcm deleted the feature/oss-430-fix-emailnodecreate-type-regression-this-context-lost-in branch March 13, 2026 18:43
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