(null);
+
+ useEffect(() => {
+ if (editorRef.current) {
+ const quill = new Quill(editorRef.current, modules);
+ quillRef.current = quill; // Store the Quill instance in a ref
+
+ if (ref) {
+ // Assign the Quill instance to the forwarded ref
+ if (typeof ref !== 'function') {
+ ref.current = quill; // For object refs
+ }
+
+ if (value) {
+ setValue(quill);
+ }
+ configureListeners(quill);
+ }
+ }
+ }, []);
+
+ useImperativeHandle(ref, () => quillRef.current as Quill);
+
+ const setValue = (quillRef: Quill) => {
+ const delta = quillRef.clipboard.convert({html: value})
+ quillRef.setContents(delta, 'silent')
+ }
+
+ const configureListeners = (quill: Quill) => {
+ quill.on('text-change', (e) => {
+ if (onChange) {
+ onChange(quillRef.current?.getSemanticHTML() || '');
+ }
+ });
+ }
+
+ return
+}
+
+
+export default forwardRef(FormRichText);
-export default FormRichText;