UNPKG

@gechiui/block-editor

Version:
45 lines (41 loc) 1.13 kB
/** * GeChiUI dependencies */ import { store as blocksStore } from '@gechiui/blocks'; import { useSelect } from '@gechiui/data'; /** * Internal dependencies */ import groups from './groups'; import { store as blockEditorStore } from '../../store'; import { useBlockEditContext } from '../block-edit/context'; import useDisplayBlockControls from '../use-display-block-controls'; export default function useBlockControlsFill( group, shareWithChildBlocks ) { const isDisplayed = useDisplayBlockControls(); const { clientId } = useBlockEditContext(); const isParentDisplayed = useSelect( ( select ) => { const { getBlockName, hasSelectedInnerBlock } = select( blockEditorStore ); const { hasBlockSupport } = select( blocksStore ); return ( shareWithChildBlocks && hasBlockSupport( getBlockName( clientId ), '__experimentalExposeControlsToChildren', false ) && hasSelectedInnerBlock( clientId ) ); }, [ shareWithChildBlocks, clientId ] ); if ( isDisplayed ) { return groups[ group ]?.Fill; } if ( isParentDisplayed ) { return groups.parent.Fill; } return null; }