import { useBlockProps, RichText, BlockControls, InspectorControls, MediaReplaceFlow, MediaUpload, MediaUploadCheck, } from '@wordpress/block-editor'; import { PanelBody, Button, PanelRow } from '@wordpress/components'; import { URLSelectionUI, UnitControl } from '@l-clutch/core/block-editor'; const ALLOWED_MEDIA_TYPES = ['image']; export default function edit({ attributes, setAttributes }) { const onChangeText = (newText) => { newText = newText.replace(/(\r?\n)|()/g, ' '); setAttributes({ ...attributes, text: newText }); }; return (
{attributes.imageUrl ? ( <> setAttributes({ ...attributes, imageId: image.id, imageUrl: image.url, imageAlt: image.alt }) } onSelectURL={(image) => { setAttributes({ ...attributes, imageUrl: image }); }} onError={() => {}} /> ) : ( <> setAttributes({ ...attributes, imageId: image.id, imageUrl: image.url, imageAlt: image.alt }) } allowedTypes={ALLOWED_MEDIA_TYPES} value={attributes.imageId} render={({ open }) => } /> setAttributes({ ...attributes, imageUrl: src })} /> )} {attributes.imageUrl && ( setAttributes({ ...attributes, imageWidth: value })} value={attributes.imageWidth} /> )}
); }