import React, { useCallback, useState } from 'react'; import { useDropzone } from 'react-dropzone'; interface FileEmbedderProps { handleEmbed: (acceptedFiles: File[]) => void; } export const FileEmbedder: React.FC = ({ handleEmbed }) => { const [isDragActive, setIsDragActive] = useState(false); const onDrop = useCallback( (acceptedFiles: File[]) => { handleEmbed(acceptedFiles); setIsDragActive(false); }, [handleEmbed], ); const { acceptedFiles, getRootProps, getInputProps, isDragReject } = useDropzone({ onDrop, accept: { 'application/pdf': ['.pdf'], 'text/plain': ['.txt', '.md'], }, onDragEnter: () => setIsDragActive(true), onDragLeave: () => setIsDragActive(false), }); const acceptedFileItems = acceptedFiles.map((file: any) => (
  • {file.name} - {file.size} bytes
  • )); return ( <>
    {isDragActive ? (

    Drop the files here...

    ) : (

    Click or drag and drop files here (PDF, MD, TXT)

    )}
    ); };