Add copyToClipboard so that adding a mixin is not necessary.
This commit is contained in:
16
clipboard.js
16
clipboard.js
@@ -1,12 +1,16 @@
|
||||
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);
|
||||
copyToClipboard(content);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
export const copyToClipboard = (content) => {
|
||||
const txtEl = document.createElement('input');
|
||||
txtEl.type = 'hidden';
|
||||
document.body.appendChild(txtEl);
|
||||
txtEl.value = content;
|
||||
navigator.clipboard.writeText(content);
|
||||
document.body.removeChild(txtEl);
|
||||
}
|
||||
|
Reference in New Issue
Block a user