Overview
Comment: | [fx] send result via event only with the parameter grammalecte_result_via_event |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk | fx |
Files: | files | file ages | folders |
SHA3-256: |
981544fa3043aec8c2bb3335cf3f4e94 |
User & Date: | olr on 2020-03-10 07:01:24 |
Other Links: | manifest | tags |
Context
2020-03-11
| ||
20:29 | [fx] API for web pages and context menu for iframes check-in: c775552b47 user: olr tags: trunk, fx | |
2020-03-10
| ||
07:01 | [fx] send result via event only with the parameter grammalecte_result_via_event check-in: 981544fa30 user: olr tags: trunk, fx | |
2020-03-09
| ||
19:17 | [fx] send result in event also if Grammalecte is launched by the context menu check-in: 98cbcc00d8 user: olr tags: trunk, fx | |
Changes
Modified gc_lang/fr/webext/content_scripts/panel_gc.js from [952baf8eed] to [058490fba6].
︙ | ︙ | |||
961 962 963 964 965 966 967 | this.clear(); this.xNode = xNode; this.bTextArea = (xNode.tagName == "TEXTAREA" || xNode.tagName == "INPUT"); if (!this.bTextArea) { oGrammalecte.oGCPanel.addMessageToGCPanel("Attention : La zone de texte analysée est un champ textuel enrichi susceptible de contenir des éléments non textuels qui seront effacés lors de la correction."); } this.xNode.disabled = true; | | | | > > > > > > > > > > > > > > > > > | 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 | this.clear(); this.xNode = xNode; this.bTextArea = (xNode.tagName == "TEXTAREA" || xNode.tagName == "INPUT"); if (!this.bTextArea) { oGrammalecte.oGCPanel.addMessageToGCPanel("Attention : La zone de texte analysée est un champ textuel enrichi susceptible de contenir des éléments non textuels qui seront effacés lors de la correction."); } this.xNode.disabled = true; this.bResultInEvent = Boolean(xNode.dataset.grammalecte_result_via_event && xNode.dataset.grammalecte_result_via_event == "true"); this._loadText((this.bTextArea) ? this.xNode.value : this.xNode.innerText); } setText (sText) { this.clear(); oGrammalecte.oGCPanel.addMessageToGCPanel("Note : Aucun champ textuel défini. Les changements ne seront pas répercutés sur la zone d’où le texte a été extrait."); this._loadText(sText); } _loadText (sText) { if (typeof(sText) === "string") { this.dParagraph.clear(); let i = 0; let iStart = 0; let iEnd = 0; sText = sText.replace(/\r\n/g, "\n").replace(/\r/g, "\n").normalize("NFC"); while ((iEnd = sText.indexOf("\n", iStart)) !== -1) { this.dParagraph.set(i, sText.slice(iStart, iEnd)); i++; iStart = iEnd+1; } this.dParagraph.set(i, sText.slice(iStart)); //console.log("Paragraphs number: " + (i+1)); } } clear () { if (this.xNode !== null) { this.xNode.disabled = false; this.bTextArea = false; this.xNode = null; |
︙ | ︙ | |||
992 993 994 995 996 997 998 | return sText.slice(0,-1).normalize("NFC"); } setParagraph (iParagraph, sText) { this.dParagraph.set(iParagraph, sText); } | < < < < < < < < < < < < < < < < < | | 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 | return sText.slice(0,-1).normalize("NFC"); } setParagraph (iParagraph, sText) { this.dParagraph.set(iParagraph, sText); } eraseNodeContent () { while (this.xNode.firstChild) { this.xNode.removeChild(this.xNode.firstChild); } } write () { if (this.xNode !== null) { if (this.bResultInEvent) { const xEvent = new CustomEvent("GrammalecteNodeContentUpdated", { detail: { text: [...this.dParagraph.values()].join("\n").normalize("NFC") } }); this.xNode.dispatchEvent(xEvent); console.log("event", xEvent.detail.text); } else if (this.bTextArea) { this.xNode.value = this.getText(); } else { this.eraseNodeContent(); this.dParagraph.forEach((val, key) => { |
︙ | ︙ |