Grammalecte  Check-in [b210b1ca73]

Overview
Comment:[build] aHSL for colors [fx] new error underlining
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | build | fx
Files: files | file ages | folders
SHA3-256: b210b1ca73057e987ee9e2c802c16576020a8060fdcd95f19cf8080ed94e1ca3
User & Date: olr on 2020-03-27 10:13:07
Other Links: manifest | tags
Context
2020-03-27
12:01
[fr] mise à jour des dictionnaires, adaptation des règles check-in: fd348a300b user: olr tags: trunk, fr
10:13
[build] aHSL for colors [fx] new error underlining check-in: b210b1ca73 user: olr tags: trunk, build, fx
2020-03-26
22:45
[fx] main panel: don’t wrap link text content with <b> check-in: 75737f3b7b user: olr tags: trunk, fx
Changes

Modified compile_rules.py from [eebd1a5977] to [5ad409424e].

36
37
38
39
40
41
42

43
44
45
46
47

48
49
50
51
52
53
54
    r, g, b = colorsys.hls_to_rgb(h/360, l/100, s/100)
    return [round(r*255), round(g*255), round(b*255)]


def createColors (dColor):
    "dictionary of colors {color_name: [h, s, l]} -> returns dictionary of colors as dictionaries of color types"
    dColorType = {

        "sCSS": {},     # dictionary of colors as strings for HTML/CSS (example: hsl(0, 50%, 50%))
        "aRGB": {},     # dictionary of colors as RGB tuple
        "nInt": {}      # dictionary of colors as integer values (for Writer)
    }
    for sKey, aHSL in dColor.items():

        dColorType["sCSS"][sKey] = "hsl({}, {}%, {}%)".format(*aHSL)
        dColorType["aRGB"][sKey] = convertHSLToRBG(*aHSL)
        dColorType["nInt"][sKey] = convertRGBToInteger(*dColorType["aRGB"][sKey])
    return dColorType


def prepareFunction (s):







>

|



>







36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
    r, g, b = colorsys.hls_to_rgb(h/360, l/100, s/100)
    return [round(r*255), round(g*255), round(b*255)]


def createColors (dColor):
    "dictionary of colors {color_name: [h, s, l]} -> returns dictionary of colors as dictionaries of color types"
    dColorType = {
        "aHSL": {},     # dictionary of colors as HSL list
        "sCSS": {},     # dictionary of colors as strings for HTML/CSS (example: hsl(0, 50%, 50%))
        "aRGB": {},     # dictionary of colors as RGB list
        "nInt": {}      # dictionary of colors as integer values (for Writer)
    }
    for sKey, aHSL in dColor.items():
        dColorType["aHSL"][sKey] = aHSL
        dColorType["sCSS"][sKey] = "hsl({}, {}%, {}%)".format(*aHSL)
        dColorType["aRGB"][sKey] = convertHSLToRBG(*aHSL)
        dColorType["nInt"][sKey] = convertRGBToInteger(*dColorType["aRGB"][sKey])
    return dColorType


def prepareFunction (s):

Modified gc_lang/fr/webext/content_scripts/panel_gc.css from [4c07e86380] to [ae16866faf].

14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
}

p.grammalecte_paragraph {
    margin: 0;
    padding: 12px;
    background-color: hsl(0, 0%, 96%);
    border-radius: 2px;
    line-height: normal;
    text-align: left;
    font-size: 14px;
    font-family: "Courier New", Courier, "Lucida Sans Typewriter", "Lucida Typewriter", monospace;
    color: hsl(0, 0%, 0%);
    hyphens: none;
}








|







14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
}

p.grammalecte_paragraph {
    margin: 0;
    padding: 12px;
    background-color: hsl(0, 0%, 96%);
    border-radius: 2px;
    line-height: 1.3;
    text-align: left;
    font-size: 14px;
    font-family: "Courier New", Courier, "Lucida Sans Typewriter", "Lucida Typewriter", monospace;
    color: hsl(0, 0%, 0%);
    hyphens: none;
}

205
206
207
208
209
210
211
212

213
214
215
216
217
218
219

220
221
222
223
224
225
226
227
228






229
230
231
232
233
234
235
236
237
238
    color: hsla(0, 0%, 100%, 1);
}


/*
    ERRORS
*/
mark.grammalecte_error {

    margin: 0;
    padding: 0;
    cursor: pointer;
    border-radius: 2px;
    /* default color */
    background-color: hsl(240, 10%, 50%);
    color: hsl(240, 0%, 96%);

    font-size: 14px;
    font-style: normal;
    font-family : "Courier New", Courier, "Lucida Sans Typewriter", "Lucida Typewriter", monospace;
    text-decoration: none;
    text-shadow: unset;
    text-align: left;
    hyphens: none;
}
mark.grammalecte_error:hover {






    background-color: hsl(240, 10%, 40%);
    color: hsl(240, 0%, 100%);
    box-shadow: 0px 0px 0px 3px hsla(0, 0%, 50%, 0.2);
}

mark.grammalecte_error_corrected,
mark.grammalecte_error_ignored {
    margin: 0;
    padding: 0;
    display: inline-block;







|
>




<
|
|
>








|
>
>
>
>
>
>
|
|
|







205
206
207
208
209
210
211
212
213
214
215
216
217

218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
    color: hsla(0, 0%, 100%, 1);
}


/*
    ERRORS
*/
mark.grammalecte_error,
mark.grammalecte_spellerror {
    margin: 0;
    padding: 0;
    cursor: pointer;
    border-radius: 2px;

    background-color: hsl(240, 0%, 80%);        /* default color */
    color: hsl(240, 0%, 10%);                   /* default color */
    border-bottom: solid 2px hsl(0, 0%, 50%);   /* default color */
    font-size: 14px;
    font-style: normal;
    font-family : "Courier New", Courier, "Lucida Sans Typewriter", "Lucida Typewriter", monospace;
    text-decoration: none;
    text-shadow: unset;
    text-align: left;
    hyphens: none;
}
mark.grammalecte_error:hover,
mark.grammalecte_spellerror:hover {
    opacity: .9;
    box-shadow: 0px 0px 0px 3px hsla(0, 0%, 50%, 0.25);
}

mark.grammalecte_spellerror {
    background-color: hsl(0, 100%, 88%);
    color: hsl(0, 80%, 30%);
    border-bottom: solid 2px hsl(0, 100%, 50%);
}

mark.grammalecte_error_corrected,
mark.grammalecte_error_ignored {
    margin: 0;
    padding: 0;
    display: inline-block;

Modified gc_lang/fr/webext/content_scripts/panel_gc.js from [c1b09949c0] to [8b9524e63b].

345
346
347
348
349
350
351



352

353
354
355
356
357
358
359






360

361
362

363
364
365
366
367
368
369
    _createError (sUnderlined, oErr) {
        let xNodeErr = document.createElement("mark");
        xNodeErr.id = "grammalecte_err" + oErr['sErrorId'];
        xNodeErr.textContent = sUnderlined;
        xNodeErr.dataset.error_id = oErr['sErrorId'];
        xNodeErr.dataset.ignored_key = oErr['sIgnoredKey'];
        xNodeErr.dataset.error_type = (oErr['sType'] === "WORD") ? "spelling" : "grammar";



        if (xNodeErr.dataset.error_type === "grammar") {

            xNodeErr.dataset.gc_message = oErr['sMessage'];
            xNodeErr.dataset.gc_url = oErr['URL'];
            if (xNodeErr.dataset.gc_message.includes(" #")) {
                xNodeErr.dataset.line_id = oErr['sLineId'];
                xNodeErr.dataset.rule_id = oErr['sRuleId'];
            }
            xNodeErr.dataset.suggestions = oErr["aSuggestions"].join("|");






        }

        xNodeErr.className = (this.aIgnoredErrors.has(xNodeErr.dataset.ignored_key)) ? "grammalecte_error_ignored" : "grammalecte_error";
        xNodeErr.style.backgroundColor = (oErr['sType'] === "WORD") ? "hsl(0, 50%, 50%)" : oErr["aColor"];

        return xNodeErr;
    }

    _blockParagraph (xParagraph) {
        xParagraph.contentEditable = "false";
        this.xParent.getElementById("grammalecte_check"+xParagraph.dataset.para_num).textContent = "!!";
        this.xParent.getElementById("grammalecte_check"+xParagraph.dataset.para_num).style.backgroundColor = "hsl(0, 50%, 50%)";







>
>
>
|
>







>
>
>
>
>
>

>
|
<
>







345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372

373
374
375
376
377
378
379
380
    _createError (sUnderlined, oErr) {
        let xNodeErr = document.createElement("mark");
        xNodeErr.id = "grammalecte_err" + oErr['sErrorId'];
        xNodeErr.textContent = sUnderlined;
        xNodeErr.dataset.error_id = oErr['sErrorId'];
        xNodeErr.dataset.ignored_key = oErr['sIgnoredKey'];
        xNodeErr.dataset.error_type = (oErr['sType'] === "WORD") ? "spelling" : "grammar";
        if (this.aIgnoredErrors.has(xNodeErr.dataset.ignored_key)) {
            xNodeErr.className = "grammalecte_error_ignored";
        }
        else if (xNodeErr.dataset.error_type === "grammar") {
            xNodeErr.className = "grammalecte_error";
            xNodeErr.dataset.gc_message = oErr['sMessage'];
            xNodeErr.dataset.gc_url = oErr['URL'];
            if (xNodeErr.dataset.gc_message.includes(" #")) {
                xNodeErr.dataset.line_id = oErr['sLineId'];
                xNodeErr.dataset.rule_id = oErr['sRuleId'];
            }
            xNodeErr.dataset.suggestions = oErr["aSuggestions"].join("|");
            let sHue = oErr["aColor"][0].toString();
            let sSat = oErr["aColor"][1].toString();
            let sLum = oErr["aColor"][2].toString();
            xNodeErr.style.color = `hsl(${sHue}, ${sSat}%, 15%)`;
            xNodeErr.style.backgroundColor = `hsl(${sHue}, ${sSat}%, 85%)`;
            xNodeErr.style.borderBottom = `solid 2px hsl(${sHue}, ${sSat}%, ${sLum}%)`;
        }
        else {
            xNodeErr.className = "grammalecte_spellerror";

        }
        return xNodeErr;
    }

    _blockParagraph (xParagraph) {
        xParagraph.contentEditable = "false";
        this.xParent.getElementById("grammalecte_check"+xParagraph.dataset.para_num).textContent = "!!";
        this.xParent.getElementById("grammalecte_check"+xParagraph.dataset.para_num).style.backgroundColor = "hsl(0, 50%, 50%)";
402
403
404
405
406
407
408

409
410
411
412
413
414
415

    ignoreError (sIgnoreButtonId) {  // ignore
        try {
            let sErrorId = this.xParent.getElementById(sIgnoreButtonId).dataset.error_id;
            let xNodeErr = this.xParent.getElementById("grammalecte_err" + sErrorId);
            this.aIgnoredErrors.add(xNodeErr.dataset.ignored_key);
            xNodeErr.className = "grammalecte_error_ignored";

            this.oTooltip.hide();
        }
        catch (e) {
            showError(e);
        }
    }








>







413
414
415
416
417
418
419
420
421
422
423
424
425
426
427

    ignoreError (sIgnoreButtonId) {  // ignore
        try {
            let sErrorId = this.xParent.getElementById(sIgnoreButtonId).dataset.error_id;
            let xNodeErr = this.xParent.getElementById("grammalecte_err" + sErrorId);
            this.aIgnoredErrors.add(xNodeErr.dataset.ignored_key);
            xNodeErr.className = "grammalecte_error_ignored";
            xNodeErr.removeAttribute("style");
            this.oTooltip.hide();
        }
        catch (e) {
            showError(e);
        }
    }

Modified gc_lang/fr/webext/gce_worker.js from [2a88013ffc] to [67fa9791af].

172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
    try {
        if (!bInitDone) {
            //console.log("[Worker] Loading… Extension path: " + sExtensionPath);
            conj.init(helpers.loadFile(sExtensionPath + "/grammalecte/fr/conj_data.json"));
            phonet.init(helpers.loadFile(sExtensionPath + "/grammalecte/fr/phonet_data.json"));
            mfsp.init(helpers.loadFile(sExtensionPath + "/grammalecte/fr/mfsp_data.json"));
            //console.log("[Worker] Modules have been initialized…");
            gc_engine.load(sContext, "sCSS", sExtensionPath+"grammalecte/graphspell/_dictionaries");
            oSpellChecker = gc_engine.getSpellChecker();
            oTest = new TestGrammarChecking(gc_engine, sExtensionPath+"/grammalecte/fr/tests_data.json");
            oTokenizer = new Tokenizer("fr");
            oLocution =  helpers.loadFile(sExtensionPath + "/grammalecte/fr/locutions_data.json");
            oLxg = new Lexicographe(oSpellChecker, oTokenizer, oLocution);
            if (dOptions !== null) {
                if (!(dOptions instanceof Map)) {







|







172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
    try {
        if (!bInitDone) {
            //console.log("[Worker] Loading… Extension path: " + sExtensionPath);
            conj.init(helpers.loadFile(sExtensionPath + "/grammalecte/fr/conj_data.json"));
            phonet.init(helpers.loadFile(sExtensionPath + "/grammalecte/fr/phonet_data.json"));
            mfsp.init(helpers.loadFile(sExtensionPath + "/grammalecte/fr/mfsp_data.json"));
            //console.log("[Worker] Modules have been initialized…");
            gc_engine.load(sContext, "aHSL", sExtensionPath+"grammalecte/graphspell/_dictionaries");
            oSpellChecker = gc_engine.getSpellChecker();
            oTest = new TestGrammarChecking(gc_engine, sExtensionPath+"/grammalecte/fr/tests_data.json");
            oTokenizer = new Tokenizer("fr");
            oLocution =  helpers.loadFile(sExtensionPath + "/grammalecte/fr/locutions_data.json");
            oLxg = new Lexicographe(oSpellChecker, oTokenizer, oLocution);
            if (dOptions !== null) {
                if (!(dOptions instanceof Map)) {