mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
fix: fixed copy to clipboard button (#8426)
Co-authored-by: dwelle <5153846+dwelle@users.noreply.github.com>
This commit is contained in:
parent
afb68a6467
commit
26d2296578
12 changed files with 160 additions and 284 deletions
22
packages/excalidraw/hooks/useCopiedIndicator.ts
Normal file
22
packages/excalidraw/hooks/useCopiedIndicator.ts
Normal file
|
@ -0,0 +1,22 @@
|
|||
import { useRef, useState } from "react";
|
||||
|
||||
const TIMEOUT = 2000;
|
||||
|
||||
export const useCopyStatus = () => {
|
||||
const [copyStatus, setCopyStatus] = useState<"success" | null>(null);
|
||||
const timeoutRef = useRef<number>(0);
|
||||
|
||||
const onCopy = () => {
|
||||
clearTimeout(timeoutRef.current);
|
||||
setCopyStatus("success");
|
||||
|
||||
timeoutRef.current = window.setTimeout(() => {
|
||||
setCopyStatus(null);
|
||||
}, TIMEOUT);
|
||||
};
|
||||
|
||||
return {
|
||||
copyStatus,
|
||||
onCopy,
|
||||
};
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue