1. function copyToClipBoard(content: string): Promise<void> {
    2. return new Promise((resolve, reject) => {
    3. let inputEle = document.getElementById('clipboard') as HTMLInputElement;
    4. if (!inputEle) {
    5. inputEle = document.createElement('input');
    6. inputEle.id = 'clipboard';
    7. document.body.appendChild(inputEle);
    8. }
    9. inputEle.setAttribute('value', content);
    10. inputEle.style.display = 'block';
    11. if (inputEle && inputEle.select) {
    12. inputEle.select();
    13. try {
    14. const isSuccessful = document.execCommand('copy');
    15. // eslint-disable-next-line @typescript-eslint/no-unused-expressions
    16. isSuccessful ? resolve() : reject();
    17. } catch (err) {
    18. reject(err);
    19. }
    20. }
    21. inputEle.style.display = 'none';
    22. });
    23. }