Grammalecte  Check-in [f4a00c03d1]

Overview
Comment:[fx] gc panel: fix copy to clipboard again
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | fx
Files: files | file ages | folders
SHA3-256: f4a00c03d1caf6541e18bd7dbdb829e0e9e7a1ae449bf81bef4cee20a3fee2d0
User & Date: olr on 2019-05-20 14:57:46
Other Links: manifest | tags
Context
2019-05-20
16:34
[build][fr] Dicollecte doesn’t exist anymore check-in: 2eeeb8f39d user: olr tags: trunk, fr, build
14:57
[fx] gc panel: fix copy to clipboard again check-in: f4a00c03d1 user: olr tags: trunk, fx
14:53
[fx] gc panel: prevent autorefresh after opening the tooltip check-in: 364440f87f user: olr tags: trunk, fx
Changes

Modified gc_lang/fr/webext/content_scripts/panel_gc.js from [079c92ab4e] to [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
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.hasOwnProperty("clipboard") && navigator.clipboard.hasOwnProperty("writeText")) {
        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);