Quick start
ImportuseEditorImage, add the returned extension to your editor, register
imageSlashCommand, and render BubbleMenu.ImageDefault for inline editing.
uploadImage receives a File and must resolve with { url }. The returned
URL is written to the image node once the promise resolves.
See Image Upload API for the hook,
types, slash command, and editor commands exposed by this plugin.
How image upload works
The image upload plugin combines animage node extension with a ProseMirror
file-handler plugin:
useEditorImage({ uploadImage })creates the extension and keeps the latest upload handler wired in.- Paste and drop events are intercepted when the first file is an image.
editor.commands.uploadImage()opens a file picker forimage/*.- All entry points run the same upload flow: insert a temporary blob URL,
await
uploadImage(file), then swap the node to the final hosted URL.
uploadImage throws, the temporary image node is removed and the error is
logged, which keeps failed uploads from lingering in the document.
Using EmailEditor
EmailEditor wraps the same extension behind a single prop. Use this when you
don’t need direct access to the extension or slash command list:
onUploadImage is present, EmailEditor enables the same upload flow for
paste, drop, and image insertion.
Bubble menus and slash commands
When pairingBubbleMenu.ImageDefault with the default BubbleMenu, pass
hideWhenActiveNodes={['image']} so the text menu steps aside when an image
is focused.
/, add imageSlashCommand to the slash command
items:
Upload triggers
Once the extension is registered, three input paths upload automatically:- Paste — paste an image from the clipboard
- Drop — drag an image file onto the editor
- Slash command — type
/and pick Image (fromimageSlashCommand)
uploadImage
runs, and the node swaps to the resolved URL on success.
Programmatic insertion
The extension adds two editor commands:uploadImage() opens a file picker and runs the upload flow. setImage()
inserts an image node directly, which is useful when you already have a URL.
Available setImage attributes: src, alt, width, height,
alignment ('left' | 'center' | 'right'), and href (wraps the image in a
link on export).
Error handling
IfuploadImage throws, the plugin removes the temporary node for you and
logs the failure via console.error. Handle the error inside your own
function when you need custom UI or telemetry:
Examples
See image upload in action with a runnable example:Image Upload
Paste, drop, and slash-command image upload with a stubbed uploader.