UNPKG

@wordpress/block-library

Version:
63 lines (59 loc) 1.17 kB
/** * External dependencies */ import classnames from 'classnames'; /** * WordPress dependencies */ import { __ } from '@wordpress/i18n'; import { RichText, BlockControls, AlignmentToolbar, useBlockProps, } from '@wordpress/block-editor'; export default function VerseEdit( { attributes, setAttributes, mergeBlocks, onRemove, style, } ) { const { textAlign, content } = attributes; const blockProps = useBlockProps( { className: classnames( { [ `has-text-align-${ textAlign }` ]: textAlign, } ), style, } ); return ( <> <BlockControls> <AlignmentToolbar value={ textAlign } onChange={ ( nextAlign ) => { setAttributes( { textAlign: nextAlign } ); } } /> </BlockControls> <RichText tagName="pre" identifier="content" preserveWhiteSpace value={ content } onChange={ ( nextContent ) => { setAttributes( { content: nextContent, } ); } } aria-label={ __( 'Verse text' ) } placeholder={ __( 'Write verse…' ) } onRemove={ onRemove } onMerge={ mergeBlocks } textAlign={ textAlign } { ...blockProps } __unstablePastePlainText /> </> ); }