UNPKG

reactjs-tiptap-editor

Version:

A modern WYSIWYG rich text editor based on tiptap and shadcn ui for React

362 lines (308 loc) 8.95 kB
import { Editor } from '@tiptap/react'; import { Extension } from '@tiptap/core'; import { Node as Node_2 } from '@tiptap/core'; import { TaskItemOptions } from '@tiptap/extension-task-item'; import { TaskListOptions as TaskListOptions_2 } from '@tiptap/extension-task-list'; /** * Represents the ButtonView function. */ declare type ButtonView<T = any> = (options: ButtonViewParams<T>) => ButtonViewReturn | ButtonViewReturn[]; /** * Represents the parameters for the ButtonView function. */ declare interface ButtonViewParams<T = any> { /** Editor object */ editor: Editor; /** Extension object */ extension: Extension<T>; /** Translation function */ t: (path: string) => string; } /** * Represents the return value for the ButtonView component. */ declare interface ButtonViewReturn { /** Component */ component: unknown; /** Component props */ componentProps: ButtonViewReturnComponentProps; /** Component slots */ componentSlots?: ButtonViewReturnComponentSlots; } /** * Represents the props for the ButtonView component. */ declare interface ButtonViewReturnComponentProps { /** Method triggered when action is performed */ action?: (value?: any) => void; /** Whether it is in the active state */ isActive?: () => boolean; /** Button icon */ icon?: any; /** Text displayed on hover */ tooltip?: string; [x: string]: any; } /** * Represents the slots for the ButtonView component. */ declare interface ButtonViewReturnComponentSlots { /** Dialog slot */ dialog: () => any; [x: string]: () => any; } /** * Represents the general options for Tiptap extensions. */ declare interface GeneralOptions<T> { /** Enabled divider */ divider: boolean; /** Enabled spacer */ spacer: boolean; /** Button view function */ button: ButtonView<T>; /** Show on Toolbar */ toolbar?: boolean; } export declare const TaskList: Node_2<TaskListOptions, any>; /** * Represents the interface for task list options, extending TiptapTaskListOptions and GeneralOptions. */ export declare interface TaskListOptions extends TaskListOptions_2, GeneralOptions<TaskListOptions> { /** options for task items */ taskItem: Partial<TaskItemOptions>; } export { } declare module '@tiptap/core' { interface Commands<ReturnType> { attachment: { setAttachment: (attrs?: unknown) => ReturnType; }; } } declare module '@tiptap/core' { interface Commands<ReturnType> { codeView: { /** * Toggle code view mode */ toggleCodeView: () => ReturnType; }; } } declare module '@tiptap/core' { interface Commands<ReturnType> { setCodeBlock: { setCodeBlock: (options?: any) => ReturnType; }; } } declare module '@tiptap/core' { interface Commands<ReturnType> { drawer: { setDrawer: (options: any, replace?: any) => ReturnType; setAlignImageDrawer: (align: 'left' | 'center' | 'right') => ReturnType; }; } } declare module '@tiptap/core' { interface Commands<ReturnType> { emoji: { setEmoji: (emoji: { name: string; emoji: string; }) => ReturnType; }; } } declare module '@tiptap/core' { interface Commands<ReturnType> { excalidraw: { setExcalidraw: (attrs?: IExcalidrawAttrs) => ReturnType; }; } } declare module '@tiptap/core' { interface Commands<ReturnType> { exportWord: { exportToWord: () => ReturnType; }; } } declare module '@tiptap/core' { interface Commands<ReturnType> { fontSize: { /** * Set the text font size. ex: "12px", "2em", or "small". Must be a valid * CSS font-size * (https://developer.mozilla.org/en-US/docs/Web/CSS/font-size). */ setFontSize: (fontSize: string) => ReturnType; /** * Unset the font size */ unsetFontSize: () => ReturnType; }; } } declare module '@tiptap/core' { interface Commands<ReturnType> { painter: { setPainter: (marks: Mark[]) => ReturnType; }; } } declare module '@tiptap/core' { interface Commands<ReturnType> { iframe: { /** * Add an iframe */ setIframe: (options: { src: string; service: string; }) => ReturnType; }; } } declare module '@tiptap/core' { interface Commands<ReturnType> { imageUpload: { /** * Add an image */ setImageInline: (options: Partial<SetImageAttrsOptions>) => ReturnType; /** * Update an image */ updateImage: (options: Partial<SetImageAttrsOptions>) => ReturnType; /** * Set image alignment */ setAlignImage: (align: 'left' | 'center' | 'right') => ReturnType; }; } } declare module '@tiptap/core' { interface Commands<ReturnType> { imageGifUpload: { /** * Add an image gif */ setImageGif: (options: Partial<SetImageAttrsOptions>) => ReturnType; /** * Update an image gif */ updateImageGif: (options: Partial<SetImageAttrsOptions>) => ReturnType; /** * Set image alignment */ setAlignImageGif: (align: 'left' | 'center' | 'right') => ReturnType; }; } } declare module '@tiptap/core' { interface Commands<ReturnType> { indent: { /** * Set the indent attribute */ indent: () => ReturnType; /** * Set the outdent attribute */ outdent: () => ReturnType; }; } } declare module '@tiptap/core' { interface Commands<ReturnType> { katex: { setKatex: (arg?: IKatexAttrs) => ReturnType; }; } } declare module '@tiptap/core' { interface Commands<ReturnType> { lineHeight: { setLineHeight: (lineHeight: string) => ReturnType; unsetLineHeight: () => ReturnType; }; } } declare module '@tiptap/core' { interface Commands<ReturnType> { mermaid: { setMermaid: (options: any, replace?: any) => ReturnType; setAlignImageMermaid: (align: 'left' | 'center' | 'right') => ReturnType; }; } } declare module '@tiptap/core' { interface Commands<ReturnType> { columns: { insertColumns: (attrs?: { cols: number; }) => ReturnType; addColBefore: () => ReturnType; addColAfter: () => ReturnType; deleteCol: () => ReturnType; }; } } declare module '@tiptap/core' { interface Commands<ReturnType> { search: { setSearchTerm: (searchTerm: string) => ReturnType; setReplaceTerm: (replaceTerm: string) => ReturnType; replace: () => ReturnType; replaceAll: () => ReturnType; goToPrevSearchResult: () => void; goToNextSearchResult: () => void; setCaseSensitive: (caseSensitive: boolean) => ReturnType; }; } } declare module '@tiptap/core' { interface Commands<ReturnType> { tableOfContents: { setTableOfContents: () => ReturnType; removeTableOfContents: () => ReturnType; }; } } declare module '@tiptap/core' { interface Commands<ReturnType> { twitter: { /** * Insert a tweet * @param options The tweet attributes * @example editor.commands.setTweet({ src: 'https://x.com/seanpk/status/1800145949580517852' }) */ setTweet: (options: SetTweetOptions) => ReturnType; updateTweet: (options: SetTweetOptions) => ReturnType; }; } } declare module '@tiptap/core' { interface Commands<ReturnType> { video: { /** * Add an video */ setVideo: (options: Partial<SetVideoOptions>) => ReturnType; /** * Update an video */ updateVideo: (options: Partial<SetVideoOptions>) => ReturnType; }; } } declare module '@tiptap/core' { interface Commands<ReturnType> { tableCellBackground: { setTableCellBackground: (color: string) => ReturnType; unsetTableCellBackground: () => ReturnType; }; } }