Grammalecte  Check-in [218f25c554]

Overview
Comment:[tb][fx] MailExtension: copy all paragraphs to cmopose window when closing the gc panel
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | tb | fx | mailext
Files: files | file ages | folders
SHA3-256: 218f25c554030dc3e20c59c840be9be8620e3dda1462cc6f6e59661503450edb
User & Date: olr on 2020-07-10 11:00:14
Other Links: branch diff | manifest | tags
Context
2020-07-10
11:02
[tb][fx] merge mailext: MailExtension (as extension of WebExtension) check-in: ad5baf4d9f user: olr tags: trunk, build, tb, major_change, fx
11:00
[tb][fx] MailExtension: copy all paragraphs to cmopose window when closing the gc panel Closed-Leaf check-in: 218f25c554 user: olr tags: tb, fx, mailext
08:28
merge trunk check-in: bbfed11857 user: olr tags: mailext
Changes

Modified gc_lang/fr/webext/content_scripts/editor.js from [4d321e586a] to [c96624ca8d].

16
17
18
19
20
21
22



23
24
25
26
27
28
29
        this.xRootNode = xDocument.body;
        //console.log(xDocument.body);
        //console.log(xDocument.body.innerHTML);
        this.lNode = [];
        this.bCheckSignature = bCheckSignature;
        this._lParsableNodes = ["P", "LI", "H1", "H2", "H3", "H4", "H5", "H6"];
        this._lRootNodes = ["DIV", "UL", "OL"];



    }

    * _getParsableNodes (xRootNode) {
        // recursive function
        try {
            for (let xNode of xRootNode.childNodes) {
                if (xNode.className !== "moz-cite-prefix" && xNode.tagName !== "BLOCKQUOTE"







>
>
>







16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
        this.xRootNode = xDocument.body;
        //console.log(xDocument.body);
        //console.log(xDocument.body.innerHTML);
        this.lNode = [];
        this.bCheckSignature = bCheckSignature;
        this._lParsableNodes = ["P", "LI", "H1", "H2", "H3", "H4", "H5", "H6"];
        this._lRootNodes = ["DIV", "UL", "OL"];
        if (bThunderbird) {
            oGrammalecte.oGCPanel.addMessageToGCPanel("❗ Interface pour Thunderbird en version bêta.");
        }
    }

    * _getParsableNodes (xRootNode) {
        // recursive function
        try {
            for (let xNode of xRootNode.childNodes) {
                if (xNode.className !== "moz-cite-prefix" && xNode.tagName !== "BLOCKQUOTE"

Modified gc_lang/fr/webext/content_scripts/panel_gc.js from [505aead2d8] to [30dbeca75c].

58
59
60
61
62
63
64

65
66
67
68
69
70
71
        this.xGCPanelContent.appendChild(this.xParagraphList);
        this.xPanelContent.addEventListener("click", onGrammalecteGCPanelClick, false);
        this.oTooltip = new GrammalecteTooltip(this.xParent, this.xGCPanelContent);
        this.xPanelContent.appendChild(this.xGCPanelContent);
        this.oTextControl = null;
        this.nLastResult = 0;
        this.iLastEditedParagraph = -1;

        // Lexicographer
        this.nLxgCount = 0;
        this.xLxgPanelContent = oGrammalecte.createNode("div", {id: "grammalecte_lxg_panel_content"});
        this.xPanelContent.appendChild(this.xLxgPanelContent);
        // Conjugueur
        this.xConjPanelContent = oGrammalecte.createNode("div", {id: "grammalecte_conj_panel_content"});
        this.xConjPanelContent.innerHTML = sGrammalecteConjugueurHTML;  // @Reviewers: sGrammalecteConjugueurHTML is a const value defined in <content_scripts/html_src.js>







>







58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
        this.xGCPanelContent.appendChild(this.xParagraphList);
        this.xPanelContent.addEventListener("click", onGrammalecteGCPanelClick, false);
        this.oTooltip = new GrammalecteTooltip(this.xParent, this.xGCPanelContent);
        this.xPanelContent.appendChild(this.xGCPanelContent);
        this.oTextControl = null;
        this.nLastResult = 0;
        this.iLastEditedParagraph = -1;
        this.nParagraph = 0;
        // Lexicographer
        this.nLxgCount = 0;
        this.xLxgPanelContent = oGrammalecte.createNode("div", {id: "grammalecte_lxg_panel_content"});
        this.xPanelContent.appendChild(this.xLxgPanelContent);
        // Conjugueur
        this.xConjPanelContent = oGrammalecte.createNode("div", {id: "grammalecte_conj_panel_content"});
        this.xConjPanelContent.innerHTML = sGrammalecteConjugueurHTML;  // @Reviewers: sGrammalecteConjugueurHTML is a const value defined in <content_scripts/html_src.js>
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
        }
        else if (typeof(what) === "string" || (what.nodeType && what.nodeType === 1)) {
            // Text or node
            this.oTextControl = new TextNodeEditor(what, xResultNode);
        }
        else {
            // error
            oGrammalecte.oMessageBox.showMessage("[BUG] Analyse d’un élément inconnu…");
            console.log("[Grammalecte] Unknown element:", what);
        }
    }

    setAutoRefreshButton () {
        this.xAutoRefresh.style.backgroundColor = (this.bAutoRefresh) ? "hsl(150, 50%, 50%)" : "";
        this.xAutoRefresh.style.color = (this.bAutoRefresh) ? "hsl(150, 50%, 96%)" : "";







|







148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
        }
        else if (typeof(what) === "string" || (what.nodeType && what.nodeType === 1)) {
            // Text or node
            this.oTextControl = new TextNodeEditor(what, xResultNode);
        }
        else {
            // error
            oGrammalecte.showMessage("[BUG] Analyse d’un élément inconnu…");
            console.log("[Grammalecte] Unknown element:", what);
        }
    }

    setAutoRefreshButton () {
        this.xAutoRefresh.style.backgroundColor = (this.bAutoRefresh) ? "hsl(150, 50%, 50%)" : "";
        this.xAutoRefresh.style.color = (this.bAutoRefresh) ? "hsl(150, 50%, 96%)" : "";
212
213
214
215
216
217
218




219
220
221
222
223
224
225
        while (this.xParagraphList.firstChild) {
            this.xParagraphList.removeChild(this.xParagraphList.firstChild);
        }
        this.aIgnoredErrors.clear();
    }

    hide () {




        if (oGrammalecte.oTFPanel) { oGrammalecte.oTFPanel.hide(); }
        if (oGrammalecte.oMessageBox) { oGrammalecte.oMessageBox.hide(); }
        oGrammalecte.clearRightClickedNode();
        this.xPanel.style.display = "none";
        this.oTextControl.clear();
    }








>
>
>
>







213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
        while (this.xParagraphList.firstChild) {
            this.xParagraphList.removeChild(this.xParagraphList.firstChild);
        }
        this.aIgnoredErrors.clear();
    }

    hide () {
        if (bThunderbird) {
            oGrammalecte.showMessage("Veuillez patienter…");
            this.copyAllParagraphsToComposeWindow();
        }
        if (oGrammalecte.oTFPanel) { oGrammalecte.oTFPanel.hide(); }
        if (oGrammalecte.oMessageBox) { oGrammalecte.oMessageBox.hide(); }
        oGrammalecte.clearRightClickedNode();
        this.xPanel.style.display = "none";
        this.oTextControl.clear();
    }

248
249
250
251
252
253
254

255
256
257
258
259
260
261
                }.bind(this)
                , true);
                this._tagParagraph(xParagraph, oResult.sParagraph, oResult.iParaNum, oResult.aGrammErr, oResult.aSpellErr);
                // creation
                xNodeDiv.appendChild(xActionsBar);
                xNodeDiv.appendChild(xParagraph);
                this.xParagraphList.appendChild(xNodeDiv);

            }
        }
        catch (e) {
            showError(e);
        }
    }








>







253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
                }.bind(this)
                , true);
                this._tagParagraph(xParagraph, oResult.sParagraph, oResult.iParaNum, oResult.aGrammErr, oResult.aSpellErr);
                // creation
                xNodeDiv.appendChild(xActionsBar);
                xNodeDiv.appendChild(xParagraph);
                this.xParagraphList.appendChild(xNodeDiv);
                this.nParagraph += 1;
            }
        }
        catch (e) {
            showError(e);
        }
    }

439
440
441
442
443
444
445











446
447
448
449
450
451
452
            showError(e);
        }
    }

    addSummary () {
        // todo
    }












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

    copyTextToClipboard () {







>
>
>
>
>
>
>
>
>
>
>







445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
            showError(e);
        }
    }

    addSummary () {
        // todo
    }

    copyAllParagraphsToComposeWindow () {
        // Thunderbird only
        // When closing the window, we change all nodes according to the content of paragraphs in the gc panel
        for (let iPara = 0;  iPara < this.nParagraph;  iPara++) {
            let sParagraphId = "grammalecte_paragraph"+iPara;
            if (this.xParent.getElementById(sParagraphId)) {
                this.oTextControl.setParagraph(iPara, this.xParent.getElementById(sParagraphId).textContent);
            }
        }
    }

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

    copyTextToClipboard () {