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 1 commit
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
40 changes: 28 additions & 12 deletions packages/block-editor/src/components/block-inspector/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,37 @@ import { useBorderPanelLabel } from '../../hooks/border';

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

function BlockStylesPanel( { clientId } ) {
return (
<div>
<PanelBody title={ __( 'Styles' ) }>
<BlockStyles clientId={ clientId } />
</PanelBody>
</div>
ntsekouras marked this conversation as resolved.
Show resolved Hide resolved
);
}

function BlockInspectorLockedBlocks( { topLevelLockedBlock } ) {
const contentClientIds = useSelect(
const { contentClientIds, hasBlockStyles } = useSelect(
( select ) => {
const {
getClientIdsOfDescendants,
getBlockName,
getBlockEditingMode,
} = select( blockEditorStore );
return getClientIdsOfDescendants( topLevelLockedBlock ).filter(
( clientId ) =>
getBlockName( clientId ) !== 'core/list-item' &&
getBlockEditingMode( clientId ) === 'contentOnly'
);
const { getBlockStyles } = select( blocksStore );
return {
contentClientIds: getClientIdsOfDescendants(
topLevelLockedBlock
).filter(
( clientId ) =>
getBlockName( clientId ) !== 'core/list-item' &&
getBlockEditingMode( clientId ) === 'contentOnly'
),
Mamaduka marked this conversation as resolved.
Show resolved Hide resolved
hasBlockStyles: !! getBlockStyles(
getBlockName( topLevelLockedBlock )
)?.length,
};
},
[ topLevelLockedBlock ]
);
Expand All @@ -57,6 +75,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 +102,6 @@ const BlockInspector = ( { showNoBlockSelectedMessage = true } ) => {
getContentLockingParent,
getTemplateLock,
} = unlock( select( blockEditorStore ) );

const _selectedBlockClientId = getSelectedBlockClientId();
const _selectedBlockName =
_selectedBlockClientId && getBlockName( _selectedBlockClientId );
Expand Down Expand Up @@ -276,11 +296,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