-
Notifications
You must be signed in to change notification settings - Fork 4.3k
/
index.js
37 lines (31 loc) · 886 Bytes
/
index.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
/**
* External dependencies
*/
import TextareaAutosize from 'react-autosize-textarea';
import classnames from 'classnames';
/**
* WordPress dependencies
*/
import { forwardRef } from '@wordpress/element';
/**
* Internal dependencies
*/
import EditableText from '../editable-text';
/**
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/plain-text/README.md
*/
const PlainText = forwardRef( ( { __experimentalVersion, ...props }, ref ) => {
if ( __experimentalVersion === 2 ) {
return <EditableText ref={ ref } { ...props } />;
}
const { className, onChange, ...remainingProps } = props;
return (
<TextareaAutosize
ref={ ref }
className={ classnames( 'block-editor-plain-text', className ) }
onChange={ ( event ) => onChange( event.target.value ) }
{ ...remainingProps }
/>
);
} );
export default PlainText;