nuxt-tiptap-editor
Version:
Essentials to Quickly Integrate TipTap Editor into your Nuxt App
27 lines (26 loc) • 1.35 kB
TypeScript
import type { Node, Schema } from 'prosemirror-model';
import { Plugin, PluginKey } from 'prosemirror-state';
import type { EditorView } from 'prosemirror-view';
import type { ImageUploaderPluginOptions } from './imageUpload.js';
export interface ImageUploaderStorage {
cache: Map<string, File | string>;
getFileCache: (id: string) => File | string | undefined;
}
export declare const imageUploaderPluginKey: PluginKey<any>;
export interface UploaderContext {
options: ImageUploaderPluginOptions;
storage: ImageUploaderStorage;
}
/**
* Build a placeholder node for the given uploadId. Used by the uploadImage
* command, which mutates the provided transaction directly rather than
* calling view.dispatch.
*/
export declare function createPlaceholderNode(ctx: UploaderContext, schema: Schema, uploadId: string, attrs?: Record<string, unknown>): Node;
/**
* Run the upload for an already-inserted placeholder identified by id.
* Used by the uploadImage command's deferred follow-up.
*/
export declare function uploadAndReplaceById(ctx: UploaderContext, view: EditorView, id: string, fileOrUrl: File | string): Promise<void>;
export declare function imageUploader(ctx: UploaderContext): Plugin;
export declare function insertPlaceholderAndUpload(ctx: UploaderContext, view: EditorView, fileOrUrl: File | string, at: number): void;