import type { Editor, Extension, Node, Mark } from '@tiptap/core'; /** Built-in presets. Each preset fixes the allowed nodes/marks + default toolbar + sanitization profile. */ export type RichTextPreset = 'comment' | 'task' | 'email' | 'document'; /** Toolbar layouts. `auto` resolves to the preset's default variant. */ export type ToolbarVariant = 'auto' | 'none' | 'compact' | 'basic' | 'full'; /** Output payload shape emitted by the editor on every change. */ export interface RichTextOutput { /** ProseMirror document as JSON, or `null` when the editor is empty. */ json: object | null; /** Sanitized HTML derived from the document. */ html: string; /** Plain text derived from the document. */ text: string; } /** A variable definition usable by the variable node / picker. */ export interface VariableItem { /** Dotted path, e.g. `contact.firstName`. Stored in the node attrs. */ name: string; /** Human label shown in the picker (defaults to `name`). */ label?: string; } /** A mention candidate returned by the host's search callback. */ export interface MentionItem { id: string; label: string; } /** Fine-grained feature overrides layered on top of a preset. */ export interface RichTextFeatures { /** Enable mentions (host wires the search). */ mentions?: boolean; /** Enable the `{{variable}}` node. */ variables?: boolean; /** Enable the image node. */ image?: boolean; /** Enable table nodes (table, row, cell, header). */ table?: boolean; /** Enable YouTube embed node. */ youtube?: boolean; /** Enable generic iframe embed node (https-only). */ iframe?: boolean; /** Enable callout/admonition blocks. */ callout?: boolean; /** Enable highlight (background color on text). */ highlight?: boolean; /** Enable text alignment (left, center, right, justify). */ textAlign?: boolean; /** Enable code blocks. */ codeBlock?: boolean; /** Character limit (adds CharacterCount). */ characterCount?: number; /** Link behavior overrides. */ link?: boolean | { autolink?: boolean; openOnClick?: boolean; }; } /** Result of an image upload: either a plain URL or an object with file metadata. */ export interface ImageUploadResult { src: string; fileId?: string; } /** Uploads an image file and resolves to its final URL or an object with src + fileId. */ export type ImageUploadHandler = (file: File) => Promise; /** Called when an image upload fails — the host surfaces the error (toast, retry…). */ export type ImageUploadErrorHandler = (error: unknown, file: File) => void; export interface CreateEditorOptions { preset?: RichTextPreset; /** Mount target. Pass `null` to construct now and `editor.mount(el)` later. */ element?: HTMLElement | null; /** Initial content: ProseMirror JSON, an HTML string, or `null`. */ content?: object | string | null; editable?: boolean; placeholder?: string; /** Character limit; adds the CharacterCount extension. */ maxLength?: number; features?: RichTextFeatures; /** Escape hatch — extra extensions appended after the preset's. */ customExtensions?: (Extension | Node | Mark)[]; /** * When provided, the BubbleMenu extension is registered and will position * this element next to the current text selection. */ bubbleMenuElement?: HTMLElement; /** * When provided, pasted/dropped image files are uploaded via this handler and * inserted as image nodes. Requires the image node (preset `document` or * `features.image`). */ imageUpload?: ImageUploadHandler; /** Surface image upload failures (otherwise the pasted image just vanishes). */ onImageUploadError?: ImageUploadErrorHandler; onUpdate?: (editor: Editor) => void; onSelectionUpdate?: (editor: Editor) => void; onFocus?: (editor: Editor) => void; onBlur?: (editor: Editor) => void; onCreate?: (editor: Editor) => void; onDestroy?: () => void; onContentError?: (error: unknown) => void; } export type { Editor } from '@tiptap/core'; //# sourceMappingURL=types.d.ts.map