import { __ } from '@wordpress/i18n'; import { useBlockProps, InnerBlocks, InspectorControls } from '@wordpress/block-editor'; import { ToggleControl } from '@wordpress/components'; import './editor.scss'; export default function Edit({ attributes, setAttributes }) { const { hasSidecontent } = attributes; // Block props const blockProps = useBlockProps(); // Custom template logic based on hasSidecontent const template = [ hasSidecontent && ['lcp/sidecontent'], // Only include lcp/sidecontent if the toggle is true ['lcp/main-area'], // Always include lcp/main-area ].filter(Boolean); // Filter out falsey values (e.g., undefined when hasSidecontent is false) // Render appender logic to handle block insertion const renderAppender = () => { return ; }; return (
{/* Inspector Controls: Add a toggle for the `hasSidecontent` attribute */} setAttributes({ hasSidecontent: value })} />

{__('Lcp Viewport – hello from the editor!', 'lcp-viewport')}

{/* Render the InnerBlocks with conditional template */}
); }