import { __ } from "@wordpress/i18n"; import "./editor.scss"; import { useBlockProps, RichText } from "@wordpress/block-editor"; import { InnerBlocks } from "@wordpress/block-editor"; import { PanelBody, ToggleControl, Button } from "@wordpress/components"; import { InspectorControls } from "@wordpress/block-editor"; import { trash } from "@wordpress/icons"; import { MediaReplaceFlow } from "@wordpress/block-editor"; export default function Edit({ attributes, setAttributes, ...props }) { let { hasIllustration, illustrationId, illustrationUrl, illustrationAlt } = attributes; function onHasIllustrationChange() { setAttributes({ hasIllustration: !hasIllustration }); if (!hasIllustration) { removeIllustrationAttributes(); } } function setIllustrationAttributes(media) { setAttributes({ illustrationUrl: media.url, illustrationId: media.id, illustrationAlt: media?.alt, }); } function removeIllustrationAttributes() { setAttributes({ illustrationUrl: null, illustrationId: null, illustrationAlt: null, }); } return ( <> {illustrationUrl && ( {illustrationAlt} )} {hasIllustration && (
{illustrationUrl && ( <>
)}
{hasIllustration && ( {illustrationAlt} )}
); }