helpers/clipboard.js
2022-10-29 22:05:19 +02:00

13 lines
355 B
JavaScript

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);
}
};
};