diff --git a/src/libs/utils.ts b/src/libs/utils.ts index eace84dbc..926e71a03 100644 --- a/src/libs/utils.ts +++ b/src/libs/utils.ts @@ -171,3 +171,16 @@ export const isElectron = (): boolean => { return false } + +/** + * Copy text to clipboard + * @param {string} text The text to copy + * @returns {Promise} A promise that resolves when the text is copied + */ +export const copyToClipboard = async (text: string): Promise => { + try { + await navigator.clipboard.writeText(text) + } catch (err) { + throw new Error(`Failed to copy text. Error: ${err}`) + } +}