From 48fd68f550ce52b760ab46106ca101089a0eb268 Mon Sep 17 00:00:00 2001 From: Ella Date: Tue, 26 Nov 2024 12:11:19 +0100 Subject: [PATCH] Revert "Fix media placeholder to only activate for media objects. (#66986)" This reverts commit 2e4b8d8a0593f3791fb580d127c51a9f334bf59d. --- .../src/components/inserter-draggable-blocks/index.js | 11 +---------- .../src/components/media-placeholder/index.js | 10 +++++----- test/e2e/specs/editor/blocks/image.spec.js | 2 +- 3 files changed, 7 insertions(+), 16 deletions(-) diff --git a/packages/block-editor/src/components/inserter-draggable-blocks/index.js b/packages/block-editor/src/components/inserter-draggable-blocks/index.js index 0e1aaadc72e67..5a63535be3d3c 100644 --- a/packages/block-editor/src/components/inserter-draggable-blocks/index.js +++ b/packages/block-editor/src/components/inserter-draggable-blocks/index.js @@ -29,15 +29,6 @@ const InserterDraggableBlocks = ( { blocks, }; - const blocksContainMedia = - blocks.filter( - ( block ) => - ( block.name === 'core/image' || - block.name === 'core/audio' || - block.name === 'core/video' ) && - ( block.attributes.url || block.attributes.src ) - ).length > 0; - const blockTypeIcon = useSelect( ( select ) => { const { getBlockType } = select( blocksStore ); @@ -72,7 +63,7 @@ const InserterDraggableBlocks = ( { ? [ createBlock( 'core/block', { ref: pattern.id } ) ] : blocks; event.dataTransfer.setData( - blocksContainMedia ? 'default' : 'text/html', + 'text/html', serialize( parsedBlocks ) ); } } diff --git a/packages/block-editor/src/components/media-placeholder/index.js b/packages/block-editor/src/components/media-placeholder/index.js index e7b6c836468f0..df0cd1e895c03 100644 --- a/packages/block-editor/src/components/media-placeholder/index.js +++ b/packages/block-editor/src/components/media-placeholder/index.js @@ -292,10 +292,8 @@ export function MediaPlaceholder( { } } - async function onDrop( event ) { - const blocks = pasteHandler( { - HTML: event.dataTransfer?.getData( 'default' ), - } ); + async function onHTMLDrop( HTML ) { + const blocks = pasteHandler( { HTML } ); return await handleBlocksDrop( blocks ); } @@ -385,7 +383,9 @@ export function MediaPlaceholder( { return null; } - return ; + return ( + + ); }; const renderCancelLink = () => { diff --git a/test/e2e/specs/editor/blocks/image.spec.js b/test/e2e/specs/editor/blocks/image.spec.js index b2195f2c67688..6110a125ff6f7 100644 --- a/test/e2e/specs/editor/blocks/image.spec.js +++ b/test/e2e/specs/editor/blocks/image.spec.js @@ -545,7 +545,7 @@ test.describe( 'Image', () => { dummy.style.left = 0; dummy.draggable = 'true'; dummy.addEventListener( 'dragstart', ( event ) => { - event.dataTransfer.setData( 'default', _html ); + event.dataTransfer.setData( 'text/html', _html ); setTimeout( () => { dummy.remove(); }, 0 );