Index: gc_lang/fr/webext/content_scripts/editor.js ================================================================== --- gc_lang/fr/webext/content_scripts/editor.js +++ gc_lang/fr/webext/content_scripts/editor.js @@ -16,11 +16,11 @@ 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"]; + this._lParsableNodes = ["P", "LI", "H1", "H2", "H3", "H4", "H5", "H6"]; this._lRootNodes = ["DIV", "UL", "OL"]; } * _getParsableNodes (xRootNode) { // recursive function @@ -85,11 +85,11 @@ } } setParagraph (iPara, sText) { try { - return this.lNode[iPara].textContent = sText; + return this.lNode[iPara].textContent = oGrammalecte.purgeText(sText); } catch (e) { showError(e); } } @@ -189,11 +189,11 @@ getText () { return [...this.dParagraph.values()].join("\n").normalize("NFC"); } setParagraph (iParagraph, sText) { - this.dParagraph.set(iParagraph, sText); + this.dParagraph.set(iParagraph, oGrammalecte.purgeText(sText)); this.write(); } getParagraph (iParaNum) { return this.dParagraph.get(iParaNum); Index: gc_lang/fr/webext/content_scripts/init.js ================================================================== --- gc_lang/fr/webext/content_scripts/init.js +++ gc_lang/fr/webext/content_scripts/init.js @@ -68,11 +68,11 @@ sExtensionUrl: null, oOptions: null, - bAutoRefresh: true, + bAutoRefresh: (bThunderbird) ? false : true, listen: function () { document.addEventListener("click", (xEvent) => { //console.log("click", xEvent.target.id); this.oPanelButton.examineNode(xEvent.target); @@ -143,10 +143,14 @@ if (nPos >= 0) { sPageText = sPageText.slice(0, nPos).normalize("NFC"); } return sPageText; }, + + purgeText: function (sText) { + return sText.replace(/ /g, " ").replace(/</g, "<").replace(/>/g, ">").replace(/&/g, "&"); + }, createNode: function (sType, oAttr, oDataset=null) { try { let xNode = document.createElement(sType); Object.assign(xNode, oAttr); @@ -266,10 +270,13 @@ }; function autoRefreshOption (oSavedOptions=null) { // auto recallable function + if (bThunderbird) { + return; + } if (oSavedOptions === null) { if (bChrome) { browser.storage.local.get("autorefresh_option", autoRefreshOption); return; } Index: gc_lang/fr/webext/content_scripts/panel_gc.js ================================================================== --- gc_lang/fr/webext/content_scripts/panel_gc.js +++ gc_lang/fr/webext/content_scripts/panel_gc.js @@ -99,10 +99,14 @@ if (!this.bWorking) { this.showEditor(); } }; this.xAutoRefresh.onclick = () => { + if (bThunderbird) { + oGrammalecte.showMessage("À cause d’une limitation de Thunberbird, l’auto-rafraîchissement est indisponible. Si vous modifiez le texte dans ce panneau, cliquez sur le bouton ↻ pour relancer l’analyse grammaticale du paragraphe.") + return; + } this.bAutoRefresh = !this.bAutoRefresh; oGrammalecte.bAutoRefresh = this.bAutoRefresh; browser.storage.local.set({"autorefresh_option": this.bAutoRefresh}); this.setAutoRefreshButton(); } @@ -238,11 +242,11 @@ window.clearTimeout(parseInt(xParagraph.dataset.timer_id, 10)); xParagraph.dataset.timer_id = window.setTimeout(this.recheckParagraph.bind(this), 3000, oResult.iParaNum); this.iLastEditedParagraph = oResult.iParaNum; } // write text - this.oTextControl.setParagraph(parseInt(xEvent.target.dataset.para_num, 10), this.purgeText(xEvent.target.textContent)); + this.oTextControl.setParagraph(parseInt(xEvent.target.dataset.para_num, 10), xEvent.target.textContent); }.bind(this) , true); this._tagParagraph(xParagraph, oResult.sParagraph, oResult.iParaNum, oResult.aGrammErr, oResult.aSpellErr); // creation xNodeDiv.appendChild(xActionsBar); @@ -276,11 +280,14 @@ return; } let sParagraphId = "grammalecte_paragraph" + iParaNum; let xParagraph = this.xParent.getElementById(sParagraphId); this._blockParagraph(xParagraph); - //let sText = this.purgeText(xParagraph.textContent); + if (bThunderbird) { + // WORKAROUND: input event isn’t triggered by key input, so as textContent isn’t up to date, we do it now + this.oTextControl.setParagraph(iParaNum, xParagraph.textContent); + } let sText = this.oTextControl.getParagraph(iParaNum); oGrammalecteBackgroundPort.parseAndSpellcheck1(sText, "__GrammalectePanel__", sParagraphId); } refreshParagraph (sParagraphId, oResult) { @@ -407,11 +414,11 @@ let xNodeErr = this.xParent.getElementById("grammalecte_err" + sErrorId); xNodeErr.textContent = this.xParent.getElementById(sNodeSuggId).textContent; xNodeErr.className = "grammalecte_error_corrected"; xNodeErr.removeAttribute("style"); let iParaNum = parseInt(sErrorId.slice(0, sErrorId.indexOf("-")), 10); - this.oTextControl.setParagraph(iParaNum, this.purgeText(this.xParent.getElementById("grammalecte_paragraph" + iParaNum).textContent)); + this.oTextControl.setParagraph(iParaNum, this.xParent.getElementById("grammalecte_paragraph" + iParaNum).textContent); this.oTooltip.hide(); this.recheckParagraph(iParaNum); this.iLastEditedParagraph = iParaNum; } catch (e) { @@ -431,14 +438,10 @@ catch (e) { showError(e); } } - purgeText (sText) { - return sText.replace(/ /g, " ").replace(/</g, "<").replace(/>/g, ">").replace(/&/g, "&"); - } - addSummary () { // todo } addMessageToGCPanel (sMessage) { Index: gc_lang/fr/webext/content_scripts/panel_tf.js ================================================================== --- gc_lang/fr/webext/content_scripts/panel_tf.js +++ gc_lang/fr/webext/content_scripts/panel_tf.js @@ -75,20 +75,22 @@ xMisc.appendChild(this._createOrdinalOptions()); xMisc.appendChild(this._createBlockOption("o_etc", true, "Et cætera, etc.")); xMisc.appendChild(this._createBlockOption("o_missing_hyphens", true, "Traits d’union manquants")); xMisc.appendChild(this._createBlockOption("o_ma_word", true, "Apostrophes manquantes")); xMisc.appendChild(this._createSingleLetterOptions()); - let xStruct = this._createFieldset("group_struct", false, "Restructuration [!]"); - xStruct.appendChild(this._createBlockOption("o_remove_hyphens_at_end_of_paragraphs", false, "Enlever césures en fin de ligne/paragraphe [!]")); - xStruct.appendChild(this._createBlockOption("o_merge_contiguous_paragraphs", false, "Fusionner les paragraphes contigus [!]")); xColumn1.appendChild(xSSP); xColumn1.appendChild(xSpace); xColumn1.appendChild(xNBSP); xColumn1.appendChild(xDelete); xColumn2.appendChild(xTypo); xColumn2.appendChild(xMisc); - xColumn2.appendChild(xStruct); + if (!bThunderbird) { + let xStruct = this._createFieldset("group_struct", false, "Restructuration [!]"); + xStruct.appendChild(this._createBlockOption("o_remove_hyphens_at_end_of_paragraphs", false, "Enlever césures en fin de ligne/paragraphe [!]")); + xStruct.appendChild(this._createBlockOption("o_merge_contiguous_paragraphs", false, "Fusionner les paragraphes contigus [!]")); + xColumn2.appendChild(xStruct); + } xOptions.appendChild(xColumn1); xOptions.appendChild(xColumn2); // Actions let xActions = oGrammalecte.createNode("div", {id: "grammalecte_tf_actions"}); let xDefaultButton = oGrammalecte.createNode("div", {id: "grammalecte_tf_reset", textContent: "Par défaut", className: "grammalecte_tf_button"});