From 6010c9dc42ddb6fbb239aa96a0b8e48ca425eef1 Mon Sep 17 00:00:00 2001 From: Vlad Hrytsev Date: Sun, 11 Sep 2022 18:56:05 +0300 Subject: [PATCH 1/2] [@mantine/rte] fix prop types --- .../src/components/RichTextEditor/RichTextEditor.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/mantine-rte/src/components/RichTextEditor/RichTextEditor.tsx b/src/mantine-rte/src/components/RichTextEditor/RichTextEditor.tsx index bda190943dd..e5773701430 100644 --- a/src/mantine-rte/src/components/RichTextEditor/RichTextEditor.tsx +++ b/src/mantine-rte/src/components/RichTextEditor/RichTextEditor.tsx @@ -45,10 +45,13 @@ export interface RichTextEditorProps extends DefaultProps, Omit, 'onChange'> { /** 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; From a79e8725407995a08e9e87bbce8b84e591edae2b Mon Sep 17 00:00:00 2001 From: Vlad Hrytsev Date: Sun, 11 Sep 2022 19:23:09 +0300 Subject: [PATCH 2/2] pass default value to editor component --- .../src/components/RichTextEditor/RichTextEditor.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/mantine-rte/src/components/RichTextEditor/RichTextEditor.tsx b/src/mantine-rte/src/components/RichTextEditor/RichTextEditor.tsx index e5773701430..a5d6ed2d693 100644 --- a/src/mantine-rte/src/components/RichTextEditor/RichTextEditor.tsx +++ b/src/mantine-rte/src/components/RichTextEditor/RichTextEditor.tsx @@ -43,7 +43,7 @@ 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; @@ -97,6 +97,7 @@ export const RichTextEditor = forwardRef( (props: RichTextEditorProps, ref) => { const { value, + defaultValue, onChange, onImageUpload, sticky, @@ -166,6 +167,7 @@ export const RichTextEditor = forwardRef( theme="snow" modules={modules} value={value} + defaultValue={defaultValue} onChange={onChange} ref={mergeRefs(editorRef, ref)} placeholder={placeholder}