-
Notifications
You must be signed in to change notification settings - Fork 43
/
index.tsx
49 lines (47 loc) · 1.03 KB
/
index.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
import { Inserter } from '@wordpress/block-editor';
import { Button, IconType } from '@wordpress/components';
import { FC } from 'react';
interface CustomBlockAppenderProps {
rootClientId: string;
className?: string;
buttonText?: string;
icon?: IconType;
[key: string]: any; // For additional props spread onto the Button component
}
/*
* CustomBlockAppender.
*
* Provide a Button component to trigger the inserter.
* Any undocumented props are spread onto the Button component.
*/
export const CustomBlockAppender: FC<CustomBlockAppenderProps> = ({
rootClientId,
buttonText = '',
icon = 'plus',
className = 'custom-block-appender',
...buttonProps
}) => {
return (
<Inserter
isAppender
rootClientId={rootClientId}
renderToggle={({
onToggle,
disabled,
}: {
onToggle: () => void;
disabled?: boolean;
}) => (
<Button
className={`tenup-${className}`}
onClick={onToggle}
disabled={disabled}
icon={icon}
{...buttonProps}
>
{buttonText}
</Button>
)}
/>
);
};