Skip to content

prosekit/extensions/file

UploadTask

A class that represents a upload task.

constructor

new UploadTask<Result>(options: { file: File; uploader: Uploader<Result> }): UploadTask<Result>

done

A boolean indicating whether the upload is complete (either successfully or with an error).

Type: boolean

finished

A promise that fulfills once the upload is complete, or rejects if an error occurs.

Type: Promise<Result>

objectURL

An object URL representing the file to be uploaded. This URL will be revoked once the upload is complete successfully.

Type: string

subscribeProgress

ts
const subscribeProgress: (callback: (progress: UploadProgress) => void) => VoidFunction

delete

ts
const delete: (objectURL: string) => void

get

ts
const get: <Result>(objectURL: string) => undefined | UploadTask<Result>

FileDropHandlerOptions

event

The event that triggered the drop.

Type: DragEvent

file

The file that was dropped.

Type: File

pos

The position of the document where the file was dropped.

Type: number

view

The editor view.

Type: EditorView

FilePasteHandlerOptions

event

The event that triggered the paste.

Type: ClipboardEvent

file

The file that was pasted.

Type: File

view

The editor view.

Type: EditorView

UploaderOptions

file

The file to be uploaded.

Type: File

onProgress

A callback function that should be called with the upload progress updates.

Type: (progress: UploadProgress) => void

UploadProgress

An interface representing the upload progress.

loaded

Type: number

total

Type: number

Uploader

The implementation of the actual upload function. You need to implement this function to upload files to your desired destination.

Type: (options: UploaderOptions) => Promise<Result>

defineFileDropHandler

ts
function defineFileDropHandler(handler: FileDropHandler): PlainExtension

defineFilePasteHandler

ts
function defineFilePasteHandler(handler: FilePasteHandler): PlainExtension