Overview
Comment: | [fx] API for web pages and context menu for iframes |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk | fx |
Files: | files | file ages | folders |
SHA3-256: |
c775552b47b5d24dc69d3ee28c3854c3 |
User & Date: | olr on 2020-03-11 20:29:34 |
Other Links: | manifest | tags |
Context
2020-03-11
| ||
21:44 | [fr] faux positif check-in: 607796fcdc user: olr tags: trunk, fr | |
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 | |
Changes
Modified gc_lang/fr/webext/background.js from [abadc3982d] to [b8162f6122].
︙ | |||
329 330 331 332 333 334 335 | 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 | - + + | /* Context Menu */ // Analyze browser.contextMenus.create({ id: "grammar_checker_editable", title: "Analyser cette zone de texte", contexts: ["editable"] }); |
︙ | |||
352 353 354 355 356 357 358 359 360 361 362 363 364 365 | 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 | + + + | // confusing: no way to get the node where we click?! switch (xInfo.menuItemId) { // analyze case "grammar_checker_editable": case "grammar_checker_page": sendCommandToTab(xTab.id, xInfo.menuItemId); break; case "grammar_checker_iframe": sendCommandToTab(xTab.id, xInfo.menuItemId, xInfo.frameId); break; case "grammar_checker_selection": sendCommandToTab(xTab.id, xInfo.menuItemId, xInfo.selectionText); oWorkerHandler.xGCEWorker.postMessage({ sCommand: "parseAndSpellcheck", dParam: {sText: xInfo.selectionText, sCountry: "FR", bDebug: false, bContext: false}, dInfo: {iReturnPort: xTab.id} }); |
︙ |
Added gc_lang/fr/webext/content_scripts/api.js version [46315a7e69].
|
Modified gc_lang/fr/webext/content_scripts/init.js from [e1f7754754] to [83ad0c7397].
︙ | |||
11 12 13 14 15 16 17 18 19 20 21 22 23 24 | 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | + | No SharedWorker, no images allowed for now… */ "use strict"; function showError (e) { // console can’t display error objects from content scripts console.error(e.fileName + "\n" + e.name + "\nline: " + e.lineNumber + "\n" + e.message); } // Chrome don’t follow the W3C specification: // https://browserext.github.io/browserext/ let bChrome = false; if (typeof(browser) !== "object") { |
︙ | |||
84 85 86 87 88 89 90 | 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | - - - - - - - - - + + - - - - - - - - - + + | }, _prepareButtons: function (oOptions) { if (oOptions.hasOwnProperty("ui_options")) { this.oOptions = oOptions.ui_options; // textarea for (let xNode of document.getElementsByTagName("textarea")) { |
︙ | |||
383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 | 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | break; case "grammar_checker_page": oGrammalecte.startGCPanel(oGrammalecte.getPageText()); break; case "grammar_checker_selection": oGrammalecte.startGCPanel(result, false); // result is the selected text // selected text is sent to the GC worker in the background script. break; case "grammar_checker_iframe": console.log("[Grammalecte] selected iframe: ", result); if (document.activeElement.tagName == "IFRAME") { //console.log(document.activeElement.id); frameId given by result is different than frame.id oGrammalecte.startGCPanel(document.activeElement.contentWindow.document.body.innerText); } else { oGrammalecte.showMessage("Erreur. Le cadre sur lequel vous avez cliqué n’a pas pu être identifié. Sélectionnez le texte à corriger et relancez le correcteur via le menu contextuel."); } break; // rescan page command case "rescanPage": oGrammalecte.rescanPage(); break; default: console.log("[Content script] Unknown command: " + sActionDone); } }); /* Callable API for the webpage. The API script must be injected this way to be callable by the page */ let xScriptGrammalecteAPI = document.createElement("script"); xScriptGrammalecteAPI.src = browser.extension.getURL("content_scripts/api.js"); document.documentElement.appendChild(xScriptGrammalecteAPI); document.addEventListener("GrammalecteCall", function (xEvent) { // GrammalecteCall events are dispatched by functions in the API try { let oCommand = xEvent.detail; switch (oCommand.sCommand) { case "parseNode": if (oCommand.xNode) { oGrammalecte.startGCPanel(oCommand.xNode); } break; case "parseText": if (oCommand.sText) { oGrammalecte.startGCPanel(oCommand.sText); } break; default: console.log("[Grammalecte] Event: Unknown command", oCommand.sCommand); } } catch (e) { showError(e); } }); /* Other messages from background */ browser.runtime.onMessage.addListener(function (oMessage) { let {sActionRequest} = oMessage; |
︙ |
Modified gc_lang/fr/webext/manifest.json from [6de540cb7c] to [8dac256bfb].
︙ | |||
91 92 93 94 95 96 97 98 99 100 101 102 103 104 | 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | + | "lexicon_editor": { "suggested_key": { "default": "Ctrl+Shift+7" }, "description": "Ouvre l’éditeur lexical" } }, "web_accessible_resources": [ "content_scripts/api.js", "content_scripts/panel.css", "content_scripts/panel_tf.css", "content_scripts/panel_gc.css", "content_scripts/panel_lxg.css", "content_scripts/panel_conj.css", "content_scripts/message_box.css", "content_scripts/menu.css", |
︙ |