@gechiui/block-editor
Version:
42 lines (37 loc) • 1.24 kB
JavaScript
/**
* 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) {
var _groups$group;
return (_groups$group = groups[group]) === null || _groups$group === void 0 ? void 0 : _groups$group.Fill;
}
if (isParentDisplayed) {
return groups.parent.Fill;
}
return null;
}
//# sourceMappingURL=hook.js.map