save: ability to copy-to-clipboard

This commit is contained in:
muerwre 2018-12-12 12:22:49 +07:00
parent e53ef85ae9
commit f4e2142b15
5 changed files with 61 additions and 6 deletions

View file

@ -33,3 +33,14 @@ export const pushLoaderState = state => {
export const pushNetworkInitError = state => {
document.getElementById('loader-error').style.opacity = 1;
};
export const copyToClipboard = str => {
const el = document.createElement('textarea');
el.value = str;
el.setAttribute('readonly', '');
el.style = { position: 'absolute', left: '-9999px' };
document.body.appendChild(el);
el.select();
document.execCommand('copy');
document.body.removeChild(el);
}