feat: add figma plugin

This commit is contained in:
quillzhou@gmail.com
2023-12-23 15:43:54 +08:00
parent f90966808b
commit 83a1d49af4
9 changed files with 306 additions and 8 deletions
+26
View File
@@ -0,0 +1,26 @@
export function copyToClipboard(value: string) {
try {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
if (window.copy) {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
window.copy(value);
} else {
const area = document.createElement('textarea');
document.body.appendChild(area);
area.value = value;
// area.focus();
area.select();
const result = document.execCommand('copy');
document.body.removeChild(area);
if (!result) {
throw new Error();
}
}
} catch (e) {
console.error(`Unable to copy the value: ${value}`);
return false;
}
return true;
}