Skip to content

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

ParameterType
optionsVizelImageUploadWithFileHandlerOptions

Returns

( | Extension&lt;any, any&gt; | Extension&lt;Omit&lt;FileHandlePluginOptions, "editor" | "key"&gt;, any&gt; | Node&lt;ImageOptions, any&gt; | Node&lt;VizelResizableImageOptions, any&gt;)[]

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;
      },
    },
  }),
];

Released under the MIT License.