"use client"; import { cn } from "@/lib/utils"; import { Actions } from "flexlayout-react"; import { Button } from "@/components/ui/button"; import { ReactNode, useRef, useState } from "react"; import { CheckIcon, CopyIcon, RepeatIcon } from "lucide-react"; import { useProblemEditorStore } from "@/stores/problem-editor"; import { useProblemFlexLayoutStore } from "@/stores/flexlayout"; import { ScrollArea, ScrollBar } from "@/components/ui/scroll-area"; interface PreDetailProps { children?: ReactNode; className?: string; } export const PreDetail = ({ children, className, ...props }: PreDetailProps) => { const preRef = useRef(null); const { setValue } = useProblemEditorStore(); const { model } = useProblemFlexLayoutStore(); const [copied, setCopied] = useState(false); const [hovered, setHovered] = useState(false); const handleCopy = async () => { const code = preRef.current?.textContent; if (code) { try { await navigator.clipboard.writeText(code); setCopied(true); setTimeout(() => setCopied(false), 1500); } catch (err) { console.error("Failed to copy text: ", err); } } }; const handleCopyToEditor = () => { const code = preRef.current?.textContent; if (code) { setValue(code); } if (model) { model.doAction(Actions.selectTab("code")); } }; return (
setHovered(true)} onMouseLeave={() => setHovered(false)} >
          {children}
        
); };