diff --git a/packages/block-editor/src/components/block-toolbar/shuffle.js b/packages/block-editor/src/components/block-toolbar/shuffle.js index d84fdacdd3a055..99df4bbcfc6d99 100644 --- a/packages/block-editor/src/components/block-toolbar/shuffle.js +++ b/packages/block-editor/src/components/block-toolbar/shuffle.js @@ -14,7 +14,15 @@ import { store as blockEditorStore } from '../../store'; const EMPTY_ARRAY = []; -export default function Shuffle( { clientId } ) { +function Container( props ) { + return ( + + + + ); +} + +export default function Shuffle( { clientId, as = Container } ) { const { categories, patterns } = useSelect( ( select ) => { const { @@ -57,30 +65,29 @@ export default function Shuffle( { clientId } ) { if ( sameCategoryPatternsWithSingleWrapper.length === 0 ) { return null; } + const ComponentToUse = as; return ( - - { - const randomPattern = - sameCategoryPatternsWithSingleWrapper[ - Math.floor( - // eslint-disable-next-line no-restricted-syntax - Math.random() * - sameCategoryPatternsWithSingleWrapper.length - ) - ]; - randomPattern.blocks[ 0 ].attributes = { - ...randomPattern.blocks[ 0 ].attributes, - metadata: { - ...randomPattern.blocks[ 0 ].attributes.metadata, - categories, - }, - }; - replaceBlocks( clientId, randomPattern.blocks ); - } } - /> - + { + const randomPattern = + sameCategoryPatternsWithSingleWrapper[ + Math.floor( + // eslint-disable-next-line no-restricted-syntax + Math.random() * + sameCategoryPatternsWithSingleWrapper.length + ) + ]; + randomPattern.blocks[ 0 ].attributes = { + ...randomPattern.blocks[ 0 ].attributes, + metadata: { + ...randomPattern.blocks[ 0 ].attributes.metadata, + categories, + }, + }; + replaceBlocks( clientId, randomPattern.blocks ); + } } + /> ); } diff --git a/packages/block-editor/src/components/block-tools/block-selection-button.js b/packages/block-editor/src/components/block-tools/block-selection-button.js index bfc8e7893ddd45..0ed295803b612a 100644 --- a/packages/block-editor/src/components/block-tools/block-selection-button.js +++ b/packages/block-editor/src/components/block-tools/block-selection-button.js @@ -39,6 +39,7 @@ import { store as blockEditorStore } from '../../store'; import BlockDraggable from '../block-draggable'; import { __unstableUseBlockElement as useBlockElement } from '../block-list/use-block-props/use-block-refs'; import BlockMover from '../block-mover'; +import Shuffle from '../block-toolbar/shuffle'; /** * Block selection button component, displaying the label of the block. If the block @@ -271,6 +272,9 @@ function BlockSelectionButton( { clientId, rootClientId } ) { ) } + { editorMode === 'zoom-out' && ( + + ) }