diff --git a/frontend/admin-panel/src/components/ui/RichTextEditor.tsx b/frontend/admin-panel/src/components/ui/RichTextEditor.tsx index 6261e71f..23e0cc62 100644 --- a/frontend/admin-panel/src/components/ui/RichTextEditor.tsx +++ b/frontend/admin-panel/src/components/ui/RichTextEditor.tsx @@ -87,6 +87,22 @@ export default function RichTextEditor({ const [isFullscreen, setIsFullscreen] = useState(false); const [showColorPicker, setShowColorPicker] = useState(false); const [showBgColorPicker, setShowBgColorPicker] = useState(false); + const colorPickerRef = useRef(null); + const bgColorPickerRef = useRef(null); + + useEffect(() => { + const handleClickOutside = (event: MouseEvent) => { + if (colorPickerRef.current && !colorPickerRef.current.contains(event.target as Node)) { + setShowColorPicker(false); + } + if (bgColorPickerRef.current && !bgColorPickerRef.current.contains(event.target as Node)) { + setShowBgColorPicker(false); + } + }; + document.addEventListener('mousedown', handleClickOutside); + return () => document.removeEventListener('mousedown', handleClickOutside); + }, []); + const [customColor, setCustomColor] = useState('#111827'); const [customBgColor, setCustomBgColor] = useState('#fef08a'); @@ -608,7 +624,7 @@ export default function RichTextEditor({ {/* Text Color Picker */} -
+
- + setFormData({ ...formData, description: val })} + placeholder="توضیحات کامل علمی، نحوه عملکرد مکمل و جزئیات ترکیبات محصول را وارد کنید..." + minHeight="min-h-[250px]" + />