From 470dca23afc70116b2093d6b6db657df64f81306 Mon Sep 17 00:00:00 2001 From: Aadarsha Acharya Date: Mon, 28 Nov 2022 15:29:28 +0545 Subject: [PATCH] [@mantine/tiptap] Add ref forwarding (#3068) --- src/mantine-tiptap/src/RichTextEditor.tsx | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/mantine-tiptap/src/RichTextEditor.tsx b/src/mantine-tiptap/src/RichTextEditor.tsx index 55076e05783..ec62fa159c3 100644 --- a/src/mantine-tiptap/src/RichTextEditor.tsx +++ b/src/mantine-tiptap/src/RichTextEditor.tsx @@ -1,5 +1,5 @@ /* eslint-disable react/no-unused-prop-types */ -import React, { useMemo } from 'react'; +import React, { useMemo, forwardRef } from 'react'; import { Box, useComponentDefaultProps, @@ -50,7 +50,7 @@ const defaultProps: Partial = { withTypographyStyles: true, }; -export function RichTextEditor(props: RichTextEditorProps) { +export const RichTextEditor = forwardRef((props, ref) => { const { editor, children, @@ -63,7 +63,12 @@ export function RichTextEditor(props: RichTextEditorProps) { unstyled, ...others } = useComponentDefaultProps('RichTextEditor', defaultProps, props); - const { classes, cx } = useStyles(null, { name: 'RichTextEditor', classNames, styles, unstyled }); + const { classes, cx } = useStyles(null, { + name: 'RichTextEditor', + classNames, + styles, + unstyled, + }); const mergedLabels = useMemo(() => ({ ...DEFAULT_LABELS, ...labels }), [labels]); return ( @@ -71,13 +76,13 @@ export function RichTextEditor(props: RichTextEditorProps) { - + {children} ); -} +}) as any; // Generic components RichTextEditor.Content = Content;