Skip to content

Commit c07a965

Browse files
committed
Allow onChange to be string or void
1 parent 1c441f9 commit c07a965

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Diff for: src/components/form/components/FormRichText.tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ export interface QuillEditorProps {
1313
style?: CSSProperties;
1414
id?: string;
1515
modules?: Record<string, unknown>;
16-
onChange?: (value: string) => string | void;
16+
valueChange?(value: string): any;
1717
value?: string;
1818
}
1919

2020
const FormRichText: React.ForwardRefRenderFunction<Quill, QuillEditorProps> = (
21-
{ modules, value, onChange, ...rest }: QuillEditorProps,
21+
{ modules, value, valueChange, ...rest }: QuillEditorProps,
2222
ref: ForwardedRef<Quill>
2323
) => {
2424
const editorRef = useRef<HTMLDivElement | null>(null);
@@ -31,8 +31,8 @@ const FormRichText: React.ForwardRefRenderFunction<Quill, QuillEditorProps> = (
3131

3232
const configureListeners = (quill: Quill) => {
3333
quill.on('text-change', () => {
34-
if (onChange) {
35-
onChange(quillRef.current?.getSemanticHTML() || '');
34+
if (valueChange) {
35+
valueChange(quillRef.current?.getSemanticHTML() || '');
3636
}
3737
});
3838
};
@@ -54,7 +54,7 @@ const FormRichText: React.ForwardRefRenderFunction<Quill, QuillEditorProps> = (
5454
configureListeners(quill);
5555
}
5656
}
57-
});
57+
}, []);
5858

5959
useImperativeHandle(ref, () => quillRef.current as Quill);
6060

0 commit comments

Comments
 (0)