Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ContentOnly: Add support for block styles on top-level contentOnly locked blocks #64872

Merged
merged 3 commits into from
Aug 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions packages/block-editor/src/components/block-inspector/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ import { useBorderPanelLabel } from '../../hooks/border';

import { unlock } from '../../lock-unlock';

function BlockStylesPanel( { clientId } ) {
return (
<PanelBody title={ __( 'Styles' ) }>
<BlockStyles clientId={ clientId } />
</PanelBody>
);
}

function BlockInspectorLockedBlocks( { topLevelLockedBlock } ) {
const contentClientIds = useSelect(
( select ) => {
Expand All @@ -48,6 +56,15 @@ function BlockInspectorLockedBlocks( { topLevelLockedBlock } ) {
},
[ topLevelLockedBlock ]
);
const hasBlockStyles = useSelect(
( select ) => {
const { getBlockName } = select( blockEditorStore );
const { getBlockStyles } = select( blocksStore );
return !! getBlockStyles( getBlockName( topLevelLockedBlock ) )
?.length;
},
[ topLevelLockedBlock ]
);
const blockInformation = useBlockDisplayInformation( topLevelLockedBlock );
return (
<div className="block-editor-block-inspector">
Expand All @@ -57,6 +74,9 @@ function BlockInspectorLockedBlocks( { topLevelLockedBlock } ) {
/>
<BlockVariationTransforms blockClientId={ topLevelLockedBlock } />
<BlockInfo.Slot />
{ hasBlockStyles && (
<BlockStylesPanel clientId={ topLevelLockedBlock } />
) }
{ contentClientIds.length > 0 && (
<PanelBody title={ __( 'Content' ) }>
<BlockQuickNavigation clientIds={ contentClientIds } />
Expand All @@ -81,7 +101,6 @@ const BlockInspector = ( { showNoBlockSelectedMessage = true } ) => {
getContentLockingParent,
getTemplateLock,
} = unlock( select( blockEditorStore ) );

const _selectedBlockClientId = getSelectedBlockClientId();
const _selectedBlockName =
_selectedBlockClientId && getBlockName( _selectedBlockClientId );
Expand Down Expand Up @@ -276,11 +295,7 @@ const BlockInspectorSingleBlock = ( { clientId, blockName } ) => {
{ ! showTabs && (
<>
{ hasBlockStyles && (
<div>
<PanelBody title={ __( 'Styles' ) }>
<BlockStyles clientId={ clientId } />
</PanelBody>
</div>
<BlockStylesPanel clientId={ clientId } />
) }
<InspectorControls.Slot />
<InspectorControls.Slot group="list" />
Expand Down
Loading