UNPKG

@mantine/tiptap

Version:

Rich text editor based on tiptap

142 lines (141 loc) 7.24 kB
import { Editor } from '@tiptap/react'; import { BoxProps, ElementProps, Factory, StylesApiProps } from '@mantine/core'; import { RichTextEditorLabels } from './labels'; import { RichTextEditorContent, type RichTextEditorContentProps } from './RichTextEditorContent/RichTextEditorContent'; import * as controls from './RichTextEditorControl'; import { RichTextEditorControl, type RichTextEditorControlProps } from './RichTextEditorControl/RichTextEditorControl'; import type { RichTextEditorColorControlProps } from './RichTextEditorControl/RichTextEditorColorControl'; import type { RichTextEditorLinkControlProps } from './RichTextEditorControl/RichTextEditorLinkControl'; import { RichTextEditorSourceCodeControl, type RichTextEditorSourceCodeControlProps } from './RichTextEditorControl/RichTextEditorSourceCodeControl'; import { RichTextEditorControlsGroup, type RichTextEditorControlsGroupProps } from './RichTextEditorControlsGroup/RichTextEditorControlsGroup'; import { RichTextEditorToolbar, type RichTextEditorToolbarProps } from './RichTextEditorToolbar/RichTextEditorToolbar'; export type RichTextEditorVariant = 'default' | 'subtle'; export type RichTextEditorStylesNames = 'linkEditorSave' | 'linkEditorDropdown' | 'root' | 'content' | 'Typography' | 'control' | 'controlIcon' | 'controlsGroup' | 'toolbar' | 'linkEditor' | 'linkEditorInput' | 'linkEditorExternalControl'; export interface RichTextEditorProps extends BoxProps, StylesApiProps<RichTextEditorFactory>, ElementProps<'div'> { /** Tiptap editor instance */ editor: Editor | null; /** Determines whether code highlight styles should be added @default true */ withCodeHighlightStyles?: boolean; /** Determines whether typography styles should be added @default true */ withTypographyStyles?: boolean; /** Called if `RichTextEditor.SourceCode` clicked. */ onSourceCodeTextSwitch?: (isSourceCodeModeActive: boolean) => void; /** Labels that are used in controls */ labels?: Partial<RichTextEditorLabels>; /** Child editor components */ children: React.ReactNode; } export type RichTextEditorFactory = Factory<{ props: RichTextEditorProps; ref: HTMLDivElement; stylesNames: RichTextEditorStylesNames; variant: RichTextEditorVariant; staticComponents: { Content: typeof RichTextEditorContent; Control: typeof RichTextEditorControl; Toolbar: typeof RichTextEditorToolbar; ControlsGroup: typeof RichTextEditorControlsGroup; Bold: typeof controls.BoldControl; Italic: typeof controls.ItalicControl; Strikethrough: typeof controls.StrikeThroughControl; Underline: typeof controls.UnderlineControl; ClearFormatting: typeof controls.ClearFormattingControl; H1: typeof controls.H1Control; H2: typeof controls.H2Control; H3: typeof controls.H3Control; H4: typeof controls.H4Control; H5: typeof controls.H5Control; H6: typeof controls.H6Control; BulletList: typeof controls.BulletListControl; OrderedList: typeof controls.OrderedListControl; Link: typeof controls.RichTextEditorLinkControl; Unlink: typeof controls.UnlinkControl; Blockquote: typeof controls.BlockquoteControl; AlignLeft: typeof controls.AlignLeftControl; AlignRight: typeof controls.AlignRightControl; AlignCenter: typeof controls.AlignCenterControl; AlignJustify: typeof controls.AlignJustifyControl; Superscript: typeof controls.SuperscriptControl; Subscript: typeof controls.SubscriptControl; Code: typeof controls.CodeControl; CodeBlock: typeof controls.CodeBlockControl; ColorPicker: typeof controls.RichTextEditorColorPickerControl; Color: typeof controls.RichTextEditorColorControl; Highlight: typeof controls.HighlightControl; Hr: typeof controls.HrControl; UnsetColor: typeof controls.UnsetColorControl; Undo: typeof controls.UndoControl; Redo: typeof controls.RedoControl; TaskList: typeof controls.TaskListControl; TaskListSink: typeof controls.TaskListSinkControl; TaskListLift: typeof controls.TaskListLiftControl; SourceCode: typeof RichTextEditorSourceCodeControl; }; }>; export declare const RichTextEditor: import("@mantine/core").MantineComponent<{ props: RichTextEditorProps; ref: HTMLDivElement; stylesNames: RichTextEditorStylesNames; variant: RichTextEditorVariant; staticComponents: { Content: typeof RichTextEditorContent; Control: typeof RichTextEditorControl; Toolbar: typeof RichTextEditorToolbar; ControlsGroup: typeof RichTextEditorControlsGroup; Bold: typeof controls.BoldControl; Italic: typeof controls.ItalicControl; Strikethrough: typeof controls.StrikeThroughControl; Underline: typeof controls.UnderlineControl; ClearFormatting: typeof controls.ClearFormattingControl; H1: typeof controls.H1Control; H2: typeof controls.H2Control; H3: typeof controls.H3Control; H4: typeof controls.H4Control; H5: typeof controls.H5Control; H6: typeof controls.H6Control; BulletList: typeof controls.BulletListControl; OrderedList: typeof controls.OrderedListControl; Link: typeof controls.RichTextEditorLinkControl; Unlink: typeof controls.UnlinkControl; Blockquote: typeof controls.BlockquoteControl; AlignLeft: typeof controls.AlignLeftControl; AlignRight: typeof controls.AlignRightControl; AlignCenter: typeof controls.AlignCenterControl; AlignJustify: typeof controls.AlignJustifyControl; Superscript: typeof controls.SuperscriptControl; Subscript: typeof controls.SubscriptControl; Code: typeof controls.CodeControl; CodeBlock: typeof controls.CodeBlockControl; ColorPicker: typeof controls.RichTextEditorColorPickerControl; Color: typeof controls.RichTextEditorColorControl; Highlight: typeof controls.HighlightControl; Hr: typeof controls.HrControl; UnsetColor: typeof controls.UnsetColorControl; Undo: typeof controls.UndoControl; Redo: typeof controls.RedoControl; TaskList: typeof controls.TaskListControl; TaskListSink: typeof controls.TaskListSinkControl; TaskListLift: typeof controls.TaskListLiftControl; SourceCode: typeof RichTextEditorSourceCodeControl; }; }>; export declare namespace RichTextEditor { type Props = RichTextEditorProps; type StylesNames = RichTextEditorStylesNames; type Factory = RichTextEditorFactory; namespace Toolbar { type Props = RichTextEditorToolbarProps; } namespace Control { type Props = RichTextEditorControlProps; type ColorProps = RichTextEditorColorControlProps; type LinkProps = RichTextEditorLinkControlProps; type SourceCodeProps = RichTextEditorSourceCodeControlProps; } namespace Content { type Props = RichTextEditorContentProps; } namespace ControlsGroup { type Props = RichTextEditorControlsGroupProps; } }