Grammalecte  Diff

Differences From Artifact [079c92ab4e]:

To Artifact [137acfaece]:


428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451

452
453
454
455
456
457
458
            showError(e);
        }
        this.stopWaitIcon();
    }

    _sendTextToClipboard (sText)  {
        this.xClipboardButton.textContent = "⇒ presse-papiers";
        if (navigator.hasOwnProperty("clipboard") && navigator.clipboard.hasOwnProperty("writeText")) {
            // Firefox 63+, Chrome 66+
            // Working draft: https://developer.mozilla.org/en-US/docs/Web/API/Clipboard
            navigator.clipboard.writeText(sText)
            .then(
                (res) => { window.setTimeout(() => { this.xClipboardButton.textContent = "📋"; }, 2000); }
            )
            .catch(
                (e) => { console.error(e); this._sendTextToClipboard(sText); }
            );
        } else {
            this._sendTextToClipboardFallback(sText);
        }
    }

    _sendTextToClipboardFallback (sText) {
        try {

            // Copy to clipboard fallback
            // recipe from https://github.com/mdn/webextensions-examples/blob/master/context-menu-copy-link-with-types/clipboard-helper.js
            function setClipboardData (xEvent) {
                document.removeEventListener("copy", setClipboardData, true);
                xEvent.stopImmediatePropagation();
                xEvent.preventDefault();
                xEvent.clipboardData.setData("text/plain", sText);







|
















>







428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
            showError(e);
        }
        this.stopWaitIcon();
    }

    _sendTextToClipboard (sText)  {
        this.xClipboardButton.textContent = "⇒ presse-papiers";
        if (navigator.clipboard && navigator.clipboard.writeText) {
            // Firefox 63+, Chrome 66+
            // Working draft: https://developer.mozilla.org/en-US/docs/Web/API/Clipboard
            navigator.clipboard.writeText(sText)
            .then(
                (res) => { window.setTimeout(() => { this.xClipboardButton.textContent = "📋"; }, 2000); }
            )
            .catch(
                (e) => { console.error(e); this._sendTextToClipboard(sText); }
            );
        } else {
            this._sendTextToClipboardFallback(sText);
        }
    }

    _sendTextToClipboardFallback (sText) {
        try {
            console.log("send text to clipboard fallback");
            // Copy to clipboard fallback
            // recipe from https://github.com/mdn/webextensions-examples/blob/master/context-menu-copy-link-with-types/clipboard-helper.js
            function setClipboardData (xEvent) {
                document.removeEventListener("copy", setClipboardData, true);
                xEvent.stopImmediatePropagation();
                xEvent.preventDefault();
                xEvent.clipboardData.setData("text/plain", sText);