Vizel API / core/src / createVizelImageUploadWithFileHandler
Function: createVizelImageUploadWithFileHandler()
ts
function createVizelImageUploadWithFileHandler(options): (
| Extension<any, any>
| Extension<Omit<FileHandlePluginOptions, "editor" | "key">, any>
| Node<ImageOptions, any>
| Node<VizelResizableImageOptions, any>)[];Defined in: packages/core/src/extensions/image.ts:213
Beta
Create Image extension with upload support using @tiptap/extension-file-handler.
This is an alternative to createVizelImageUploadExtensions that routes drop/paste through the official Tiptap FileHandler extension. Use one or the other — never both, since both register an extension named imageUpload.
The two image-upload entry points may be unified in a future minor release; see the issue tracker for the consolidation plan.
Parameters
| Parameter | Type |
|---|---|
options | VizelImageUploadWithFileHandlerOptions |
Returns
( | Extension<any, any> | Extension<Omit<FileHandlePluginOptions, "editor" | "key">, any> | Node<ImageOptions, any> | Node<VizelResizableImageOptions, any>)[]
Example
ts
const extensions = [
...createVizelExtensions(),
...createImageUploadWithFileHandler({
upload: {
onUpload: async (file) => {
const formData = new FormData();
formData.append("image", file);
const res = await fetch("/api/upload", { method: "POST", body: formData });
return (await res.json()).url;
},
},
}),
];