From 99995d3e0252103148636e629114709d70eecb4c Mon Sep 17 00:00:00 2001 From: Aaron Robertshaw <60436221+aaronrobertshaw@users.noreply.github.com> Date: Mon, 19 Apr 2021 19:06:03 +1000 Subject: [PATCH] Use hasPaddingSupport from padding hook --- packages/block-editor/src/hooks/padding.js | 4 ++-- packages/block-editor/src/hooks/spacing.js | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/block-editor/src/hooks/padding.js b/packages/block-editor/src/hooks/padding.js index f476a03ce3bfb2..c4de17d208b0f6 100644 --- a/packages/block-editor/src/hooks/padding.js +++ b/packages/block-editor/src/hooks/padding.js @@ -20,10 +20,10 @@ import { useCustomUnits } from '../components/unit-control'; * @param {string|Object} blockType Block name or Block Type object. * @return {boolean} Whether there is support. */ -const hasPaddingSupport = ( blockType ) => { +export function hasPaddingSupport( blockType ) { const support = getBlockSupport( blockType, SPACING_SUPPORT_KEY ); return !! ( true === support || support?.padding ); -}; +} /** * Custom hook that checks if padding settings have been disabled. diff --git a/packages/block-editor/src/hooks/spacing.js b/packages/block-editor/src/hooks/spacing.js index 1e1295cb7fafd1..c90b756eb87ea9 100644 --- a/packages/block-editor/src/hooks/spacing.js +++ b/packages/block-editor/src/hooks/spacing.js @@ -7,7 +7,11 @@ import { Platform } from '@wordpress/element'; /** * Internal dependencies */ -import { PaddingEdit, useIsPaddingDisabled } from './padding'; +import { + PaddingEdit, + hasPaddingSupport, + useIsPaddingDisabled, +} from './padding'; import SpacingPanelControl from '../components/spacing-panel-control'; export const SPACING_SUPPORT_KEY = 'spacing'; @@ -44,9 +48,7 @@ export function hasSpacingSupport( blockName ) { return false; } - const support = getBlockSupport( blockName, SPACING_SUPPORT_KEY ); - - return !! ( true === support || support?.padding ); + return hasPaddingSupport( blockName ); } /**