diff --git a/src/app/(app)/playground/@workspace/@editor/components/copy-button.tsx b/src/app/(app)/playground/@workspace/@editor/components/copy-button.tsx new file mode 100644 index 0000000..984ca04 --- /dev/null +++ b/src/app/(app)/playground/@workspace/@editor/components/copy-button.tsx @@ -0,0 +1,70 @@ +"use client"; + +import { + Tooltip, + TooltipContent, + TooltipProvider, + TooltipTrigger, +} from "@/components/ui/tooltip"; +import { cn } from "@/lib/utils"; +import { useState } from "react"; +import { Check, Copy } from "lucide-react"; +import { Button } from "@/components/ui/button"; +import { useCodeEditorState } from "@/store/useCodeEditor"; + +export default function CopyButton() { + const [copied, setCopied] = useState(false); + const { editor } = useCodeEditorState(); + + const handleCopy = async () => { + try { + await navigator.clipboard.writeText(editor?.getValue() || ""); + setCopied(true); + setTimeout(() => setCopied(false), 1500); + } catch (err) { + console.error("Failed to copy text: ", err); + } + }; + + return ( + + + + + + + Click to Copy + + + + ); +}