accounts-frontend/packages/app/services/copy.ts

17 lines
413 B
TypeScript
Raw Normal View History

import copyToClipboard from 'copy-to-clipboard';
/**
* Simple wrapper to copy-to-clipboard library, that adds support
* for the new navigator.clipboard API.
*
* @param {string} content
* @returns {Promise<*>}
*/
export default async function copy(content: string): Promise<void> {
2020-05-24 04:38:24 +05:30
if (navigator.clipboard) {
return navigator.clipboard.writeText(content);
}
2020-05-24 04:38:24 +05:30
copyToClipboard(content);
}