@wordpress/block-library
Version:
Block library for the WordPress editor.
45 lines (38 loc) • 926 B
JavaScript
/**
* External dependencies
*/
import clsx from 'clsx';
/**
* WordPress dependencies
*/
import { useBlockProps, useInnerBlocksProps } from '@wordpress/block-editor';
const DEFAULT_BLOCK = {
name: 'core/button',
attributesToCopy: [
'backgroundColor',
'border',
'className',
'fontFamily',
'fontSize',
'gradient',
'style',
'textColor',
'width',
],
};
function ButtonsEdit( { attributes, className } ) {
const { fontSize, layout, style } = attributes;
const blockProps = useBlockProps( {
className: clsx( className, {
'has-custom-font-size': fontSize || style?.typography?.fontSize,
} ),
} );
const innerBlocksProps = useInnerBlocksProps( blockProps, {
defaultBlock: DEFAULT_BLOCK,
template: [ [ 'core/button' ] ],
templateInsertUpdatesSelection: true,
orientation: layout?.orientation ?? 'horizontal',
} );
return <div { ...innerBlocksProps } />;
}
export default ButtonsEdit;