UNPKG

rhino-editor

Version:

A custom element wrapped rich text editor

72 lines (71 loc) 2.69 kB
import { Maybe } from "../types.js"; import type { EditorView } from "@tiptap/pm/view"; import { AttachmentUpload } from "./attachment-upload.js"; export interface AttachmentManagerAttributes { src: string; file?: Maybe<File>; attachmentId?: Maybe<string>; imageId?: Maybe<string>; sgid?: Maybe<string>; contentType?: Maybe<string>; fileName?: Maybe<string>; fileSize?: Maybe<number>; content?: Maybe<string>; caption?: Maybe<string>; url?: Maybe<string>; width?: Maybe<number>; height?: Maybe<number>; previewable?: Maybe<boolean>; } /** * An attachment manager that matches the interface of Trix's attachment manager. * This is what gets built on "rhino-attachment-add" */ export declare class AttachmentManager implements AttachmentManagerAttributes { attributes: AttachmentManagerAttributes; editorView: EditorView; directUpload?: AttachmentUpload; static get previewableRegex(): RegExp; static isPreviewable(str: string): boolean; constructor(obj: AttachmentManagerAttributes, editorView: EditorView); setUploadProgress(progress: number): void; setAttributes(obj: Partial<AttachmentManagerAttributes>): void; handleSuccess(): void; /** * Helper function to set the markup for an attachment. We map a uuid to the "attachmentId" * of the TipTap node to guarantee we're targeting the right one. */ setNodeMarkup(obj: Record<string, unknown>): void; /** * This is an internal ID used for finding newly attached attachments in the TipTap editor. * This is used primarily for direct upload purposes. * This generally won't exist when a node is recreated from you database. */ get attachmentId(): Maybe<string>; /** * This is an internal ID used for finding newly attached images in the TipTap editor. * This is used primarily for direct upload purposes. * This generally won't exist when a node is recreated from you database. */ get imageId(): Maybe<string>; /** * `src` (when present) always maps to a URL.createObjectURL. */ get src(): string; set src(val: string); get sgid(): Maybe<string>; get file(): Maybe<File>; get contentType(): string | undefined; get fileName(): string | undefined; get fileSize(): number | undefined; /** * This field is populated by the old Trix custom attachment API and denotes if we're using a custom * attachment. */ get content(): Maybe<string>; set content(val: Maybe<string>); get height(): Maybe<number>; get width(): Maybe<number>; get isPreviewable(): boolean; get caption(): string; }