diff --git a/projects/plugins/jetpack/changelog/update-block-template-api-version b/projects/plugins/jetpack/changelog/update-block-template-api-version new file mode 100644 index 0000000000000..ec1b840ed823c --- /dev/null +++ b/projects/plugins/jetpack/changelog/update-block-template-api-version @@ -0,0 +1,4 @@ +Significance: patch +Type: other + +Block Scaffolding: update API version in template diff --git a/projects/plugins/jetpack/wp-cli-templates/block-block-json.mustache b/projects/plugins/jetpack/wp-cli-templates/block-block-json.mustache index 91579b5074917..c743e41a0d6bf 100644 --- a/projects/plugins/jetpack/wp-cli-templates/block-block-json.mustache +++ b/projects/plugins/jetpack/wp-cli-templates/block-block-json.mustache @@ -1,6 +1,6 @@ { "$schema": "https://schemas.wp.org/trunk/block.json", - "apiVersion": 1, + "apiVersion": 3, "name": "jetpack/{{ slug }}", "title": {{ title }}, "description": {{ description }}, diff --git a/projects/plugins/jetpack/wp-cli-templates/block-edit-js.mustache b/projects/plugins/jetpack/wp-cli-templates/block-edit-js.mustache index f9e0b86187e4a..0157e92a19e23 100644 --- a/projects/plugins/jetpack/wp-cli-templates/block-edit-js.mustache +++ b/projects/plugins/jetpack/wp-cli-templates/block-edit-js.mustache @@ -1,5 +1,5 @@ import { getBlockIconComponent } from '@automattic/jetpack-shared-extension-utils'; -import { BlockIcon } from '@wordpress/block-editor'; +import { BlockIcon, useBlockProps } from '@wordpress/block-editor'; import { Placeholder, withNotices } from '@wordpress/components'; import { useState } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; @@ -8,7 +8,7 @@ import './editor.scss'; const icon = getBlockIconComponent( metadata ); -function {{ className }}Edit( { attributes, className, noticeOperations, noticeUI, setAttributes } ) { +function {{ className }}Edit( { attributes, noticeOperations, noticeUI, setAttributes } ) { /** * Write the block editor UI. * @@ -22,8 +22,10 @@ function {{ className }}Edit( { attributes, className, noticeOperations, noticeU noticeOperations.createErrorNotice( __( 'Put error message here.', 'jetpack' ) ); }; + const blockProps = useBlockProps(); + return ( -
+
null, // TODO: Implement save. + // TODO: implement the `save` function for static blocks. If you do, make sure to add the block + // props returned by `useBlockProps.save()`. + // https://developer.wordpress.org/news/2023/02/27/static-vs-dynamic-blocks-whats-the-difference/ + // https://developer.wordpress.org/block-editor/reference-guides/block-api/block-edit-save/#save + save: () => null, } );