Skip to content

Commit 01b7b6f

Browse files
Copy to Clipboard: Fixed clipboard.writeText not working inside iFrames (#2826)
1 parent 4c8b855 commit 01b7b6f

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

plugins/copy-to-clipboard/prism-copy-to-clipboard.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,10 @@
6363
/** @param {CopyInfo} copyInfo */
6464
function copyTextToClipboard(copyInfo) {
6565
if (navigator.clipboard) {
66-
navigator.clipboard.writeText(copyInfo.getText()).then(copyInfo.success, copyInfo.error);
66+
navigator.clipboard.writeText(copyInfo.getText()).then(copyInfo.success, function() {
67+
// try the fallback in case `writeText` didn't work
68+
fallbackCopyTextToClipboard(copyInfo);
69+
});
6770
} else {
6871
fallbackCopyTextToClipboard(copyInfo);
6972
}

plugins/copy-to-clipboard/prism-copy-to-clipboard.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)