@wordpress/block-editor
Version:
8 lines (7 loc) • 2.64 kB
Source Map (JSON)
{
"version": 3,
"sources": ["../../../src/components/plain-text/index.js"],
"sourcesContent": ["/**\n * External dependencies\n */\nimport TextareaAutosize from 'react-autosize-textarea';\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport EditableText from '../editable-text';\n\n/**\n * Render an auto-growing textarea allow users to fill any textual content.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/plain-text/README.md\n *\n * @example\n * ```jsx\n * import { registerBlockType } from '@wordpress/blocks';\n * import { PlainText } from '@wordpress/block-editor';\n *\n * registerBlockType( 'my-plugin/example-block', {\n * // ...\n *\n * attributes: {\n * content: {\n * type: 'string',\n * },\n * },\n *\n * edit( { className, attributes, setAttributes } ) {\n * return (\n * <PlainText\n * className={ className }\n * value={ attributes.content }\n * onChange={ ( content ) => setAttributes( { content } ) }\n * />\n * );\n * },\n * } );\n * ````\n *\n * @param {Object} props Component props.\n * @param {string} props.value String value of the textarea.\n * @param {Function} props.onChange Function called when the text value changes.\n * @param {Object} [props.ref] The component forwards the `ref` property to the `TextareaAutosize` component.\n * @return {Element} Plain text component\n */\nconst PlainText = forwardRef( ( { __experimentalVersion, ...props }, ref ) => {\n\tif ( __experimentalVersion === 2 ) {\n\t\treturn <EditableText ref={ ref } { ...props } />;\n\t}\n\n\tconst { className, onChange, ...remainingProps } = props;\n\n\treturn (\n\t\t<TextareaAutosize\n\t\t\tref={ ref }\n\t\t\tclassName={ clsx( 'block-editor-plain-text', className ) }\n\t\t\tonChange={ ( event ) => onChange( event.target.value ) }\n\t\t\t{ ...remainingProps }\n\t\t/>\n\t);\n} );\n\nexport default PlainText;\n"],
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qCAA6B;AAC7B,kBAAiB;AAKjB,qBAA2B;AAK3B,2BAAyB;AAyChB;AAFT,IAAM,gBAAY,2BAAY,CAAE,EAAE,uBAAuB,GAAG,MAAM,GAAG,QAAS;AAC7E,MAAK,0BAA0B,GAAI;AAClC,WAAO,4CAAC,qBAAAA,SAAA,EAAa,KAAc,GAAG,OAAQ;AAAA,EAC/C;AAEA,QAAM,EAAE,WAAW,UAAU,GAAG,eAAe,IAAI;AAEnD,SACC;AAAA,IAAC,+BAAAC;AAAA,IAAA;AAAA,MACA;AAAA,MACA,eAAY,YAAAC,SAAM,2BAA2B,SAAU;AAAA,MACvD,UAAW,CAAE,UAAW,SAAU,MAAM,OAAO,KAAM;AAAA,MACnD,GAAG;AAAA;AAAA,EACN;AAEF,CAAE;AAEF,IAAO,qBAAQ;",
"names": ["EditableText", "TextareaAutosize", "clsx"]
}