I try to make a Gutenberg plugin but I have problem to set a value of attributes.
I npm this template
npx @wordpress/create-block example-plugin --template @ryanwelcher/multiple-blocks-template
because I want create a multiblock plugin.
the problem is where and how register attributes.
I register it on block.json:
"attributes": {
"content": {
"type": "string",
"selector": "h2"
}
},
Then I used it on edit.js
export default function Edit({attributes: {content}}) {
const blockProps = useBlockProps();
return (
<p {...useBlockProps()}>
<input value={content} />
<TextControl label="Question:" value={content}
allowedFormats={["core/italic"]}
onChange={(content) => setAttributes({ content })} />
{__('larum ipsume', 'page-builder')}
</p>
);
}