Add context menu
This commit is contained in:
13
clipboard.js
13
clipboard.js
@@ -6,11 +6,18 @@ export const clipboard = function(superClass) {
|
||||
};
|
||||
};
|
||||
|
||||
export const copyToClipboard = (content) => {
|
||||
export const copyToClipboard = async (content) => {
|
||||
const txtEl = document.createElement('input');
|
||||
txtEl.type = 'hidden';
|
||||
document.body.appendChild(txtEl);
|
||||
txtEl.value = content;
|
||||
navigator.clipboard.writeText(content);
|
||||
document.body.removeChild(txtEl);
|
||||
|
||||
try {
|
||||
await navigator.clipboard.writeText(content);
|
||||
return true;
|
||||
} catch (err) {
|
||||
return false;
|
||||
} finally {
|
||||
document.body.removeChild(txtEl);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user