Skip to content

fix: register inline content spec extensions and mount their content correctly - #3251

Merged
nperez0111 merged 6 commits into
TypeCellOS:mainfrom
RovshanMuradov:fix/register-inline-content-extensions
Oct 24, 2026
Merged

nperez0111 merged 6 commits into
TypeCellOS:mainfrom
RovshanMuradov:fix/register-inline-content-extensions

Conversation

@RovshanMuradov

@RovshanMuradov RovshanMuradov commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This PR fixes two bugs in React inline content specs, one commit each. Both show up on inline math from @blocknote/math-block:

  1. Typing $x^2$ or \(x^2\) never turns into a formula.
  2. The raw LaTeX source shows next to the rendered formula.

The follow-up commits also let style specs declare extensions, and register the extensions of block, inline content and style specs in one loop.

1. Formulas typed with $...$ don't render

Cause: createReactInlineContentSpec accepts extensions, but ExtensionManager only registers extensions from block specs. So MathInlineInputRulesExtension never runs.

Fix: ExtensionManager also registers extensions from inlineContentSpecs, through the same addExtension path as block specs. Key de-duplication and disableExtensions apply, so apps that already pass the extension to the editor are unaffected.

2. Raw source shows next to the formula

Repro on main: in the math example, delete a paragraph with inline math, then undo. e^{i\pi} + 1 = 0 shows beside the formula.

Cause: inline content inserted after the editor mounts renders before TipTap creates its contentDOM. TipTap then mounts the content into a [data-node-view-content] element, or the node view root if there is none. Block specs set this attribute (#1954); inline content specs don't.

Fix: createReactInlineContentSpec sets data-node-view-content on the content element, as createReactBlockSpec does.

Fix 1 makes this bug reachable by just typing, so both land together.

Testing

  • Reproduced both bugs in Chromium on /custom-schema/math-block and confirmed both fixed on this branch.
  • ExtensionManager.node.test.ts covers registering extensions from block, inline content and style specs.
  • ReactInlineContentSpec.browser.test.tsx checks that plain and styled inline content mounts inside its contentRef after insertion and after undo.
  • @blocknote/core (1418) and @blocknote/react (21) unit tests pass; the browser test passes in Chromium and Firefox.

Screenshots/Video

The video shows both bugs on main first, then the same steps on this branch.

screenrecording-2026-10-24_08-13-48.mp4

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

Summary by CodeRabbit

  • New Features
    • Style specs can now include extensions, which are registered alongside extensions declared by block and inline content specs.
  • Bug Fixes
    • React inline content views now correctly identify their editable content area. This keeps inline content visible and editable after insertion, removal, and undo.

Once the editor has mounted, TipTap renders a React node view
synchronously, before it creates the contentDOM, so the contentRef call
can't mount it. TipTap then mounts it into a [data-node-view-content]
element or, failing that, into the node view's root. Inline content
specs didn't set that attribute (block specs do since TypeCellOS#1954), so the
content ended up outside the element the spec rendered for it, e.g. the
source of inline math showed next to its preview after an undo, until
the next re-render.
createReactInlineContentSpec accepts extensions and keeps them on the
spec, but ExtensionManager only collected them from block specs, so they
were silently dropped. This left the math-block inline input rules
($...$ and \(...\)) unregistered.
@vercel

vercel Bot commented Oct 24, 2026

Copy link
Copy Markdown

@RovshanMuradov is attempting to deploy a commit to the TypeCell Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters: 1
  • tests/src/unit/core/schema/__snapshots__/styles.json is excluded by !**/__snapshots__/**

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ed3bfc64-4dc6-47e4-89f4-0c78e62888b4

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 98963852-e1d3-4e70-ba9f-5b1800292e0e
Commits

Reviewing files that changed from the base of the PR and between 9d371b5 and 78d1fa0.

Files selected for processing: 8
  • packages/core/src/editor/managers/ExtensionManager/ExtensionManager.node.test.ts
  • packages/core/src/editor/managers/ExtensionManager/index.ts
  • packages/core/src/schema/inlineContent/types.ts
  • packages/core/src/schema/styles/createSpec.ts
  • packages/core/src/schema/styles/internal.ts
  • packages/core/src/schema/styles/types.ts
  • packages/react/src/schema/ReactInlineContentSpec.browser.test.tsx
  • packages/react/src/schema/ReactStyleSpec.tsx

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

Walkthrough

Style specs can now declare extensions, and ExtensionManager registers extensions from block, inline-content, and style specs. The React inline-content view marks its content element for the node view. Tests cover editor mounting, plugin registration, and inline-content insertion and undo.

Changes: Spec extension registration and React inline content

Layer / File(s) Summary
Add extension support to style specs
packages/core/src/schema/styles/*, packages/react/src/schema/ReactStyleSpec.tsx, packages/core/src/schema/inlineContent/types.ts
Style spec types and creation functions accept optional extensions and include them in the returned spec. The built-in text and link inline-content types now derive their fields from InlineContentSpec.
Register extensions from specs
packages/core/src/editor/managers/ExtensionManager/index.ts, packages/core/src/editor/managers/ExtensionManager/ExtensionManager.node.test.ts
ExtensionManager registers extensions declared by block, inline-content, and style specs. Tests mount editors to check extension and plugin registration, replacement, removal, state retention, and ordering.
Mark React inline-content target
packages/react/src/schema/ReactInlineContentSpec.tsx, packages/react/src/schema/ReactInlineContentSpec.browser.test.tsx
The content element receives data-node-view-content in addition to data-editable. Browser tests cover plain and styled inline content during insertion and undo.

Priority: Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant Editor
  participant ExtensionManager
  participant SpecCollections
  participant ProseMirrorState
  Editor->>ExtensionManager: Construct manager
  ExtensionManager->>SpecCollections: Read block, inline-content, and style specs
  ExtensionManager->>ProseMirrorState: Register spec-declared extensions and plugins
Loading

Possibly related PRs

Suggested reviewers: nperez0111

Merge Risk: Minimal · up to 78d1f

No actionable merge-blocking issue is established; the change appears ready for normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 9 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly identifies both primary changes: registering inline-content extensions and mounting inline-content correctly.
Description check Passed The description explains the bugs, causes, fixes, testing, and impact in sufficient detail. It omits explicit Rationale, Changes, Impact, and Additional Notes headings, and the checklist conflicts wit…
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.
Full details: Description check

Explanation

The description explains the bugs, causes, fixes, testing, and impact in sufficient detail. It omits explicit Rationale, Changes, Impact, and Additional Notes headings, and the checklist conflicts with the reported test results because existing tests are marked unchecked.

Finishing Touches: 💡 1
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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 hops past specs in flight
Style extensions join the write
Inline content finds its place
Marked for React’s node-view space
Tests remount and check the flow
Then undo brings text aglow

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

@RovshanMuradov
RovshanMuradov marked this pull request as draft October 24, 2026 04:20
@pkg-pr-new

pkg-pr-new Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@blocknote/ariakit

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

@blocknote/code-block

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

@blocknote/core

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

@blocknote/diagram-block

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

@blocknote/mantine

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

@blocknote/math-block

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

@blocknote/react

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

@blocknote/server-util

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

@blocknote/shadcn

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

@blocknote/xl-ai

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

@blocknote/xl-docx-exporter

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

@blocknote/xl-email-exporter

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

@blocknote/xl-multi-column

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

@blocknote/xl-odt-exporter

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

@blocknote/xl-pdf-exporter

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

@blocknote/xl-typst-exporter

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

commit: c09b261

@RovshanMuradov
RovshanMuradov marked this pull request as ready for review October 24, 2026 05:45
@RovshanMuradov

Copy link
Copy Markdown
Contributor Author

@nperez0111 sorry for some reason my push failed, I had tests localy. But overall it looks good to go now

@nperez0111

Copy link
Copy Markdown
Contributor

No worries, this is a great catch @RovshanMuradov thanks for submitting a PR for this. I also added support for style specs to provide extensions too which is a shortcoming of the API

@RovshanMuradov

Copy link
Copy Markdown
Contributor Author

@nperez0111 createStyleSpec now takes extensions, but vanilla createInlineContentSpec doesn't. Intentional, or should I add it?

@nperez0111
nperez0111 merged commit f90c34b into TypeCellOS:main Oct 24, 2026
18 of 20 checks passed
@RovshanMuradov

Copy link
Copy Markdown
Contributor Author

No worries, this is a great catch @RovshanMuradov thanks for submitting a PR for this. I also added support for style specs to provide extensions too which is a shortcoming of the API

thanks, I'm working on my project and I want to make sure math works smoothly. I will create couple PR's later too. I had other fixes on my project but I always forget to contribute

@nperez0111

Copy link
Copy Markdown
Contributor

@nperez0111 createStyleSpec now takes extensions, but vanilla createInlineContentSpec doesn't. Intentional, or should I add it?

Not intentional, that'd be good to add too!

@nperez0111

Copy link
Copy Markdown
Contributor

No worries, this is a great catch @RovshanMuradov thanks for submitting a PR for this. I also added support for style specs to provide extensions too which is a shortcoming of the API

thanks, I'm working on my project and I want to make sure math works smoothly. I will create couple PR's later too. I had other fixes on my project but I always forget to contribute

I'd be happy to take more fixes for math @RovshanMuradov

@RovshanMuradov

RovshanMuradov commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor Author

@nperez0111 createStyleSpec now takes extensions, but vanilla createInlineContentSpec doesn't. Intentional, or should I add it?

Not intentional, that'd be good to add too!

done #3253

@RovshanMuradov
RovshanMuradov deleted the fix/register-inline-content-extensions branch October 24, 2026 06:26
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