Skip to content

feat: Code mark input rule edge case (BLO-938)#2698

Merged
matthewlipski merged 2 commits intomainfrom
code-input-rule-case
May 1, 2026
Merged

feat: Code mark input rule edge case (BLO-938)#2698
matthewlipski merged 2 commits intomainfrom
code-input-rule-case

Conversation

@matthewlipski
Copy link
Copy Markdown
Collaborator

@matthewlipski matthewlipski commented Apr 30, 2026

Summary

The code mark/style has an input rule which converts text wrapped in backticks into code. However, it misses an edge case where the user inputs 2 backticks, then enters text between them and adds a space after. This PR adds an additional input rule for this case.

Closes #1970

Rationale

While minor, this is a nice improvement to UX.

Changes

  • Extended Code TipTap mark with additional input rule.

Impact

N/A

Testing

N/A

Screenshots/Video

N/A

Checklist

  • Code follows the project's coding standards.
  • Unit tests covering the new feature have been added.
  • All existing tests pass.
  • The documentation has been updated to reflect the new feature

Additional Notes

N/A

Summary by CodeRabbit

  • Bug Fixes
    • Improved inline code handling so backtick-wrapped text followed immediately by a space is reliably recognized and rendered as code, preserving the trailing space correctly for smoother typing and display.

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 30, 2026

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

Project Deployment Actions Updated (UTC)
blocknote Ready Ready Preview May 1, 2026 9:52am
blocknote-website Ready Ready Preview May 1, 2026 9:52am

Request Review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 30, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 98db80de-3b67-45c5-ac01-aa988f212079

📥 Commits

Reviewing files that changed from the base of the PR and between cdba17e and 112985e.

📒 Files selected for processing (1)
  • packages/core/src/blocks/defaultBlocks.ts

📝 Walkthrough

Walkthrough

The code style spec in default blocks now uses an extended Code mark and adds a custom InputRule that triggers when a space is typed after closing backticks, replacing the matched range with a marked inline-code node plus a trailing space to address backtick-edge cases.

Changes

Cohort / File(s) Summary
Inline Code Input Rule Enhancement
packages/core/src/blocks/defaultBlocks.ts
Replaced direct @tiptap/extension-code usage with an extended Code mark. Added a new InputRule that detects backtick-delimited text followed by a space and replaces the range with two schema-created text nodes: one with the Code mark applied and one containing the trailing space. Maintains original markInputRule for closing-backtick input.

Sequence Diagram(s)

sequenceDiagram
    participant User as User (typing)
    participant Editor as Editor/InputRules
    participant Schema as Schema/Document
    User->>Editor: type backtick(s), text, closing backtick, then space
    Editor->>Editor: match custom InputRule (backticked text + space)
    Editor->>Schema: create marked text node (Code) and text node (space)
    Schema-->>Editor: updated document fragment
    Editor-->>User: render inline code with trailing space
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

  • nperez0111

Poem

🐰 I nibbled backticks, hopped through the space,
Turned stray ticks to tidy code in place,
No letters lost, no cursor fuss—
A rabbit’s fix for bugs like us! 🥕

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and specifically describes the main change: adding a code mark input rule for an edge case, with reference to the issue number (BLO-938).
Description check ✅ Passed The PR description follows the required template and provides sufficient detail: summary of the edge case, rationale, changes made, and verification that tests pass and standards are met.
Linked Issues check ✅ Passed The changes directly address the edge case described in issue #1970 by extending the Code mark with an additional input rule to handle the two-backtick sequence followed by text and space.
Out of Scope Changes check ✅ Passed All changes are focused on the specific edge case in the Code mark's input rule behavior as described in issue #1970; no out-of-scope modifications are evident.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch code-input-rule-case

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: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.

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

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Apr 30, 2026

Open in StackBlitz

@blocknote/ariakit

npm i https://pkg.pr.new/@blocknote/ariakit@2698

@blocknote/code-block

npm i https://pkg.pr.new/@blocknote/code-block@2698

@blocknote/core

npm i https://pkg.pr.new/@blocknote/core@2698

@blocknote/mantine

npm i https://pkg.pr.new/@blocknote/mantine@2698

@blocknote/react

npm i https://pkg.pr.new/@blocknote/react@2698

@blocknote/server-util

npm i https://pkg.pr.new/@blocknote/server-util@2698

@blocknote/shadcn

npm i https://pkg.pr.new/@blocknote/shadcn@2698

@blocknote/xl-ai

npm i https://pkg.pr.new/@blocknote/xl-ai@2698

@blocknote/xl-docx-exporter

npm i https://pkg.pr.new/@blocknote/xl-docx-exporter@2698

@blocknote/xl-email-exporter

npm i https://pkg.pr.new/@blocknote/xl-email-exporter@2698

@blocknote/xl-multi-column

npm i https://pkg.pr.new/@blocknote/xl-multi-column@2698

@blocknote/xl-odt-exporter

npm i https://pkg.pr.new/@blocknote/xl-odt-exporter@2698

@blocknote/xl-pdf-exporter

npm i https://pkg.pr.new/@blocknote/xl-pdf-exporter@2698

commit: 112985e

Copy link
Copy Markdown
Contributor

@nperez0111 nperez0111 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works from what I can tell

Comment thread packages/core/src/blocks/defaultBlocks.ts Outdated
@matthewlipski matthewlipski merged commit c48abc8 into main May 1, 2026
23 checks passed
@matthewlipski matthewlipski deleted the code-input-rule-case branch May 1, 2026 09:56
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.

Bug with inline code using backticks

2 participants