Skip to content

Commit

Permalink
[@mantine/rte] Fix incorrect props types (#2420)
Browse files Browse the repository at this point in the history
* [@mantine/rte] fix prop types

* pass default value to editor component

Co-authored-by: Vlad Hrytsev <vhrytsev@atlassian.com>
  • Loading branch information
Jawell and vhrytsev committed Sep 12, 2022
1 parent bfea252 commit e6a0676
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/mantine-rte/src/components/RichTextEditor/RichTextEditor.tsx
Expand Up @@ -43,12 +43,15 @@ function defaultImageUpload(file: File): Promise<string> {

export interface RichTextEditorProps
extends DefaultProps<RichTextEditorStylesNames>,
Omit<React.ComponentPropsWithoutRef<'div'>, 'onChange'> {
Omit<React.ComponentPropsWithoutRef<'div'>, '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<string>;
Expand Down Expand Up @@ -94,6 +97,7 @@ export const RichTextEditor = forwardRef<Editor, RichTextEditorProps>(
(props: RichTextEditorProps, ref) => {
const {
value,
defaultValue,
onChange,
onImageUpload,
sticky,
Expand Down Expand Up @@ -163,6 +167,7 @@ export const RichTextEditor = forwardRef<Editor, RichTextEditorProps>(
theme="snow"
modules={modules}
value={value}
defaultValue={defaultValue}
onChange={onChange}
ref={mergeRefs(editorRef, ref)}
placeholder={placeholder}
Expand Down

0 comments on commit e6a0676

Please sign in to comment.