@wordpress/block-library
Version:
Block library for the WordPress editor.
24 lines (22 loc) • 590 B
JavaScript
/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import { RichText, useBlockProps } from '@wordpress/block-editor';
export default function CodeEdit( { attributes, setAttributes, onRemove } ) {
const blockProps = useBlockProps();
return (
<pre { ...blockProps }>
<RichText
tagName="code"
value={ attributes.content }
onChange={ ( content ) => setAttributes( { content } ) }
onRemove={ onRemove }
placeholder={ __( 'Write code…' ) }
aria-label={ __( 'Code' ) }
preserveWhiteSpace
__unstablePastePlainText
/>
</pre>
);
}