import { __ } from '@wordpress/i18n'; import { RichText, BlockIcon, useBlockProps, __experimentalGetElementClassName, useInnerBlocksProps, } from '@wordpress/block-editor'; import { blockTable as icon } from '@wordpress/icons'; import { Button, Placeholder } from '@wordpress/components'; export default function Edit( { attributes, setAttributes, clientId, advancedControl, } ) { const { caption, rowCount, columnCount, headers, footers, hasHeader, hasFooter, isEmpty, } = attributes; const { GkitStyle, GkitNumber, GkitSwitcher } = window.gutenkit.components; const { useDeviceType } = window.gutenkit.helpers; const device = useDeviceType(); const template = Array.from( { length: rowCount }, () => [ 'gutenkit/table-builder-row', ] ); const blockProps = useBlockProps(); const innerBlocksProps = useInnerBlocksProps( { className: 'gkit-table__body', }, { allowedBlocks: [ 'gutenkit/table-builder-row' ], renderAppender: false, template, } ); return ( <>
{ ! isEmpty ? ( <> { hasHeader && ( { Headers } ) } { hasFooter && ( { Footers } ) }
setAttributes( { caption: value } ) } placeholder="Caption for Table" /> ) : ( } instructions={ __( 'Insert a table for sharing data.' ) } >
setAttributes( { isEmpty: false } ) } >
) }
); }