From 7cfbdfdff1b94ce9794ed738db55c0e38040456d Mon Sep 17 00:00:00 2001 From: Aaron Robertshaw <60436221+aaronrobertshaw@users.noreply.github.com> Date: Mon, 30 Jan 2023 12:31:00 +0800 Subject: [PATCH] Inspector Controls: Stabilize the experimental control groups (#47105) --- .../src/components/block-inspector/index.js | 18 ++++++++++-------- .../advanced-controls-panel.js | 2 +- .../inspector-controls-tabs/index.js | 4 +--- .../position-controls-panel.js | 2 +- .../inspector-controls-tabs/styles-tab.js | 12 +++++------- .../use-inspector-controls-tabs.js | 2 ++ .../src/components/inspector-controls/fill.js | 16 +++++++++++++++- .../inspector-controls/fill.native.js | 15 ++++++++++++++- .../components/inspector-controls/groups.js | 3 +++ .../src/components/inspector-controls/index.js | 8 ++------ .../src/components/inspector-controls/slot.js | 15 ++++++++++++++- .../inspector-controls/slot.native.js | 15 ++++++++++++++- packages/block-editor/src/hooks/anchor.js | 2 +- packages/block-editor/src/hooks/border.js | 2 +- packages/block-editor/src/hooks/color-panel.js | 2 +- .../src/hooks/custom-class-name.js | 2 +- packages/block-editor/src/hooks/dimensions.js | 2 +- packages/block-editor/src/hooks/position.js | 2 +- packages/block-editor/src/hooks/typography.js | 2 +- packages/block-library/src/button/edit.js | 2 +- .../edit/comments-inspector-controls.js | 2 +- .../src/cover/edit/inspector-controls.js | 6 +++--- packages/block-library/src/group/edit.js | 2 +- packages/block-library/src/image/image.js | 2 +- .../block-library/src/navigation/edit/index.js | 4 ++-- .../navigation/edit/menu-inspector-controls.js | 2 +- packages/block-library/src/paragraph/edit.js | 2 +- .../post-featured-image/dimension-controls.js | 2 +- .../src/post-featured-image/overlay.js | 2 +- packages/block-library/src/post-terms/edit.js | 2 +- .../src/query/edit/query-content.js | 2 +- packages/block-library/src/social-link/edit.js | 2 +- .../block-library/src/social-links/edit.js | 2 +- .../template-part/edit/advanced-controls.js | 2 +- 34 files changed, 107 insertions(+), 55 deletions(-) diff --git a/packages/block-editor/src/components/block-inspector/index.js b/packages/block-editor/src/components/block-inspector/index.js index e37f6fb09efff..e7a769f51cec7 100644 --- a/packages/block-editor/src/components/block-inspector/index.js +++ b/packages/block-editor/src/components/block-inspector/index.js @@ -198,22 +198,23 @@ const BlockInspector = ( { showNoBlockSelectedMessage = true } ) => { <> + ) } @@ -356,22 +357,23 @@ const BlockInspectorSingleBlock = ( { clientId, blockName } ) => { ) } +
diff --git a/packages/block-editor/src/components/inspector-controls-tabs/advanced-controls-panel.js b/packages/block-editor/src/components/inspector-controls-tabs/advanced-controls-panel.js index 83027861e9d19..6807a776b0ee6 100644 --- a/packages/block-editor/src/components/inspector-controls-tabs/advanced-controls-panel.js +++ b/packages/block-editor/src/components/inspector-controls-tabs/advanced-controls-panel.js @@ -29,7 +29,7 @@ const AdvancedControls = () => { title={ __( 'Advanced' ) } initialOpen={ false } > - + ); }; diff --git a/packages/block-editor/src/components/inspector-controls-tabs/index.js b/packages/block-editor/src/components/inspector-controls-tabs/index.js index efdaed591b4fe..74f89754428cb 100644 --- a/packages/block-editor/src/components/inspector-controls-tabs/index.js +++ b/packages/block-editor/src/components/inspector-controls-tabs/index.js @@ -52,9 +52,7 @@ export default function InspectorControlsTabs( { } if ( tab.name === TAB_LIST_VIEW.name ) { - return ( - - ); + return ; } } } diff --git a/packages/block-editor/src/components/inspector-controls-tabs/position-controls-panel.js b/packages/block-editor/src/components/inspector-controls-tabs/position-controls-panel.js index 5fc71fab5960f..f145d961e1f30 100644 --- a/packages/block-editor/src/components/inspector-controls-tabs/position-controls-panel.js +++ b/packages/block-editor/src/components/inspector-controls-tabs/position-controls-panel.js @@ -29,7 +29,7 @@ const PositionControls = () => { title={ __( 'Position' ) } initialOpen={ false } > - + ); }; diff --git a/packages/block-editor/src/components/inspector-controls-tabs/styles-tab.js b/packages/block-editor/src/components/inspector-controls-tabs/styles-tab.js index f2eac99680b9a..3a7f625d10de2 100644 --- a/packages/block-editor/src/components/inspector-controls-tabs/styles-tab.js +++ b/packages/block-editor/src/components/inspector-controls-tabs/styles-tab.js @@ -28,22 +28,20 @@ const StylesTab = ( { blockName, clientId, hasBlockStyles } ) => {
) } - + + ); }; diff --git a/packages/block-editor/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js b/packages/block-editor/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js index 42b0474af1b0e..3d78d4fa70ebe 100644 --- a/packages/block-editor/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +++ b/packages/block-editor/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js @@ -38,6 +38,7 @@ export default function useInspectorControlsTabs( blockName ) { dimensions: dimensionsGroup, list: listGroup, position: positionGroup, + styles: stylesGroup, typography: typographyGroup, } = InspectorControlsGroups; @@ -55,6 +56,7 @@ export default function useInspectorControlsTabs( blockName ) { ...( useSlotFills( borderGroup.Slot.__unstableName ) || [] ), ...( useSlotFills( colorGroup.Slot.__unstableName ) || [] ), ...( useSlotFills( dimensionsGroup.Slot.__unstableName ) || [] ), + ...( useSlotFills( stylesGroup.Slot.__unstableName ) || [] ), ...( useSlotFills( typographyGroup.Slot.__unstableName ) || [] ), ]; diff --git a/packages/block-editor/src/components/inspector-controls/fill.js b/packages/block-editor/src/components/inspector-controls/fill.js index af3478252de6d..8b3e3f600bd84 100644 --- a/packages/block-editor/src/components/inspector-controls/fill.js +++ b/packages/block-editor/src/components/inspector-controls/fill.js @@ -11,6 +11,7 @@ import { __experimentalToolsPanelContext as ToolsPanelContext, } from '@wordpress/components'; import warning from '@wordpress/warning'; +import deprecated from '@wordpress/deprecated'; /** * Internal dependencies @@ -19,9 +20,22 @@ import useDisplayBlockControls from '../use-display-block-controls'; import groups from './groups'; export default function InspectorControlsFill( { - __experimentalGroup: group = 'default', children, + group = 'default', + __experimentalGroup, } ) { + if ( __experimentalGroup ) { + deprecated( + '`__experimentalGroup` property in `InspectorControlsFill`', + { + since: '6.2', + version: '6.4', + alternative: '`group`', + } + ); + group = __experimentalGroup; + } + const isDisplayed = useDisplayBlockControls(); const Fill = groups[ group ]?.Fill; if ( ! Fill ) { diff --git a/packages/block-editor/src/components/inspector-controls/fill.native.js b/packages/block-editor/src/components/inspector-controls/fill.native.js index 01d3fc9c10472..37c084806da68 100644 --- a/packages/block-editor/src/components/inspector-controls/fill.native.js +++ b/packages/block-editor/src/components/inspector-controls/fill.native.js @@ -9,6 +9,7 @@ import { View } from 'react-native'; import { Children } from '@wordpress/element'; import { BottomSheetConsumer } from '@wordpress/components'; import warning from '@wordpress/warning'; +import deprecated from '@wordpress/deprecated'; /** * Internal dependencies @@ -19,9 +20,21 @@ import { BlockSettingsButton } from '../block-settings'; export default function InspectorControlsFill( { children, - __experimentalGroup: group = 'default', + group = 'default', + __experimentalGroup, ...props } ) { + if ( __experimentalGroup ) { + deprecated( + '`__experimentalGroup` property in `InspectorControlsFill`', + { + since: '6.2', + version: '6.4', + alternative: '`group`', + } + ); + group = __experimentalGroup; + } const isDisplayed = useDisplayBlockControls(); const Fill = groups[ group ]?.Fill; diff --git a/packages/block-editor/src/components/inspector-controls/groups.js b/packages/block-editor/src/components/inspector-controls/groups.js index 46fca564925aa..f1adbb66252b5 100644 --- a/packages/block-editor/src/components/inspector-controls/groups.js +++ b/packages/block-editor/src/components/inspector-controls/groups.js @@ -15,6 +15,7 @@ const InspectorControlsTypography = createSlotFill( 'InspectorControlsTypography' ); const InspectorControlsListView = createSlotFill( 'InspectorControlsListView' ); +const InspectorControlsStyles = createSlotFill( 'InspectorControlsStyles' ); const groups = { default: InspectorControlsDefault, @@ -23,6 +24,8 @@ const groups = { color: InspectorControlsColor, dimensions: InspectorControlsDimensions, list: InspectorControlsListView, + settings: InspectorControlsDefault, // Alias for default. + styles: InspectorControlsStyles, typography: InspectorControlsTypography, position: InspectorControlsPosition, }; diff --git a/packages/block-editor/src/components/inspector-controls/index.js b/packages/block-editor/src/components/inspector-controls/index.js index 4cb36cdc84399..f066f05923506 100644 --- a/packages/block-editor/src/components/inspector-controls/index.js +++ b/packages/block-editor/src/components/inspector-controls/index.js @@ -10,14 +10,10 @@ InspectorControls.Slot = InspectorControlsSlot; // This is just here for backward compatibility. export const InspectorAdvancedControls = ( props ) => { - return ( - - ); + return ; }; InspectorAdvancedControls.Slot = ( props ) => { - return ( - - ); + return ; }; InspectorAdvancedControls.slotName = 'InspectorAdvancedControls'; diff --git a/packages/block-editor/src/components/inspector-controls/slot.js b/packages/block-editor/src/components/inspector-controls/slot.js index 010332c0a3112..883421cacec23 100644 --- a/packages/block-editor/src/components/inspector-controls/slot.js +++ b/packages/block-editor/src/components/inspector-controls/slot.js @@ -6,6 +6,7 @@ import { __experimentalUseSlotFills as useSlotFills, } from '@wordpress/components'; import warning from '@wordpress/warning'; +import deprecated from '@wordpress/deprecated'; /** * Internal dependencies @@ -15,10 +16,22 @@ import BlockSupportSlotContainer from './block-support-slot-container'; import groups from './groups'; export default function InspectorControlsSlot( { - __experimentalGroup: group = 'default', + __experimentalGroup, + group = 'default', label, ...props } ) { + if ( __experimentalGroup ) { + deprecated( + '`__experimentalGroup` property in `InspectorControlsSlot`', + { + since: '6.2', + version: '6.4', + alternative: '`group`', + } + ); + group = __experimentalGroup; + } const Slot = groups[ group ]?.Slot; const slot = useSlot( Slot?.__unstableName ); const fills = useSlotFills( Slot?.__unstableName ); diff --git a/packages/block-editor/src/components/inspector-controls/slot.native.js b/packages/block-editor/src/components/inspector-controls/slot.native.js index adf4da06965e4..4354e08165d91 100644 --- a/packages/block-editor/src/components/inspector-controls/slot.native.js +++ b/packages/block-editor/src/components/inspector-controls/slot.native.js @@ -2,6 +2,7 @@ * WordPress dependencies */ import warning from '@wordpress/warning'; +import deprecated from '@wordpress/deprecated'; /** * Internal dependencies @@ -9,9 +10,21 @@ import warning from '@wordpress/warning'; import groups from './groups'; export default function InspectorControlsSlot( { - __experimentalGroup: group = 'default', + __experimentalGroup, + group = 'default', ...props } ) { + if ( __experimentalGroup ) { + deprecated( + '`__experimentalGroup` property in `InspectorControlsSlot`', + { + since: '6.2', + version: '6.4', + alternative: '`group`', + } + ); + group = __experimentalGroup; + } const Slot = groups[ group ]?.Slot; if ( ! Slot ) { warning( `Unknown InspectorControl group "${ group }" provided.` ); diff --git a/packages/block-editor/src/hooks/anchor.js b/packages/block-editor/src/hooks/anchor.js index 027b17d0c243e..65e227ab107eb 100644 --- a/packages/block-editor/src/hooks/anchor.js +++ b/packages/block-editor/src/hooks/anchor.js @@ -105,7 +105,7 @@ export const withInspectorControl = createHigherOrderComponent( <> { isWeb && ( - + { textControl } ) } diff --git a/packages/block-editor/src/hooks/border.js b/packages/block-editor/src/hooks/border.js index 74e79ecec8048..d99416e6cd665 100644 --- a/packages/block-editor/src/hooks/border.js +++ b/packages/block-editor/src/hooks/border.js @@ -255,7 +255,7 @@ export function BorderPanel( props ) { const hydratedBorder = getBorderObject( attributes, colors ); return ( - + { ( isWidthSupported || isColorSupported ) && ( hasBorderValue( props ) } diff --git a/packages/block-editor/src/hooks/color-panel.js b/packages/block-editor/src/hooks/color-panel.js index 6bf9ff036280d..97113b5a060f0 100644 --- a/packages/block-editor/src/hooks/color-panel.js +++ b/packages/block-editor/src/hooks/color-panel.js @@ -75,7 +75,7 @@ export default function ColorPanel( { const colorGradientSettings = useMultipleOriginColorsAndGradients(); return ( - + - + - + { ! isPaddingDisabled && ( 1 ? ( - + + { ! isFontFamilyDisabled && ( hasFontFamilyValue( props ) } diff --git a/packages/block-library/src/button/edit.js b/packages/block-library/src/button/edit.js index d204dd921a972..9eab35ff3c007 100644 --- a/packages/block-library/src/button/edit.js +++ b/packages/block-library/src/button/edit.js @@ -260,7 +260,7 @@ function ButtonEdit( props ) { setAttributes={ setAttributes } /> - + - + ) } - + - + !! minHeight } label={ __( 'Minimum height' ) } @@ -335,7 +335,7 @@ export default function CoverInspectorControls( { /> - + + - + ) } - + { hasColorSettings && ( <> { stylingInspectorControls } { isEntityAvailable && ( - + { hasResolvedCanUserUpdateNavigationMenu && canUserUpdateNavigationMenu && ( diff --git a/packages/block-library/src/navigation/edit/menu-inspector-controls.js b/packages/block-library/src/navigation/edit/menu-inspector-controls.js index bdb969e990806..e83656af70f96 100644 --- a/packages/block-library/src/navigation/edit/menu-inspector-controls.js +++ b/packages/block-library/src/navigation/edit/menu-inspector-controls.js @@ -132,7 +132,7 @@ const DefaultControls = ( props ) => { const MenuInspectorControls = ( props ) => { // Show the OffCanvasEditor controls if we're in the Gutenberg plugin. Previously used isOffCanvasNavigationEditorEnabled. return ( - + diff --git a/packages/block-library/src/paragraph/edit.js b/packages/block-library/src/paragraph/edit.js index 5340eb5e4ea54..5cb465dc6da66 100644 --- a/packages/block-library/src/paragraph/edit.js +++ b/packages/block-library/src/paragraph/edit.js @@ -99,7 +99,7 @@ function ParagraphBlock( { /> { isDropCapFeatureEnabled && ( - + !! dropCap } label={ __( 'Drop cap' ) } diff --git a/packages/block-library/src/post-featured-image/dimension-controls.js b/packages/block-library/src/post-featured-image/dimension-controls.js index 76bc9787bd587..171924ec5fb3d 100644 --- a/packages/block-library/src/post-featured-image/dimension-controls.js +++ b/packages/block-library/src/post-featured-image/dimension-controls.js @@ -71,7 +71,7 @@ const DimensionControls = ( { }; const scaleLabel = _x( 'Scale', 'Image scaling options' ); return ( - + !! height } diff --git a/packages/block-library/src/post-featured-image/overlay.js b/packages/block-library/src/post-featured-image/overlay.js index 4b523abfb4916..236038897439f 100644 --- a/packages/block-library/src/post-featured-image/overlay.js +++ b/packages/block-library/src/post-featured-image/overlay.js @@ -64,7 +64,7 @@ const Overlay = ( { style={ overlayStyles } /> ) } - + - + - + - + - + { colorSettings.map( ( { onChange, label, value, resetAllFilter } ) => ( + { isEntityAvailable && ( <>