Skip to content
GitHubDiscord

prosekit/extensions/image

src?: null | string

width?: null | number

height?: null | number


Options for the ImageUploadErrorHandler callback.

file: File

The file that was uploaded.

error: unknown

The error that occurred during the upload.

uploadTask: UploadTask<string>

The upload task that was used to upload the file.


Options for defineImageUploadHandler.

uploader: Uploader<string>

The uploader used to upload the file. It should return a promise that resolves to the URL of the uploaded image.

canPaste?: ImageCanPastePredicate

A predicate to determine if the pasted file should be uploaded and inserted as an image. If not provided, it defaults to only allowing paste of files with a content type starting with image/.

canDrop?: ImageCanDropPredicate

A predicate to determine if the dropped file should be uploaded and inserted as an image. If not provided, it defaults to only allowing drop of files with a content type starting with image/.

onError?: ImageUploadErrorHandler

A handler to be called when an error occurs during the upload. If not provided, it defaults to logging the error to the console.

type ImageCanPastePredicate = (options: FilePasteHandlerOptions) => boolean

A predicate to determine if the pasted file should be uploaded and inserted as an image.


type ImageCanDropPredicate = (options: FileDropHandlerOptions) => boolean

A predicate to determine if the dropped file should be uploaded and inserted as an image.


type ImageUploadErrorHandler = (options: ImageUploadErrorHandlerOptions) => void

A handler to be called when an error occurs during the upload.

function insertImage(attrs?: ImageAttrs): Command

Returns a command that inserts an image node with the given attributes at the current selection position.


function defineImageUploadHandler(options: ImageUploadHandlerOptions): PlainExtension

Returns an extension that handles image file uploads when pasting or dropping images into the editor.


function defineImage(): ImageExtension