/** * WordPress dependencies */ import { __ } from '@wordpress/i18n'; import { InspectorControls, useBlockProps } from '@wordpress/block-editor'; import { // Use `ToggleControl` to match the controls on the front end. // eslint-disable-next-line @wordpress/use-recommended-components ToggleControl, __experimentalToolsPanel as ToolsPanel, __experimentalToolsPanelItem as ToolsPanelItem, } from '@wordpress/components'; import { useViewportMatch } from '@wordpress/compose'; import { useState } from '@wordpress/element'; import type { BlockEditProps } from '@wordpress/blocks'; /** * Internal dependencies */ import Piano from './components/piano'; import type { BlockAttributes } from './constants'; export default function Edit( { attributes, setAttributes }: BlockEditProps< BlockAttributes > ) { const [ blockWrapper, setBlockWrapper ] = useState< HTMLDivElement | null >( null ); const blockProps = useBlockProps( { ref: setBlockWrapper } ); const dropdownMenuProps = ! useViewportMatch( 'medium', '<' ) ? { popoverProps: { placement: 'left-start' as const, offset: 259, }, } : undefined; return ( <> { setAttributes( { showOnFront: false } ); } } dropdownMenuProps={ dropdownMenuProps } > attributes.showOnFront } onDeselect={ () => setAttributes( { showOnFront: false } ) } > setAttributes( { showOnFront: value } ) } />
); }