From 5283628cc04501a86fdfd8663e00a972aa7ace6b Mon Sep 17 00:00:00 2001 From: Robert Anderson Date: Mon, 5 Oct 2020 21:48:27 +1100 Subject: [PATCH] Widgets editor: Add basic options for extensibility (#25758) * Widgets editor: Add basic options for extensibility - Adds a WidgetAreas.Sidebar Fill component so that third party plugins can add custom UI to the widget editor's sidebar. - Sets the widget editor's block editor provider to not use a sub-registry, so that third party plugins can add custom blocks (including custom UI) to the block editor used in this screen. * Remove the WidgetAreas.Sidebar slot for now --- .../src/components/sidebar/block-areas.js | 51 +++++++++---------- .../index.js | 1 + 2 files changed, 24 insertions(+), 28 deletions(-) diff --git a/packages/edit-widgets/src/components/sidebar/block-areas.js b/packages/edit-widgets/src/components/sidebar/block-areas.js index 3541ebb77ed53c..3d387ad951908f 100644 --- a/packages/edit-widgets/src/components/sidebar/block-areas.js +++ b/packages/edit-widgets/src/components/sidebar/block-areas.js @@ -7,34 +7,25 @@ import { BlockIcon } from '@wordpress/block-editor'; import { Button } from '@wordpress/components'; import { __ } from '@wordpress/i18n'; -function BlockArea( { clientId } ) { - const { name, selectedBlock } = useSelect( - ( select ) => { - const { getBlockAttributes, getBlockSelectionStart } = select( - 'core/block-editor' - ); - return { - name: getBlockAttributes( clientId ).name, - selectedBlock: getBlockSelectionStart(), - }; - }, - [ clientId ] +function BlockArea( { block } ) { + const selectedBlock = useSelect( + ( select ) => select( 'core/block-editor' ).getBlockSelectionStart(), + [] ); + const { selectBlock } = useDispatch( 'core/block-editor' ); - const isSelected = selectedBlock === clientId; + + if ( block.name !== 'core/widget-area' ) { + return null; + } + return (