Skip to content

fix: inline code clears comments (BLO-1207) (BLO-1363) - #2832

Merged
matthewlipski merged 3 commits into
mainfrom
comments-inline-code
Sep 25, 2026
Merged

matthewlipski merged 3 commits into
mainfrom
comments-inline-code

Conversation

@matthewlipski

@matthewlipski matthewlipski commented Jun 4, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

This PR fixes an issues where comments cannot overlap inline code. This is because the inline code mark has exclude: "_" in its spec, meaning no other marks can overlap it. This makes sense for things like colors and bold/italic/etc, but not comments. Therefore, an exception has been added.

Closes #2803 #3084

Rationale

This is a bug.

Changes

  • Extended Code mark with onBeforeCreate to remove the comment mark from the exclude array.

Impact

N/A

Testing

Added e2e test.

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
    • Resolved an issue preventing inline code formatting from being applied to previously-commented text. Comment formatting is now preserved alongside code formatting, allowing both styles to coexist on the same text selection.

Summary by CodeRabbit

  • Bug Fixes
    • Applying inline code formatting to text with an existing comment now preserves the comment, allowing both to appear together.
    • This also works when formatting selected, commented text with the keyboard shortcut. The comment remains visible alongside the inline code formatting.
    • Inline code formatting now coexists correctly with annotation marks, including marks registered through nested extensions.

@vercel

vercel Bot commented Jun 4, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
blocknote Ready Ready Preview Sep 23, 2026 11:22am UTC
blocknote-website Ready Ready Preview Sep 23, 2026 11:22am UTC

Request Review

@matthewlipski
matthewlipski requested a review from nperez0111 June 4, 2026 09:23
@coderabbitai

coderabbitai Bot commented Jun 4, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: eea6590e-c5da-4951-9883-885051430831

📥 Commits

Reviewing files that changed from the base of the PR and between 41938f6 and 71dcf9b.

📒 Files selected for processing (3)
  • packages/core/src/blocks/defaultBlocks.test.ts
  • packages/core/src/blocks/defaultBlocks.ts
  • packages/core/src/schema/markGroups.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The code mark now uses a shared helper to exclude formatting marks while allowing non-formatting marks, including comments. Unit and end-to-end tests cover exclusion behavior and applying inline code to commented text.

Changes

Code and Comment Mark Overlap

Layer / File(s) Summary
Code mark exclusion schema
packages/core/src/schema/markGroups.ts, packages/core/src/blocks/defaultBlocks.ts, packages/core/src/blocks/defaultBlocks.test.ts
A shared helper uses flattened extensions to identify marks excluded by the code mark. Unit tests cover exclusions, comment coexistence, and schema creation without an editor.
Preserving comments when applying code
tests/src/end-to-end/comments/comments.test.tsx
An end-to-end test applies inline code to previously-commented text and checks that the comment mark remains visible with inline-code rendering.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: yousefed

Merge Risk: ⚪ Minimal · up to 71dcf

Inline code can coexist with comment annotations while formatting-mark exclusions remain intact. No actionable merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning Issue #2803 requires a coding change for unwanted table indentation after Tab in the last cell, or an easy unindent path, with automated coverage. The reviewed changes modify inline-code mark exclusio… Implement and test the #2803 table behavior. Prevent unwanted indentation after Tab in the last cell or provide an easy, tested unindent path.
Out of Scope Changes check ⚠️ Warning The changes in packages/core/src/blocks/defaultBlocks.ts, packages/core/src/blocks/defaultBlocks.test.ts, packages/core/src/schema/markGroups.ts, and `tests/src/end-to-end/comments/comments.test… Remove these unrelated changes from this pull request, or link and assess the issue that requires the inline-code and comment behavior.
✅ Passed checks (3 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 4 files.
Title check ✅ Passed The title clearly identifies the main change: fixing the interaction between inline code and comments.
Description check ✅ Passed The description includes all required template sections and explains the rationale, changes, impact, testing, and checklist status. It is mostly complete, although it does not mention the added unit t…
Full details: Linked Issues check

Explanation

Issue #2803 requires a coding change for unwanted table indentation after Tab in the last cell, or an easy unindent path, with automated coverage. The reviewed changes modify inline-code mark exclusions and add comment/code tests. They do not change table navigation or indentation behavior.

Full details: Out of Scope Changes check

Explanation

The changes in packages/core/src/blocks/defaultBlocks.ts, packages/core/src/blocks/defaultBlocks.test.ts, packages/core/src/schema/markGroups.ts, and tests/src/end-to-end/comments/comments.test.tsx address coexistence of comments and inline code. They have no demonstrated connection to table indentation or unindent behavior in issue #2803.

  • Fix all pre-merge checks with AI
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

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

A rabbit marks a word in code,
While comment threads remain bestowed.
The marks can share the text,
The tests confirm what comes next.
The rabbit hops along its road.

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

@pkg-pr-new

pkg-pr-new Bot commented Jun 4, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@blocknote/ariakit

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

@blocknote/code-block

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

@blocknote/core

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

@blocknote/diagram-block

npm i https://pkg.pr.new/@blocknote/diagram-block@2832

@blocknote/mantine

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

@blocknote/math-block

npm i https://pkg.pr.new/@blocknote/math-block@2832

@blocknote/react

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

@blocknote/server-util

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

@blocknote/shadcn

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

@blocknote/xl-ai

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

@blocknote/xl-docx-exporter

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

@blocknote/xl-email-exporter

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

@blocknote/xl-multi-column

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

@blocknote/xl-odt-exporter

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

@blocknote/xl-pdf-exporter

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

@blocknote/xl-typst-exporter

npm i https://pkg.pr.new/@blocknote/xl-typst-exporter@2832

commit: 71dcf9b

@github-actions

github-actions Bot commented Jun 4, 2026 •

Copy link
Copy Markdown
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-09-25 11:12 UTC

@matthewlipski matthewlipski changed the title fix: Inline code clears comments (BLO-1211) fix: Inline code clears comments (BLO-1207) Jun 4, 2026
Comment thread packages/core/src/blocks/defaultBlocks.ts Outdated

@nperez0111 nperez0111 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This looks good now, I couldn't find a simpler solution than to flatten the extensions straight from the options like you did

@nperez0111 nperez0111 changed the title fix: Inline code clears comments (BLO-1207) fix: inline code clears comments (BLO-1207) Sep 23, 2026
strike: createStyleSpecFromTipTapMark(Strike, "boolean"),
code: createStyleSpecFromTipTapMark(
Code.extend({
excludes() {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think we have NON_FORMATTING_MARK_GROUP for this right? cc @nperez0111 ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ah yea, true. we would need a function similar to nonFormattingMarks which sort of does the same thing based on group membership

@matthewlipski matthewlipski changed the title fix: inline code clears comments (BLO-1207) fix: inline code clears comments (BLO-1207) (BLO-1363) Sep 24, 2026
@matthewlipski
matthewlipski merged commit a79dd49 into main Sep 25, 2026
41 checks passed
@matthewlipski
matthewlipski deleted the comments-inline-code branch September 25, 2026 11:12

This branch was successfully deployed

2 active deployments
Preview – blocknote-website — 71dcf9b5 Deployed Sep 23, 2026 by vercel[bot]
Preview – blocknote — 71dcf9b5 Deployed Sep 23, 2026 by vercel[bot]
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.

Tables are hard to un-nest

3 participants