@@ -13,6 +13,13 @@ import { getBlockSupport } from '@wordpress/blocks';
1313 * Internal dependencies
1414 */
1515import InspectorControls from '../components/inspector-controls' ;
16+ import {
17+ HeightEdit ,
18+ hasHeightSupport ,
19+ hasHeightValue ,
20+ resetHeight ,
21+ useIsHeightDisabled ,
22+ } from './height' ;
1623import {
1724 MarginEdit ,
1825 hasMarginSupport ,
@@ -29,6 +36,7 @@ import {
2936} from './padding' ;
3037import { cleanEmptyObject } from './utils' ;
3138
39+ export const DIMENSIONS_SUPPORT_KEY = '__experimentalDimensions' ;
3240export const SPACING_SUPPORT_KEY = 'spacing' ;
3341export const ALL_SIDES = [ 'top' , 'right' , 'bottom' , 'left' ] ;
3442export const AXIAL_SIDES = [ 'vertical' , 'horizontal' ] ;
@@ -37,19 +45,24 @@ export const AXIAL_SIDES = [ 'vertical', 'horizontal' ];
3745 * Inspector controls for dimensions support.
3846 *
3947 * @param {Object } props Block props.
40- *
41- * @return {WPElement } Inspector controls for spacing support features.
48+ * @return {WPElement } Inspector controls for dimensions support features.
4249 */
4350export function DimensionsPanel ( props ) {
4451 const isPaddingDisabled = useIsPaddingDisabled ( props ) ;
4552 const isMarginDisabled = useIsMarginDisabled ( props ) ;
53+ const isHeightDisabled = useIsHeightDisabled ( props ) ;
4654 const isDisabled = useIsDimensionsDisabled ( props ) ;
4755 const isSupported = hasDimensionsSupport ( props . name ) ;
4856
4957 if ( isDisabled || ! isSupported ) {
5058 return null ;
5159 }
5260
61+ const defaultDimensionsControls = getBlockSupport ( props . name , [
62+ DIMENSIONS_SUPPORT_KEY ,
63+ '__experimentalDefaultControls' ,
64+ ] ) ;
65+
5366 const defaultSpacingControls = getBlockSupport ( props . name , [
5467 SPACING_SUPPORT_KEY ,
5568 '__experimentalDefaultControls' ,
@@ -62,6 +75,10 @@ export function DimensionsPanel( props ) {
6275 props . setAttributes ( {
6376 style : cleanEmptyObject ( {
6477 ...style ,
78+ dimensions : {
79+ ...style ?. dimensions ,
80+ height : undefined ,
81+ } ,
6582 spacing : {
6683 ...style ?. spacing ,
6784 margin : undefined ,
@@ -78,6 +95,17 @@ export function DimensionsPanel( props ) {
7895 header = { __ ( 'Dimensions' ) }
7996 resetAll = { resetAll }
8097 >
98+ { ! isHeightDisabled && (
99+ < ToolsPanelItem
100+ className = "single-column"
101+ hasValue = { ( ) => hasHeightValue ( props ) }
102+ label = { __ ( 'Height' ) }
103+ onDeselect = { ( ) => resetHeight ( props ) }
104+ isShownByDefault = { defaultDimensionsControls ?. height }
105+ >
106+ < HeightEdit { ...props } />
107+ </ ToolsPanelItem >
108+ ) }
81109 { ! isPaddingDisabled && (
82110 < ToolsPanelItem
83111 hasValue = { ( ) => hasPaddingValue ( props ) }
@@ -115,21 +143,25 @@ export function hasDimensionsSupport( blockName ) {
115143 return false ;
116144 }
117145
118- return hasPaddingSupport ( blockName ) || hasMarginSupport ( blockName ) ;
146+ return (
147+ hasHeightSupport ( blockName ) ||
148+ hasPaddingSupport ( blockName ) ||
149+ hasMarginSupport ( blockName )
150+ ) ;
119151}
120152
121153/**
122154 * Determines whether dimensions support has been disabled.
123155 *
124156 * @param {Object } props Block properties.
125- *
126- * @return {boolean } If spacing support is completely disabled.
157+ * @return {boolean } If dimensions support is completely disabled.
127158 */
128159const useIsDimensionsDisabled = ( props = { } ) => {
160+ const heightDisabled = useIsHeightDisabled ( props ) ;
129161 const paddingDisabled = useIsPaddingDisabled ( props ) ;
130162 const marginDisabled = useIsMarginDisabled ( props ) ;
131163
132- return paddingDisabled && marginDisabled ;
164+ return heightDisabled && paddingDisabled && marginDisabled ;
133165} ;
134166
135167/**
0 commit comments