1+ import { Editor as MonacoEditor } from "@monaco-editor/react" ;
2+ import {
3+ CheckIcon ,
4+ ChevronDownIcon ,
5+ CopyIcon ,
6+ FileJsonIcon ,
7+ SettingsIcon ,
8+ ZapIcon ,
9+ } from "lucide-react" ;
10+ import { type FC , useEffect , useState } from "react" ;
111import { Button } from "@/client/components/Button" ;
212import {
313 DropdownMenu ,
@@ -13,21 +23,11 @@ import {
1323 TooltipContent ,
1424 TooltipTrigger ,
1525} from "@/client/components/Tooltip" ;
16- import { useTheme } from "@/client/contexts/theme" ;
17- import { snippets , type SnippetFunc } from "@/client/snippets" ;
18- import { cn } from "@/utils/cn" ;
19- import { Editor as MonacoEditor } from "@monaco-editor/react" ;
20- import {
21- CheckIcon ,
22- ChevronDownIcon ,
23- CopyIcon ,
24- FileJsonIcon ,
25- SettingsIcon ,
26- ZapIcon ,
27- } from "lucide-react" ;
28- import { type FC , useEffect , useRef , useState } from "react" ;
2926import { useEditor } from "@/client/contexts/editor" ;
27+ import { useTheme } from "@/client/contexts/theme" ;
28+ import { type SnippetFunc , snippets } from "@/client/snippets" ;
3029import type { ParameterWithSource } from "@/gen/types" ;
30+ import { cn } from "@/utils/cn" ;
3131
3232type EditorProps = {
3333 code : string ;
@@ -42,9 +42,6 @@ export const Editor: FC<EditorProps> = ({ code, setCode, parameters }) => {
4242 const [ tab , setTab ] = useState ( ( ) => "code" ) ;
4343
4444 const [ codeCopied , setCodeCopied ] = useState ( ( ) => false ) ;
45- const copyTimeoutId = useRef < ReturnType < typeof setTimeout > | undefined > (
46- undefined ,
47- ) ;
4845
4946 const onCopy = ( ) => {
5047 navigator . clipboard . writeText ( code ) ;
@@ -65,13 +62,11 @@ export const Editor: FC<EditorProps> = ({ code, setCode, parameters }) => {
6562 return ;
6663 }
6764
68- clearTimeout ( copyTimeoutId . current ) ;
69-
70- copyTimeoutId . current = setTimeout ( ( ) => {
65+ const copyTimeoutId = setTimeout ( ( ) => {
7166 setCodeCopied ( ( ) => false ) ;
7267 } , 1000 ) ;
7368
74- return ( ) => clearTimeout ( copyTimeoutId . current ) ;
69+ return ( ) => clearTimeout ( copyTimeoutId ) ;
7570 } , [ codeCopied ] ) ;
7671
7772 return (
0 commit comments