# File Handler
Paste and drop files into the document as image nodes.
## Installation
```bash
npx shadcn@latest add litingyes/blocove/rich-text-editor-file-handler
```
> Typography requires [shadcn/typeset](https://ui.shadcn.com/docs/typeset). Copy `typeset.css` next to your main stylesheet, import it after Tailwind and add the `.typeset-docs` preset.
Files are inserted as image nodes, so install the image node too. The default reads the file into a data URL, which keeps the document self-contained; pass `onFile` to upload the file first and insert the returned URL instead.
## Usage
### Upload the file yourself
```tsx
import { EditorFileHandler } from "@/components/blocove/rich-text-editor/file-handler"
async function upload(file: File) {
const body = new FormData()
body.append("file", file)
const response = await fetch("/api/upload", { method: "POST", body })
const { url } = await response.json()
return url
}
export function UploadEditor() {
return (
)
}
```
## API Reference
### EditorFileHandler
Registers the paste and drop handler for files.
| Prop | Type | Default |
| --- | --- | --- |
| `allowedMimeTypes` | `string[]` | `PNG, JPEG, GIF and WebP` |
| `onFile` | `(file: File) => Promise | string` | `Reads the file as a data URL` |
## Registry dependencies
- `litingyes/blocove/rich-text-editor`
- `litingyes/blocove/rich-text-editor-extension`
- `litingyes/blocove/rich-text-editor-image`
Namespace: `npx shadcn@latest add @blocove/rich-text-editor-file-handler`