-
Notifications
You must be signed in to change notification settings - Fork 808
/
Copy pathcolumn-toolbar-popover.tsx
94 lines (84 loc) · 2.67 KB
/
column-toolbar-popover.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import React from 'react';
import { useRemoveNodeButton } from '@udecode/plate-common';
import { useColumnState, useDebouncePopoverOpen } from '@udecode/plate-layout';
import { useReadOnly } from 'slate-react';
import { Icons, iconVariants } from '@/components/icons';
import { Button } from './button';
import { Popover, PopoverAnchor, PopoverContent } from './popover';
import { Separator } from './separator';
export interface LayoutToolbarPopoverProps {}
export function LayoutToolbarPopover({
children,
}: React.PropsWithChildren<LayoutToolbarPopoverProps>) {
const readOnly = useReadOnly();
const {
element,
setDoubleColumn,
setDoubleSideDoubleColumn,
setLeftSideDoubleColumn,
setRightSideDoubleColumn,
setThreeColumn,
} = useColumnState();
const { props: buttonProps } = useRemoveNodeButton({ element });
const isOpen = useDebouncePopoverOpen();
if (readOnly) return <>{children}</>;
return (
<Popover open={isOpen} modal={false}>
<PopoverAnchor>{children}</PopoverAnchor>
<PopoverContent
align="center"
side="top"
sideOffset={10}
className="w-auto p-1"
onOpenAutoFocus={(e) => e.preventDefault()}
>
<div className="box-content flex h-9 items-center gap-1">
<Button
variant="ghost"
size="sms"
// tooltip="doubleColumn"
onClick={setDoubleColumn}
>
<Icons.doubleColumn />
</Button>
<Button
variant="ghost"
size="sms"
// tooltip="threeColumn"
onClick={setThreeColumn}
>
<Icons.threeColumn />
</Button>
<Button
variant="ghost"
size="sms"
// tooltip="rightSideDoubleColumn"
onClick={setRightSideDoubleColumn}
>
<Icons.rightSideDoubleColumn />
</Button>
<Button
variant="ghost"
size="sms"
// tooltip="plugins.layout.leftSideDoubleColumn"
onClick={setLeftSideDoubleColumn}
>
<Icons.leftSideDoubleColumn />
</Button>
<Button
variant="ghost"
size="sms"
// tooltip="plugins.layout.doubleSideDoubleColumn"
onClick={setDoubleSideDoubleColumn}
>
<Icons.doubleSideDoubleColumn />
</Button>
<Separator orientation="vertical" className="my-1" />
<Button variant="ghost" size="sms" {...buttonProps}>
<Icons.delete className={iconVariants({ variant: 'toolbar' })} />
</Button>
</div>
</PopoverContent>
</Popover>
);
}