Grammalecte  Diff

Differences From Artifact [6bf4fd5886]:

To Artifact [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");
            }
        }
    }
}