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) {
|
export const clipboard = function(superClass) {
|
||||||
return class extends superClass {
|
return class extends superClass {
|
||||||
copy(content) {
|
copy(content) {
|
||||||
const txtEl = document.createElement('input');
|
copyToClipboard(content);
|
||||||
txtEl.type = 'hidden';
|
|
||||||
document.body.appendChild(txtEl);
|
|
||||||
txtEl.value = content;
|
|
||||||
navigator.clipboard.writeText(content);
|
|
||||||
document.body.removeChild(txtEl);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@tp/helpers",
|
"name": "@tp/helpers",
|
||||||
"version": "2.7.1",
|
"version": "2.8.0",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "closest.js",
|
"main": "closest.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
Reference in New Issue
Block a user