From be1bb388924f4422058099dcb0debdd1c857d36a Mon Sep 17 00:00:00 2001 From: kamtschatka Date: Sun, 9 Jun 2024 15:30:56 +0200 Subject: feature(web): Add syntax highlighting to code blocks and a quick copy button. Fixes #195 (#197) * Any plans to support copy to clipboard (markdown code) for notes? #195 added a button to copy the markdown and added code highlighting * Any plans to support copy to clipboard (markdown code) for notes? #195 Changed the copy-button to a generic one added a safeguard and a message to the copy button if copying is not possible * Some code cleanups --------- Co-authored-by: kamtschatka Co-authored-by: MohamedBassem --- .../components/dashboard/settings/AddApiKey.tsx | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) (limited to 'apps/web/components/dashboard/settings/AddApiKey.tsx') diff --git a/apps/web/components/dashboard/settings/AddApiKey.tsx b/apps/web/components/dashboard/settings/AddApiKey.tsx index 15a78d56..34fd2df7 100644 --- a/apps/web/components/dashboard/settings/AddApiKey.tsx +++ b/apps/web/components/dashboard/settings/AddApiKey.tsx @@ -5,6 +5,7 @@ import { useState } from "react"; import { useRouter } from "next/navigation"; import { ActionButton } from "@/components/ui/action-button"; import { Button } from "@/components/ui/button"; +import CopyBtn from "@/components/ui/copy-button"; import { Dialog, DialogClose, @@ -28,19 +29,10 @@ import { Input } from "@/components/ui/input"; import { toast } from "@/components/ui/use-toast"; import { api } from "@/lib/trpc"; import { zodResolver } from "@hookform/resolvers/zod"; -import { Check, Copy } from "lucide-react"; import { useForm } from "react-hook-form"; import { z } from "zod"; function ApiKeySuccess({ apiKey }: { apiKey: string }) { - const [isCopied, setCopied] = useState(false); - - const onCopy = () => { - navigator.clipboard.writeText(apiKey); - setCopied(true); - setTimeout(() => setCopied(false), 2000); - }; - return (
@@ -49,13 +41,11 @@ function ApiKeySuccess({ apiKey }: { apiKey: string }) {
- + { + return apiKey; + }} + />
); -- cgit v1.2.3-70-g09d2