From b24d52753151b3365123001f005a92eba455ffe5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Grzegorz=20Zi=C3=B3=C5=82kowski?= Date: Thu, 28 Nov 2024 09:47:28 +0100 Subject: [PATCH] Wrap Edit with bindings logic only when the block supports it --- .../block-editor/src/components/block-edit/index.js | 10 ++++++---- ...gs-attributes.js => with-block-bindings-support.js} | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) rename packages/block-editor/src/components/block-edit/{with-block-bindings-attributes.js => with-block-bindings-support.js} (99%) diff --git a/packages/block-editor/src/components/block-edit/index.js b/packages/block-editor/src/components/block-edit/index.js index 09b92ad2e8246..a16385d694ffc 100644 --- a/packages/block-editor/src/components/block-edit/index.js +++ b/packages/block-editor/src/components/block-edit/index.js @@ -8,7 +8,7 @@ import { hasBlockSupport } from '@wordpress/blocks'; * Internal dependencies */ import Edit from './edit'; -import { withBlockBindingSupport } from './with-block-bindings-attributes'; +import { withBlockBindingsSupport } from './with-block-bindings-support'; import { BlockEditContextProvider, useBlockEditContext, @@ -20,6 +20,9 @@ import { } from './context'; import { MultipleUsageWarning } from './multiple-usage-warning'; import { PrivateBlockContext } from '../block-list/private-block-context'; +import { canBindBlock } from '../../utils/block-bindings'; + +const BlockEditWithBindings = withBlockBindingsSupport( Edit ); /** * The `useBlockEditContext` hook provides information about the block this hook is being used in. @@ -31,8 +34,6 @@ import { PrivateBlockContext } from '../block-list/private-block-context'; */ export { useBlockEditContext }; -const BlockEditWithBindings = withBlockBindingSupport( Edit ); - export default function BlockEdit( { mayDisplayControls, mayDisplayParentControls, @@ -55,6 +56,7 @@ export default function BlockEdit( { hasBlockSupport( name, 'layout', false ) || hasBlockSupport( name, '__experimentalLayout', false ); const { originalBlockClientId } = useContext( PrivateBlockContext ); + const EditComponent = canBindBlock( name ) ? BlockEditWithBindings : Edit; return ( - + { originalBlockClientId && ( ( props ) => { const registry = useRegistry(); const blockContext = useContext( BlockContext );