'use client'; import { useEditor, EditorContent } from '@tiptap/react'; import StarterKit from '@tiptap/starter-kit'; import Link from '@tiptap/extension-link'; import Placeholder from '@tiptap/extension-placeholder'; import { useEffect } from 'react'; import { Button } from '@/components/ui/button'; import { Bold, Italic, Strikethrough, Code, List, ListOrdered, Quote, Undo, Redo, Heading1, Heading2, } from 'lucide-react'; import { cn } from '@/lib/utils'; interface ReportEditorProps { content: string; onChange: (content: string) => void; onBlur?: () => void; } function ToolbarButton({ onClick, active, disabled, label, children, }: { onClick: () => void; active?: boolean; disabled?: boolean; label: string; children: React.ReactNode; }) { return ( ); } export function ReportEditor({ content, onChange, onBlur }: ReportEditorProps) { const editor = useEditor({ extensions: [ StarterKit, Link.configure({ openOnClick: false, }), Placeholder.configure({ placeholder: 'Start writing your report...', }), ], content, onUpdate: ({ editor: e }) => { onChange(e.getHTML()); }, onBlur: () => { onBlur?.(); }, }); useEffect(() => { if (editor && content !== editor.getHTML()) { editor.commands.setContent(content); } }, [content, editor]); if (!editor) { return null; } return (