From 7f794d751ba64036feaf328061da2bbcc69a59c1 Mon Sep 17 00:00:00 2001 From: Aadarsha Acharya Date: Thu, 8 Dec 2022 06:23:45 +0545 Subject: [PATCH] [@mantine/tiptap]: add missing ref type for TextEditor static components --- src/mantine-tiptap/src/RichTextEditor.tsx | 45 ++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/src/mantine-tiptap/src/RichTextEditor.tsx b/src/mantine-tiptap/src/RichTextEditor.tsx index ec62fa159c3..54d3ee89e5e 100644 --- a/src/mantine-tiptap/src/RichTextEditor.tsx +++ b/src/mantine-tiptap/src/RichTextEditor.tsx @@ -8,6 +8,7 @@ import { StylesApiProvider, } from '@mantine/core'; import { Editor } from '@tiptap/react'; +import { ForwardRefWithStaticComponents } from '@mantine/utils'; import { RichTextEditorProvider } from './RichTextEditor.context'; import * as controls from './controls'; import { Content, ContentStylesNames } from './Content/Content'; @@ -50,7 +51,49 @@ const defaultProps: Partial = { withTypographyStyles: true, }; -export const RichTextEditor = forwardRef((props, ref) => { +type RichTextEditorComponent = ForwardRefWithStaticComponents< + RichTextEditorProps, + { + Content: typeof Content; + Control: typeof Control; + ControlsGroup: typeof ControlsGroup; + Toolbar: typeof Toolbar; + 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.LinkControl; + 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.ColorPickerControl; + Color: typeof controls.ColorControl; + Highlight: typeof controls.HighlightControl; + Hr: typeof controls.HrControl; + UnsetColor: typeof controls.UnsetColorControl; + } +>; + +export const RichTextEditor: RichTextEditorComponent = forwardRef< + HTMLDivElement, + RichTextEditorProps +>((props, ref) => { const { editor, children,