'use client';
import dynamic from 'next/dynamic';
import { useEffect, useState } from 'react';
// Import ReactQuill dynamically to avoid SSR issues
const ReactQuill = dynamic(() => import('react-quill-new'), {
ssr: false,
loading: () =>
Loading editor...
});
// Import styles
import 'react-quill-new/dist/quill.snow.css';
//import 'react-quill/dist/quill.snow.css';
interface QuillEditorProps {
value: string;
onChange: (value: string) => void;
placeholder?: string;
}
// Create a client-side only component
const QuillEditor = ({ value, onChange, placeholder }: QuillEditorProps) => {
// Use state to track if component is mounted (client-side)
const [mounted, setMounted] = useState(false);
// Only render the editor on the client
useEffect(() => {
setMounted(true);
}, []);
// Default toolbar options
const modules = {
toolbar: [
[{ 'header': [1, 2, 3, false] }],
['bold', 'italic', 'underline', 'strike'],
[{ 'list': 'ordered' }, { 'list': 'bullet' }],
['link'],
['clean']
]
};
if (!mounted) {
return Loading editor...
;
}
return (
);
};
export default QuillEditor;