@blocknote/mantine 0.23.5 → 0.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blocknote-mantine.js +126 -122
- package/dist/blocknote-mantine.js.map +1 -1
- package/dist/blocknote-mantine.umd.cjs +1 -1
- package/dist/blocknote-mantine.umd.cjs.map +1 -1
- package/dist/webpack-stats.json +1 -1
- package/package.json +4 -4
- package/src/BlockNoteView.tsx +97 -0
- package/src/components.tsx +97 -0
- package/src/index.tsx +2 -189
- package/types/src/BlockNoteView.d.ts +10 -0
- package/types/src/components.d.ts +3 -0
- package/types/src/index.d.ts +2 -11
- package/types/src/toolbar/Toolbar.d.ts +0 -3
- package/types/src/toolbar/ToolbarButton.d.ts +15 -4
package/dist/webpack-stats.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"builtAt":
|
|
1
|
+
{"builtAt":1739818783659,"assets":[{"name":"blocknote-mantine.umd.cjs","size":17000},{"name":"blocknote-mantine.umd.cjs.map","size":295396}],"chunks":[{"id":"ec22802","entry":true,"initial":true,"files":["blocknote-mantine.umd.cjs"],"names":["index"]}],"modules":[{"name":"./src/BlockNoteTheme.ts","size":2185,"chunks":["ec22802"]},{"name":"./src/form/TextInput.tsx","size":575,"chunks":["ec22802"]},{"name":"../../node_modules/react-icons/lib/iconContext.mjs","size":251,"chunks":["ec22802"]},{"name":"../../node_modules/react-icons/lib/iconBase.mjs","size":4014,"chunks":["ec22802"]},{"name":"../../node_modules/react-icons/hi/index.mjs","size":744,"chunks":["ec22802"]},{"name":"./src/menu/Menu.tsx","size":4215,"chunks":["ec22802"]},{"name":"./src/panel/Panel.tsx","size":1015,"chunks":["ec22802"]},{"name":"./src/panel/PanelButton.tsx","size":345,"chunks":["ec22802"]},{"name":"./src/panel/PanelFileInput.tsx","size":367,"chunks":["ec22802"]},{"name":"./src/panel/PanelTab.tsx","size":209,"chunks":["ec22802"]},{"name":"./src/panel/PanelTextInput.tsx","size":392,"chunks":["ec22802"]},{"name":"./src/popover/Popover.tsx","size":679,"chunks":["ec22802"]},{"name":"./src/sideMenu/SideMenu.tsx","size":309,"chunks":["ec22802"]},{"name":"./src/sideMenu/SideMenuButton.tsx","size":773,"chunks":["ec22802"]},{"name":"./src/style.css","size":0,"chunks":["ec22802"]},{"name":"./src/suggestionMenu/gridSuggestionMenu/GridSuggestionMenu.tsx","size":361,"chunks":["ec22802"]},{"name":"./src/suggestionMenu/gridSuggestionMenu/GridSuggestionMenuEmptyItem.tsx","size":436,"chunks":["ec22802"]},{"name":"./src/suggestionMenu/gridSuggestionMenu/GridSuggestionMenuItem.tsx","size":855,"chunks":["ec22802"]},{"name":"./src/suggestionMenu/gridSuggestionMenu/GridSuggestionMenuLoader.tsx","size":385,"chunks":["ec22802"]},{"name":"./src/suggestionMenu/SuggestionMenu.tsx","size":307,"chunks":["ec22802"]},{"name":"./src/suggestionMenu/SuggestionMenuEmptyItem.tsx","size":338,"chunks":["ec22802"]},{"name":"./src/suggestionMenu/SuggestionMenuItem.tsx","size":1822,"chunks":["ec22802"]},{"name":"./src/suggestionMenu/SuggestionMenuLabel.tsx","size":227,"chunks":["ec22802"]},{"name":"./src/suggestionMenu/SuggestionMenuLoader.tsx","size":283,"chunks":["ec22802"]},{"name":"./src/tableHandle/ExtendButton.tsx","size":333,"chunks":["ec22802"]},{"name":"./src/tableHandle/TableHandle.tsx","size":452,"chunks":["ec22802"]},{"name":"./src/toolbar/Toolbar.tsx","size":562,"chunks":["ec22802"]},{"name":"./src/toolbar/ToolbarButton.tsx","size":2229,"chunks":["ec22802"]},{"name":"./src/toolbar/ToolbarSelect.tsx","size":1785,"chunks":["ec22802"]},{"name":"./src/components.tsx","size":1311,"chunks":["ec22802"]},{"name":"./src/BlockNoteView.tsx","size":1459,"chunks":["ec22802"]},{"name":"./src/defaultThemes.ts","size":2023,"chunks":["ec22802"]},{"name":"./src/index.tsx","size":0,"chunks":["ec22802"]}]}
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"*.css"
|
|
7
7
|
],
|
|
8
8
|
"license": "MPL-2.0",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.24.0",
|
|
10
10
|
"files": [
|
|
11
11
|
"dist",
|
|
12
12
|
"types",
|
|
@@ -50,8 +50,8 @@
|
|
|
50
50
|
"clean": "rimraf dist && rimraf types"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@blocknote/core": "^0.
|
|
54
|
-
"@blocknote/react": "^0.
|
|
53
|
+
"@blocknote/core": "^0.24.0",
|
|
54
|
+
"@blocknote/react": "^0.24.0",
|
|
55
55
|
"@mantine/core": "^7.10.1",
|
|
56
56
|
"@mantine/hooks": "^7.10.1",
|
|
57
57
|
"@mantine/utils": "^6.0.21",
|
|
@@ -83,5 +83,5 @@
|
|
|
83
83
|
"access": "public",
|
|
84
84
|
"registry": "https://registry.npmjs.org/"
|
|
85
85
|
},
|
|
86
|
-
"gitHead": "
|
|
86
|
+
"gitHead": "4aa4f25c190f4cc364cbefe25e9b17c25d47e84d"
|
|
87
87
|
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BlockSchema,
|
|
3
|
+
InlineContentSchema,
|
|
4
|
+
mergeCSSClasses,
|
|
5
|
+
StyleSchema,
|
|
6
|
+
} from "@blocknote/core";
|
|
7
|
+
import {
|
|
8
|
+
BlockNoteViewProps,
|
|
9
|
+
BlockNoteViewRaw,
|
|
10
|
+
ComponentsContext,
|
|
11
|
+
useBlockNoteContext,
|
|
12
|
+
usePrefersColorScheme,
|
|
13
|
+
} from "@blocknote/react";
|
|
14
|
+
import { MantineProvider } from "@mantine/core";
|
|
15
|
+
import { useCallback } from "react";
|
|
16
|
+
import {
|
|
17
|
+
applyBlockNoteCSSVariablesFromTheme,
|
|
18
|
+
removeBlockNoteCSSVariables,
|
|
19
|
+
Theme,
|
|
20
|
+
} from "./BlockNoteTheme.js";
|
|
21
|
+
import { components } from "./components.js";
|
|
22
|
+
import "./style.css";
|
|
23
|
+
|
|
24
|
+
const mantineTheme = {
|
|
25
|
+
// Removes button press effect
|
|
26
|
+
activeClassName: "",
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const BlockNoteView = <
|
|
30
|
+
BSchema extends BlockSchema,
|
|
31
|
+
ISchema extends InlineContentSchema,
|
|
32
|
+
SSchema extends StyleSchema
|
|
33
|
+
>(
|
|
34
|
+
props: Omit<BlockNoteViewProps<BSchema, ISchema, SSchema>, "theme"> & {
|
|
35
|
+
theme?:
|
|
36
|
+
| "light"
|
|
37
|
+
| "dark"
|
|
38
|
+
| Theme
|
|
39
|
+
| {
|
|
40
|
+
light: Theme;
|
|
41
|
+
dark: Theme;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
) => {
|
|
45
|
+
const { className, theme, ...rest } = props;
|
|
46
|
+
|
|
47
|
+
const existingContext = useBlockNoteContext();
|
|
48
|
+
const systemColorScheme = usePrefersColorScheme();
|
|
49
|
+
const defaultColorScheme =
|
|
50
|
+
existingContext?.colorSchemePreference || systemColorScheme;
|
|
51
|
+
|
|
52
|
+
const ref = useCallback(
|
|
53
|
+
(node: HTMLDivElement | null) => {
|
|
54
|
+
if (!node) {
|
|
55
|
+
// todo: clean variables?
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
removeBlockNoteCSSVariables(node);
|
|
60
|
+
|
|
61
|
+
if (typeof theme === "object") {
|
|
62
|
+
if ("light" in theme && "dark" in theme) {
|
|
63
|
+
applyBlockNoteCSSVariablesFromTheme(
|
|
64
|
+
theme[defaultColorScheme === "dark" ? "dark" : "light"],
|
|
65
|
+
node
|
|
66
|
+
);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
applyBlockNoteCSSVariablesFromTheme(theme, node);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
[defaultColorScheme, theme]
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
return (
|
|
78
|
+
<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 */}
|
|
81
|
+
<MantineProvider
|
|
82
|
+
theme={mantineTheme}
|
|
83
|
+
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.
|
|
87
|
+
getRootElement={() => undefined}>
|
|
88
|
+
<BlockNoteViewRaw
|
|
89
|
+
className={mergeCSSClasses("bn-mantine", className || "")}
|
|
90
|
+
theme={typeof theme === "object" ? undefined : theme}
|
|
91
|
+
{...rest}
|
|
92
|
+
ref={ref}
|
|
93
|
+
/>
|
|
94
|
+
</MantineProvider>
|
|
95
|
+
</ComponentsContext.Provider>
|
|
96
|
+
);
|
|
97
|
+
};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { Components } from "@blocknote/react";
|
|
2
|
+
|
|
3
|
+
import { TextInput } from "./form/TextInput.js";
|
|
4
|
+
import {
|
|
5
|
+
Menu,
|
|
6
|
+
MenuDivider,
|
|
7
|
+
MenuDropdown,
|
|
8
|
+
MenuItem,
|
|
9
|
+
MenuLabel,
|
|
10
|
+
MenuTrigger,
|
|
11
|
+
} from "./menu/Menu.js";
|
|
12
|
+
import { Panel } from "./panel/Panel.js";
|
|
13
|
+
import { PanelButton } from "./panel/PanelButton.js";
|
|
14
|
+
import { PanelFileInput } from "./panel/PanelFileInput.js";
|
|
15
|
+
import { PanelTab } from "./panel/PanelTab.js";
|
|
16
|
+
import { PanelTextInput } from "./panel/PanelTextInput.js";
|
|
17
|
+
import { Popover, PopoverContent, PopoverTrigger } from "./popover/Popover.js";
|
|
18
|
+
import { SideMenu } from "./sideMenu/SideMenu.js";
|
|
19
|
+
import { SideMenuButton } from "./sideMenu/SideMenuButton.js";
|
|
20
|
+
import "./style.css";
|
|
21
|
+
import { GridSuggestionMenu } from "./suggestionMenu/gridSuggestionMenu/GridSuggestionMenu.js";
|
|
22
|
+
import { GridSuggestionMenuEmptyItem } from "./suggestionMenu/gridSuggestionMenu/GridSuggestionMenuEmptyItem.js";
|
|
23
|
+
import { GridSuggestionMenuItem } from "./suggestionMenu/gridSuggestionMenu/GridSuggestionMenuItem.js";
|
|
24
|
+
import { GridSuggestionMenuLoader } from "./suggestionMenu/gridSuggestionMenu/GridSuggestionMenuLoader.js";
|
|
25
|
+
import { SuggestionMenu } from "./suggestionMenu/SuggestionMenu.js";
|
|
26
|
+
import { SuggestionMenuEmptyItem } from "./suggestionMenu/SuggestionMenuEmptyItem.js";
|
|
27
|
+
import { SuggestionMenuItem } from "./suggestionMenu/SuggestionMenuItem.js";
|
|
28
|
+
import { SuggestionMenuLabel } from "./suggestionMenu/SuggestionMenuLabel.js";
|
|
29
|
+
import { SuggestionMenuLoader } from "./suggestionMenu/SuggestionMenuLoader.js";
|
|
30
|
+
import { ExtendButton } from "./tableHandle/ExtendButton.js";
|
|
31
|
+
import { TableHandle } from "./tableHandle/TableHandle.js";
|
|
32
|
+
import { Toolbar } from "./toolbar/Toolbar.js";
|
|
33
|
+
import { ToolbarButton } from "./toolbar/ToolbarButton.js";
|
|
34
|
+
import { ToolbarSelect } from "./toolbar/ToolbarSelect.js";
|
|
35
|
+
|
|
36
|
+
export const components: Components = {
|
|
37
|
+
FormattingToolbar: {
|
|
38
|
+
Root: Toolbar,
|
|
39
|
+
Button: ToolbarButton,
|
|
40
|
+
Select: ToolbarSelect,
|
|
41
|
+
},
|
|
42
|
+
FilePanel: {
|
|
43
|
+
Root: Panel,
|
|
44
|
+
Button: PanelButton,
|
|
45
|
+
FileInput: PanelFileInput,
|
|
46
|
+
TabPanel: PanelTab,
|
|
47
|
+
TextInput: PanelTextInput,
|
|
48
|
+
},
|
|
49
|
+
GridSuggestionMenu: {
|
|
50
|
+
Root: GridSuggestionMenu,
|
|
51
|
+
Item: GridSuggestionMenuItem,
|
|
52
|
+
EmptyItem: GridSuggestionMenuEmptyItem,
|
|
53
|
+
Loader: GridSuggestionMenuLoader,
|
|
54
|
+
},
|
|
55
|
+
LinkToolbar: {
|
|
56
|
+
Root: Toolbar,
|
|
57
|
+
Button: ToolbarButton,
|
|
58
|
+
},
|
|
59
|
+
SideMenu: {
|
|
60
|
+
Root: SideMenu,
|
|
61
|
+
Button: SideMenuButton,
|
|
62
|
+
},
|
|
63
|
+
SuggestionMenu: {
|
|
64
|
+
Root: SuggestionMenu,
|
|
65
|
+
Item: SuggestionMenuItem,
|
|
66
|
+
EmptyItem: SuggestionMenuEmptyItem,
|
|
67
|
+
Label: SuggestionMenuLabel,
|
|
68
|
+
Loader: SuggestionMenuLoader,
|
|
69
|
+
},
|
|
70
|
+
TableHandle: {
|
|
71
|
+
Root: TableHandle,
|
|
72
|
+
ExtendButton: ExtendButton,
|
|
73
|
+
},
|
|
74
|
+
Generic: {
|
|
75
|
+
Toolbar: {
|
|
76
|
+
Root: Toolbar,
|
|
77
|
+
Button: ToolbarButton,
|
|
78
|
+
},
|
|
79
|
+
Form: {
|
|
80
|
+
Root: (props) => <div>{props.children}</div>,
|
|
81
|
+
TextInput: TextInput,
|
|
82
|
+
},
|
|
83
|
+
Menu: {
|
|
84
|
+
Root: Menu,
|
|
85
|
+
Trigger: MenuTrigger,
|
|
86
|
+
Dropdown: MenuDropdown,
|
|
87
|
+
Divider: MenuDivider,
|
|
88
|
+
Label: MenuLabel,
|
|
89
|
+
Item: MenuItem,
|
|
90
|
+
},
|
|
91
|
+
Popover: {
|
|
92
|
+
Root: Popover,
|
|
93
|
+
Trigger: PopoverTrigger,
|
|
94
|
+
Content: PopoverContent,
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
};
|
package/src/index.tsx
CHANGED
|
@@ -1,191 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
BlockSchema,
|
|
3
|
-
InlineContentSchema,
|
|
4
|
-
mergeCSSClasses,
|
|
5
|
-
StyleSchema,
|
|
6
|
-
} from "@blocknote/core";
|
|
7
|
-
import {
|
|
8
|
-
BlockNoteViewProps,
|
|
9
|
-
BlockNoteViewRaw,
|
|
10
|
-
Components,
|
|
11
|
-
ComponentsContext,
|
|
12
|
-
useBlockNoteContext,
|
|
13
|
-
usePrefersColorScheme,
|
|
14
|
-
} from "@blocknote/react";
|
|
15
|
-
import { MantineProvider } from "@mantine/core";
|
|
16
|
-
import { useCallback } from "react";
|
|
17
|
-
|
|
18
|
-
import {
|
|
19
|
-
applyBlockNoteCSSVariablesFromTheme,
|
|
20
|
-
removeBlockNoteCSSVariables,
|
|
21
|
-
Theme,
|
|
22
|
-
} from "./BlockNoteTheme.js";
|
|
23
|
-
import { TextInput } from "./form/TextInput.js";
|
|
24
|
-
import {
|
|
25
|
-
Menu,
|
|
26
|
-
MenuDivider,
|
|
27
|
-
MenuDropdown,
|
|
28
|
-
MenuItem,
|
|
29
|
-
MenuLabel,
|
|
30
|
-
MenuTrigger,
|
|
31
|
-
} from "./menu/Menu.js";
|
|
32
|
-
import { Panel } from "./panel/Panel.js";
|
|
33
|
-
import { PanelButton } from "./panel/PanelButton.js";
|
|
34
|
-
import { PanelFileInput } from "./panel/PanelFileInput.js";
|
|
35
|
-
import { PanelTab } from "./panel/PanelTab.js";
|
|
36
|
-
import { PanelTextInput } from "./panel/PanelTextInput.js";
|
|
37
|
-
import { Popover, PopoverContent, PopoverTrigger } from "./popover/Popover.js";
|
|
38
|
-
import { SideMenu } from "./sideMenu/SideMenu.js";
|
|
39
|
-
import { SideMenuButton } from "./sideMenu/SideMenuButton.js";
|
|
40
|
-
import "./style.css";
|
|
41
|
-
import { GridSuggestionMenu } from "./suggestionMenu/gridSuggestionMenu/GridSuggestionMenu.js";
|
|
42
|
-
import { GridSuggestionMenuEmptyItem } from "./suggestionMenu/gridSuggestionMenu/GridSuggestionMenuEmptyItem.js";
|
|
43
|
-
import { GridSuggestionMenuItem } from "./suggestionMenu/gridSuggestionMenu/GridSuggestionMenuItem.js";
|
|
44
|
-
import { GridSuggestionMenuLoader } from "./suggestionMenu/gridSuggestionMenu/GridSuggestionMenuLoader.js";
|
|
45
|
-
import { SuggestionMenu } from "./suggestionMenu/SuggestionMenu.js";
|
|
46
|
-
import { SuggestionMenuEmptyItem } from "./suggestionMenu/SuggestionMenuEmptyItem.js";
|
|
47
|
-
import { SuggestionMenuItem } from "./suggestionMenu/SuggestionMenuItem.js";
|
|
48
|
-
import { SuggestionMenuLabel } from "./suggestionMenu/SuggestionMenuLabel.js";
|
|
49
|
-
import { SuggestionMenuLoader } from "./suggestionMenu/SuggestionMenuLoader.js";
|
|
50
|
-
import { ExtendButton } from "./tableHandle/ExtendButton.js";
|
|
51
|
-
import { TableHandle } from "./tableHandle/TableHandle.js";
|
|
52
|
-
import { Toolbar } from "./toolbar/Toolbar.js";
|
|
53
|
-
import { ToolbarButton } from "./toolbar/ToolbarButton.js";
|
|
54
|
-
import { ToolbarSelect } from "./toolbar/ToolbarSelect.js";
|
|
55
|
-
|
|
56
1
|
export * from "./BlockNoteTheme.js";
|
|
2
|
+
export * from "./BlockNoteView.js";
|
|
3
|
+
export * from "./components.js";
|
|
57
4
|
export * from "./defaultThemes.js";
|
|
58
|
-
|
|
59
|
-
export const components: Components = {
|
|
60
|
-
FormattingToolbar: {
|
|
61
|
-
Root: Toolbar,
|
|
62
|
-
Button: ToolbarButton,
|
|
63
|
-
Select: ToolbarSelect,
|
|
64
|
-
},
|
|
65
|
-
FilePanel: {
|
|
66
|
-
Root: Panel,
|
|
67
|
-
Button: PanelButton,
|
|
68
|
-
FileInput: PanelFileInput,
|
|
69
|
-
TabPanel: PanelTab,
|
|
70
|
-
TextInput: PanelTextInput,
|
|
71
|
-
},
|
|
72
|
-
GridSuggestionMenu: {
|
|
73
|
-
Root: GridSuggestionMenu,
|
|
74
|
-
Item: GridSuggestionMenuItem,
|
|
75
|
-
EmptyItem: GridSuggestionMenuEmptyItem,
|
|
76
|
-
Loader: GridSuggestionMenuLoader,
|
|
77
|
-
},
|
|
78
|
-
LinkToolbar: {
|
|
79
|
-
Root: Toolbar,
|
|
80
|
-
Button: ToolbarButton,
|
|
81
|
-
},
|
|
82
|
-
SideMenu: {
|
|
83
|
-
Root: SideMenu,
|
|
84
|
-
Button: SideMenuButton,
|
|
85
|
-
},
|
|
86
|
-
SuggestionMenu: {
|
|
87
|
-
Root: SuggestionMenu,
|
|
88
|
-
Item: SuggestionMenuItem,
|
|
89
|
-
EmptyItem: SuggestionMenuEmptyItem,
|
|
90
|
-
Label: SuggestionMenuLabel,
|
|
91
|
-
Loader: SuggestionMenuLoader,
|
|
92
|
-
},
|
|
93
|
-
TableHandle: {
|
|
94
|
-
Root: TableHandle,
|
|
95
|
-
ExtendButton: ExtendButton,
|
|
96
|
-
},
|
|
97
|
-
Generic: {
|
|
98
|
-
Form: {
|
|
99
|
-
Root: (props) => <div>{props.children}</div>,
|
|
100
|
-
TextInput: TextInput,
|
|
101
|
-
},
|
|
102
|
-
Menu: {
|
|
103
|
-
Root: Menu,
|
|
104
|
-
Trigger: MenuTrigger,
|
|
105
|
-
Dropdown: MenuDropdown,
|
|
106
|
-
Divider: MenuDivider,
|
|
107
|
-
Label: MenuLabel,
|
|
108
|
-
Item: MenuItem,
|
|
109
|
-
},
|
|
110
|
-
Popover: {
|
|
111
|
-
Root: Popover,
|
|
112
|
-
Trigger: PopoverTrigger,
|
|
113
|
-
Content: PopoverContent,
|
|
114
|
-
},
|
|
115
|
-
},
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
const mantineTheme = {
|
|
119
|
-
// Removes button press effect
|
|
120
|
-
activeClassName: "",
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
export const BlockNoteView = <
|
|
124
|
-
BSchema extends BlockSchema,
|
|
125
|
-
ISchema extends InlineContentSchema,
|
|
126
|
-
SSchema extends StyleSchema
|
|
127
|
-
>(
|
|
128
|
-
props: Omit<BlockNoteViewProps<BSchema, ISchema, SSchema>, "theme"> & {
|
|
129
|
-
theme?:
|
|
130
|
-
| "light"
|
|
131
|
-
| "dark"
|
|
132
|
-
| Theme
|
|
133
|
-
| {
|
|
134
|
-
light: Theme;
|
|
135
|
-
dark: Theme;
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
) => {
|
|
139
|
-
const { className, theme, ...rest } = props;
|
|
140
|
-
|
|
141
|
-
const existingContext = useBlockNoteContext();
|
|
142
|
-
const systemColorScheme = usePrefersColorScheme();
|
|
143
|
-
const defaultColorScheme =
|
|
144
|
-
existingContext?.colorSchemePreference || systemColorScheme;
|
|
145
|
-
|
|
146
|
-
const ref = useCallback(
|
|
147
|
-
(node: HTMLDivElement | null) => {
|
|
148
|
-
if (!node) {
|
|
149
|
-
// todo: clean variables?
|
|
150
|
-
return;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
removeBlockNoteCSSVariables(node);
|
|
154
|
-
|
|
155
|
-
if (typeof theme === "object") {
|
|
156
|
-
if ("light" in theme && "dark" in theme) {
|
|
157
|
-
applyBlockNoteCSSVariablesFromTheme(
|
|
158
|
-
theme[defaultColorScheme === "dark" ? "dark" : "light"],
|
|
159
|
-
node
|
|
160
|
-
);
|
|
161
|
-
return;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
applyBlockNoteCSSVariablesFromTheme(theme, node);
|
|
165
|
-
return;
|
|
166
|
-
}
|
|
167
|
-
},
|
|
168
|
-
[defaultColorScheme, theme]
|
|
169
|
-
);
|
|
170
|
-
|
|
171
|
-
return (
|
|
172
|
-
<ComponentsContext.Provider value={components}>
|
|
173
|
-
{/* `cssVariablesSelector` scopes Mantine CSS variables to only the editor, */}
|
|
174
|
-
{/* as proposed here: https://github.com/orgs/mantinedev/discussions/5685 */}
|
|
175
|
-
<MantineProvider
|
|
176
|
-
theme={mantineTheme}
|
|
177
|
-
cssVariablesSelector=".bn-mantine"
|
|
178
|
-
// This gets the element to set `data-mantine-color-scheme` on. Since we
|
|
179
|
-
// don't need this attribute (we use our own theming API), we return
|
|
180
|
-
// undefined here.
|
|
181
|
-
getRootElement={() => undefined}>
|
|
182
|
-
<BlockNoteViewRaw
|
|
183
|
-
className={mergeCSSClasses("bn-mantine", className || "")}
|
|
184
|
-
theme={typeof theme === "object" ? undefined : theme}
|
|
185
|
-
{...rest}
|
|
186
|
-
ref={ref}
|
|
187
|
-
/>
|
|
188
|
-
</MantineProvider>
|
|
189
|
-
</ComponentsContext.Provider>
|
|
190
|
-
);
|
|
191
|
-
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { InlineContentSchema, StyleSchema } from "@blocknote/core";
|
|
2
|
+
import { BlockNoteViewProps } from "@blocknote/react";
|
|
3
|
+
import { Theme } from "./BlockNoteTheme.js";
|
|
4
|
+
import "./style.css";
|
|
5
|
+
export declare const BlockNoteView: <BSchema extends Record<string, import("@blocknote/core").BlockConfig>, ISchema extends InlineContentSchema, SSchema extends StyleSchema>(props: Omit<BlockNoteViewProps<BSchema, ISchema, SSchema>, "theme"> & {
|
|
6
|
+
theme?: "light" | "dark" | Theme | {
|
|
7
|
+
light: Theme;
|
|
8
|
+
dark: Theme;
|
|
9
|
+
};
|
|
10
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
package/types/src/index.d.ts
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
|
-
import { InlineContentSchema, StyleSchema } from "@blocknote/core";
|
|
2
|
-
import { BlockNoteViewProps, Components } from "@blocknote/react";
|
|
3
|
-
import { Theme } from "./BlockNoteTheme.js";
|
|
4
|
-
import "./style.css";
|
|
5
1
|
export * from "./BlockNoteTheme.js";
|
|
2
|
+
export * from "./BlockNoteView.js";
|
|
3
|
+
export * from "./components.js";
|
|
6
4
|
export * from "./defaultThemes.js";
|
|
7
|
-
export declare const components: Components;
|
|
8
|
-
export declare const BlockNoteView: <BSchema extends Record<string, import("@blocknote/core").BlockConfig>, ISchema extends InlineContentSchema, SSchema extends StyleSchema>(props: Omit<BlockNoteViewProps<BSchema, ISchema, SSchema>, "theme"> & {
|
|
9
|
-
theme?: "light" | "dark" | Theme | {
|
|
10
|
-
light: Theme;
|
|
11
|
-
dark: Theme;
|
|
12
|
-
};
|
|
13
|
-
}) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -2,9 +2,6 @@
|
|
|
2
2
|
export declare const Toolbar: import("react").ForwardRefExoticComponent<{
|
|
3
3
|
className?: string | undefined;
|
|
4
4
|
children?: import("react").ReactNode;
|
|
5
|
-
} & {
|
|
6
|
-
className?: string | undefined;
|
|
7
|
-
children?: import("react").ReactNode;
|
|
8
5
|
onMouseEnter?: (() => void) | undefined;
|
|
9
6
|
onMouseLeave?: (() => void) | undefined;
|
|
10
7
|
} & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { ComponentProps } from "@blocknote/react";
|
|
3
2
|
export declare const TooltipContent: (props: {
|
|
4
3
|
mainTooltip: string;
|
|
5
4
|
secondaryTooltip?: string;
|
|
6
5
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
-
type ToolbarButtonProps = ComponentProps["FormattingToolbar"]["Button"] & ComponentProps["LinkToolbar"]["Button"];
|
|
8
6
|
/**
|
|
9
7
|
* Helper for basic buttons that show in the formatting toolbar.
|
|
10
8
|
*/
|
|
11
|
-
export declare const ToolbarButton: import("react").ForwardRefExoticComponent<
|
|
12
|
-
|
|
9
|
+
export declare const ToolbarButton: import("react").ForwardRefExoticComponent<({
|
|
10
|
+
className?: string | undefined;
|
|
11
|
+
mainTooltip: string;
|
|
12
|
+
secondaryTooltip?: string | undefined;
|
|
13
|
+
icon?: import("react").ReactNode;
|
|
14
|
+
onClick?: ((e: import("react").MouseEvent<Element, MouseEvent>) => void) | undefined;
|
|
15
|
+
isSelected?: boolean | undefined;
|
|
16
|
+
isDisabled?: boolean | undefined;
|
|
17
|
+
} & ({
|
|
18
|
+
children: import("react").ReactNode;
|
|
19
|
+
label?: string | undefined;
|
|
20
|
+
} | {
|
|
21
|
+
children?: undefined;
|
|
22
|
+
label: string;
|
|
23
|
+
})) & import("react").RefAttributes<HTMLButtonElement>>;
|