mirror of
https://github.com/massbug/judge4c.git
synced 2025-05-18 15:26:33 +00:00
feat(copy-button): update to use useProblemEditor hook for editor state
This commit is contained in:
parent
74c8175153
commit
12d0eed66a
@ -10,11 +10,11 @@ import { cn } from "@/lib/utils";
|
|||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { Check, Copy } from "lucide-react";
|
import { Check, Copy } from "lucide-react";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { useCodeEditorStore } from "@/store/useCodeEditorStore";
|
import { useProblemEditor } from "@/hooks/use-problem-editor";
|
||||||
|
|
||||||
export default function CopyButton() {
|
export default function CopyButton() {
|
||||||
|
const { editor } = useProblemEditor();
|
||||||
const [copied, setCopied] = useState(false);
|
const [copied, setCopied] = useState(false);
|
||||||
const { editor } = useCodeEditorStore();
|
|
||||||
|
|
||||||
const handleCopy = async () => {
|
const handleCopy = async () => {
|
||||||
try {
|
try {
|
||||||
@ -33,10 +33,13 @@ export default function CopyButton() {
|
|||||||
<Button
|
<Button
|
||||||
variant="outline"
|
variant="outline"
|
||||||
size="icon"
|
size="icon"
|
||||||
className="h-6 w-6 border-none shadow-none px-1.5 py-0.5 disabled:opacity-100 hover:bg-muted"
|
className={cn(
|
||||||
|
"h-6 w-6 border-none shadow-none px-1.5 py-0.5 hover:bg-muted",
|
||||||
|
copied ? "disabled:opacity-100" : ""
|
||||||
|
)}
|
||||||
onClick={handleCopy}
|
onClick={handleCopy}
|
||||||
aria-label={copied ? "Copied" : "Copy to clipboard"}
|
aria-label={copied ? "Copied" : "Copy to clipboard"}
|
||||||
disabled={copied}
|
disabled={!editor || copied}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
className={cn(
|
className={cn(
|
||||||
|
Loading…
Reference in New Issue
Block a user