mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-15 18:25:18 +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
File diff suppressed because it is too large
Load diff
|
|
@ -1,5 +1,5 @@
|
||||||
"use client";
|
"use client";
|
||||||
import { useState } from "react";
|
import { useEffect, useRef, useState } from "react";
|
||||||
import type { RefObject } from "react";
|
import type { RefObject } from "react";
|
||||||
import { Button } from "./ui/button";
|
import { Button } from "./ui/button";
|
||||||
import { Copy, CopyCheck } from "lucide-react";
|
import { Copy, CopyCheck } from "lucide-react";
|
||||||
|
|
@ -10,6 +10,15 @@ export default function CopyButton({
|
||||||
ref: RefObject<HTMLDivElement | null>;
|
ref: RefObject<HTMLDivElement | null>;
|
||||||
}) {
|
}) {
|
||||||
const [copy, setCopy] = useState(false);
|
const [copy, setCopy] = useState(false);
|
||||||
|
const timeoutRef = useRef<NodeJS.Timeout | null>(null);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
return () => {
|
||||||
|
if (timeoutRef.current) {
|
||||||
|
clearTimeout(timeoutRef.current);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
const handleClick = () => {
|
const handleClick = () => {
|
||||||
if (ref.current) {
|
if (ref.current) {
|
||||||
|
|
@ -17,9 +26,9 @@ export default function CopyButton({
|
||||||
navigator.clipboard.writeText(text);
|
navigator.clipboard.writeText(text);
|
||||||
|
|
||||||
setCopy(true);
|
setCopy(true);
|
||||||
setTimeout(() => {
|
timeoutRef.current = setTimeout(() => {
|
||||||
setCopy(false);
|
setCopy(false);
|
||||||
}, 500);
|
}, 2000);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue