@theredhead — Frontend Library - v1.0.0
    Preparing search index...

    Type Alias RichTextImageHandler

    RichTextImageHandler: (file: File) => Promise<string>

    Callback that handles an image file and returns a URL string.

    When provided to the rich-text editor's imageHandler input, this function is called when the user pastes an image from the clipboard. The returned URL is inserted as an <img> (HTML mode) or ![alt](url) (Markdown mode).

    Typical implementations upload the file to a CDN or object store and return the resulting public URL.

    Type Declaration

      • (file: File): Promise<string>
      • Parameters

        • file: File

        Returns Promise<string>

    const uploadImage: RichTextImageHandler = async (file) => {
    const form = new FormData();
    form.append('image', file);
    const res = await fetch('/api/upload', { method: 'POST', body: form });
    const { url } = await res.json();
    return url;
    };