Skip to content

fix(editor): migrate autoformat-kit to PlateJS v53 inputRules API#175

Merged
ryota-murakami merged 2 commits intomainfrom
fix/platejs-v53-migration
Apr 29, 2026
Merged

fix(editor): migrate autoformat-kit to PlateJS v53 inputRules API#175
ryota-murakami merged 2 commits intomainfrom
fix/platejs-v53-migration

Conversation

@ryota-murakami
Copy link
Copy Markdown
Contributor

@ryota-murakami ryota-murakami commented Apr 29, 2026

Summary

  • Fixes 17/19 CI jobs that broke after the supply-chain pnpm install pulled in @platejs/* v53.0.0 (commit 6623b40). Build/Test/TypeCheck/Vercel/all 12 E2E shards were failing because v53 removed the pre-built rule arrays (autoformatSmartQuotes, autoformatPunctuation, autoformatLegal, autoformatLegalHtml, autoformatArrow, autoformatMath) and deprecated AutoformatPlugin.
  • Migrates src/components/editor/plugins/autoformat-kit.tsx to the v53 plugin-owned inputRules pattern using createSlatePlugin({ key: 'markdownShortcuts', inputRules: [...] }) plus the new Rules.markdown() factories from @platejs/basic-nodes, @platejs/code-block, and @platejs/list.
  • Preserves the v52 codeBlock-disable behavior via the v53 enabled callback.

Notes

  • v52 text substitution rules (smart quotes, punctuation, legal, arrow, math) are intentionally not migrated in this PR — they require createTextSubstitutionInputRule with custom patterns and are tracked separately as a follow-up. They are not blocking CI.
  • No other @platejs/* import in src/ needed migration (verified by grep + typecheck). The blast radius was 1 file.
  • Cannot use key: 'autoformat' for the new plugin because v53 throws AutoformatPlugin cannot be used with plugin-owned input rules when both coexist. Used markdownShortcuts instead.

Test plan

  • pnpm typecheck — exit 0
  • pnpm lint — exit 0
  • pnpm vitest run — 91 files, 1295 tests passed
  • pnpm build — 15 routes built
  • CI green (Build / Test / TypeCheck / 12 E2E shards / Vercel)
  • Manual smoke test: **bold**, # heading, - list, [] todo markdown shortcuts trigger correctly in the editor

Summary by CodeRabbit

  • Refactor
    • Restructured markdown shortcut formatting to use an improved plugin architecture. All existing shortcuts (headings, blockquotes, code blocks, marks, lists, and task lists) remain available.

PlateJS v53 removed the pre-built rule arrays (autoformatSmartQuotes,
autoformatPunctuation, autoformatLegal, autoformatLegalHtml,
autoformatArrow, autoformatMath) and deprecated AutoformatPlugin.
The new pattern is plugin-owned inputRules registered via
createSlatePlugin({ inputRules: [...] }).

Replace v52 mark/block/list rules with v53 Rules.markdown() factories
from @platejs/basic-nodes, @platejs/code-block, @platejs/list. Preserve
the v52 codeBlock-disable behavior using the v53 enabled callback.

Text substitution rules (smart quotes, arrows, math, legal) are
intentionally omitted from this migration and tracked separately.
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Apr 29, 2026

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

Project Deployment Actions Updated (UTC)
gitbox Ready Ready Preview, Comment Apr 29, 2026 3:08am

Request Review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 29, 2026

Warning

Rate limit exceeded

@ryota-murakami has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 21 minutes and 36 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 40a39e3e-d059-422c-8580-1aa197d706ef

📥 Commits

Reviewing files that changed from the base of the PR and between 6623b40 and 7222c3c.

📒 Files selected for processing (2)
  • src/components/editor/plugins/autoformat-kit.tsx
  • src/components/editor/plugins/basic-blocks-kit.tsx
📝 Walkthrough

Walkthrough

The autoformat plugin configuration was refactored to use createSlatePlugin with rule helpers from @platejs/basic-nodes, @platejs/code-block, and @platejs/list, replacing the previous @platejs/autoformat manual configuration approach. The code-block disabling logic was centralized into a shared isNotInCodeBlock function.

Changes

Cohort / File(s) Summary
Autoformat Plugin Refactoring
src/components/editor/plugins/autoformat-kit.tsx
Replaced manual AutoformatPlugin.configure() with createSlatePlugin() using inputRules for headings, blockquotes, horizontal rules, code blocks, marks (bold/italic/underline/strikethrough/subscript/superscript/highlight), and lists. Centralized code-block disabling logic into isNotInCodeBlock function applied per rule.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

📝 From manual marks to rules so neat,
A plugin refresh, refactored complete!
Code blocks now safer, logic condensed—
Less clutter, more clarity, perfectly tensed! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: migrating the autoformat-kit plugin from the deprecated v52 AutoformatPlugin to the v53 inputRules API, which is the core objective of this PR.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/platejs-v53-migration

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 21 minutes and 36 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 29, 2026

Codecov Report

❌ Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 70.37%. Comparing base (ba9aec3) to head (7222c3c).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/components/editor/plugins/basic-blocks-kit.tsx 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #175      +/-   ##
==========================================
+ Coverage   70.16%   70.37%   +0.20%     
==========================================
  Files         161      161              
  Lines        4659     4641      -18     
  Branches     1228     1227       -1     
==========================================
- Hits         3269     3266       -3     
+ Misses       1371     1356      -15     
  Partials       19       19              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 29, 2026

🧪 E2E Coverage Report (Sharded: 12 parallel jobs)

Metric Coverage
Lines 93.25%
Functions 21.87%
Branches 18.16%
Statements 31.46%

📊 Full report available in workflow artifacts

…toformat

HeadingRules.markdown() resolves the markdown prefix (#, ##, ...)
from pluginKey via /^h([1-6])$/. When attached to a standalone
aggregator plugin (key: 'markdownShortcuts') the regex never matches,
so '# ' input never converted to <h1> in v53.

Attach HeadingRules.markdown({ enabled: isNotInCodeBlock }) directly
to each H1Plugin..H6Plugin so pluginKey === 'h1'..'h6' and prefix
resolves correctly.

Fixes E2E shard 9/12 failure: should support markdown autoformat for heading
@ryota-murakami
Copy link
Copy Markdown
Contributor Author

@coderabbitai full review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 29, 2026

✅ Actions performed

Full review triggered.

@ryota-murakami ryota-murakami merged commit 5b786e6 into main Apr 29, 2026
20 checks passed
@ryota-murakami ryota-murakami deleted the fix/platejs-v53-migration branch April 29, 2026 03:35
ryota-murakami added a commit that referenced this pull request Apr 29, 2026
Reflects the v52→v53 migration completed in PR #175.
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