/** * External dependencies */ import * as React from 'react'; /** * WordPress dependencies */ import { registerBlockType } from '@wordpress/blocks'; import { __ } from '@wordpress/i18n'; // @ts-ignore - The package does not ship type declarations. import { InspectorControls, useBlockProps } from '@wordpress/block-editor'; import { Disabled, PanelBody, SelectControl } from '@wordpress/components'; // @ts-ignore - The package does not ship type declarations. import ServerSideRender from '@wordpress/server-side-render'; /** * Internal dependencies */ import { ElementSave } from '../shared/ElementEdit'; type ExpressAttributes = { context: string; }; type ExpressEditProps = { name: string; attributes: ExpressAttributes; setAttributes: (attributes: Partial) => void; }; /** * Edit component for the Kustom Express Element block, following the shared ElementEdit pattern. * * @param {ExpressEditProps} props The block edit props. */ const ExpressEdit = ({ name, attributes, setAttributes }: ExpressEditProps) => { const blockProps = useBlockProps(); return ( <> setAttributes({ context }) } />
); }; // The block metadata comes from block.json, registered server side in src/Elements/Block.php. registerBlockType('kustom/express-element', { edit: ExpressEdit, save: ElementSave, } as any); // eslint-disable-line @typescript-eslint/no-explicit-any