Index: gc_lang/fr/modules-js/textformatter.js ================================================================== --- gc_lang/fr/modules-js/textformatter.js +++ gc_lang/fr/modules-js/textformatter.js @@ -349,7 +349,6 @@ } if (typeof(exports) !== 'undefined') { exports.TextFormatter = TextFormatter; - exports.oReplTable = oReplTable; } 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 @@ -9,10 +9,13 @@ constructor (...args) { super(...args); this.xTFNode = this._createTextFormatter(); this.xPanelContent.appendChild(this.xTFNode); this.xTextArea = null; + + this.TextFormatter = new TextFormatter(); + this.formatText = this.TextFormatter.formatTextRuleCount; } _createTextFormatter () { let xTFNode = document.createElement("div"); try { @@ -157,11 +160,11 @@ xLine.appendChild(this._createOption("o_ordinals_no_exponant", true, "Ordinaux (15e, XXIe…)")); xLine.appendChild(this._createOption("o_ordinals_exponant", true, "e → ᵉ")); xLine.appendChild(oGrammalecte.createNode("div", {id: "res_"+"o_ordinals_no_exponant", className: "grammalecte_tf_result", textContent: "·"})); return xLine; } - + /* Actions */ start (xNode) { if (xNode !== null && xNode.tagName == "TEXTAREA") { @@ -258,11 +261,11 @@ //window.setCursor("wait"); // change pointer this.resetProgressBar(); let sText = this.xTextArea.value.normalize("NFC"); document.getElementById('grammalecte_tf_progressbar').max = 7; let n1 = 0, n2 = 0, n3 = 0, n4 = 0, n5 = 0, n6 = 0, n7 = 0; - + // Restructuration if (this.isSelected("o_group_struct")) { if (this.isSelected("o_remove_hyphens_at_end_of_paragraphs")) { [sText, n1] = this.removeHyphenAtEndOfParagraphs(sText); document.getElementById('res_o_remove_hyphens_at_end_of_paragraphs').textContent = n1; @@ -508,28 +511,10 @@ catch (e) { showError(e); } } - formatText (sText, sOptName) { - let nCount = 0; - try { - if (!oReplTable.hasOwnProperty(sOptName)) { - console.log("# Error. TF: there is no option “" + sOptName+ "”."); - return [sText, nCount]; - } - for (let [zRgx, sRep] of oReplTable[sOptName]) { - nCount += (sText.match(zRgx) || []).length; - sText = sText.replace(zRgx, sRep); - } - } - catch (e) { - showError(e); - } - return [sText, nCount]; - } - removeHyphenAtEndOfParagraphs (sText) { let nCount = (sText.match(/-[  ]*\n/gm) || []).length; sText = sText.replace(/-[  ]*\n/gm, ""); return [sText, nCount]; }