-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Expand file tree
/
Copy pathedit.native.js
More file actions
61 lines (60 loc) · 1.48 KB
/
edit.native.js
File metadata and controls
61 lines (60 loc) · 1.48 KB
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
/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import { Fragment } from '@wordpress/element';
import { AlignmentToolbar, BlockControls, RichText } from '@wordpress/block-editor';
export default function QuoteEdit( { attributes, setAttributes, isSelected, mergeBlocks, onReplace } ) {
const { align, value, citation } = attributes;
return (
<Fragment>
<BlockControls>
<AlignmentToolbar
value={ align }
onChange={ ( nextAlign ) => {
setAttributes( { align: nextAlign } );
} }
/>
</BlockControls>
<RichText
identifier="value"
tagName="blockquote"
multiline
value={ value }
onChange={
( nextValue ) => setAttributes( {
value: nextValue,
} )
}
onMerge={ mergeBlocks }
onRemove={ ( forward ) => {
const hasEmptyCitation = ! citation || citation.length === 0;
if ( ! forward && hasEmptyCitation ) {
onReplace( [] );
}
} }
placeholder={
// translators: placeholder text used for the quote
__( 'Write quote…' )
}
/>
{ ( ! RichText.isEmpty( citation ) || isSelected ) && (
<RichText
identifier="citation"
tagName="cite"
value={ citation }
onChange={
( nextCitation ) => setAttributes( {
citation: nextCitation,
} )
}
placeholder={
// translators: placeholder text used for the citation
__( 'Write citation…' )
}
className="wp-block-quote__citation"
/>
) }
</Fragment>
);
}