@blocknote/shadcn 0.23.6 → 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-shadcn.js +14 -10
- package/dist/blocknote-shadcn.js.map +1 -1
- package/dist/blocknote-shadcn.umd.cjs +1 -1
- package/dist/blocknote-shadcn.umd.cjs.map +1 -1
- package/dist/webpack-stats.json +1 -1
- package/package.json +4 -4
- package/src/BlockNoteView.tsx +52 -0
- package/src/components.ts +97 -0
- package/src/index.tsx +2 -141
- package/types/src/BlockNoteView.d.ts +9 -0
- package/types/src/components.d.ts +3 -0
- package/types/src/index.d.ts +2 -10
- package/types/src/toolbar/Toolbar.d.ts +15 -7
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BlockSchema,
|
|
3
|
+
InlineContentSchema,
|
|
4
|
+
mergeCSSClasses,
|
|
5
|
+
StyleSchema,
|
|
6
|
+
} from "@blocknote/core";
|
|
7
|
+
import {
|
|
8
|
+
BlockNoteViewProps,
|
|
9
|
+
BlockNoteViewRaw,
|
|
10
|
+
ComponentsContext,
|
|
11
|
+
} from "@blocknote/react";
|
|
12
|
+
import { useMemo } from "react";
|
|
13
|
+
|
|
14
|
+
import { components } from "./components.js";
|
|
15
|
+
import {
|
|
16
|
+
ShadCNComponents,
|
|
17
|
+
ShadCNComponentsContext,
|
|
18
|
+
ShadCNDefaultComponents,
|
|
19
|
+
} from "./ShadCNComponentsContext.js";
|
|
20
|
+
|
|
21
|
+
export const BlockNoteView = <
|
|
22
|
+
BSchema extends BlockSchema,
|
|
23
|
+
ISchema extends InlineContentSchema,
|
|
24
|
+
SSchema extends StyleSchema
|
|
25
|
+
>(
|
|
26
|
+
props: BlockNoteViewProps<BSchema, ISchema, SSchema> & {
|
|
27
|
+
/**
|
|
28
|
+
* (optional)Provide your own shadcn component overrides
|
|
29
|
+
*/
|
|
30
|
+
shadCNComponents?: Partial<ShadCNComponents>;
|
|
31
|
+
}
|
|
32
|
+
) => {
|
|
33
|
+
const { className, shadCNComponents, ...rest } = props;
|
|
34
|
+
|
|
35
|
+
const componentsValue = useMemo(() => {
|
|
36
|
+
return {
|
|
37
|
+
...ShadCNDefaultComponents,
|
|
38
|
+
...shadCNComponents,
|
|
39
|
+
};
|
|
40
|
+
}, [shadCNComponents]);
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<ShadCNComponentsContext.Provider value={componentsValue}>
|
|
44
|
+
<ComponentsContext.Provider value={components}>
|
|
45
|
+
<BlockNoteViewRaw
|
|
46
|
+
className={mergeCSSClasses("bn-shadcn", className || "")}
|
|
47
|
+
{...rest}
|
|
48
|
+
/>
|
|
49
|
+
</ComponentsContext.Provider>
|
|
50
|
+
</ShadCNComponentsContext.Provider>
|
|
51
|
+
);
|
|
52
|
+
};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { Components } from "@blocknote/react";
|
|
2
|
+
|
|
3
|
+
import { Form } from "./form/Form.js";
|
|
4
|
+
import { TextInput } from "./form/TextInput.js";
|
|
5
|
+
import {
|
|
6
|
+
Menu,
|
|
7
|
+
MenuDivider,
|
|
8
|
+
MenuDropdown,
|
|
9
|
+
MenuItem,
|
|
10
|
+
MenuLabel,
|
|
11
|
+
MenuTrigger,
|
|
12
|
+
} from "./menu/Menu.js";
|
|
13
|
+
import { Panel } from "./panel/Panel.js";
|
|
14
|
+
import { PanelTab } from "./panel/PanelTab.js";
|
|
15
|
+
import { PanelTextInput } from "./panel/PanelTextInput.js";
|
|
16
|
+
import { Popover, PopoverContent, PopoverTrigger } from "./popover/popover.js";
|
|
17
|
+
import { SideMenu } from "./sideMenu/SideMenu.js";
|
|
18
|
+
import { SideMenuButton } from "./sideMenu/SideMenuButton.js";
|
|
19
|
+
import { GridSuggestionMenu } from "./suggestionMenu/gridSuggestionMenu/GridSuggestionMenu.js";
|
|
20
|
+
import { GridSuggestionMenuEmptyItem } from "./suggestionMenu/gridSuggestionMenu/GridSuggestionMenuEmptyItem.js";
|
|
21
|
+
import { SuggestionMenu } from "./suggestionMenu/SuggestionMenu.js";
|
|
22
|
+
import { SuggestionMenuEmptyItem } from "./suggestionMenu/SuggestionMenuEmptyItem.js";
|
|
23
|
+
import { SuggestionMenuItem } from "./suggestionMenu/SuggestionMenuItem.js";
|
|
24
|
+
import { SuggestionMenuLabel } from "./suggestionMenu/SuggestionMenuLabel.js";
|
|
25
|
+
import { SuggestionMenuLoader } from "./suggestionMenu/SuggestionMenuLoader.js";
|
|
26
|
+
import { ExtendButton } from "./tableHandle/ExtendButton.js";
|
|
27
|
+
import { TableHandle } from "./tableHandle/TableHandle.js";
|
|
28
|
+
import { Toolbar, ToolbarButton, ToolbarSelect } from "./toolbar/Toolbar.js";
|
|
29
|
+
|
|
30
|
+
import { PanelButton } from "./panel/PanelButton.js";
|
|
31
|
+
import { PanelFileInput } from "./panel/PanelFileInput.js";
|
|
32
|
+
import "./style.css";
|
|
33
|
+
import { GridSuggestionMenuItem } from "./suggestionMenu/gridSuggestionMenu/GridSuggestionMenuItem.js";
|
|
34
|
+
import { GridSuggestionMenuLoader } from "./suggestionMenu/gridSuggestionMenu/GridSuggestionMenuLoader.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
|
+
LinkToolbar: {
|
|
50
|
+
Root: Toolbar,
|
|
51
|
+
Button: ToolbarButton,
|
|
52
|
+
},
|
|
53
|
+
SideMenu: {
|
|
54
|
+
Root: SideMenu,
|
|
55
|
+
Button: SideMenuButton,
|
|
56
|
+
},
|
|
57
|
+
SuggestionMenu: {
|
|
58
|
+
Root: SuggestionMenu,
|
|
59
|
+
Item: SuggestionMenuItem,
|
|
60
|
+
EmptyItem: SuggestionMenuEmptyItem,
|
|
61
|
+
Label: SuggestionMenuLabel,
|
|
62
|
+
Loader: SuggestionMenuLoader,
|
|
63
|
+
},
|
|
64
|
+
GridSuggestionMenu: {
|
|
65
|
+
Root: GridSuggestionMenu,
|
|
66
|
+
Item: GridSuggestionMenuItem,
|
|
67
|
+
EmptyItem: GridSuggestionMenuEmptyItem,
|
|
68
|
+
Loader: GridSuggestionMenuLoader,
|
|
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: Form,
|
|
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,143 +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
|
-
} from "@blocknote/react";
|
|
13
|
-
import { useMemo } from "react";
|
|
14
|
-
|
|
15
|
-
import { Form } from "./form/Form.js";
|
|
16
|
-
import { TextInput } from "./form/TextInput.js";
|
|
17
|
-
import {
|
|
18
|
-
Menu,
|
|
19
|
-
MenuDivider,
|
|
20
|
-
MenuDropdown,
|
|
21
|
-
MenuItem,
|
|
22
|
-
MenuLabel,
|
|
23
|
-
MenuTrigger,
|
|
24
|
-
} from "./menu/Menu.js";
|
|
25
|
-
import { Panel } from "./panel/Panel.js";
|
|
26
|
-
import { PanelTab } from "./panel/PanelTab.js";
|
|
27
|
-
import { PanelTextInput } from "./panel/PanelTextInput.js";
|
|
28
|
-
import { Popover, PopoverContent, PopoverTrigger } from "./popover/popover.js";
|
|
29
|
-
import {
|
|
30
|
-
ShadCNComponents,
|
|
31
|
-
ShadCNComponentsContext,
|
|
32
|
-
ShadCNDefaultComponents,
|
|
33
|
-
} from "./ShadCNComponentsContext.js";
|
|
34
|
-
import { SideMenu } from "./sideMenu/SideMenu.js";
|
|
35
|
-
import { SideMenuButton } from "./sideMenu/SideMenuButton.js";
|
|
36
|
-
import { GridSuggestionMenu } from "./suggestionMenu/gridSuggestionMenu/GridSuggestionMenu.js";
|
|
37
|
-
import { GridSuggestionMenuEmptyItem } from "./suggestionMenu/gridSuggestionMenu/GridSuggestionMenuEmptyItem.js";
|
|
38
|
-
import { SuggestionMenu } from "./suggestionMenu/SuggestionMenu.js";
|
|
39
|
-
import { SuggestionMenuEmptyItem } from "./suggestionMenu/SuggestionMenuEmptyItem.js";
|
|
40
|
-
import { SuggestionMenuItem } from "./suggestionMenu/SuggestionMenuItem.js";
|
|
41
|
-
import { SuggestionMenuLabel } from "./suggestionMenu/SuggestionMenuLabel.js";
|
|
42
|
-
import { SuggestionMenuLoader } from "./suggestionMenu/SuggestionMenuLoader.js";
|
|
43
|
-
import { ExtendButton } from "./tableHandle/ExtendButton.js";
|
|
44
|
-
import { TableHandle } from "./tableHandle/TableHandle.js";
|
|
45
|
-
import { Toolbar, ToolbarButton, ToolbarSelect } from "./toolbar/Toolbar.js";
|
|
46
|
-
|
|
47
|
-
import { PanelButton } from "./panel/PanelButton.js";
|
|
48
|
-
import { PanelFileInput } from "./panel/PanelFileInput.js";
|
|
49
1
|
import "./style.css";
|
|
50
|
-
import { GridSuggestionMenuItem } from "./suggestionMenu/gridSuggestionMenu/GridSuggestionMenuItem.js";
|
|
51
|
-
import { GridSuggestionMenuLoader } from "./suggestionMenu/gridSuggestionMenu/GridSuggestionMenuLoader.js";
|
|
52
|
-
|
|
53
|
-
export const components: Components = {
|
|
54
|
-
FormattingToolbar: {
|
|
55
|
-
Root: Toolbar,
|
|
56
|
-
Button: ToolbarButton,
|
|
57
|
-
Select: ToolbarSelect,
|
|
58
|
-
},
|
|
59
|
-
FilePanel: {
|
|
60
|
-
Root: Panel,
|
|
61
|
-
Button: PanelButton,
|
|
62
|
-
FileInput: PanelFileInput,
|
|
63
|
-
TabPanel: PanelTab,
|
|
64
|
-
TextInput: PanelTextInput,
|
|
65
|
-
},
|
|
66
|
-
LinkToolbar: {
|
|
67
|
-
Root: Toolbar,
|
|
68
|
-
Button: ToolbarButton,
|
|
69
|
-
},
|
|
70
|
-
SideMenu: {
|
|
71
|
-
Root: SideMenu,
|
|
72
|
-
Button: SideMenuButton,
|
|
73
|
-
},
|
|
74
|
-
SuggestionMenu: {
|
|
75
|
-
Root: SuggestionMenu,
|
|
76
|
-
Item: SuggestionMenuItem,
|
|
77
|
-
EmptyItem: SuggestionMenuEmptyItem,
|
|
78
|
-
Label: SuggestionMenuLabel,
|
|
79
|
-
Loader: SuggestionMenuLoader,
|
|
80
|
-
},
|
|
81
|
-
GridSuggestionMenu: {
|
|
82
|
-
Root: GridSuggestionMenu,
|
|
83
|
-
Item: GridSuggestionMenuItem,
|
|
84
|
-
EmptyItem: GridSuggestionMenuEmptyItem,
|
|
85
|
-
Loader: GridSuggestionMenuLoader,
|
|
86
|
-
},
|
|
87
|
-
TableHandle: {
|
|
88
|
-
Root: TableHandle,
|
|
89
|
-
ExtendButton: ExtendButton,
|
|
90
|
-
},
|
|
91
|
-
Generic: {
|
|
92
|
-
Form: {
|
|
93
|
-
Root: Form,
|
|
94
|
-
TextInput: TextInput,
|
|
95
|
-
},
|
|
96
|
-
Menu: {
|
|
97
|
-
Root: Menu,
|
|
98
|
-
Trigger: MenuTrigger,
|
|
99
|
-
Dropdown: MenuDropdown,
|
|
100
|
-
Divider: MenuDivider,
|
|
101
|
-
Label: MenuLabel,
|
|
102
|
-
Item: MenuItem,
|
|
103
|
-
},
|
|
104
|
-
Popover: {
|
|
105
|
-
Root: Popover,
|
|
106
|
-
Trigger: PopoverTrigger,
|
|
107
|
-
Content: PopoverContent,
|
|
108
|
-
},
|
|
109
|
-
},
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
export const BlockNoteView = <
|
|
113
|
-
BSchema extends BlockSchema,
|
|
114
|
-
ISchema extends InlineContentSchema,
|
|
115
|
-
SSchema extends StyleSchema
|
|
116
|
-
>(
|
|
117
|
-
props: BlockNoteViewProps<BSchema, ISchema, SSchema> & {
|
|
118
|
-
/**
|
|
119
|
-
* (optional)Provide your own shadcn component overrides
|
|
120
|
-
*/
|
|
121
|
-
shadCNComponents?: Partial<ShadCNComponents>;
|
|
122
|
-
}
|
|
123
|
-
) => {
|
|
124
|
-
const { className, shadCNComponents, ...rest } = props;
|
|
125
|
-
|
|
126
|
-
const componentsValue = useMemo(() => {
|
|
127
|
-
return {
|
|
128
|
-
...ShadCNDefaultComponents,
|
|
129
|
-
...shadCNComponents,
|
|
130
|
-
};
|
|
131
|
-
}, [shadCNComponents]);
|
|
132
2
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
<ComponentsContext.Provider value={components}>
|
|
136
|
-
<BlockNoteViewRaw
|
|
137
|
-
className={mergeCSSClasses("bn-shadcn", className || "")}
|
|
138
|
-
{...rest}
|
|
139
|
-
/>
|
|
140
|
-
</ComponentsContext.Provider>
|
|
141
|
-
</ShadCNComponentsContext.Provider>
|
|
142
|
-
);
|
|
143
|
-
};
|
|
3
|
+
export { BlockNoteView } from "./BlockNoteView.js";
|
|
4
|
+
export { components } from "./components.js";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { InlineContentSchema, StyleSchema } from "@blocknote/core";
|
|
2
|
+
import { BlockNoteViewProps } from "@blocknote/react";
|
|
3
|
+
import { ShadCNComponents } from "./ShadCNComponentsContext.js";
|
|
4
|
+
export declare const BlockNoteView: <BSchema extends Record<string, import("@blocknote/core").BlockConfig>, ISchema extends InlineContentSchema, SSchema extends StyleSchema>(props: BlockNoteViewProps<BSchema, ISchema, SSchema> & {
|
|
5
|
+
/**
|
|
6
|
+
* (optional)Provide your own shadcn component overrides
|
|
7
|
+
*/
|
|
8
|
+
shadCNComponents?: Partial<ShadCNComponents>;
|
|
9
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
package/types/src/index.d.ts
CHANGED
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
import { InlineContentSchema, StyleSchema } from "@blocknote/core";
|
|
2
|
-
import { BlockNoteViewProps, Components } from "@blocknote/react";
|
|
3
|
-
import { ShadCNComponents } from "./ShadCNComponentsContext.js";
|
|
4
1
|
import "./style.css";
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
/**
|
|
8
|
-
* (optional)Provide your own shadcn component overrides
|
|
9
|
-
*/
|
|
10
|
-
shadCNComponents?: Partial<ShadCNComponents>;
|
|
11
|
-
}) => import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export { BlockNoteView } from "./BlockNoteView.js";
|
|
3
|
+
export { components } from "./components.js";
|
|
@@ -1,16 +1,25 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { ComponentProps } from "@blocknote/react";
|
|
3
2
|
export declare const Toolbar: import("react").ForwardRefExoticComponent<{
|
|
4
3
|
className?: string | undefined;
|
|
5
4
|
children?: import("react").ReactNode;
|
|
6
|
-
} & {
|
|
7
|
-
className?: string | undefined;
|
|
8
|
-
children?: import("react").ReactNode;
|
|
9
5
|
onMouseEnter?: (() => void) | undefined;
|
|
10
6
|
onMouseLeave?: (() => void) | undefined;
|
|
11
7
|
} & import("react").RefAttributes<HTMLDivElement>>;
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
export declare const ToolbarButton: import("react").ForwardRefExoticComponent<({
|
|
9
|
+
className?: string | undefined;
|
|
10
|
+
mainTooltip: string;
|
|
11
|
+
secondaryTooltip?: string | undefined;
|
|
12
|
+
icon?: import("react").ReactNode;
|
|
13
|
+
onClick?: ((e: import("react").MouseEvent<Element, MouseEvent>) => void) | undefined;
|
|
14
|
+
isSelected?: boolean | undefined;
|
|
15
|
+
isDisabled?: boolean | undefined;
|
|
16
|
+
} & ({
|
|
17
|
+
children: import("react").ReactNode;
|
|
18
|
+
label?: string | undefined;
|
|
19
|
+
} | {
|
|
20
|
+
children?: undefined;
|
|
21
|
+
label: string;
|
|
22
|
+
})) & import("react").RefAttributes<HTMLButtonElement>>;
|
|
14
23
|
export declare const ToolbarSelect: import("react").ForwardRefExoticComponent<{
|
|
15
24
|
className?: string | undefined;
|
|
16
25
|
items: {
|
|
@@ -22,4 +31,3 @@ export declare const ToolbarSelect: import("react").ForwardRefExoticComponent<{
|
|
|
22
31
|
}[];
|
|
23
32
|
isDisabled?: boolean | undefined;
|
|
24
33
|
} & import("react").RefAttributes<HTMLDivElement>>;
|
|
25
|
-
export {};
|