Skip to content

Commit

Permalink
[6.7] Zoom-out (contentOnly): show more menu in block toolbar (#66311)
Browse files Browse the repository at this point in the history
Co-authored-by: ellatrix <[email protected]>
Co-authored-by: getdave <[email protected]>
Co-authored-by: draganescu <[email protected]>
Co-authored-by: andrewserong <[email protected]>
Co-authored-by: kevin940726 <[email protected]>
Co-authored-by: annezazu <[email protected]>
Co-authored-by: richtabor <[email protected]>
Co-authored-by: talldan <[email protected]>
* Zoom-out (contentOnly): show more menu in block toolbar

* Remove group/ungroup from contentOnly

* Avoid special content only settings menu in Zoom Out

* add copy back, remove pattern related group of options

---------

Co-authored-by: Dave Smith <[email protected]>
Co-authored-by: Andrei Draganescu <[email protected]>
  • Loading branch information
3 people authored Nov 4, 2024
1 parent 9631601 commit 16cbfe3
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 8 deletions.
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
4 changes: 1 addition & 3 deletions packages/block-editor/src/components/block-toolbar/index.js
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

0 comments on commit 16cbfe3

Please sign in to comment.