Grammalecte  Check-in [9d2f92044a]

Overview
Comment:[fx] don’t rewrite text when rechecking paragraphs -> prevent bug of overlapping events
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | fx
Files: files | file ages | folders
SHA3-256: 9d2f92044a03d2aff0901757bd86f3dea5588c15cae5bf0dab399b6693ed4647
User & Date: olr on 2020-04-08 08:50:16
Other Links: manifest | tags
Context
2020-04-08
10:11
[build] build chrome extension check-in: 359d58c56b user: olr tags: build, trunk
08:50
[fx] don’t rewrite text when rechecking paragraphs -> prevent bug of overlapping events check-in: 9d2f92044a user: olr tags: fx, trunk
07:31
[fr] ajustements check-in: 651318a215 user: olr tags: fr, trunk
Changes

Modified gc_lang/fr/webext/content_scripts/api.js from [2457ed4f51] to [0dfb85fb05].

     7      7       // functions callable from within pages
     8      8       // to be sent to the content-cript via an event “GrammalecteCall”
     9      9   
    10     10       sVersion: "1.0",
    11     11   
    12     12       generateNodeId: function (xNode) {
    13     13           xNode.id = "grammalecte_generated_id_" + Date.now().toString(36) + "_" + (Math.floor(Math.random() * (1000000))).toString(36);
    14         -        console.log("[Grammalecte API] generated id", xNode.id);
           14  +        console.log("[Grammalecte API] generated id:", xNode.id);
    15     15           return xNode.id;
    16     16       },
    17     17   
    18     18       openPanelForNode: function (vNode) {
    19     19           //  Parameter: a HTML node or the identifier of a HTML node
    20     20           if (vNode instanceof HTMLElement) {
    21     21               let sNodeId = vNode.id || this.generateNodeId(vNode);

Modified gc_lang/fr/webext/content_scripts/panel_gc.js from [ec198a43f7] to [a5deafa9f3].

   277    277       recheckParagraph (iParaNum) {
   278    278           if (!this.bOpened) {
   279    279               return;
   280    280           }
   281    281           let sParagraphId = "grammalecte_paragraph" + iParaNum;
   282    282           let xParagraph = this.xParent.getElementById(sParagraphId);
   283    283           this._blockParagraph(xParagraph);
   284         -        let sText = this.purgeText(xParagraph.textContent);
          284  +        //let sText = this.purgeText(xParagraph.textContent);
          285  +        let sText = this.oTextControl.getParagraph(iParaNum);
   285    286           oGrammalecteBackgroundPort.parseAndSpellcheck1(sText, "__GrammalectePanel__", sParagraphId);
   286         -        this.oTextControl.setParagraph(iParaNum, sText);
   287         -        this.oTextControl.write();
   288    287       }
   289    288   
   290    289       refreshParagraph (sParagraphId, oResult) {
   291    290           // function called when results are sent by the Worker
   292    291           if (!this.bOpened) {
   293    292               return;
   294    293           }
................................................................................
   407    406           try {
   408    407               let sErrorId = this.xParent.getElementById(sNodeSuggId).dataset.error_id;
   409    408               //let sParaNum = sErrorId.slice(0, sErrorId.indexOf("-"));
   410    409               let xNodeErr = this.xParent.getElementById("grammalecte_err" + sErrorId);
   411    410               xNodeErr.textContent = this.xParent.getElementById(sNodeSuggId).textContent;
   412    411               xNodeErr.className = "grammalecte_error_corrected";
   413    412               xNodeErr.removeAttribute("style");
          413  +            let iParaNum = parseInt(sErrorId.slice(0, sErrorId.indexOf("-")), 10);
          414  +            this.oTextControl.setParagraph(iParaNum, this.purgeText(this.xParent.getElementById("grammalecte_paragraph" + iParaNum).textContent));
          415  +            this.oTextControl.write();
   414    416               this.oTooltip.hide();
   415         -            this.recheckParagraph(parseInt(sErrorId.slice(0, sErrorId.indexOf("-")), 10));
          417  +            this.recheckParagraph(iParaNum);
   416    418           }
   417    419           catch (e) {
   418    420               showError(e);
   419    421           }
   420    422       }
   421    423   
   422    424       ignoreError (sIgnoreButtonId) {  // ignore
................................................................................
  1030   1032       getText () {
  1031   1033           return [...this.dParagraph.values()].join("\n").normalize("NFC");
  1032   1034       }
  1033   1035   
  1034   1036       setParagraph (iParagraph, sText) {
  1035   1037           this.dParagraph.set(iParagraph, sText);
  1036   1038       }
         1039  +
         1040  +    getParagraph (iParaNum) {
         1041  +        return this.dParagraph.get(iParaNum);
         1042  +    }
  1037   1043   
  1038   1044       eraseNodeContent () {
  1039   1045           while (this.xNode.firstChild) {
  1040   1046               this.xNode.removeChild(this.xNode.firstChild);
  1041   1047           }
  1042   1048       }
  1043   1049