-
Notifications
You must be signed in to change notification settings - Fork 4k
/
edit.js
32 lines (30 loc) · 943 Bytes
/
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
/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import { PlainText, useBlockProps } from '@wordpress/block-editor';
import { useInstanceId } from '@wordpress/compose';
import { Icon, shortcode } from '@wordpress/icons';
export default function ShortcodeEdit( { attributes, setAttributes } ) {
const instanceId = useInstanceId( ShortcodeEdit );
const inputId = `blocks-shortcode-input-${ instanceId }`;
return (
<div { ...useBlockProps( { className: 'components-placeholder' } ) }>
<label
htmlFor={ inputId }
className="components-placeholder__label"
>
<Icon icon={ shortcode } />
{ __( 'Shortcode' ) }
</label>
<PlainText
className="blocks-shortcode__textarea"
id={ inputId }
value={ attributes.text }
aria-label={ __( 'Shortcode text' ) }
placeholder={ __( 'Write shortcode here…' ) }
onChange={ ( text ) => setAttributes( { text } ) }
/>
</div>
);
}