Created
November 5, 2018 09:50
-
-
Save andreasvirkus/04236a22b968dfa0a11c66a4dc28b54a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const copy = async (text) => { | |
try { | |
await navigator.clipboard.writeText(text) | |
console.log('Text copied:', text) | |
} catch (err) { | |
console.error('Failed to copy:', err) | |
} | |
} | |
export const paste = async (selector, readOnly = false) => { | |
const contents = await navigator.clipboard.readText() | |
if (!readOnly) document.querySelector(selector).innerText = contents | |
return contents | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment