Skip to content

Conversation

matthewlipski
Copy link
Collaborator

@matthewlipski matthewlipski commented Sep 23, 2025

This PR changes the Mantine BlockNoteView to check if it's being rendered within an existing MantineContext. If it isn't, it wraps the editor in a MantineProvider. Otherwise, it just renders the editor.

I've changed how the Mantine active styles are reset too (using CSS instead of Mantine theme) so that in case a MantineContext is found, the theme set on it doesn't affect BlockNote's styles.

Closes #1555

Copy link

vercel bot commented Sep 23, 2025

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

Project Deployment Preview Updated (UTC)
blocknote Ready Ready Preview Sep 24, 2025 2:51pm
blocknote-website Ready Ready Preview Sep 24, 2025 2:51pm

Copy link

pkg-pr-new bot commented Sep 23, 2025

Open in StackBlitz

@blocknote/ariakit

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/ariakit@2029

@blocknote/code-block

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/code-block@2029

@blocknote/core

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/core@2029

@blocknote/mantine

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/mantine@2029

@blocknote/react

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/react@2029

@blocknote/server-util

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/server-util@2029

@blocknote/shadcn

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/shadcn@2029

@blocknote/xl-ai

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/xl-ai@2029

@blocknote/xl-docx-exporter

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/xl-docx-exporter@2029

@blocknote/xl-email-exporter

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/xl-email-exporter@2029

@blocknote/xl-multi-column

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/xl-multi-column@2029

@blocknote/xl-odt-exporter

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/xl-odt-exporter@2029

@blocknote/xl-pdf-exporter

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/xl-pdf-exporter@2029

commit: aa94d72

@matthewlipski
Copy link
Collaborator Author

@nperez0111 any suggestions for how to name the component? I think BlockNoteViewNoProvider is not great but not sure what to change it with since it should still be specific in what it does imo.

@nperez0111
Copy link
Contributor

@matthewlipski, BlockNoteViewRaw, CustomBlockNoteView maybe?

I prefer naming things as what they are, instead of naming them as what they are not 😂

Copy link
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.

Actually, I just thought of something @matthewlipski, I think that may be able to use the provider if it exists by calling:

import { MantineContext } from "@mantine/core";
const hasContextSet = useContext(MantineContext)
if (hasContextSet) {
  return // simple render
} else {
  return // wrap with a provider
}

Because Mantine has a default value of null (https://github.com/mantinedev/mantine/blob/81e38bc8e3894c433f065557df60db5691aaf131/packages/%40mantine/core/src/core/MantineProvider/Mantine.context.ts#L25) we can easily tell whether the project already has a Mantine context set or not, and branch based on that. So maybe it can "just work" for the dev without having to use a separate component.

Maybe this is worth exploring?

Copy link
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.

EASY!

@matthewlipski matthewlipski merged commit b46968f into mantine-update-8 Sep 25, 2025
12 checks passed
@matthewlipski matthewlipski deleted the mantine-no-provider branch September 25, 2025 09:09
matthewlipski added a commit that referenced this pull request Sep 25, 2025
* Updated mantine

* Updated submenu code

* Small fixes

* Small fixes

* Small fix

* Updated Mantine 8.3.2

* feat: Render Mantine `BlockNoteView` without `MantineProvider` (#2029)

* Added `withMantineProvider` prop

* Ran `pnpm gen`

* Made separate component instead of boolean flag

* Updated naming

* Made `BlockNoteView` render `MantineProvider` only if it's not already within a `MantineContext`
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