@wordpress/block-library
Version:
Block library for the WordPress editor.
50 lines (44 loc) • 891 B
JavaScript
/**
* External dependencies
*/
import classnames from 'classnames';
/**
* WordPress dependencies
*/
import {
AlignmentControl,
BlockControls,
useBlockProps,
} from '@wordpress/block-editor';
/**
* Internal dependencies
*/
import CommentsForm from './form';
export default function PostCommentsFormEdit( {
attributes,
context,
setAttributes,
} ) {
const { textAlign } = attributes;
const { postId, postType } = context;
const blockProps = useBlockProps( {
className: classnames( {
[ `has-text-align-${ textAlign }` ]: textAlign,
} ),
} );
return (
<>
<BlockControls group="block">
<AlignmentControl
value={ textAlign }
onChange={ ( nextAlign ) => {
setAttributes( { textAlign: nextAlign } );
} }
/>
</BlockControls>
<div { ...blockProps }>
<CommentsForm postId={ postId } postType={ postType } />
</div>
</>
);
}