Skip to content
GitHubDiscord

prosekit/extensions/file

A class that represents a upload task.

Type Parameter

Result

new UploadTask<Result>(options: object): UploadTask<Result>

Creates a new upload task. You can find the upload task by its object URL later using UploadTask.get().

protected done: boolean = false

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

readonly finished: Promise<Result>

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

readonly objectURL: string

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

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

Subscribes to progress updates. Returns a function to unsubscribe.

static delete(objectURL: string): void

Deletes an upload task by its object URL.

static get<Result>(objectURL: string): undefined | UploadTask<Result>

Finds an upload task by its object URL.

event: DragEvent

The event that triggered the drop.

file: File

The file that was dropped.

pos: number

The position of the document where the file was dropped.

view: EditorView

The editor view.


event: ClipboardEvent

The event that triggered the paste.

file: File

The file that was pasted.

view: EditorView

The editor view.


file: File

The file to be uploaded.

onProgress: (progress: UploadProgress) => void

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


An interface representing the upload progress.

loaded: number

total: number

type Uploader<Result> = (options: UploaderOptions) => Promise<Result>

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

Type Parameter

Result

function defineFileDropHandler(handler: FileDropHandler): PlainExtension


function defineFilePasteHandler(handler: FilePasteHandler): PlainExtension