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

Block settings menu: rearrange items #50453

Merged
merged 1 commit into from
May 9, 2023
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 @@ -4,9 +4,12 @@
import {
createSlotFill,
MenuGroup,
MenuItem,
__experimentalStyleProvider as StyleProvider,
} from '@wordpress/components';
import { useSelect } from '@wordpress/data';
import { pipe } from '@wordpress/compose';
import { __ } from '@wordpress/i18n';

/**
* Internal dependencies
Expand All @@ -17,6 +20,7 @@ import {
} from '../convert-to-group-buttons';
import { BlockLockMenuItem, useBlockLock } from '../block-lock';
import { store as blockEditorStore } from '../../store';
import BlockModeToggle from '../block-settings-menu/block-mode-toggle';

const { Fill, Slot } = createSlotFill( 'BlockSettingsMenuControls' );

Expand Down Expand Up @@ -74,16 +78,32 @@ const BlockSettingsMenuControlsSlot = ( {

return (
<MenuGroup>
{ showConvertToGroupButton && (
<ConvertToGroupButton
{ ...convertToGroupButtonProps }
onClose={ fillProps?.onClose }
/>
) }
{ showLockButton && (
<BlockLockMenuItem
clientId={ selectedClientIds[ 0 ] }
/>
) }
{ fills }
{ showConvertToGroupButton && (
<ConvertToGroupButton
{ ...convertToGroupButtonProps }
onClose={ fillProps?.onClose }
{ fillProps?.canMove && ! fillProps?.onlyBlock && (
<MenuItem
onClick={ pipe(
fillProps?.onClose,
fillProps?.onMoveTo
) }
>
{ __( 'Move to' ) }
</MenuItem>
) }
{ fillProps?.count === 1 && (
<BlockModeToggle
clientId={ fillProps?.firstBlockClientId }
onToggle={ fillProps?.onClose }
/>
) }
</MenuGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import { pipe, useCopyToClipboard } from '@wordpress/compose';
*/
import BlockActions from '../block-actions';
import BlockIcon from '../block-icon';
import BlockModeToggle from './block-mode-toggle';
import BlockHTMLConvertButton from './block-html-convert-button';
import __unstableBlockSettingsMenuFirstItem from './block-settings-menu-first-item';
import BlockSettingsMenuControls from '../block-settings-menu-controls';
Expand Down Expand Up @@ -291,19 +290,6 @@ export function BlockSettingsDropdown( {
</MenuItem>
</>
) }
{ canMove && ! onlyBlock && (
<MenuItem
onClick={ pipe( onClose, onMoveTo ) }
>
{ __( 'Move to' ) }
</MenuItem>
) }
{ count === 1 && (
<BlockModeToggle
clientId={ firstBlockClientId }
onToggle={ onClose }
/>
) }
</MenuGroup>
<MenuGroup>
<CopyMenuItem
Expand All @@ -316,7 +302,14 @@ export function BlockSettingsDropdown( {
</MenuItem>
</MenuGroup>
<BlockSettingsMenuControls.Slot
fillProps={ { onClose } }
fillProps={ {
onClose,
canMove,
onMoveTo,
onlyBlock,
count,
firstBlockClientId,
} }
clientIds={ clientIds }
__unstableDisplayLocation={
__unstableDisplayLocation
Expand Down