Grammalecte  Diff

Differences From Artifact [7e87ea2dd9]:

To Artifact [b9694fbb2e]:


382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
    }

    addMessageToGCPanel (sMessage) {
        let xNode = oGrammalecte.createNode("div", {className: "grammalecte_panel_flow_message", textContent: sMessage});
        this.xParagraphList.appendChild(xNode);
    }

    _copyToClipboard (sText)  {
        // 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);
        }
        document.addEventListener("copy", setClipboardData, true);
        document.execCommand("copy");
    }

    copyTextToClipboard () {
        this.startWaitIcon();
        try {
            let xClipboardButton = this.xParent.getElementById("grammalecte_clipboard_button");
            xClipboardButton.textContent = "⇒ presse-papiers";
            let sText = "";
            // Quand c'est dans un shadow "this.xParent.getElementsByClassName" n'existe pas.
            let xElem = this.xParent.getElementById("grammalecte_gc_panel");
            for (let xNode of xElem.getElementsByClassName("grammalecte_paragraph")) {
                sText += xNode.textContent + "\n";
            }
            this._copyToClipboard(sText);
            window.setTimeout(() => { xClipboardButton.textContent = "📋"; }, 2000);
        }
        catch (e) {
            showError(e);
        }
        this.stopWaitIcon();
    }







<
<
<
<
<
<
<
<
<
<
<
<











|







382
383
384
385
386
387
388












389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
    }

    addMessageToGCPanel (sMessage) {
        let xNode = oGrammalecte.createNode("div", {className: "grammalecte_panel_flow_message", textContent: sMessage});
        this.xParagraphList.appendChild(xNode);
    }













    copyTextToClipboard () {
        this.startWaitIcon();
        try {
            let xClipboardButton = this.xParent.getElementById("grammalecte_clipboard_button");
            xClipboardButton.textContent = "⇒ presse-papiers";
            let sText = "";
            // Quand c'est dans un shadow "this.xParent.getElementsByClassName" n'existe pas.
            let xElem = this.xParent.getElementById("grammalecte_gc_panel");
            for (let xNode of xElem.getElementsByClassName("grammalecte_paragraph")) {
                sText += xNode.textContent + "\n";
            }
            oGrammalecte.sendTextToClipboard(sText);
            window.setTimeout(() => { xClipboardButton.textContent = "📋"; }, 2000);
        }
        catch (e) {
            showError(e);
        }
        this.stopWaitIcon();
    }