Index: gc_lang/fr/webext/content_scripts/init.js ================================================================== --- gc_lang/fr/webext/content_scripts/init.js +++ gc_lang/fr/webext/content_scripts/init.js @@ -79,11 +79,13 @@ if (this.oGCPanel !== null) { this.oGCPanel.hide(); } for (let oMenu of this.lMenu) { oMenu.deleteNodes(); } this.lMenu.length = 0; // to clear an array + this.listenRightClick(); this.createMenus(); + this.createMenus2(); }, createTFPanel: function () { if (this.oTFPanel === null) { this.oTFPanel = new GrammalecteTextFormatter("grammalecte_tf_panel", "Formateur de texte", 760, 600, false); @@ -186,17 +188,19 @@ Commands received from the context menu (Context menu are initialized in background) */ // Grammar checker commands case "rightClickGCEditableNode": - oGrammalecte.startGCPanel(oGrammalecte.xRightClickedNode); - sText = (oGrammalecte.xRightClickedNode.tagName == "TEXTAREA") ? oGrammalecte.xRightClickedNode.value : oGrammalecte.xRightClickedNode.textContent; - xGrammalectePort.postMessage({ - sCommand: "parseAndSpellcheck", - dParam: {sText: sText, sCountry: "FR", bDebug: false, bContext: false}, - dInfo: {sTextAreaId: oGrammalecte.xRightClickedNode.id} - }); + if (oGrammalecte.xRightClickedNode !== null) { + oGrammalecte.startGCPanel(oGrammalecte.xRightClickedNode); + sText = (oGrammalecte.xRightClickedNode.tagName == "TEXTAREA") ? oGrammalecte.xRightClickedNode.value : oGrammalecte.xRightClickedNode.textContent; + xGrammalectePort.postMessage({ + sCommand: "parseAndSpellcheck", + dParam: {sText: sText, sCountry: "FR", bDebug: false, bContext: false}, + dInfo: {sTextAreaId: oGrammalecte.xRightClickedNode.id} + }); + } break; case "rightClickGCPage": oGrammalecte.startGCPanel(); xGrammalectePort.postMessage({ sCommand: "parseAndSpellcheck", @@ -208,17 +212,19 @@ oGrammalecte.startGCPanel(); // selected text is sent to the GC worker in the background script. break; // Lexicographer commands case "rightClickLxgEditableNode": - oGrammalecte.startLxgPanel(); - sText = (oGrammalecte.xRightClickedNode.tagName == "TEXTAREA") ? oGrammalecte.xRightClickedNode.value : oGrammalecte.xRightClickedNode.textContent; - xGrammalectePort.postMessage({ - sCommand: "getListOfTokens", - dParam: {sText: sText}, - dInfo: {sTextAreaId: oGrammalecte.xRightClickedNode.id} - }); + if (oGrammalecte.xRightClickedNode !== null) { + oGrammalecte.startLxgPanel(); + sText = (oGrammalecte.xRightClickedNode.tagName == "TEXTAREA") ? oGrammalecte.xRightClickedNode.value : oGrammalecte.xRightClickedNode.textContent; + xGrammalectePort.postMessage({ + sCommand: "getListOfTokens", + dParam: {sText: sText}, + dInfo: {sTextAreaId: oGrammalecte.xRightClickedNode.id} + }); + } break; case "rightClickLxgPage": oGrammalecte.startLxgPanel(); xGrammalectePort.postMessage({ sCommand: "getListOfTokens",