mirror of
https://github.com/sqlchat/sqlchat.git
synced 2025-08-02 22:58:43 +08:00
chore: use copy-to-clipboard (#43)
This commit is contained in:
@ -19,6 +19,7 @@
|
||||
"@radix-ui/react-tooltip": "^1.0.5",
|
||||
"@vercel/analytics": "^0.1.11",
|
||||
"axios": "^1.3.4",
|
||||
"copy-to-clipboard": "^3.3.3",
|
||||
"csstype": "^3.1.1",
|
||||
"dayjs": "^1.11.7",
|
||||
"eventsource-parser": "^1.0.0",
|
||||
|
3
pnpm-lock.yaml
generated
3
pnpm-lock.yaml
generated
@ -31,6 +31,9 @@ dependencies:
|
||||
axios:
|
||||
specifier: ^1.3.4
|
||||
version: 1.3.4
|
||||
copy-to-clipboard:
|
||||
specifier: ^3.3.3
|
||||
version: 3.3.3
|
||||
csstype:
|
||||
specifier: ^3.1.1
|
||||
version: 3.1.1
|
||||
|
@ -1,3 +1,4 @@
|
||||
import copy from "copy-to-clipboard";
|
||||
import { toast } from "react-hot-toast";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Prism as SyntaxHighlighter } from "react-syntax-highlighter";
|
||||
@ -23,13 +24,8 @@ export const CodeBlock = (props: Props) => {
|
||||
const showExecuteButton = currentConnectionCtx?.connection && currentConnectionCtx?.database && language.toUpperCase() === "SQL";
|
||||
|
||||
const copyToClipboard = () => {
|
||||
if (!navigator.clipboard || !navigator.clipboard.writeText) {
|
||||
toast.error("Failed to copy to clipboard");
|
||||
return;
|
||||
}
|
||||
navigator.clipboard.writeText(value).then(() => {
|
||||
toast.success("Copied to clipboard");
|
||||
});
|
||||
copy(value);
|
||||
toast.success("Copied to clipboard");
|
||||
};
|
||||
|
||||
const handleExecuteQuery = () => {
|
||||
|
Reference in New Issue
Block a user