2022-05-19 16:16:46 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { useBlockProps } from '@wordpress/block-editor';
|
2023-03-02 14:26:00 +00:00
|
|
|
import type { FunctionComponent } from 'react';
|
2022-05-19 16:16:46 +00:00
|
|
|
|
|
|
|
export function Edit< T >( Block: FunctionComponent< T > ) {
|
|
|
|
return function WithBlock( props: T ): JSX.Element {
|
|
|
|
const blockProps = useBlockProps();
|
|
|
|
|
|
|
|
// The useBlockProps function returns the style with the `color`.
|
|
|
|
// We need to remove it to avoid the block to be styled with the color.
|
|
|
|
const { color, ...styles } = blockProps.style;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div { ...blockProps } style={ styles }>
|
|
|
|
<Block { ...props } />
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
}
|