From 883830f360e6e7353ffaee94c03fb53cb408d75a Mon Sep 17 00:00:00 2001 From: Ella Date: Tue, 26 Nov 2024 18:33:21 +0100 Subject: [PATCH] cleanup --- .../src/components/media-placeholder/index.js | 32 +++---------------- 1 file changed, 5 insertions(+), 27 deletions(-) diff --git a/packages/block-editor/src/components/media-placeholder/index.js b/packages/block-editor/src/components/media-placeholder/index.js index 3a21d8a252d080..2c151a8df668fd 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 = [];