mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-27 09:46:25 +02:00
Added type prop to markdown viewer
Forgot to add type prop to MarkdownViewer component in last commit
This commit is contained in:
parent
8530226edb
commit
4c53290c8c
2 changed files with 1823 additions and 1530 deletions
|
|
@ -1,5 +1,5 @@
|
|||
"use client";
|
||||
import { useState } from "react";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import type { RefObject } from "react";
|
||||
import { Button } from "./ui/button";
|
||||
import { Copy, CopyCheck } from "lucide-react";
|
||||
|
|
@ -10,6 +10,15 @@ export default function CopyButton({
|
|||
ref: RefObject<HTMLDivElement | null>;
|
||||
}) {
|
||||
const [copy, setCopy] = useState(false);
|
||||
const timeoutRef = useRef<NodeJS.Timeout | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
if (timeoutRef.current) {
|
||||
clearTimeout(timeoutRef.current);
|
||||
}
|
||||
};
|
||||
}, []);
|
||||
|
||||
const handleClick = () => {
|
||||
if (ref.current) {
|
||||
|
|
@ -17,9 +26,9 @@ export default function CopyButton({
|
|||
navigator.clipboard.writeText(text);
|
||||
|
||||
setCopy(true);
|
||||
setTimeout(() => {
|
||||
timeoutRef.current = setTimeout(() => {
|
||||
setCopy(false);
|
||||
}, 500);
|
||||
}, 2000);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue