@blocknote/shadcn 0.13.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/LICENSE +373 -0
- package/dist/blocknote-shadcn.js +1881 -0
- package/dist/blocknote-shadcn.js.map +1 -0
- package/dist/blocknote-shadcn.umd.cjs +28 -0
- package/dist/blocknote-shadcn.umd.cjs.map +1 -0
- package/dist/style.css +1 -0
- package/dist/webpack-stats.json +1 -0
- package/package.json +104 -0
- package/src/ShadCNComponentsContext.tsx +39 -0
- package/src/components/ui/badge.tsx +36 -0
- package/src/components/ui/button.tsx +56 -0
- package/src/components/ui/card.tsx +86 -0
- package/src/components/ui/dropdown-menu.tsx +195 -0
- package/src/components/ui/form.tsx +176 -0
- package/src/components/ui/input.tsx +24 -0
- package/src/components/ui/label.tsx +24 -0
- package/src/components/ui/popover.tsx +29 -0
- package/src/components/ui/select.tsx +152 -0
- package/src/components/ui/tabs.tsx +53 -0
- package/src/components/ui/toggle.tsx +43 -0
- package/src/components/ui/tooltip.tsx +28 -0
- package/src/form/Form.tsx +21 -0
- package/src/form/TextInput.tsx +61 -0
- package/src/index.tsx +122 -0
- package/src/lib/utils.ts +6 -0
- package/src/menu/Menu.tsx +212 -0
- package/src/panel/Panel.tsx +54 -0
- package/src/panel/PanelButton.tsx +27 -0
- package/src/panel/PanelFileInput.tsx +27 -0
- package/src/panel/PanelTab.tsx +25 -0
- package/src/panel/PanelTextInput.tsx +29 -0
- package/src/popover/popover.tsx +69 -0
- package/src/sideMenu/SideMenu.tsx +18 -0
- package/src/sideMenu/SideMenuButton.tsx +45 -0
- package/src/style.css +109 -0
- package/src/suggestionMenu/SuggestionMenu.tsx +28 -0
- package/src/suggestionMenu/SuggestionMenuEmptyItem.tsx +26 -0
- package/src/suggestionMenu/SuggestionMenuItem.tsx +47 -0
- package/src/suggestionMenu/SuggestionMenuLabel.tsx +22 -0
- package/src/suggestionMenu/SuggestionMenuLoader.tsx +18 -0
- package/src/tableHandle/TableHandle.tsx +43 -0
- package/src/toolbar/Toolbar.tsx +153 -0
- package/types/src/ShadCNComponentsContext.d.ts +56 -0
- package/types/src/components/ui/badge.d.ts +9 -0
- package/types/src/components/ui/button.d.ts +11 -0
- package/types/src/components/ui/card.d.ts +8 -0
- package/types/src/components/ui/dropdown-menu.d.ts +27 -0
- package/types/src/components/ui/form.d.ts +23 -0
- package/types/src/components/ui/input.d.ts +4 -0
- package/types/src/components/ui/label.d.ts +5 -0
- package/types/src/components/ui/popover.d.ts +6 -0
- package/types/src/components/ui/select.d.ts +13 -0
- package/types/src/components/ui/tabs.d.ts +7 -0
- package/types/src/components/ui/toggle.d.ts +12 -0
- package/types/src/components/ui/tooltip.d.ts +7 -0
- package/types/src/form/Form.d.ts +2 -0
- package/types/src/form/TextInput.d.ts +13 -0
- package/types/src/index.d.ts +12 -0
- package/types/src/lib/utils.d.ts +2 -0
- package/types/src/menu/Menu.d.ts +24 -0
- package/types/src/panel/Panel.d.ts +12 -0
- package/types/src/panel/PanelButton.d.ts +11 -0
- package/types/src/panel/PanelFileInput.d.ts +7 -0
- package/types/src/panel/PanelTab.d.ts +5 -0
- package/types/src/panel/PanelTextInput.d.ts +8 -0
- package/types/src/popover/popover.d.ts +11 -0
- package/types/src/sideMenu/SideMenu.d.ts +5 -0
- package/types/src/sideMenu/SideMenuButton.d.ts +15 -0
- package/types/src/suggestionMenu/SuggestionMenu.d.ts +6 -0
- package/types/src/suggestionMenu/SuggestionMenuEmptyItem.d.ts +5 -0
- package/types/src/suggestionMenu/SuggestionMenuItem.d.ts +8 -0
- package/types/src/suggestionMenu/SuggestionMenuLabel.d.ts +5 -0
- package/types/src/suggestionMenu/SuggestionMenuLoader.d.ts +5 -0
- package/types/src/tableHandle/TableHandle.d.ts +14 -0
- package/types/src/toolbar/Toolbar.d.ts +25 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { ComponentProps } from "@blocknote/react";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
|
|
4
|
+
import { assertEmpty } from "@blocknote/core";
|
|
5
|
+
import { useShadCNComponentsContext } from "../ShadCNComponentsContext";
|
|
6
|
+
import { cn } from "../lib/utils";
|
|
7
|
+
|
|
8
|
+
export const Panel = forwardRef<
|
|
9
|
+
HTMLDivElement,
|
|
10
|
+
ComponentProps["ImagePanel"]["Root"]
|
|
11
|
+
>((props, ref) => {
|
|
12
|
+
const {
|
|
13
|
+
className,
|
|
14
|
+
tabs,
|
|
15
|
+
defaultOpenTab,
|
|
16
|
+
openTab,
|
|
17
|
+
setOpenTab,
|
|
18
|
+
loading, // TODO: implement loader
|
|
19
|
+
...rest
|
|
20
|
+
} = props;
|
|
21
|
+
|
|
22
|
+
assertEmpty(rest);
|
|
23
|
+
|
|
24
|
+
const ShadCNComponents = useShadCNComponentsContext()!;
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<ShadCNComponents.Tabs.Tabs
|
|
28
|
+
className={cn(className, "bg-popover p-2 rounded-lg")}
|
|
29
|
+
ref={ref}
|
|
30
|
+
value={openTab}
|
|
31
|
+
defaultValue={defaultOpenTab}
|
|
32
|
+
onValueChange={setOpenTab}>
|
|
33
|
+
{/*{loading && <LoadingOverlay visible={loading} />}*/}
|
|
34
|
+
|
|
35
|
+
<ShadCNComponents.Tabs.TabsList>
|
|
36
|
+
{tabs.map((tab) => (
|
|
37
|
+
<ShadCNComponents.Tabs.TabsTrigger value={tab.name} key={tab.name}>
|
|
38
|
+
{tab.name}
|
|
39
|
+
</ShadCNComponents.Tabs.TabsTrigger>
|
|
40
|
+
))}
|
|
41
|
+
</ShadCNComponents.Tabs.TabsList>
|
|
42
|
+
|
|
43
|
+
{tabs.map((tab) => (
|
|
44
|
+
<ShadCNComponents.Tabs.TabsContent value={tab.name} key={tab.name}>
|
|
45
|
+
<ShadCNComponents.Card.Card>
|
|
46
|
+
<ShadCNComponents.Card.CardContent className={"p-4"}>
|
|
47
|
+
{tab.tabPanel}
|
|
48
|
+
</ShadCNComponents.Card.CardContent>
|
|
49
|
+
</ShadCNComponents.Card.Card>
|
|
50
|
+
</ShadCNComponents.Tabs.TabsContent>
|
|
51
|
+
))}
|
|
52
|
+
</ShadCNComponents.Tabs.Tabs>
|
|
53
|
+
);
|
|
54
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ComponentProps } from "@blocknote/react";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
|
|
4
|
+
import { assertEmpty } from "@blocknote/core";
|
|
5
|
+
import { useShadCNComponentsContext } from "../ShadCNComponentsContext";
|
|
6
|
+
|
|
7
|
+
export const PanelButton = forwardRef<
|
|
8
|
+
HTMLButtonElement,
|
|
9
|
+
ComponentProps["ImagePanel"]["Button"]
|
|
10
|
+
>((props, ref) => {
|
|
11
|
+
const { className, children, onClick, label, ...rest } = props;
|
|
12
|
+
|
|
13
|
+
assertEmpty(rest);
|
|
14
|
+
|
|
15
|
+
const ShadCNComponents = useShadCNComponentsContext()!;
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<ShadCNComponents.Button.Button
|
|
19
|
+
type={"submit"}
|
|
20
|
+
className={className}
|
|
21
|
+
aria-label={label}
|
|
22
|
+
ref={ref}
|
|
23
|
+
onClick={onClick}>
|
|
24
|
+
{children}
|
|
25
|
+
</ShadCNComponents.Button.Button>
|
|
26
|
+
);
|
|
27
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ComponentProps } from "@blocknote/react";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
|
|
4
|
+
import { assertEmpty } from "@blocknote/core";
|
|
5
|
+
import { useShadCNComponentsContext } from "../ShadCNComponentsContext";
|
|
6
|
+
|
|
7
|
+
export const PanelFileInput = forwardRef<
|
|
8
|
+
HTMLInputElement,
|
|
9
|
+
ComponentProps["ImagePanel"]["FileInput"]
|
|
10
|
+
>((props, ref) => {
|
|
11
|
+
const { className, value, placeholder, onChange, ...rest } = props;
|
|
12
|
+
|
|
13
|
+
assertEmpty(rest);
|
|
14
|
+
|
|
15
|
+
const ShadCNComponents = useShadCNComponentsContext()!;
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<ShadCNComponents.Input.Input
|
|
19
|
+
type={"file"}
|
|
20
|
+
className={className}
|
|
21
|
+
ref={ref}
|
|
22
|
+
value={value ? value.name : undefined}
|
|
23
|
+
onChange={async (e) => onChange?.(e.target.files![0])}
|
|
24
|
+
placeholder={placeholder}
|
|
25
|
+
/>
|
|
26
|
+
);
|
|
27
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ComponentProps } from "@blocknote/react";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
|
|
4
|
+
import { assertEmpty } from "@blocknote/core";
|
|
5
|
+
import { cn } from "../lib/utils";
|
|
6
|
+
|
|
7
|
+
export const PanelTab = forwardRef<
|
|
8
|
+
HTMLDivElement,
|
|
9
|
+
ComponentProps["ImagePanel"]["TabPanel"]
|
|
10
|
+
>((props, ref) => {
|
|
11
|
+
const { className, children, ...rest } = props;
|
|
12
|
+
|
|
13
|
+
assertEmpty(rest);
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<div
|
|
17
|
+
className={cn(
|
|
18
|
+
className,
|
|
19
|
+
"flex flex-col gap-2 items-start justify-center"
|
|
20
|
+
)}
|
|
21
|
+
ref={ref}>
|
|
22
|
+
{children}
|
|
23
|
+
</div>
|
|
24
|
+
);
|
|
25
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ComponentProps } from "@blocknote/react";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
|
|
4
|
+
import { assertEmpty } from "@blocknote/core";
|
|
5
|
+
import { useShadCNComponentsContext } from "../ShadCNComponentsContext";
|
|
6
|
+
import { cn } from "../lib/utils";
|
|
7
|
+
|
|
8
|
+
export const PanelTextInput = forwardRef<
|
|
9
|
+
HTMLInputElement,
|
|
10
|
+
ComponentProps["ImagePanel"]["TextInput"]
|
|
11
|
+
>((props, ref) => {
|
|
12
|
+
const { className, value, placeholder, onKeyDown, onChange, ...rest } = props;
|
|
13
|
+
|
|
14
|
+
assertEmpty(rest);
|
|
15
|
+
|
|
16
|
+
const ShadCNComponents = useShadCNComponentsContext()!;
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<ShadCNComponents.Input.Input
|
|
20
|
+
data-test={"embed-input"}
|
|
21
|
+
className={cn(className, "w-80")}
|
|
22
|
+
ref={ref}
|
|
23
|
+
value={value}
|
|
24
|
+
placeholder={placeholder}
|
|
25
|
+
onKeyDown={onKeyDown}
|
|
26
|
+
onChange={onChange}
|
|
27
|
+
/>
|
|
28
|
+
);
|
|
29
|
+
});
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { ComponentProps } from "@blocknote/react";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
|
|
4
|
+
import { assertEmpty } from "@blocknote/core";
|
|
5
|
+
import { useShadCNComponentsContext } from "../ShadCNComponentsContext";
|
|
6
|
+
import { cn } from "../lib/utils";
|
|
7
|
+
|
|
8
|
+
export const Popover = (
|
|
9
|
+
props: ComponentProps["Generic"]["Popover"]["Root"]
|
|
10
|
+
) => {
|
|
11
|
+
const {
|
|
12
|
+
children,
|
|
13
|
+
opened,
|
|
14
|
+
position, // unused
|
|
15
|
+
...rest
|
|
16
|
+
} = props;
|
|
17
|
+
|
|
18
|
+
assertEmpty(rest);
|
|
19
|
+
|
|
20
|
+
const ShadCNComponents = useShadCNComponentsContext()!;
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<ShadCNComponents.Popover.Popover open={opened}>
|
|
24
|
+
{children}
|
|
25
|
+
</ShadCNComponents.Popover.Popover>
|
|
26
|
+
);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const PopoverTrigger = forwardRef(
|
|
30
|
+
(props: ComponentProps["Generic"]["Popover"]["Trigger"], ref: any) => {
|
|
31
|
+
const { children, ...rest } = props;
|
|
32
|
+
|
|
33
|
+
assertEmpty(rest);
|
|
34
|
+
|
|
35
|
+
const ShadCNComponents = useShadCNComponentsContext()!;
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<ShadCNComponents.Popover.PopoverTrigger ref={ref} asChild={true}>
|
|
39
|
+
{children}
|
|
40
|
+
</ShadCNComponents.Popover.PopoverTrigger>
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
export const PopoverContent = forwardRef<
|
|
46
|
+
HTMLDivElement,
|
|
47
|
+
ComponentProps["Generic"]["Popover"]["Content"]
|
|
48
|
+
>((props, ref) => {
|
|
49
|
+
const { className, variant, children, ...rest } = props;
|
|
50
|
+
|
|
51
|
+
assertEmpty(rest);
|
|
52
|
+
|
|
53
|
+
const ShadCNComponents = useShadCNComponentsContext()!;
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<ShadCNComponents.Popover.PopoverContent
|
|
57
|
+
sideOffset={8}
|
|
58
|
+
className={cn(
|
|
59
|
+
className,
|
|
60
|
+
"flex flex-col gap-2",
|
|
61
|
+
variant === "panel-popover"
|
|
62
|
+
? "p-0 border-none shadow-none max-w-none w-fit"
|
|
63
|
+
: ""
|
|
64
|
+
)}
|
|
65
|
+
ref={ref}>
|
|
66
|
+
{children}
|
|
67
|
+
</ShadCNComponents.Popover.PopoverContent>
|
|
68
|
+
);
|
|
69
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { assertEmpty } from "@blocknote/core";
|
|
2
|
+
import { ComponentProps } from "@blocknote/react";
|
|
3
|
+
import { forwardRef } from "react";
|
|
4
|
+
|
|
5
|
+
export const SideMenu = forwardRef<
|
|
6
|
+
HTMLDivElement,
|
|
7
|
+
ComponentProps["SideMenu"]["Root"]
|
|
8
|
+
>((props, ref) => {
|
|
9
|
+
const { className, children, ...rest } = props;
|
|
10
|
+
|
|
11
|
+
assertEmpty(rest);
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<div className={className} ref={ref}>
|
|
15
|
+
{children}
|
|
16
|
+
</div>
|
|
17
|
+
);
|
|
18
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ComponentProps } from "@blocknote/react";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
|
|
4
|
+
import { assertEmpty } from "@blocknote/core";
|
|
5
|
+
import { useShadCNComponentsContext } from "../ShadCNComponentsContext";
|
|
6
|
+
import { cn } from "../lib/utils";
|
|
7
|
+
|
|
8
|
+
export const SideMenuButton = forwardRef<
|
|
9
|
+
HTMLButtonElement,
|
|
10
|
+
ComponentProps["SideMenu"]["Button"]
|
|
11
|
+
>((props, ref) => {
|
|
12
|
+
const {
|
|
13
|
+
className,
|
|
14
|
+
children,
|
|
15
|
+
icon,
|
|
16
|
+
onClick,
|
|
17
|
+
onDragEnd,
|
|
18
|
+
onDragStart,
|
|
19
|
+
draggable,
|
|
20
|
+
label,
|
|
21
|
+
...rest
|
|
22
|
+
} = props;
|
|
23
|
+
|
|
24
|
+
// false, because rest props can be added by ariakit when button is used as a trigger
|
|
25
|
+
// assertEmpty in this case is only used at typescript level, not runtime level
|
|
26
|
+
assertEmpty(rest, false);
|
|
27
|
+
|
|
28
|
+
const ShadCNComponents = useShadCNComponentsContext()!;
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<ShadCNComponents.Button.Button
|
|
32
|
+
variant={"ghost"}
|
|
33
|
+
className={cn(className, "text-gray-400")}
|
|
34
|
+
ref={ref}
|
|
35
|
+
aria-label={label}
|
|
36
|
+
onClick={onClick}
|
|
37
|
+
onDragStart={onDragStart}
|
|
38
|
+
onDragEnd={onDragEnd}
|
|
39
|
+
draggable={draggable}
|
|
40
|
+
{...rest}>
|
|
41
|
+
{icon}
|
|
42
|
+
{children}
|
|
43
|
+
</ShadCNComponents.Button.Button>
|
|
44
|
+
);
|
|
45
|
+
});
|
package/src/style.css
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
@import url("@blocknote/react/style.css");
|
|
2
|
+
|
|
3
|
+
@tailwind base;
|
|
4
|
+
@tailwind components;
|
|
5
|
+
@tailwind utilities;
|
|
6
|
+
|
|
7
|
+
.bn-container {
|
|
8
|
+
--background: 0 0% 100%;
|
|
9
|
+
--foreground: 222.2 84% 4.9%;
|
|
10
|
+
|
|
11
|
+
--card: 0 0% 100%;
|
|
12
|
+
--card-foreground: 222.2 84% 4.9%;
|
|
13
|
+
|
|
14
|
+
--popover: 0 0% 100%;
|
|
15
|
+
--popover-foreground: 222.2 84% 4.9%;
|
|
16
|
+
|
|
17
|
+
--primary: 222.2 47.4% 11.2%;
|
|
18
|
+
--primary-foreground: 210 40% 98%;
|
|
19
|
+
|
|
20
|
+
--secondary: 210 40% 96.1%;
|
|
21
|
+
--secondary-foreground: 222.2 47.4% 11.2%;
|
|
22
|
+
|
|
23
|
+
--muted: 210 40% 96.1%;
|
|
24
|
+
--muted-foreground: 215.4 16.3% 46.9%;
|
|
25
|
+
|
|
26
|
+
--accent: 210 40% 96.1%;
|
|
27
|
+
--accent-foreground: 222.2 47.4% 11.2%;
|
|
28
|
+
|
|
29
|
+
--destructive: 0 84.2% 60.2%;
|
|
30
|
+
--destructive-foreground: 210 40% 98%;
|
|
31
|
+
|
|
32
|
+
--border: 214.3 31.8% 91.4%;
|
|
33
|
+
--input: 214.3 31.8% 91.4%;
|
|
34
|
+
--ring: 222.2 84% 4.9%;
|
|
35
|
+
|
|
36
|
+
--radius: 0.5rem;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.bn-container.dark {
|
|
40
|
+
--background: 222.2 84% 4.9%;
|
|
41
|
+
--foreground: 210 40% 98%;
|
|
42
|
+
|
|
43
|
+
--card: 222.2 84% 4.9%;
|
|
44
|
+
--card-foreground: 210 40% 98%;
|
|
45
|
+
|
|
46
|
+
--popover: 222.2 84% 4.9%;
|
|
47
|
+
--popover-foreground: 210 40% 98%;
|
|
48
|
+
|
|
49
|
+
--primary: 210 40% 98%;
|
|
50
|
+
--primary-foreground: 222.2 47.4% 11.2%;
|
|
51
|
+
|
|
52
|
+
--secondary: 217.2 32.6% 17.5%;
|
|
53
|
+
--secondary-foreground: 210 40% 98%;
|
|
54
|
+
|
|
55
|
+
--muted: 217.2 32.6% 17.5%;
|
|
56
|
+
--muted-foreground: 215 20.2% 65.1%;
|
|
57
|
+
|
|
58
|
+
--accent: 217.2 32.6% 17.5%;
|
|
59
|
+
--accent-foreground: 210 40% 98%;
|
|
60
|
+
|
|
61
|
+
--destructive: 0 62.8% 30.6%;
|
|
62
|
+
--destructive-foreground: 210 40% 98%;
|
|
63
|
+
|
|
64
|
+
--border: 217.2 32.6% 17.5%;
|
|
65
|
+
--input: 217.2 32.6% 17.5%;
|
|
66
|
+
--ring: 212.7 26.8% 83.9%;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.bn-container * {
|
|
70
|
+
@apply border-border;
|
|
71
|
+
}
|
|
72
|
+
.bn-editor {
|
|
73
|
+
@apply bg-background text-foreground;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
:focus-visible {
|
|
77
|
+
outline: none;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
[data-radix-popper-content-wrapper] {
|
|
81
|
+
z-index: 99999 !important;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.bn-side-menu {
|
|
85
|
+
display: flex;
|
|
86
|
+
justify-content: center;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.bn-side-menu .bn-button {
|
|
90
|
+
padding: 0;
|
|
91
|
+
height: 24px;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.bn-select {
|
|
95
|
+
max-height: var(--radix-select-content-available-height);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.bn-menu-dropdown {
|
|
99
|
+
max-height: var(--radix-dropdown-menu-content-available-height);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.bn-color-picker-dropdown {
|
|
103
|
+
overflow: auto;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.bn-suggestion-menu-item[aria-selected="true"],
|
|
107
|
+
.bn-suggestion-menu-item:hover {
|
|
108
|
+
background-color: hsl(var(--accent));
|
|
109
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ComponentProps } from "@blocknote/react";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
|
|
4
|
+
import { assertEmpty } from "@blocknote/core";
|
|
5
|
+
import { cn } from "../lib/utils";
|
|
6
|
+
|
|
7
|
+
export const SuggestionMenu = forwardRef<
|
|
8
|
+
HTMLDivElement,
|
|
9
|
+
ComponentProps["SuggestionMenu"]["Root"]
|
|
10
|
+
>((props, ref) => {
|
|
11
|
+
const { className, children, id, ...rest } = props;
|
|
12
|
+
|
|
13
|
+
assertEmpty(rest);
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<div
|
|
17
|
+
id={id}
|
|
18
|
+
role="listbox"
|
|
19
|
+
// Styles from ShadCN DropdownMenuContent component
|
|
20
|
+
className={cn(
|
|
21
|
+
"z-50 min-w-[8rem] overflow-auto rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
|
|
22
|
+
className
|
|
23
|
+
)}
|
|
24
|
+
ref={ref}>
|
|
25
|
+
{children}
|
|
26
|
+
</div>
|
|
27
|
+
);
|
|
28
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ComponentProps } from "@blocknote/react";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
|
|
4
|
+
import { assertEmpty } from "@blocknote/core";
|
|
5
|
+
import { cn } from "../lib/utils";
|
|
6
|
+
|
|
7
|
+
export const SuggestionMenuEmptyItem = forwardRef<
|
|
8
|
+
HTMLDivElement,
|
|
9
|
+
ComponentProps["SuggestionMenu"]["EmptyItem"]
|
|
10
|
+
>((props, ref) => {
|
|
11
|
+
const { className, children, ...rest } = props;
|
|
12
|
+
|
|
13
|
+
assertEmpty(rest);
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<div
|
|
17
|
+
// Styles from ShadCN DropdownMenuItem component
|
|
18
|
+
className={cn(
|
|
19
|
+
"relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
20
|
+
className
|
|
21
|
+
)}
|
|
22
|
+
ref={ref}>
|
|
23
|
+
<div>{children}</div>
|
|
24
|
+
</div>
|
|
25
|
+
);
|
|
26
|
+
});
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { assertEmpty } from "@blocknote/core";
|
|
2
|
+
import { ComponentProps } from "@blocknote/react";
|
|
3
|
+
import { forwardRef } from "react";
|
|
4
|
+
import { useShadCNComponentsContext } from "../ShadCNComponentsContext";
|
|
5
|
+
import { cn } from "../lib/utils";
|
|
6
|
+
|
|
7
|
+
export const SuggestionMenuItem = forwardRef<
|
|
8
|
+
HTMLDivElement,
|
|
9
|
+
ComponentProps["SuggestionMenu"]["Item"]
|
|
10
|
+
>((props, ref) => {
|
|
11
|
+
const ShadCNComponents = useShadCNComponentsContext()!;
|
|
12
|
+
|
|
13
|
+
const { className, item, isSelected, onClick, id, ...rest } = props;
|
|
14
|
+
|
|
15
|
+
assertEmpty(rest);
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<div
|
|
19
|
+
// Styles from ShadCN DropdownMenuItem component
|
|
20
|
+
className={cn(
|
|
21
|
+
"relative flex cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
22
|
+
className
|
|
23
|
+
)}
|
|
24
|
+
ref={ref}
|
|
25
|
+
id={id}
|
|
26
|
+
onClick={onClick}
|
|
27
|
+
role="option"
|
|
28
|
+
aria-selected={isSelected || undefined}>
|
|
29
|
+
{item.icon && (
|
|
30
|
+
<div className="p-3" data-position="left">
|
|
31
|
+
{item.icon}
|
|
32
|
+
</div>
|
|
33
|
+
)}
|
|
34
|
+
<div className="flex-1">
|
|
35
|
+
<div className="text-base">{item.title}</div>
|
|
36
|
+
<div className="text-xs">{item.subtext}</div>
|
|
37
|
+
</div>
|
|
38
|
+
{item.badge && (
|
|
39
|
+
<div data-position="right" className="text-xs">
|
|
40
|
+
<ShadCNComponents.Badge.Badge variant={"secondary"}>
|
|
41
|
+
{item.badge}
|
|
42
|
+
</ShadCNComponents.Badge.Badge>
|
|
43
|
+
</div>
|
|
44
|
+
)}
|
|
45
|
+
</div>
|
|
46
|
+
);
|
|
47
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { assertEmpty } from "@blocknote/core";
|
|
2
|
+
import { ComponentProps } from "@blocknote/react";
|
|
3
|
+
import { forwardRef } from "react";
|
|
4
|
+
import { cn } from "../lib/utils";
|
|
5
|
+
|
|
6
|
+
export const SuggestionMenuLabel = forwardRef<
|
|
7
|
+
HTMLDivElement,
|
|
8
|
+
ComponentProps["SuggestionMenu"]["Label"]
|
|
9
|
+
>((props, ref) => {
|
|
10
|
+
const { className, children, ...rest } = props;
|
|
11
|
+
|
|
12
|
+
assertEmpty(rest);
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<div
|
|
16
|
+
// Styles from ShadCN DropdownMenuLabel component
|
|
17
|
+
className={cn("px-2 py-1.5 text-sm font-semibold", className)}
|
|
18
|
+
ref={ref}>
|
|
19
|
+
{children}
|
|
20
|
+
</div>
|
|
21
|
+
);
|
|
22
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { assertEmpty } from "@blocknote/core";
|
|
2
|
+
import { ComponentProps } from "@blocknote/react";
|
|
3
|
+
import { forwardRef } from "react";
|
|
4
|
+
|
|
5
|
+
export const SuggestionMenuLoader = forwardRef<
|
|
6
|
+
HTMLDivElement,
|
|
7
|
+
ComponentProps["SuggestionMenu"]["Loader"]
|
|
8
|
+
>((props, ref) => {
|
|
9
|
+
const { className, children, ...rest } = props;
|
|
10
|
+
|
|
11
|
+
assertEmpty(rest);
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<div className={className} ref={ref}>
|
|
15
|
+
{children}
|
|
16
|
+
</div>
|
|
17
|
+
);
|
|
18
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ComponentProps } from "@blocknote/react";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
|
|
4
|
+
import { assertEmpty } from "@blocknote/core";
|
|
5
|
+
import { useShadCNComponentsContext } from "../ShadCNComponentsContext";
|
|
6
|
+
import { cn } from "../lib/utils";
|
|
7
|
+
|
|
8
|
+
export const TableHandle = forwardRef<
|
|
9
|
+
HTMLButtonElement,
|
|
10
|
+
ComponentProps["TableHandle"]["Root"]
|
|
11
|
+
>((props, ref) => {
|
|
12
|
+
const {
|
|
13
|
+
className,
|
|
14
|
+
children,
|
|
15
|
+
draggable,
|
|
16
|
+
onDragStart,
|
|
17
|
+
onDragEnd,
|
|
18
|
+
style,
|
|
19
|
+
label,
|
|
20
|
+
...rest
|
|
21
|
+
} = props;
|
|
22
|
+
|
|
23
|
+
// false, because rest props can be added by shadcn when button is used as a trigger
|
|
24
|
+
// assertEmpty in this case is only used at typescript level, not runtime level
|
|
25
|
+
assertEmpty(rest, false);
|
|
26
|
+
|
|
27
|
+
const ShadCNComponents = useShadCNComponentsContext()!;
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<ShadCNComponents.Button.Button
|
|
31
|
+
variant={"ghost"}
|
|
32
|
+
className={cn(className, "p-0 h-fit w-fit text-gray-400")}
|
|
33
|
+
ref={ref}
|
|
34
|
+
aria-label={label}
|
|
35
|
+
draggable={draggable}
|
|
36
|
+
onDragStart={onDragStart}
|
|
37
|
+
onDragEnd={onDragEnd}
|
|
38
|
+
style={style}
|
|
39
|
+
{...rest}>
|
|
40
|
+
{children}
|
|
41
|
+
</ShadCNComponents.Button.Button>
|
|
42
|
+
);
|
|
43
|
+
});
|