Skip to content

Commit 9cd4fb8

Browse files
authored
fix: "Copy to Clipboard" in different browser (#543)
* fix: "Copy to Clipboard" in different browser * fix: invoke directly "navigator.clipboard.writeText" to copy
1 parent fa1d949 commit 9cd4fb8

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

app/src/components/codeExportModal/index.tsx

+4-10
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import json from "react-syntax-highlighter/dist/esm/languages/hljs/json";
55
import py from "react-syntax-highlighter/dist/esm/languages/hljs/python";
66
import atomOneLight from "react-syntax-highlighter/dist/esm/styles/hljs/atom-one-light";
77
import atomOneDark from "react-syntax-highlighter/dist/esm/styles/hljs/atom-one-dark";
8-
import type { VizSpecStore } from '@kanaries/graphic-walker/store/visualSpecStore'
8+
import type { VizSpecStore } from "@kanaries/graphic-walker/store/visualSpecStore";
99
import type { IChart } from "@kanaries/graphic-walker/interfaces";
1010
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
1111
import commonStore from "@/store/common";
@@ -42,16 +42,10 @@ const CodeExport: React.FC<ICodeExport> = observer((props) => {
4242
}, [setOpen]);
4343

4444
const copyToCliboard = async (content: string) => {
45-
const queryOpts = { name: "clipboard-read" as PermissionName, allowWithoutGesture: false };
46-
const permissionStatus = await navigator.permissions.query(queryOpts);
4745
try {
48-
if (permissionStatus.state !== "denied") {
49-
navigator.clipboard.writeText(content);
50-
setOpen(false);
51-
} else {
52-
setTips("The Clipboard API has been blocked in this environment. Please copy manully.");
53-
}
54-
} catch (e) {
46+
navigator.clipboard.writeText(content);
47+
setOpen(false);
48+
} catch(e) {
5549
setTips("The Clipboard API has been blocked in this environment. Please copy manully.");
5650
}
5751
};

0 commit comments

Comments
 (0)