From 7e7b78f943526243cd3e788ac6905d53b3026c84 Mon Sep 17 00:00:00 2001 From: Matt Sherman Date: Mon, 5 Feb 2024 15:59:39 -0500 Subject: [PATCH] [create-product-editor-block] Fix product editor block registration (#44194) * Use registerProductEditorBlockType * Changelog * Update changelog to provide more detail --- .../block-templates/index.ts.mustache | 26 ++++++++----------- ...x-create-product-editor-block-registration | 4 +++ 2 files changed, 15 insertions(+), 15 deletions(-) create mode 100644 packages/js/create-product-editor-block/changelog/fix-create-product-editor-block-registration diff --git a/packages/js/create-product-editor-block/block-templates/index.ts.mustache b/packages/js/create-product-editor-block/block-templates/index.ts.mustache index c000ddf2675..a1c4f70d513 100644 --- a/packages/js/create-product-editor-block/block-templates/index.ts.mustache +++ b/packages/js/create-product-editor-block/block-templates/index.ts.mustache @@ -1,27 +1,23 @@ /** * External dependencies */ -import { BlockConfiguration, registerBlockType } from '@wordpress/blocks'; +import { registerProductEditorBlockType } from '@woocommerce/product-editor'; /** * Internal dependencies */ import './editor.scss'; // see https://www.npmjs.com/package/@wordpress/scripts#using-css - -/** - * Internal dependencies - */ +import blockConfiguration from './block.json'; import { Edit } from './edit'; -import metadata from './block.json'; -/** - * Every block starts by registering a new block type definition. - * - * @see https://developer.wordpress.org/block-editor/developers/block-api/#registering-a-block - */ -registerBlockType( metadata as BlockConfiguration, { - /** - * @see ./edit.js - */ +const { name, ...metadata } = blockConfiguration; + +const settings = { edit: Edit, +}; + +registerProductEditorBlockType( { + name, + metadata: metadata as never, + settings: settings as never, } ); diff --git a/packages/js/create-product-editor-block/changelog/fix-create-product-editor-block-registration b/packages/js/create-product-editor-block/changelog/fix-create-product-editor-block-registration new file mode 100644 index 00000000000..2cec1d06d91 --- /dev/null +++ b/packages/js/create-product-editor-block/changelog/fix-create-product-editor-block-registration @@ -0,0 +1,4 @@ +Significance: patch +Type: fix + +Example uses registerProductEditorBlockType to register block so that functionality such as hideConditions and disableConditions work with block.