Skip to content

Commit b4b8d9a

Browse files
fix: Mantine CSS variables element (#1463)
* Added div to store all Mantine CSS variables around `BlockNoteView` * Small change * Removed extra div and set `data-mantine-color-scheme` manually
1 parent c1f8ac2 commit b4b8d9a

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

packages/mantine/src/BlockNoteView.tsx

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,18 +74,27 @@ export const BlockNoteView = <
7474
[defaultColorScheme, theme]
7575
);
7676

77+
const finalTheme =
78+
typeof theme === "string"
79+
? theme
80+
: defaultColorScheme !== "no-preference"
81+
? defaultColorScheme
82+
: "light";
83+
7784
return (
7885
<ComponentsContext.Provider value={components}>
79-
{/* `cssVariablesSelector` scopes Mantine CSS variables to only the editor, */}
80-
{/* as proposed here: https://github.com/orgs/mantinedev/discussions/5685 */}
8186
<MantineProvider
8287
theme={mantineTheme}
88+
// Scopes Mantine CSS variables to only the editor, as proposed here:
89+
// https://github.com/orgs/mantinedev/discussions/5685
8390
cssVariablesSelector=".bn-mantine"
84-
// This gets the element to set `data-mantine-color-scheme` on. Since we
85-
// don't need this attribute (we use our own theming API), we return
86-
// undefined here.
91+
// This gets the element to set `data-mantine-color-scheme` on. This
92+
// element needs to already be rendered, so we can't set it to the
93+
// editor container element. Instead, we set it to `undefined` and set it
94+
// manually in `BlockNoteViewRaw`.
8795
getRootElement={() => undefined}>
8896
<BlockNoteViewRaw
97+
data-mantine-color-scheme={finalTheme}
8998
className={mergeCSSClasses("bn-mantine", className || "")}
9099
theme={typeof theme === "object" ? undefined : theme}
91100
{...rest}

0 commit comments

Comments
 (0)