diff --git a/packages/block-editor/src/components/media-placeholder/index.js b/packages/block-editor/src/components/media-placeholder/index.js index 3a21d8a252d08..2c151a8df668f 100644 --- a/packages/block-editor/src/components/media-placeholder/index.js +++ b/packages/block-editor/src/components/media-placeholder/index.js @@ -229,30 +229,15 @@ export function MediaPlaceholder( { } ); }; - async function handleBlocksDrop( blocks ) { - if ( ! blocks || ! Array.isArray( blocks ) ) { - return; - } - - function recursivelyFindMediaFromBlocks( _blocks ) { - return _blocks.flatMap( ( block ) => - ( block.name === 'core/image' || - block.name === 'core/audio' || - block.name === 'core/video' ) && - ( block.attributes.url || block.attributes.src ) - ? [ block ] - : recursivelyFindMediaFromBlocks( block.innerBlocks ) - ); - } - - const mediaBlocks = recursivelyFindMediaFromBlocks( blocks ); + async function handleBlocksDrop( event ) { + const { blocks } = parseDropEvent( event ); - if ( ! mediaBlocks.length ) { + if ( ! blocks || ! blocks.length ) { return; } const uploadedMediaList = await Promise.all( - mediaBlocks.map( ( block ) => { + blocks.map( ( block ) => { const blockType = block.name.split( '/' )[ 1 ]; if ( block.attributes.id ) { block.attributes.type = blockType; @@ -292,13 +277,6 @@ export function MediaPlaceholder( { } } - function onDrop( event ) { - const { blocks } = parseDropEvent( event ); - if ( blocks ) { - handleBlocksDrop( blocks ); - } - } - const onUpload = ( event ) => { onFilesUpload( event.target.files ); }; @@ -388,7 +366,7 @@ export function MediaPlaceholder( { return ( { const prefix = 'wp-block:core/'; const types = [];