prosekit/extensions/file
UploadTask
A class that represents a upload task.
constructor
new UploadTask<Result>(options: { file: File; uploader: Uploader<Result> }): UploadTask<Result>
done: boolean
A boolean indicating whether the upload is complete (either successfully or with an error).
finished: Promise<Result>
A promise that fulfills once the upload is complete, or rejects if an error occurs.
objectURL: string
An object URL representing the file to be uploaded. This URL will be revoked once the upload is complete successfully.
subscribeProgress
Subscribes to progress updates. Returns a function to unsubscribe.
tsconst subscribeProgress: (callback: (progress: UploadProgress) => void) => VoidFunction
delete
Deletes an upload task by its object URL.
tsconst delete: (objectURL: string) => void
get
Finds an upload task by its object URL.
tsconst get: <Result>(objectURL: string) => undefined | UploadTask<Result>
FileDropHandlerOptions
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.
FilePasteHandlerOptions
event: ClipboardEvent
The event that triggered the paste.
file: File
The file that was pasted.
view: EditorView
The editor view.
UploaderOptions
file: File
The file to be uploaded.
onProgress: (progress: UploadProgress) => void
A callback function that should be called with the upload progress updates.
UploadProgress
An interface representing the upload progress.
loaded: number
total: 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
function defineFileDropHandler(handler: FileDropHandler): PlainExtension
defineFilePasteHandler
function defineFilePasteHandler(handler: FilePasteHandler): PlainExtension