import React, { useMemo } from "react"; import ReactQuill from "react-quill"; import "react-quill/dist/quill.snow.css"; export interface RichTextEditorProps { value: string; onChange: (value: string) => void; label?: string; placeholder?: string; helperText?: string; disabled?: boolean; minHeight?: number; maxHeight?: number; } export const RichTextEditor: React.FC = ({ value, onChange, label, placeholder, helperText, disabled = false, minHeight = 280, maxHeight = 600, }) => { const modules = useMemo( () => ({ toolbar: [ [{ header: [1, 2, 3, false] }], ["bold", "italic", "underline", "strike"], [{ list: "ordered" }, { list: "bullet" }], [{ align: [] }], ["link"], ["clean"], ], }), [], ); const formats = [ "header", "bold", "italic", "underline", "strike", "list", "bullet", "align", "link", ]; const handleChange = (content: string) => { // Normalize empty content const normalized = content === "


" ? "" : content; onChange(normalized); }; return (
{label && ( )}
{helperText && (

{helperText}

)}
); }; export default RichTextEditor;