-
Notifications
You must be signed in to change notification settings - Fork 4.1k
/
edit.js
62 lines (59 loc) · 1.15 KB
/
edit.js
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
50
51
52
53
54
55
56
57
58
59
60
61
62
/**
* 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
/>
</>
);
}