prosekit/extensions/file
Classes
Section titled “Classes”UploadTask
Section titled “UploadTask”A class that represents a upload task.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”-
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().
Properties
Section titled “Properties”-
readonly objectURL:string -
An object URL representing the file to be uploaded. This URL will be revoked once the upload is complete successfully.
-
protected done:boolean=false -
A boolean indicating whether the upload is complete (either successfully or with an error).
-
protected result:Result|undefined -
If the upload is complete successfully, this will be the result of the upload.
-
If the upload is complete with an error, this will be the error that occurred.
-
A promise that fulfills once the upload is complete, or rejects if an error occurs.
Methods
Section titled “Methods”-
subscribeProgress(callback: (progress:UploadProgress) =>void):VoidFunction -
Subscribes to progress updates. Returns a function to unsubscribe.
-
static get<Result>(objectURL:string):UploadTask<Result> |undefined -
Finds an upload task from the global store by its object URL.
-
static delete(objectURL:string):void -
Deletes an upload task from the global store by its object URL.
Interfaces
Section titled “Interfaces”FileDropHandlerOptions
Section titled “FileDropHandlerOptions”Properties
Section titled “Properties”-
The editor view.
-
pos:number -
The position of the document where the file was dropped.
FilePasteHandlerOptions
Section titled “FilePasteHandlerOptions”Properties
Section titled “Properties”-
The editor view.
-
The event that triggered the paste.
UploadProgress
Section titled “UploadProgress”An interface representing the upload progress.
Properties
Section titled “Properties”-
loaded:number
-
total:number
UploaderOptions
Section titled “UploaderOptions”Properties
Section titled “Properties”-
onProgress: (progress:UploadProgress) =>void -
A callback function that should be called with the upload progress updates.
Type Aliases
Section titled “Type Aliases”FileDropHandler()
Section titled “FileDropHandler()”-
type FileDropHandler = (options:FileDropHandlerOptions) =>boolean|void -
A function that handles one of the files in a drop event.
Returns
trueif the file was handled and thus should not be handled by other handlers.
FilePasteHandler()
Section titled “FilePasteHandler()”-
type FilePasteHandler = (options:FilePasteHandlerOptions) =>boolean|void -
A function that handles one of the files in a paste event.
Returns
trueif the file was handled and thus should not be handled by other handlers.
Uploader()
Section titled “Uploader()”-
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.
Functions
Section titled “Functions”defineFileDropHandler()
Section titled “defineFileDropHandler()”-
function defineFileDropHandler(handler:FileDropHandler):PlainExtension
defineFilePasteHandler()
Section titled “defineFilePasteHandler()”-
function defineFilePasteHandler(handler:FilePasteHandler):PlainExtension