From 3db968d701cfc4060a417b5961cb473309a2ec4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CAlamgir=E2=80=9D?= <“alamgir.hossain@multidots.com”> Date: Mon, 7 Oct 2024 17:57:14 +0600 Subject: [PATCH] Stabilize the Experimental block supports property --- packages/block-editor/src/hooks/border.js | 18 ++++++++++-------- packages/block-editor/src/hooks/color.js | 7 +++---- packages/block-editor/src/hooks/dimensions.js | 17 ++++++++--------- packages/block-editor/src/hooks/typography.js | 7 +++---- 4 files changed, 24 insertions(+), 25 deletions(-) diff --git a/packages/block-editor/src/hooks/border.js b/packages/block-editor/src/hooks/border.js index 4ab4c69a41f311..9cf7e4e4448f0a 100644 --- a/packages/block-editor/src/hooks/border.js +++ b/packages/block-editor/src/hooks/border.js @@ -160,15 +160,17 @@ export function BorderPanel( { clientId, name, setAttributes, settings } ) { return null; } + const defaultBorderControls = + getBlockSupport( name, [ BORDER_SUPPORT_KEY, '__experimentalDefaultControls' ] ) || + getBlockSupport( name, [ BORDER_SUPPORT_KEY, 'defaultControls' ] ); + + const defaultShadowControls = + getBlockSupport( name, [ SHADOW_SUPPORT_KEY, '__experimentalDefaultControls' ] ) || + getBlockSupport( name, [ SHADOW_SUPPORT_KEY, 'defaultControls' ] ); + const defaultControls = { - ...getBlockSupport( name, [ - BORDER_SUPPORT_KEY, - '__experimentalDefaultControls', - ] ), - ...getBlockSupport( name, [ - SHADOW_SUPPORT_KEY, - '__experimentalDefaultControls', - ] ), + ...defaultBorderControls, + ...defaultShadowControls, }; return ( diff --git a/packages/block-editor/src/hooks/color.js b/packages/block-editor/src/hooks/color.js index ef8984c9367853..bf84051d0647cc 100644 --- a/packages/block-editor/src/hooks/color.js +++ b/packages/block-editor/src/hooks/color.js @@ -288,10 +288,9 @@ export function ColorEdit( { clientId, name, setAttributes, settings } ) { return null; } - const defaultControls = getBlockSupport( name, [ - COLOR_SUPPORT_KEY, - '__experimentalDefaultControls', - ] ); + const defaultControls = + getBlockSupport( name, [ COLOR_SUPPORT_KEY, '__experimentalDefaultControls' ] ) || + getBlockSupport( name, [ COLOR_SUPPORT_KEY, 'defaultControls' ] ); const enableContrastChecking = Platform.OS === 'web' && diff --git a/packages/block-editor/src/hooks/dimensions.js b/packages/block-editor/src/hooks/dimensions.js index ffa4048b7740e3..b25f2d67525998 100644 --- a/packages/block-editor/src/hooks/dimensions.js +++ b/packages/block-editor/src/hooks/dimensions.js @@ -86,19 +86,18 @@ export function DimensionsPanel( { clientId, name, setAttributes, settings } ) { return null; } - const defaultDimensionsControls = getBlockSupport( name, [ - DIMENSIONS_SUPPORT_KEY, - '__experimentalDefaultControls', - ] ); - const defaultSpacingControls = getBlockSupport( name, [ - SPACING_SUPPORT_KEY, - '__experimentalDefaultControls', - ] ); + const defaultDimensionsControls = + getBlockSupport( name, [ DIMENSIONS_SUPPORT_KEY, '__experimentalDefaultControls' ] ) || + getBlockSupport( name, [ DIMENSIONS_SUPPORT_KEY, 'defaultControls' ] ); + + const defaultSpacingControls = + getBlockSupport( name, [ SPACING_SUPPORT_KEY, '__experimentalDefaultControls' ] ) || + getBlockSupport( name, [ SPACING_SUPPORT_KEY, 'defaultControls' ] ); + const defaultControls = { ...defaultDimensionsControls, ...defaultSpacingControls, }; - return ( <>