From e6a0676e8382aae3f2c755579c74fde5600a2dec Mon Sep 17 00:00:00 2001 From: Vlad Date: Mon, 12 Sep 2022 08:38:08 +0300 Subject: [PATCH] [@mantine/rte] Fix incorrect props types (#2420) * [@mantine/rte] fix prop types * pass default value to editor component Co-authored-by: Vlad Hrytsev --- .../src/components/RichTextEditor/RichTextEditor.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/mantine-rte/src/components/RichTextEditor/RichTextEditor.tsx b/src/mantine-rte/src/components/RichTextEditor/RichTextEditor.tsx index bda190943dd..a5d6ed2d693 100644 --- a/src/mantine-rte/src/components/RichTextEditor/RichTextEditor.tsx +++ b/src/mantine-rte/src/components/RichTextEditor/RichTextEditor.tsx @@ -43,12 +43,15 @@ function defaultImageUpload(file: File): Promise { export interface RichTextEditorProps extends DefaultProps, - Omit, 'onChange'> { + Omit, 'onChange' | 'defaultValue'> { /** HTML content, value not forced as quill works in uncontrolled mode */ - value: string | Delta; + value?: string | Delta; + + /** Initial value of input */ + defaultValue?: string | Delta; /** Called each time value changes */ - onChange(value: string, delta: Delta, sources: Sources, editor: Editor.UnprivilegedEditor): void; + onChange?(value: string, delta: Delta, sources: Sources, editor: Editor.UnprivilegedEditor): void; /** Called when image image is inserted in editor */ onImageUpload?(image: File): Promise; @@ -94,6 +97,7 @@ export const RichTextEditor = forwardRef( (props: RichTextEditorProps, ref) => { const { value, + defaultValue, onChange, onImageUpload, sticky, @@ -163,6 +167,7 @@ export const RichTextEditor = forwardRef( theme="snow" modules={modules} value={value} + defaultValue={defaultValue} onChange={onChange} ref={mergeRefs(editorRef, ref)} placeholder={placeholder}