Skip to content

Commit

Permalink
Remove html transfer
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed Nov 26, 2024
1 parent 48fd68f commit 732cca8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@
* WordPress dependencies
*/
import { Draggable } from '@wordpress/components';
import {
createBlock,
serialize,
store as blocksStore,
} from '@wordpress/blocks';
import { createBlock, store as blocksStore } from '@wordpress/blocks';
import { useDispatch, useSelect } from '@wordpress/data';

/**
Expand All @@ -24,11 +20,6 @@ const InserterDraggableBlocks = ( {
children,
pattern,
} ) => {
const transferData = {
type: 'inserter',
blocks,
};

const blockTypeIcon = useSelect(
( select ) => {
const { getBlockType } = select( blocksStore );
Expand All @@ -51,21 +42,18 @@ const InserterDraggableBlocks = ( {
} );
}

const parsedBlocks =
pattern?.type === INSERTER_PATTERN_TYPES.user &&
pattern?.syncStatus !== 'unsynced'
? [ createBlock( 'core/block', { ref: pattern.id } ) ]
: blocks;

return (
<Draggable
__experimentalTransferDataType="wp-blocks"
transferData={ transferData }
onDragStart={ ( event ) => {
transferData={ { type: 'inserter', blocks: parsedBlocks } }
onDragStart={ () => {
startDragging();
const parsedBlocks =
pattern?.type === INSERTER_PATTERN_TYPES.user &&
pattern?.syncStatus !== 'unsynced'
? [ createBlock( 'core/block', { ref: pattern.id } ) ]
: blocks;
event.dataTransfer.setData(
'text/html',
serialize( parsedBlocks )
);
} }
onDragEnd={ () => {
stopDragging();
Expand Down
14 changes: 7 additions & 7 deletions packages/block-editor/src/components/media-placeholder/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import { __ } from '@wordpress/i18n';
import { useState, useEffect } from '@wordpress/element';
import { useSelect } from '@wordpress/data';
import { keyboardReturn } from '@wordpress/icons';
import { pasteHandler } from '@wordpress/blocks';
import deprecated from '@wordpress/deprecated';

/**
Expand All @@ -29,6 +28,7 @@ import MediaUpload from '../media-upload';
import MediaUploadCheck from '../media-upload/check';
import URLPopover from '../url-popover';
import { store as blockEditorStore } from '../../store';
import { parseDropEvent } from '../use-on-block-drop';

const noop = () => {};

Expand Down Expand Up @@ -292,9 +292,11 @@ export function MediaPlaceholder( {
}
}

async function onHTMLDrop( HTML ) {
const blocks = pasteHandler( { HTML } );
return await handleBlocksDrop( blocks );
function onDrop( event ) {
const { blocks } = parseDropEvent( event );
if ( blocks ) {
handleBlocksDrop( blocks );
}
}

const onUpload = ( event ) => {
Expand Down Expand Up @@ -383,9 +385,7 @@ export function MediaPlaceholder( {
return null;
}

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

const renderCancelLink = () => {
Expand Down

0 comments on commit 732cca8

Please sign in to comment.