Skip to content

fix: Disable default UI when no components context is found#2611

Open
matthewlipski wants to merge 1 commit intomainfrom
raw-view-default-ui-disable
Open

fix: Disable default UI when no components context is found#2611
matthewlipski wants to merge 1 commit intomainfrom
raw-view-default-ui-disable

Conversation

@matthewlipski
Copy link
Copy Markdown
Collaborator

@matthewlipski matthewlipski commented Mar 31, 2026

Summary

When using BlockNoteViewRaw to create a minimal editor, errors are thrown when the editor attempts to render default UI elements as there is no components context to create them from. This PR makes it so that if no component context is found when rendering the editor, all default UI elements are disabled.

Note however that this is not a supported use case and we do not expect BlockNoteViewRaw to be used on its own.

Closes #889

Rationale

While this use case is not officially supported, BlockNoteViewRaw is exported and may be useful to some.

Changes

See above.

Impact

N/A

Testing

Because this is not something we officially support, no tests have been added.

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

Summary by CodeRabbit

  • Refactor
    • Improved component context handling and conditional initialization logic for UI features.
    • Optimized internal state management through memoization to enhance performance.

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 31, 2026

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

Project Deployment Actions Updated (UTC)
blocknote Ready Ready Preview Mar 31, 2026 4:25pm
blocknote-website Ready Ready Preview Mar 31, 2026 4:25pm

Request Review

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 31, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6cbc0d57-0d01-4f46-8a49-4964b158dabc

📥 Commits

Reviewing files that changed from the base of the PR and between a850078 and 4bb2d64.

📒 Files selected for processing (1)
  • packages/react/src/editor/BlockNoteView.tsx

📝 Walkthrough

Walkthrough

BlockNoteViewComponent now reads the components context and conditionally defaults UI feature props (toolbars, menus, panels) based on context availability. When no context exists, these props are explicitly set to false to prevent undefined reference errors; otherwise, they remain undefined to preserve default downstream behavior.

Changes

Cohort / File(s) Summary
UI Prop Defaulting Logic
packages/react/src/editor/BlockNoteView.tsx
Introduced context-aware conditional defaulting for UI feature props (formattingToolbar, linkToolbar, sideMenu, slashMenu, filePanel, tableHandles, emojiPicker, comments). Props are set to false when components context is absent, otherwise remain undefined. Memoized defaultUIProps value replaces individual prop dependencies in context memo configuration.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A readonly editor hops with glee,
No toolbars to fear, now context-aware and free,
Props default safely when context is gone,
No more undefined errors at dawn! 🌟

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: disabling default UI when no components context is found.
Description check ✅ Passed The description follows the template and includes Summary, Rationale, Changes, Impact, Testing, and Checklist sections, though testing section notes no tests were added.
Linked Issues check ✅ Passed The PR successfully addresses issue #889 by preventing errors when BlockNoteViewRaw is used without a components context, disabling default UI elements instead of throwing TypeErrors.
Out of Scope Changes check ✅ Passed All changes are scoped to the BlockNoteView component's context-aware UI feature detection logic, directly addressing the linked issue requirement.

✏️ 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 raw-view-default-ui-disable

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

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 Mar 31, 2026

Open in StackBlitz

@blocknote/ariakit

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

@blocknote/code-block

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

@blocknote/core

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

@blocknote/mantine

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

@blocknote/react

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

@blocknote/server-util

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

@blocknote/shadcn

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

@blocknote/xl-ai

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

@blocknote/xl-docx-exporter

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

@blocknote/xl-email-exporter

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

@blocknote/xl-multi-column

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

@blocknote/xl-odt-exporter

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

@blocknote/xl-pdf-exporter

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

commit: 4bb2d64

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.

Error on readonly editor - TypeError: Cannot read properties of undefined (reading 'FormattingToolbar')

1 participant