Skip to content

Commit

Permalink
keep only copy, duplicate and delete in the more menu (#67279)
Browse files Browse the repository at this point in the history
Co-authored-by: draganescu <[email protected]>
Co-authored-by: getdave <[email protected]>
Co-authored-by: ellatrix <[email protected]>
Co-authored-by: richtabor <[email protected]>
Co-authored-by: annezazu <[email protected]>
  • Loading branch information
6 people authored and michalczaplinski committed Dec 5, 2024
1 parent 6a2be42 commit 891740a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,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 @@ -57,13 +57,15 @@ export function BlockSettingsDropdown( {
const currentClientId = block?.clientId;
const count = clientIds.length;
const firstBlockClientId = clientIds[ 0 ];

const {
firstParentClientId,
parentBlockType,
previousBlockClientId,
selectedBlockClientIds,
openedBlockSettingsMenu,
isContentOnly,
isZoomOut,
} = useSelect(
( select ) => {
const {
Expand All @@ -74,6 +76,7 @@ export function BlockSettingsDropdown( {
getBlockAttributes,
getOpenedBlockSettingsMenu,
getBlockEditingMode,
isZoomOut: _isZoomOut,
} = unlock( select( blockEditorStore ) );

const { getActiveBlockVariation } = select( blocksStore );
Expand All @@ -98,10 +101,12 @@ export function BlockSettingsDropdown( {
openedBlockSettingsMenu: getOpenedBlockSettingsMenu(),
isContentOnly:
getBlockEditingMode( firstBlockClientId ) === 'contentOnly',
isZoomOut: _isZoomOut(),
};
},
[ firstBlockClientId ]
);

const { getBlockOrder, getSelectedBlockClientIds } =
useSelect( blockEditorStore );

Expand Down Expand Up @@ -248,7 +253,7 @@ export function BlockSettingsDropdown( {
clientId={ firstBlockClientId }
/>
) }
{ ! isContentOnly && (
{ ( ! isContentOnly || isZoomOut ) && (
<CopyMenuItem
clientIds={ clientIds }
onCopy={ onCopy }
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 @@ -205,6 +206,15 @@ export const ExperimentalEditorProvider = withRegistryProvider(
},
[ post.type ]
);

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

return _isZoomOut();
} );

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

0 comments on commit 891740a

Please sign in to comment.