1
0
mirror of https://github.com/hotomoe/hotomoe synced 2024-12-29 05:58:06 +09:00
hotomoe/src/client/app/common/scripts/copy-to-clipboard.ts
2018-03-29 20:32:18 +09:00

14 lines
320 B
TypeScript

/**
* Clipboardに値をコピー(TODO: 文字列以外も対応)
*/
export default val => {
const form = document.createElement('textarea');
form.textContent = val;
document.body.appendChild(form);
form.select();
const result = document.execCommand('copy');
document.body.removeChild(form);
return result;
};