mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-09 17:33:55 +00:00
19 lines
402 B
TypeScript
19 lines
402 B
TypeScript
/**
|
|
* copy text to clipboard
|
|
* @throws if not supported or permission denied
|
|
*/
|
|
export async function copyToClipboard(text: string) {
|
|
await navigator.clipboard?.writeText(text);
|
|
}
|
|
|
|
/**
|
|
* Copy to clipboard but safely ignore errors
|
|
*/
|
|
export async function safeCopyToClipboard(text: string): Promise<void> {
|
|
try {
|
|
await copyToClipboard(text);
|
|
} catch {
|
|
// Silently ignore errors
|
|
}
|
|
}
|