Grammalecte  Check-in [17feca742f]

Overview
Comment:[tb] delete editor.js: deprecated code
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | tb
Files: files | file ages | folders
SHA3-256: 17feca742f6d8d0bc568bef573b39a1b06e06e3cb4bdea0d971deb0b11c03554
User & Date: olr on 2020-07-20 08:32:11
Original Comment: [tb] remove deprecated code
Other Links: manifest | tags
Context
2020-07-20
08:34
[tb] delete file_handler.js: deprecated code check-in: 0b14dcdc9e user: olr tags: trunk, tb
08:32
[tb] delete editor.js: deprecated code check-in: 17feca742f user: olr tags: trunk, tb
2020-07-18
14:38
[fr] faux positifs et ajustements check-in: 0f2fdc8e40 user: olr tags: trunk, fr
Changes

Deleted gc_lang/fr/mailext/content/editor.js version [b8e86b0b84].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
// JavaScript

class Editor {

    constructor (sLang) {
        this.xEditor = GetCurrentEditor();
        this.lNode = [];
        this.lParsableNodes = ["P", "LI"];
        this.lRootNodes = ["DIV", "UL", "OL"];
    };

    _getTextFromNode (xNode) {
        if ("innerHTML" in xNode) {
            return xNode.innerHTML;
        } else {
            return xNode.textContent;
        }
    };

    * _getParsableNodes (xRootNode=this.xEditor.rootElement) {
        // recursive function
        try {
            for (let xNode of xRootNode.childNodes) {
                if (xNode.className !== "moz-cite-prefix" && xNode.tagName !== "BLOCKQUOTE"
                    && (xNode.nodeType == Node.TEXT_NODE || (xNode.nodeType == Node.ELEMENT_NODE && !xNode.textContent.startsWith(">")))
                    && xNode.textContent !== "") {
                    if (xNode.tagName === undefined) {
                        if (!xGrammalectePrefs.getBoolPref("bCheckSignature") && xNode.textContent.startsWith("-- ")) {
                            break;
                        }
                        yield xNode;
                    } else if (this.lParsableNodes.includes(xNode.tagName)) {
                        yield xNode;
                    } else if (this.lRootNodes.includes(xNode.tagName)) {
                        yield* this._getParsableNodes(xNode);
                    }
                }
            }
        } catch (e) {
            console.error(e);
            // Cu.reportError(e);
        }
    };

    * getParagraphs () {
        try {
            let i = 0;
            for (let xNode of this._getParsableNodes()) {
                this.lNode.push(xNode);
                yield [i, this._getTextFromNode(xNode)];
                i += 1;
            }
        } catch (e) {
            console.error(e);
            // Cu.reportError(e);
        }
    };

    getContent () {
        try {
            let sContent = "";
            for (let [i, sHTML] of this.getParagraphs()) {
                if (sContent.length > 0) {
                    sContent += "\n";
                }
                sContent += sHTML;
            }
            return sContent;
        } catch (e) {
            console.error(e);
            // Cu.reportError(e);
        }
    };

    getParagraph (iPara) {
        try {
            return this._getTextFromNode(this.lNode[iPara]);
        } catch (e) {
            console.error(e);
            // Cu.reportError(e);
        }
    };

    writeParagraph (iPara, sText) {
        try {
            let xNode = this.lNode[iPara];
            if ("innerHTML" in xNode) {
                xNode.innerHTML = sText;
            } else {
                xNode.textContent = sText;
            }
        } catch (e) {
            console.error(e);
            // Cu.reportError(e);
        }
    };

    changeParagraph (iPara, sModif, iStart, iEnd) {
        let sText = this.getParagraph(iPara);
        this.writeParagraph(iPara, sText.slice(0, iStart) + sModif + sText.slice(iEnd));
    };

    getLangFromSpellChecker () {
        try {
            let gSpellChecker = this.xEditor.getInlineSpellChecker(true);
            let sLang = gSpellChecker.spellChecker.GetCurrentDictionary();
            return sLang.slice(0, 2);
        } catch (e) {
            console.error(e);
            // Cu.reportError(e);
        }
    };
}
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<