Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
__experimentalUseSlotFills as useSlotFills,
} from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { useSelect } from '@wordpress/data';

/**
* Internal dependencies
Expand All @@ -15,12 +16,29 @@ import {
InspectorAdvancedControls,
} from '../inspector-controls';
import { PrivateInspectorControlsAllowedBlocks } from '../inspector-controls/groups';
import { store as blockEditorStore } from '../../store';
import { unlock } from '../../lock-unlock';

const AdvancedControls = ( { initialOpen = false } ) => {
const fills = useSlotFills( InspectorAdvancedControls.slotName );
const privateFills = useSlotFills(
PrivateInspectorControlsAllowedBlocks.name
);

const isContentOnlyMode = useSelect( ( select ) => {
const { getSelectedBlockClientId, getBlockEditingMode } = unlock(
select( blockEditorStore )
);

const clientId = getSelectedBlockClientId();

if ( ! clientId ) {
return false;
}

return getBlockEditingMode( clientId ) === 'contentOnly';
}, [] );

const hasFills = Boolean( fills && fills.length );
Comment thread
t-hamano marked this conversation as resolved.
Resolved
const hasPrivateFills = Boolean( privateFills && privateFills.length );

Expand All @@ -34,7 +52,9 @@ const AdvancedControls = ( { initialOpen = false } ) => {
title={ __( 'Advanced' ) }
initialOpen={ initialOpen }
>
<InspectorControls.Slot group="advanced" />
{ ! isContentOnlyMode && (
<InspectorControls.Slot group="advanced" />
) }
<PrivateInspectorControlsAllowedBlocks.Slot />
</PanelBody>
);
Expand Down
Loading