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: trunk, fx
18:06
[fx] Write corrections in editable node also check-in: 6565051bbd user: olr tags: trunk, fx
13:36
[graphspell] suggestion mechanism: jumps check-in: 74cd9793a9 user: olr tags: trunk, graphspell
Changes

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

55
56
57
58
59
60
61
62
63

64
65
66


67
68
69
70
71
72
73
55
56
57
58
59
60
61


62



63
64
65
66
67
68
69
70
71







-
-
+
-
-
-
+
+







        this.oNodeControl = new GrammalecteNodeControl();
    }

    start (xNode=null) {
        this.oTooltip.hide();
        this.clear();
        if (xNode) {
            if (xNode.tagName == "TEXTAREA") {
                this.oNodeControl.setNode(xNode);
            this.oNodeControl.setNode(xNode);
            } else {
                this.oNodeControl.clear();
                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.");
            if (xNode.tagName != "TEXTAREA") {
                this.addMessage("Note : cette zone de texte n’est pas un champ de formulaire “textarea” mais un node HTML éditable.");
            }
        }
    }

    clear () {
        while (this.xParagraphList.firstChild) {
            this.xParagraphList.removeChild(this.xParagraphList.firstChild);
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
428
429
430
431
432
433
434

435
436
437
438
439
440
441







-








class GrammalecteNodeControl {

    constructor () {
        this.xNode = null;
        this.dParagraph = new Map();
        this.bTextArea = null;
        this.bWriteEN = false;  // write editable node
    }

    setNode (xNode) {
        this.clear();
        this.xNode = xNode;
        this.bTextArea = (xNode.tagName == "TEXTAREA");
        this.xNode.disabled = true;
472
473
474
475
476
477
478
479

480

481
482
483



484
485
486

487



488

489
490
491
492
469
470
471
472
473
474
475

476
477
478



479
480
481



482
483
484
485
486

487
488
489
490
491







-
+

+
-
-
-
+
+
+
-
-
-
+

+
+
+
-
+




            iStart = iEnd+1;
        }
        this.dParagraph.set(i, sText.slice(iStart));
        //console.log("Paragraphs number: " + (i+1));
    }

    write () {
        if (this.xNode !== null && (this.bTextArea || this.bWriteEN)) {
        if (this.xNode !== null) {
            let sText = "";
            if (this.bTextArea) {
            this.dParagraph.forEach(function (val, key) {
                sText += val + "\n";
            });
                this.dParagraph.forEach(function (val, key) {
                    sText += val + "\n";
                });
            sText = sText.slice(0,-1).normalize("NFC");
            if (this.bTextArea) {
                this.xNode.value = sText;
                this.xNode.value = sText.slice(0,-1).normalize("NFC");
            } else {
                this.dParagraph.forEach(function (val, key) {
                    sText += val + "<br/>";
                });
                this.xNode.textContent = sText;
                this.xNode.innerHTML = sText.normalize("NFC");
            }
        }
    }
}