SyntaxHighlighter: Safely access clipboard

Use optional chaining to safely access `clipboard` on `global.navigator`
This commit is contained in:
Kyle Gach 2021-02-24 07:20:39 -07:00 committed by GitHub
parent 5c1141db47
commit 2b28aa1378
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -54,7 +54,7 @@ const themedSyntax = memoize(2)((theme) =>
let copyToClipboard: (text: string) => Promise<void>;
if (navigator.clipboard) {
if (navigator?.clipboard) {
copyToClipboard = (text: string) => navigator.clipboard.writeText(text);
} else {
copyToClipboard = async (text: string) => {