Spaces:
Running
Running
add copy button
Browse files
src/components/ask-ai/ask-ai.tsx
CHANGED
@@ -4,8 +4,9 @@ import { RiSparkling2Fill } from "react-icons/ri";
|
|
4 |
import { GrSend } from "react-icons/gr";
|
5 |
import classNames from "classnames";
|
6 |
import { toast } from "react-toastify";
|
7 |
-
import { useLocalStorage } from "react-use";
|
8 |
import { MdPreview } from "react-icons/md";
|
|
|
9 |
|
10 |
import Login from "../login/login";
|
11 |
import { defaultHTML } from "./../../../utils/consts";
|
@@ -39,6 +40,7 @@ function AskAI({
|
|
39 |
const [openProvider, setOpenProvider] = useState(false);
|
40 |
const [providerError, setProviderError] = useState("");
|
41 |
const [openProModal, setOpenProModal] = useState(false);
|
|
|
42 |
|
43 |
const audio = new Audio(SuccessSound);
|
44 |
audio.volume = 0.5;
|
@@ -148,6 +150,18 @@ function AskAI({
|
|
148 |
isAiWorking ? "animate-pulse" : ""
|
149 |
}`}
|
150 |
>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
151 |
{defaultHTML !== html && (
|
152 |
<button
|
153 |
className="bg-white lg:hidden -translate-y-[calc(100%+8px)] absolute left-0 top-0 shadow-md text-gray-950 text-xs font-medium py-2 px-3 lg:px-4 rounded-lg flex items-center gap-2 border border-gray-100 hover:brightness-150 transition-all duration-100 cursor-pointer"
|
|
|
4 |
import { GrSend } from "react-icons/gr";
|
5 |
import classNames from "classnames";
|
6 |
import { toast } from "react-toastify";
|
7 |
+
import { useCopyToClipboard, useLocalStorage } from "react-use";
|
8 |
import { MdPreview } from "react-icons/md";
|
9 |
+
import { IoCopy } from "react-icons/io5";
|
10 |
|
11 |
import Login from "../login/login";
|
12 |
import { defaultHTML } from "./../../../utils/consts";
|
|
|
40 |
const [openProvider, setOpenProvider] = useState(false);
|
41 |
const [providerError, setProviderError] = useState("");
|
42 |
const [openProModal, setOpenProModal] = useState(false);
|
43 |
+
const [state, copyToClipboard] = useCopyToClipboard();
|
44 |
|
45 |
const audio = new Audio(SuccessSound);
|
46 |
audio.volume = 0.5;
|
|
|
150 |
isAiWorking ? "animate-pulse" : ""
|
151 |
}`}
|
152 |
>
|
153 |
+
{defaultHTML !== html && (
|
154 |
+
<p
|
155 |
+
className="text-2xl text-white/50 hover:text-white/80 -translate-y-[calc(100%+8px)] absolute top-0 right-0 cursor-pointer"
|
156 |
+
onClick={() => {
|
157 |
+
copyToClipboard(html);
|
158 |
+
toast.success("HTML copied to clipboard");
|
159 |
+
audio.play();
|
160 |
+
}}
|
161 |
+
>
|
162 |
+
<IoCopy />
|
163 |
+
</p>
|
164 |
+
)}
|
165 |
{defaultHTML !== html && (
|
166 |
<button
|
167 |
className="bg-white lg:hidden -translate-y-[calc(100%+8px)] absolute left-0 top-0 shadow-md text-gray-950 text-xs font-medium py-2 px-3 lg:px-4 rounded-lg flex items-center gap-2 border border-gray-100 hover:brightness-150 transition-all duration-100 cursor-pointer"
|