Skip to content

Commit fd1e207

Browse files
committed
Use clipboard from top frame to avoid mocked clipboard in the preview
1 parent a0d1b3e commit fd1e207

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

code/core/src/components/components/syntaxhighlighter/syntaxhighlighter.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,9 @@ const themedSyntax = memoize(2)((theme) =>
5959
const copyToClipboard: (text: string) => Promise<void> = createCopyToClipboardFunction();
6060

6161
export function createCopyToClipboardFunction() {
62-
if (navigator?.clipboard) {
63-
return (text: string) => navigator.clipboard.writeText(text);
62+
if (globalWindow.top?.navigator?.clipboard) {
63+
const clipboard = globalWindow.top.navigator.clipboard;
64+
return async (text: string) => clipboard.writeText(text);
6465
}
6566
return async (text: string) => {
6667
const tmp = document.createElement('TEXTAREA') as HTMLTextAreaElement;

0 commit comments

Comments
 (0)