Fix clipboard write for Safari (#2283)

Signed-off-by: Alexander Onnikov <alexander.onnikov@xored.com>
This commit is contained in:
Alexander Onnikov 2022-10-06 13:21:38 +07:00 committed by GitHub
parent 26b319b294
commit a0814a356f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -47,7 +47,18 @@ export async function copyToClipboard (object: Issue, ev: Event, { type }: { typ
default:
return
}
await navigator.clipboard.writeText(text)
try {
// Chromium
await navigator.clipboard.writeText(text)
} catch {
// Safari specific behavior
// see https://bugs.webkit.org/show_bug.cgi?id=222262
const clipboardItem = new ClipboardItem({
'text/plain': Promise.resolve(text)
})
await navigator.clipboard.write([clipboardItem])
}
}
export function generateIssueShortLink (issueId: string): string {