Overview
Comment: | [fx] recheck paragraph: don’t replace caret in the previous position if last edited paragraph is another one |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk | fx |
Files: | files | file ages | folders |
SHA3-256: |
2b9b61bc322709850746c9d2dae80860 |
User & Date: | olr on 2020-04-10 06:29:20 |
Other Links: | manifest | tags |
Context
2020-04-10
| ||
09:47 | [fx] listen to port disconnection from background check-in: 7ca0d4636e user: olr tags: trunk, fx | |
06:29 | [fx] recheck paragraph: don’t replace caret in the previous position if last edited paragraph is another one check-in: 2b9b61bc32 user: olr tags: trunk, fx | |
06:28 | [fr] ajustements check-in: 0020cc9295 user: olr tags: trunk, fr | |
Changes
Modified gc_lang/fr/webext/content_scripts/panel_gc.js from [6633e04592] to [229ed751b6].
︙ | ︙ | |||
46 47 48 49 50 51 52 | grammalecte_error{Id} : [paragraph number]-[error_number] grammalecte_sugg{Id} : [paragraph number]-[error_number]--[suggestion_number] */ constructor (...args) { super(...args); this.aIgnoredErrors = new Set(); | | | > | 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 | grammalecte_error{Id} : [paragraph number]-[error_number] grammalecte_sugg{Id} : [paragraph number]-[error_number]--[suggestion_number] */ constructor (...args) { super(...args); this.aIgnoredErrors = new Set(); this.createMenu(); this.xPanelContent.style.marginBottom = "6px"; // Editor this.xGCPanelContent = oGrammalecte.createNode("div", {id: "grammalecte_gc_panel_content"}); this.xParagraphList = oGrammalecte.createNode("div", {id: "grammalecte_paragraph_list"}); this.xGCPanelContent.appendChild(this.xParagraphList); this.xPanelContent.addEventListener("click", onGrammalecteGCPanelClick, false); this.oTooltip = new GrammalecteTooltip(this.xParent, this.xGCPanelContent); this.xPanelContent.appendChild(this.xGCPanelContent); this.xNode = null; this.oTextControl = new GrammalecteTextControl(); this.nLastResult = 0; this.iLastEditedParagraph = -1; // Lexicographer this.nLxgCount = 0; this.xLxgPanelContent = oGrammalecte.createNode("div", {id: "grammalecte_lxg_panel_content"}); this.xPanelContent.appendChild(this.xLxgPanelContent); // Conjugueur this.xConjPanelContent = oGrammalecte.createNode("div", {id: "grammalecte_conj_panel_content"}); this.xConjPanelContent.innerHTML = sGrammalecteConjugueurHTML; // @Reviewers: sGrammalecteConjugueurHTML is a const value defined in <content_scripts/html_src.js> |
︙ | ︙ | |||
79 80 81 82 83 84 85 | // tabs this.xTFButton = oGrammalecte.createNode("div", {className: "grammalecte_menu_button", textContent: "Formateur de texte"}); this.xEditorButton = oGrammalecte.createNode("div", {className: "grammalecte_menu_button", textContent: "Éditeur"}); this.xLxgButton = oGrammalecte.createNode("div", {className: "grammalecte_menu_button", textContent: "Lexicographe"}); this.xConjButton = oGrammalecte.createNode("div", {className: "grammalecte_menu_button", textContent: "Conjugueur"}); // buttons this.xLexEditButton = oGrammalecte.createNode("div", {className: "grammalecte_menu_subbutton", textContent: "ÉditLex", title: "Ouvrir l’éditeur lexical", style: "background-color: hsl(210, 50%, 40%)"}); | | | | 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | // tabs this.xTFButton = oGrammalecte.createNode("div", {className: "grammalecte_menu_button", textContent: "Formateur de texte"}); this.xEditorButton = oGrammalecte.createNode("div", {className: "grammalecte_menu_button", textContent: "Éditeur"}); this.xLxgButton = oGrammalecte.createNode("div", {className: "grammalecte_menu_button", textContent: "Lexicographe"}); this.xConjButton = oGrammalecte.createNode("div", {className: "grammalecte_menu_button", textContent: "Conjugueur"}); // buttons this.xLexEditButton = oGrammalecte.createNode("div", {className: "grammalecte_menu_subbutton", textContent: "ÉditLex", title: "Ouvrir l’éditeur lexical", style: "background-color: hsl(210, 50%, 40%)"}); this.xLxgButton.appendChild(this.xLexEditButton); this.xAutoRefresh = oGrammalecte.createNode("div", {className: "grammalecte_menu_subbutton", textContent: "AutoRafr", title: "Auto-rafraîchissement de la correction grammaticale (3 s après la dernière frappe)"}); this.xEditorButton.appendChild(this.xAutoRefresh); this.bAutoRefresh = oGrammalecte.bAutoRefresh; this.setAutoRefreshButton(); this.xTFButton.onclick = () => { if (!this.bWorking) { oGrammalecte.createTFPanel(); oGrammalecte.oTFPanel.start(); |
︙ | ︙ | |||
120 121 122 123 124 125 126 | this.showConjugueur(); } }; this.xLexEditButton.onclick = () => { oGrammalecteBackgroundPort.openLexiconEditor(); }; // Add tabs to menu | | | | | | 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | this.showConjugueur(); } }; this.xLexEditButton.onclick = () => { oGrammalecteBackgroundPort.openLexiconEditor(); }; // Add tabs to menu this.xMenu.appendChild(this.xTFButton); this.xMenu.appendChild(this.xEditorButton); this.xMenu.appendChild(this.xLxgButton); this.xMenu.appendChild(this.xConjButton); this.xPanelBar.appendChild(this.xMenu); } start (what, xResultNode=null) { this.oTooltip.hide(); this.bWorking = false; this.clear(); |
︙ | ︙ | |||
236 237 238 239 240 241 242 243 244 245 246 247 248 249 | xParagraph.setAttribute("spellcheck", "false"); // doesn’t seem possible to use “spellcheck” as a common attribute. xParagraph.dataset.timer_id = "0"; xParagraph.addEventListener("input", function (xEvent) { if (this.bAutoRefresh) { // timer for refreshing analysis window.clearTimeout(parseInt(xParagraph.dataset.timer_id, 10)); xParagraph.dataset.timer_id = window.setTimeout(this.recheckParagraph.bind(this), 3000, oResult.iParaNum); } // write text this.oTextControl.setParagraph(parseInt(xEvent.target.dataset.para_num, 10), this.purgeText(xEvent.target.textContent)); this.oTextControl.write(); }.bind(this) , true); this._tagParagraph(xParagraph, oResult.sParagraph, oResult.iParaNum, oResult.aGrammErr, oResult.aSpellErr); | > | 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 | xParagraph.setAttribute("spellcheck", "false"); // doesn’t seem possible to use “spellcheck” as a common attribute. xParagraph.dataset.timer_id = "0"; xParagraph.addEventListener("input", function (xEvent) { if (this.bAutoRefresh) { // timer for refreshing analysis window.clearTimeout(parseInt(xParagraph.dataset.timer_id, 10)); xParagraph.dataset.timer_id = window.setTimeout(this.recheckParagraph.bind(this), 3000, oResult.iParaNum); this.iLastEditedParagraph = oResult.iParaNum; } // write text this.oTextControl.setParagraph(parseInt(xEvent.target.dataset.para_num, 10), this.purgeText(xEvent.target.textContent)); this.oTextControl.write(); }.bind(this) , true); this._tagParagraph(xParagraph, oResult.sParagraph, oResult.iParaNum, oResult.aGrammErr, oResult.aSpellErr); |
︙ | ︙ | |||
296 297 298 299 300 301 302 | // save caret position let [nStart, nEnd] = oGrammalecte.getCaretPosition(xParagraph); xParagraph.dataset.caret_position_start = nStart; xParagraph.dataset.caret_position_end = nEnd; // erase texte xParagraph.textContent = ""; // recreate and retag | > | | | 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 | // save caret position let [nStart, nEnd] = oGrammalecte.getCaretPosition(xParagraph); xParagraph.dataset.caret_position_start = nStart; xParagraph.dataset.caret_position_end = nEnd; // erase texte xParagraph.textContent = ""; // recreate and retag let sParaNum = sParagraphId.slice(21); this._tagParagraph(xParagraph, oResult.sParagraph, sParaNum, oResult.aGrammErr, oResult.aSpellErr); this._freeParagraph(xParagraph, parseInt(sParaNum, 10)); } catch (e) { showError(e); } } _tagParagraph (xParagraph, sParagraph, iParaNum, aSpellErr, aGrammErr) { |
︙ | ︙ | |||
385 386 387 388 389 390 391 | 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%)"; this.xParent.getElementById("grammalecte_check"+xParagraph.dataset.para_num).style.boxShadow = "0 0 0 3px hsla(0, 0%, 50%, .2)"; this.xParent.getElementById("grammalecte_check"+xParagraph.dataset.para_num).style.animation = "grammalecte-pulse 1s linear infinite"; } | | | | 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 | 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%)"; this.xParent.getElementById("grammalecte_check"+xParagraph.dataset.para_num).style.boxShadow = "0 0 0 3px hsla(0, 0%, 50%, .2)"; this.xParent.getElementById("grammalecte_check"+xParagraph.dataset.para_num).style.animation = "grammalecte-pulse 1s linear infinite"; } _freeParagraph (xParagraph, iParaNum) { xParagraph.contentEditable = "true"; if (iParaNum == this.iLastEditedParagraph && xParagraph.dataset.caret_position_start !== "-1") { let nStart = parseInt(xParagraph.dataset.caret_position_start, 10); let nEnd = parseInt(xParagraph.dataset.caret_position_end, 10); oGrammalecte.setCaretPosition(xParagraph, nStart, nEnd); } this.xParent.getElementById("grammalecte_check"+xParagraph.dataset.para_num).textContent = "↻"; this.xParent.getElementById("grammalecte_check"+xParagraph.dataset.para_num).style.backgroundColor = ""; this.xParent.getElementById("grammalecte_check"+xParagraph.dataset.para_num).style.animation = ""; |
︙ | ︙ | |||
411 412 413 414 415 416 417 418 419 420 421 422 423 424 | xNodeErr.className = "grammalecte_error_corrected"; xNodeErr.removeAttribute("style"); let iParaNum = parseInt(sErrorId.slice(0, sErrorId.indexOf("-")), 10); this.oTextControl.setParagraph(iParaNum, this.purgeText(this.xParent.getElementById("grammalecte_paragraph" + iParaNum).textContent)); this.oTextControl.write(); this.oTooltip.hide(); this.recheckParagraph(iParaNum); } catch (e) { showError(e); } } ignoreError (sIgnoreButtonId) { // ignore | > | 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 | xNodeErr.className = "grammalecte_error_corrected"; xNodeErr.removeAttribute("style"); let iParaNum = parseInt(sErrorId.slice(0, sErrorId.indexOf("-")), 10); this.oTextControl.setParagraph(iParaNum, this.purgeText(this.xParent.getElementById("grammalecte_paragraph" + iParaNum).textContent)); this.oTextControl.write(); this.oTooltip.hide(); this.recheckParagraph(iParaNum); this.iLastEditedParagraph = iParaNum; } catch (e) { showError(e); } } ignoreError (sIgnoreButtonId) { // ignore |
︙ | ︙ |