diff --git a/packages/block-library/src/query/edit/index.js b/packages/block-library/src/query/edit/index.js index bf8e95d06e21a..80c160ca83bb0 100644 --- a/packages/block-library/src/query/edit/index.js +++ b/packages/block-library/src/query/edit/index.js @@ -13,8 +13,9 @@ import { store as blockEditorStore, useInnerBlocksProps, __experimentalBlockPatternSetup as BlockPatternSetup, + BlockSettingsMenuControls, } from '@wordpress/block-editor'; -import { SelectControl } from '@wordpress/components'; +import { SelectControl, MenuItem } from '@wordpress/components'; import { __ } from '@wordpress/i18n'; /** @@ -27,7 +28,35 @@ import { DEFAULTS_POSTS_PER_PAGE } from '../constants'; import { getFirstQueryClientIdFromBlocks } from '../utils'; const TEMPLATE = [ [ 'core/post-template' ] ]; -export function QueryContent( { attributes, setAttributes } ) { + +function ResetQueryLoopMenuItem( { clientId, isSelected } ) { + const { replaceInnerBlocks } = useDispatch( blockEditorStore ); + if ( ! isSelected ) { + return null; + } + return ( + + { ( { onClose } ) => ( + { + replaceInnerBlocks( clientId, [] ); + onClose(); + } } + info={ __( 'Remove all innerblocks and start fresh' ) } + > + { __( 'Reset Query Loop' ) } + + ) } + + ); +} + +export function QueryContent( { + attributes, + setAttributes, + clientId, + isSelected, +} ) { const { queryId, query, @@ -104,6 +133,10 @@ export function QueryContent( { attributes, setAttributes } ) { setDisplayLayout={ updateDisplayLayout } /> +