diff --git a/.changeset/serious-spoons-collect.md b/.changeset/serious-spoons-collect.md new file mode 100644 index 0000000000..e8fa18af75 --- /dev/null +++ b/.changeset/serious-spoons-collect.md @@ -0,0 +1,5 @@ +--- +'@udecode/plate-media': patch +--- + +Fix can't drop diff --git a/packages/media/src/react/placeholder/PlaceholderPlugin.tsx b/packages/media/src/react/placeholder/PlaceholderPlugin.tsx index a8f73cd7f3..1df999168a 100644 --- a/packages/media/src/react/placeholder/PlaceholderPlugin.tsx +++ b/packages/media/src/react/placeholder/PlaceholderPlugin.tsx @@ -3,6 +3,7 @@ import { bindFirst, getAncestorNode, getNodeString, + removeNodes, } from '@udecode/plate-common'; import { findEventRange, toTPlatePlugin } from '@udecode/plate-common/react'; @@ -117,6 +118,7 @@ export const PlaceholderPlugin = toTPlatePlugin< handlers: { onDrop: ({ editor, event, tf }) => { // using DnD plugin by default + if (!getOption('disabledDndPlugin')) return; const { files } = event.dataTransfer; @@ -126,8 +128,6 @@ export const PlaceholderPlugin = toTPlatePlugin< event.preventDefault(); event.stopPropagation(); - if (!getOption('disabledDndPlugin')) return; - /** * When we drop a file, the selection won't move automatically to the * drop location. Find the location from the event and upload the files @@ -156,6 +156,7 @@ export const PlaceholderPlugin = toTPlatePlugin< const [node, path] = ancestor; if (getNodeString(node).length === 0) { + removeNodes(editor, { at: path }); tf.insert.media(files, path); inserted = true; }