Accept files dropped on the document
import { defineFilePond } from 'filepond';
import { locale } from 'filepond/locales/en-gb.js';
import { DragDropSource } from 'filepond/extensions/drag-drop-source.js';
defineFilePond({
locale,
extensions: [
// Add the DragDropSource extension
DragDropSource
]
})
Configuration
The DragDropSource extension accepts an option object of type DragDropSourceOptions which defines the properties below.
shouldHandleDrop
Determines if a drag event is handled. Defaults to () => true
shouldHandleDrop?: (e: DragEvent) => boolean
Only accept file drops on a specific element
This only accepts the dropped file(s) when they're dropped on a specific element.
<p
class="drop-area"
style="width: 200px; height: 100px; border: 1px solid silver"
>
Drop files here
</p>
<file-pond></file-pond>
<script type="module">
import { defineFilePond } from "filepond";
import { locale } from "filepond/locales/en-gb.js";
import { DragDropSource } from "filepond/extensions/drag-drop-source.js";
defineFilePond({
// The locale to use
locale,
// The extensions to load
extensions: [
// Add the DragDropSource extension
[
DragDropSource,
{
// Filter drop targets
shouldHandleDrop: (e) => {
return e.target.matches(".drop-area");
},
},
],
],
});
</script>