Skip to content

Commit

Permalink
Revert "Fix media placeholder to only activate for media objects. (#6…
Browse files Browse the repository at this point in the history
…6986)"

This reverts commit 2e4b8d8.
  • Loading branch information
ellatrix committed Nov 26, 2024
1 parent 8c34d91 commit dc20d69
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down Expand Up @@ -72,7 +63,7 @@ const InserterDraggableBlocks = ( {
? [ createBlock( 'core/block', { ref: pattern.id } ) ]
: blocks;
event.dataTransfer.setData(
blocksContainMedia ? 'default' : 'text/html',
'text/html',
serialize( parsedBlocks )
);
} }
Expand Down
10 changes: 5 additions & 5 deletions packages/block-editor/src/components/media-placeholder/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}

Expand Down Expand Up @@ -385,7 +383,9 @@ export function MediaPlaceholder( {
return null;
}

return <DropZone onFilesDrop={ onFilesUpload } onDrop={ onDrop } />;
return (
<DropZone onFilesDrop={ onFilesUpload } onHTMLDrop={ onHTMLDrop } />
);
};

const renderCancelLink = () => {
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/specs/editor/blocks/image.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down

0 comments on commit dc20d69

Please sign in to comment.