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

[6.7] Zoom-out (contentOnly): show more menu in block toolbar #66311

Merged
merged 4 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ const BlockSettingsMenuControlsSlot = ( { fillProps, clientIds = null } ) => {
const convertToGroupButtonProps =
useConvertToGroupButtonProps( selectedClientIds );
const { isGroupable, isUngroupable } = convertToGroupButtonProps;
const showConvertToGroupButton = isGroupable || isUngroupable;
const showConvertToGroupButton =
( isGroupable || isUngroupable ) && ! isContentOnly;

return (
<Slot
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ export function BlockSettingsDropdown( {
const currentClientId = block?.clientId;
const count = clientIds.length;
const firstBlockClientId = clientIds[ 0 ];

const isZoomOut = useSelect( ( select ) => {
const { __unstableGetEditorMode } = unlock(
select( blockEditorStore )
);

return __unstableGetEditorMode() === 'zoom-out';
} );

const {
firstParentClientId,
onlyBlock,
Expand Down Expand Up @@ -235,7 +244,7 @@ export function BlockSettingsDropdown( {
clientId={ firstBlockClientId }
/>
) }
{ ! isContentOnly && (
{ ( ! isContentOnly || isZoomOut ) && (
<CopyMenuItem
clientIds={ clientIds }
onCopy={ onCopy }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,7 @@ export function PrivateBlockToolbar( {
</>
) }
<BlockEditVisuallyButton clientIds={ blockClientIds } />
{ isDefaultEditingMode && (
<BlockSettingsMenu clientIds={ blockClientIds } />
) }
<BlockSettingsMenu clientIds={ blockClientIds } />
</div>
</NavigableToolbar>
);
Expand Down
20 changes: 17 additions & 3 deletions packages/editor/src/components/provider/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
BlockEditorProvider,
BlockContextProvider,
privateApis as blockEditorPrivateApis,
store as blockEditorStore,
} from '@wordpress/block-editor';
import { store as noticesStore } from '@wordpress/notices';
import { privateApis as editPatternsPrivateApis } from '@wordpress/patterns';
Expand Down Expand Up @@ -188,6 +189,15 @@ export const ExperimentalEditorProvider = withRegistryProvider(
},
[ post.type ]
);

const isZoomOut = useSelect( ( select ) => {
const { __unstableGetEditorMode } = unlock(
select( blockEditorStore )
);

return __unstableGetEditorMode() === 'zoom-out';
} );

const shouldRenderTemplate = !! template && mode !== 'post-only';
const rootLevelPost = shouldRenderTemplate ? template : post;
const defaultBlockContext = useMemo( () => {
Expand Down Expand Up @@ -332,9 +342,13 @@ export const ExperimentalEditorProvider = withRegistryProvider(
{ children }
{ ! settings.__unstableIsPreviewMode && (
<>
<PatternsMenuItems />
<TemplatePartMenuItems />
<ContentOnlySettingsMenu />
{ ! isZoomOut && (
<>
<PatternsMenuItems />
<TemplatePartMenuItems />
<ContentOnlySettingsMenu />
</>
) }
{ mode === 'template-locked' && (
<DisableNonPageContentBlocks />
) }
Expand Down
Loading