Grammalecte  Check-in [6565051bbd]

Overview
Comment:[fx] Write corrections in editable node also
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | fx
Files: files | file ages | folders
SHA3-256: 6565051bbd70043de37faa40023ff4a619e3c0e2608f963f173ddbdecfc2305f
User & Date: olr on 2018-04-16 18:06:23
Other Links: manifest | tags
Context
2018-04-16
18:19
[fx] update warning text for editable nodes check-in: afa96e5e95 user: olr tags: fx, trunk
18:06
[fx] Write corrections in editable node also check-in: 6565051bbd user: olr tags: fx, trunk
13:36
[graphspell] suggestion mechanism: jumps check-in: 74cd9793a9 user: olr tags: graphspell, trunk
Changes

Modified gc_lang/fr/webext/content_scripts/panel_gc.js from [6bf4fd5886] to [4c86810835].

    55     55           this.oNodeControl = new GrammalecteNodeControl();
    56     56       }
    57     57   
    58     58       start (xNode=null) {
    59     59           this.oTooltip.hide();
    60     60           this.clear();
    61     61           if (xNode) {
    62         -            if (xNode.tagName == "TEXTAREA") {
    63         -                this.oNodeControl.setNode(xNode);
    64         -            } else {
    65         -                this.oNodeControl.clear();
    66         -                this.addMessage("Cette zone de texte n’est pas un champ de formulaire “textarea” mais un node HTML éditable. Les modifications ne seront pas répercutées automatiquement. Une fois votre texte corrigé, vous pouvez utiliser le bouton ‹∑› pour copier le texte dans le presse-papiers.");
           62  +            this.oNodeControl.setNode(xNode);
           63  +            if (xNode.tagName != "TEXTAREA") {
           64  +                this.addMessage("Note : cette zone de texte n’est pas un champ de formulaire “textarea” mais un node HTML éditable.");
    67     65               }
    68     66           }
    69     67       }
    70     68   
    71     69       clear () {
    72     70           while (this.xParagraphList.firstChild) {
    73     71               this.xParagraphList.removeChild(this.xParagraphList.firstChild);
................................................................................
   430    428   
   431    429   class GrammalecteNodeControl {
   432    430   
   433    431       constructor () {
   434    432           this.xNode = null;
   435    433           this.dParagraph = new Map();
   436    434           this.bTextArea = null;
   437         -        this.bWriteEN = false;  // write editable node
   438    435       }
   439    436   
   440    437       setNode (xNode) {
   441    438           this.clear();
   442    439           this.xNode = xNode;
   443    440           this.bTextArea = (xNode.tagName == "TEXTAREA");
   444    441           this.xNode.disabled = true;
................................................................................
   472    469               iStart = iEnd+1;
   473    470           }
   474    471           this.dParagraph.set(i, sText.slice(iStart));
   475    472           //console.log("Paragraphs number: " + (i+1));
   476    473       }
   477    474   
   478    475       write () {
   479         -        if (this.xNode !== null && (this.bTextArea || this.bWriteEN)) {
          476  +        if (this.xNode !== null) {
   480    477               let sText = "";
   481         -            this.dParagraph.forEach(function (val, key) {
   482         -                sText += val + "\n";
   483         -            });
   484         -            sText = sText.slice(0,-1).normalize("NFC");
   485    478               if (this.bTextArea) {
   486         -                this.xNode.value = sText;
          479  +                this.dParagraph.forEach(function (val, key) {
          480  +                    sText += val + "\n";
          481  +                });
          482  +                this.xNode.value = sText.slice(0,-1).normalize("NFC");
   487    483               } else {
   488         -                this.xNode.textContent = sText;
          484  +                this.dParagraph.forEach(function (val, key) {
          485  +                    sText += val + "<br/>";
          486  +                });
          487  +                this.xNode.innerHTML = sText.normalize("NFC");
   489    488               }
   490    489           }
   491    490       }
   492    491   }