Skip to content

feat(editor): indent with tab by default in code block#2982

Draft
gabrielmfern wants to merge 4 commits intofeat/ai-oss-editorfrom
cursor/code-block-tab-indentation-d7e0
Draft

feat(editor): indent with tab by default in code block#2982
gabrielmfern wants to merge 4 commits intofeat/ai-oss-editorfrom
cursor/code-block-tab-indentation-d7e0

Conversation

@gabrielmfern
Copy link
Member

@gabrielmfern gabrielmfern commented Mar 2, 2026

feat(editor): Dynamically adjust code block tab size based on theme

This PR enhances the code block functionality in the editor by making Tab/Shift-Tab indentation dynamic, respecting the tabSize defined by the currently selected theme.

Previously, code block indentation used a static tab size, leading to inconsistencies when themes with different tabSize values (e.g., 2-space vs. 4-space) were applied.

This change:

  • Overrides the Tab and Shift-Tab keyboard shortcuts within the CodeBlockPrism extension.
  • Introduces a getThemeTabSize helper to extract the tabSize from the active code block's theme (e.g., dracula, oneDark) from @react-email/components.
  • Applies the theme-specific tabSize for both indenting (Tab) and outdenting (Shift-Tab), supporting both single cursor and multi-line selections.

This ensures that the editor's indentation behavior aligns with the visual styling of the chosen code block theme, improving consistency and user experience.


Slack Thread

Open in Web Open in Cursor 


Summary by cubic

Make Tab and Shift‑Tab indent/outdent in code blocks using the active theme’s tab size, with a 2‑space fallback. Supports single-cursor and multi-line selections with correct cursor handling.

  • New Features
    • Override Tab and Shift‑Tab in CodeBlockPrism to respect the theme’s tabSize.
    • Handles single and multi-line selections; adjusts cursor on outdent for empty selections.

Written for commit 398788e. Summary will update on new commits.

@cursor
Copy link

cursor bot commented Mar 2, 2026

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@changeset-bot
Copy link

changeset-bot bot commented Mar 2, 2026

⚠️ No Changeset found

Latest commit: 398788e

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

@vercel
Copy link

vercel bot commented Mar 2, 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 2, 2026 5:49pm
react-email-demo Ready Ready Preview, Comment Mar 2, 2026 5:49pm

Request Review

@gabrielmfern gabrielmfern changed the base branch from canary to feat/ai-oss-editor March 2, 2026 16:06
@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 2, 2026

Open in StackBlitz

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

commit: 398788e

cursoragent and others added 4 commits March 2, 2026 14:47
…s tab size

Override Tab and Shift-Tab keyboard shortcuts in CodeBlockPrism to
dynamically read the tabSize from the code block's selected theme
(e.g., dracula uses 4 spaces, oneDark uses 2 spaces) instead of
using a hardcoded value. Falls back to 2 spaces when no theme is set.

Co-authored-by: Gabriel Miranda <gabrielmfern@outlook.com>
- Replace dynamic namespace import with named imports and a static
  theme lookup record to avoid noDynamicNamespaceImportAccess warning
- Fix biome formatting: collapse multi-line chains to single lines

Co-authored-by: Gabriel Miranda <gabrielmfern@outlook.com>
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