import { InspectorControls, RichText, useBlockProps, } from '@wordpress/block-editor'; import { ToggleControl, __experimentalToolsPanel as ToolsPanel, __experimentalToolsPanelItem as ToolsPanelItem, } from '@wordpress/components'; import { createBlock, getDefaultBlockName } from '@wordpress/blocks'; import type { BlockEditProps } from '@wordpress/blocks'; import { __ } from '@wordpress/i18n'; import { useToolsPanelDropdownMenuProps } from '../utils/hooks'; import type { ReadMoreAttributes } from './types'; export default function ReadMore( { attributes: { content, linkTarget }, setAttributes, insertBlocksAfter, }: BlockEditProps< ReadMoreAttributes > ) { const blockProps = useBlockProps(); const dropdownMenuProps = useToolsPanelDropdownMenuProps(); return ( <> setAttributes( { linkTarget: '_self' } ) } dropdownMenuProps={ dropdownMenuProps } > linkTarget !== '_self' } onDeselect={ () => setAttributes( { linkTarget: '_self' } ) } > setAttributes( { linkTarget: value ? '_blank' : '_self', } ) } checked={ linkTarget === '_blank' } /> setAttributes( { content: newValue } ) } __unstableOnSplitAtEnd={ insertBlocksAfter ? () => insertBlocksAfter( createBlock( getDefaultBlockName()! ) ) : undefined } withoutInteractiveFormatting { ...blockProps } /> ); }