helpers/clipboard.js

13 lines
355 B
JavaScript
Raw Normal View History

2022-10-29 22:05:19 +02:00
export const clipboard = function(superClass) {
return class extends superClass {
copy(content) {
const txtEl = document.createElement('input');
txtEl.type = 'hidden';
document.body.appendChild(txtEl);
txtEl.value = content;
navigator.clipboard.writeText(content);
document.body.removeChild(txtEl);
}
};
};