Grammalecte  Diff

Differences From Artifact [fa30498314]:

To Artifact [72d2d1fb85]:


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
        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();
    }


































    // Lexicographer

    clearLexicographer () {
        this.nLxgCount = 0;
        while (this.xLxgPanelContent.firstChild) {
            this.xLxgPanelContent.removeChild(this.xLxgPanelContent.firstChild);







|
<

|




|
|







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







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
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
        let xNode = oGrammalecte.createNode("div", {className: "grammalecte_panel_flow_message", textContent: sMessage});
        this.xParagraphList.appendChild(xNode);
    }

    copyTextToClipboard () {
        this.startWaitIcon();
        try {


            let sText = "";
            // 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._sendTextToClipboard(sText);

        }
        catch (e) {
            showError(e);
        }
        this.stopWaitIcon();
    }

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

    _sendTextToClipboardFallback (sText, xClipboardButton) {
        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);
            }
            document.addEventListener("copy", setClipboardData, true);
            document.execCommand("copy");
            window.setTimeout(() => { xClipboardButton.textContent = "📋"; }, 2000);
        }
        catch (e) {
            console.error(e);
        }
    }

    // Lexicographer

    clearLexicographer () {
        this.nLxgCount = 0;
        while (this.xLxgPanelContent.firstChild) {
            this.xLxgPanelContent.removeChild(this.xLxgPanelContent.firstChild);