Overview
Comment: | [fx] WebExt: message box + text formatter via context menu |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | fx | webext3 |
Files: | files | file ages | folders |
SHA3-256: |
e7fc1e12a3b94e2262138a5f5ffd0c39 |
User & Date: | olr on 2017-10-16 19:33:38 |
Other Links: | branch diff | manifest | tags |
Context
2017-10-16
| ||
20:03 | [fx] WebExt: message box small improvements check-in: a44781f918 user: olr tags: fx, webext3 | |
19:33 | [fx] WebExt: message box + text formatter via context menu check-in: e7fc1e12a3 user: olr tags: fx, webext3 | |
2017-10-15
| ||
19:08 | [fx] WebExt: use innerText instead of textContent for editable nodes check-in: f9a8be8ff0 user: olr tags: fx, webext3 | |
Changes
Modified gc_lang/fr/webext/background.js from [3c3c66c38d] to [bec0f2d48c].
︙ | |||
193 194 195 196 197 198 199 200 201 202 203 204 205 206 | 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 | + + + + + + | browser.contextMenus.create({ id: "separator_selection", type: "separator", contexts: ["selection"] }); // Editable content browser.contextMenus.create({ id: "rightClickTFEditableNode", title: "Formateur de texte (zone de texte)", contexts: ["editable"] }); browser.contextMenus.create({ id: "rightClickLxgEditableNode", title: "Lexicographe (zone de texte)", contexts: ["editable"] }); browser.contextMenus.create({ |
︙ | |||
264 265 266 267 268 269 270 | 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 | - + - + + | browser.contextMenus.onClicked.addListener(function (xInfo, xTab) { // xInfo = https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/contextMenus/OnClickData // xTab = https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/tabs/Tab // confusing: no way to get the node where we click?! switch (xInfo.menuItemId) { // editable node // page |
︙ |
Modified gc_lang/fr/webext/content_scripts/init.js from [976d90ad7a] to [d44995d5ef].
︙ | |||
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | 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 | + + + | let img = document.createElement('img'); img.src = (URL || webkitURL).createObjectURL(blobTxt); // webkitURL is obsolete: https://bugs.webkit.org/show_bug.cgi?id=167518 Array.filter(document.getElementsByClassName(sContainerClass), function (oElem) { oElem.appendChild(img); }); } */ const oGrammalecte = { nMenu: 0, lMenu: [], oTFPanel: null, oLxgPanel: null, oGCPanel: null, oMessageBox: null, xRightClickedNode: null, listenRightClick: function () { // Node where a right click is done // Bug report: https://bugzilla.mozilla.org/show_bug.cgi?id=1325814 document.addEventListener('contextmenu', function (xEvent) { |
︙ | |||
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | + + + + + + + + + + + + + + + + + + + | createGCPanel: function () { if (this.oGCPanel === null) { this.oGCPanel = new GrammalecteGrammarChecker("grammalecte_gc_panel", "Grammalecte", 500, 700); this.oGCPanel.insertIntoPage(); } }, createMessageBox: function () { if (this.oMessageBox === null) { this.oMessageBox = new GrammalecteMessageBox("grammalecte_message_box", "Grammalecte", 400, 300); this.oMessageBox.insertIntoPage(); } }, startGCPanel: function (xNode=null) { oGrammalecte.createGCPanel(); oGrammalecte.oGCPanel.clear(); oGrammalecte.oGCPanel.show(); oGrammalecte.oGCPanel.start(xNode); oGrammalecte.oGCPanel.startWaitIcon(); }, startLxgPanel: function () { oGrammalecte.createLxgPanel(); oGrammalecte.oLxgPanel.clear(); oGrammalecte.oLxgPanel.show(); oGrammalecte.oLxgPanel.startWaitIcon(); }, startFTPanel: function (xNode=null) { oGrammalecte.createTFPanel(); oGrammalecte.oTFPanel.start(xNode); oGrammalecte.oTFPanel.show(); }, showMessage: function (sMessage) { oGrammalecte.createMessageBox(); oGrammalecte.oMessageBox.setMessage(sMessage); oGrammalecte.oMessageBox.show(); }, getPageText: function () { let sPageText = document.body.innerText; let nPos = sPageText.indexOf("__grammalecte_panel__"); if (nPos >= 0) { sPageText = sPageText.slice(0, nPos); } |
︙ | |||
195 196 197 198 199 200 201 | 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 | - - + - | sText = (oGrammalecte.xRightClickedNode.tagName == "TEXTAREA") ? oGrammalecte.xRightClickedNode.value : oGrammalecte.xRightClickedNode.innerText; xGrammalectePort.postMessage({ sCommand: "parseAndSpellcheck", dParam: {sText: sText, sCountry: "FR", bDebug: false, bContext: false}, dInfo: {sTextAreaId: oGrammalecte.xRightClickedNode.id} }); } else { |
︙ | |||
223 224 225 226 227 228 229 | 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 | - - + - + + + + + + + + + + + + | sText = (oGrammalecte.xRightClickedNode.tagName == "TEXTAREA") ? oGrammalecte.xRightClickedNode.value : oGrammalecte.xRightClickedNode.textContent; xGrammalectePort.postMessage({ sCommand: "getListOfTokens", dParam: {sText: sText}, dInfo: {sTextAreaId: oGrammalecte.xRightClickedNode.id} }); } else { |
︙ |
Added gc_lang/fr/webext/content_scripts/message_box.css version [d830cc07e2].
|
Added gc_lang/fr/webext/content_scripts/message_box.js version [4a05d3c991].
|
Modified gc_lang/fr/webext/content_scripts/panel_tf.js from [4e9190557a] to [af26e4e5c0].
︙ | |||
158 159 160 161 162 163 164 | 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 | - - - - - - - + + + + + + + + + | xLine.appendChild(oGrammalecte.createNode("div", {id: "res_"+"o_ordinals_no_exponant", className: "grammalecte_tf_result", textContent: "·"})); return xLine; } /* Actions */ |
︙ |
Modified gc_lang/fr/webext/manifest.json from [bbea6aa8bb] to [84fabfba5c].
︙ | |||
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | + + | "*://*.wiktionary.org/*" ], "css": [ "content_scripts/panel.css", "content_scripts/panel_tf.css", "content_scripts/panel_gc.css", "content_scripts/panel_lxg.css", "content_scripts/message_box.css", "content_scripts/menu.css" ], "js": [ "content_scripts/panel.js", "grammalecte/fr/textformatter.js", "content_scripts/panel_tf.js", "content_scripts/panel_gc.js", "content_scripts/panel_lxg.js", "content_scripts/message_box.js", "content_scripts/menu.js", "content_scripts/init.js" ], "run_at": "document_end" }, { "matches": [ |
︙ |