fix(helpers) move copyText function to web.js file

It gets bundled on mobile for no reason otherwise.
This commit is contained in:
Filip Rejmus
2022-09-26 19:31:06 +02:00
committed by GitHub
parent c613082ce1
commit c3ebde18df
4 changed files with 20 additions and 20 deletions

View File

@@ -0,0 +1,18 @@
import clipboardCopy from 'clipboard-copy';
/**
* Tries to copy a given text to the clipboard.
* Returns true if the action succeeds.
*
* @param {string} textToCopy - Text to be copied.
* @returns {Promise<boolean>}
*/
export async function copyText(textToCopy: string) {
try {
await clipboardCopy(textToCopy);
return true;
} catch (e) {
return false;
}
}