-
Notifications
You must be signed in to change notification settings - Fork 68
Expand file tree
/
Copy pathindex.js
More file actions
42 lines (37 loc) · 1.02 KB
/
index.js
File metadata and controls
42 lines (37 loc) · 1.02 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
/**
* External dependencies
*/
import { i18n } from 'stackable'
/**
* WordPress dependencies
*/
import { TextareaControl, ExternalLink } from '@wordpress/components'
import { __ } from '@wordpress/i18n'
import { useInternalValue } from '~stackable/hooks'
const ImageAltControl = props => {
// Keep track of the internal value because we will move the cursor to the
// end of the text when the user types.
const [ internalValue, setInternalValue ] = useInternalValue( props.value )
return (
<TextareaControl
{ ...props }
value={ internalValue }
onChange={ value => {
setInternalValue( value )
props.onChange( value )
} }
help={
<>
<ExternalLink href="https://www.w3.org/WAI/tutorials/images/decision-tree">
{ __( 'Describe the purpose of the image', i18n ) }
</ExternalLink>
{ __( 'Leave empty if the image is purely decorative.', i18n ) }
</>
}
/>
)
}
ImageAltControl.defaultProps = {
label: __( 'Alt Text (Alternative Text)', i18n ),
}
export default ImageAltControl