feat: Render Mantine BlockNoteView without MantineProvider#2029
feat: Render Mantine BlockNoteView without MantineProvider#2029matthewlipski merged 6 commits intomantine-update-8from
BlockNoteView without MantineProvider#2029Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
@blocknote/ariakit
@blocknote/code-block
@blocknote/core
@blocknote/mantine
@blocknote/react
@blocknote/server-util
@blocknote/shadcn
@blocknote/xl-ai
@blocknote/xl-docx-exporter
@blocknote/xl-email-exporter
@blocknote/xl-multi-column
@blocknote/xl-odt-exporter
@blocknote/xl-pdf-exporter
commit: |
|
@nperez0111 any suggestions for how to name the component? I think |
|
@matthewlipski, I prefer naming things as what they are, instead of naming them as what they are not 😂 |
nperez0111
left a comment
There was a problem hiding this comment.
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?
…y within a `MantineContext`
* 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`
This PR changes the Mantine
BlockNoteViewto check if it's being rendered within an existingMantineContext. If it isn't, it wraps the editor in aMantineProvider. 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
MantineContextis found, the theme set on it doesn't affect BlockNote's styles.Closes #1555