Index: gc_lang/fr/webext/content_scripts/api.js ================================================================== --- gc_lang/fr/webext/content_scripts/api.js +++ gc_lang/fr/webext/content_scripts/api.js @@ -53,7 +53,16 @@ let xEvent = new CustomEvent("GrammalecteCall", { detail: {sCommand: "parseNode", xNode: xNode} }); document.dispatchEvent(xEvent); } else { console.log("[Grammalecte API] Error: parameter is not a HTML node."); } + }, + + getSpellSuggestions: function (sWord, sDestination, sErrorId) { + if (typeof(sWord) === "string") { + let xEvent = new CustomEvent("GrammalecteCall", { detail: {sCommand: "getSpellSuggestions", sWord: sWord, sDestination: sDestination, sErrorId: sErrorId} }); + document.dispatchEvent(xEvent); + } else { + console.log("[Grammalecte API] Error: parameter is not a text."); + } } } 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 @@ -350,12 +350,12 @@ dParam: { sVerb: sVerb, bPro: bPro, bNeg: bNeg, bTpsCo: bTpsCo, bInt: bInt, bFem: bFem }, dInfo: { bStart: bStart } }); }, - getSpellSuggestions: function (sWord, sErrorId) { - this.xConnect.postMessage({ sCommand: "getSpellSuggestions", dParam: { sWord: sWord }, dInfo: { sErrorId: sErrorId } }); + getSpellSuggestions: function (sWord, sDestination, sErrorId) { + this.xConnect.postMessage({ sCommand: "getSpellSuggestions", dParam: { sWord: sWord }, dInfo: { sDestination: sDestination, sErrorId: sErrorId } }); }, openURL: function (sURL) { this.xConnect.postMessage({ sCommand: "openURL", dParam: { "sURL": sURL }, dInfo: null }); }, @@ -389,11 +389,11 @@ oGrammalecte.oGCPanel.stopWaitIcon(); oGrammalecte.oGCPanel.endTimer(); } } else if (dInfo.sDestination && document.getElementById(dInfo.sDestination)) { - const xEvent = new CustomEvent("GrammalecteResult", { detail: JSON.stringify(result) }); + const xEvent = new CustomEvent("GrammalecteResult", { detail: JSON.stringify({ result: result, info: dInfo }) }); document.getElementById(dInfo.sDestination).dispatchEvent(xEvent); } break; case "parseAndSpellcheck1": if (dInfo.sDestination == "__GrammalectePanel__") { @@ -410,11 +410,17 @@ oGrammalecte.oGCPanel.stopWaitIcon(); oGrammalecte.oGCPanel.endTimer(); } break; case "getSpellSuggestions": - oGrammalecte.oGCPanel.oTooltip.setSpellSuggestionsFor(result.sWord, result.aSugg, result.iSuggBlock, dInfo.sErrorId); + if (dInfo.sDestination == "__GrammalectePanel__") { + oGrammalecte.oGCPanel.oTooltip.setSpellSuggestionsFor(result.sWord, result.aSugg, result.iSuggBlock, dInfo.sErrorId); + } + else if (dInfo.sDestination && document.getElementById(dInfo.sDestination)) { + const xEvent = new CustomEvent("GrammalecteResult", { detail: JSON.stringify({ result: result, info: dInfo }) }); + document.getElementById(dInfo.sDestination).dispatchEvent(xEvent); + } break; case "getVerb": if (dInfo.bStart) { oGrammalecte.oGCPanel.conjugateWith(result.oVerb, result.oConjTable); } else { @@ -527,10 +533,15 @@ } else { oGrammalecteBackgroundPort.parseAndSpellcheck(oCommand.xNode.innerText, oCommand.xNode.id); } } + break; + case "getSpellSuggestions": + if (oCommand.sWord) { + oGrammalecteBackgroundPort.getSpellSuggestions(sWord, oCommand.sDestination, oCommand.sErrorId); + } break; default: console.log("[Grammalecte] Event: Unknown command", oCommand.sCommand); } } Index: gc_lang/fr/webext/content_scripts/panel_gc.js ================================================================== --- gc_lang/fr/webext/content_scripts/panel_gc.js +++ gc_lang/fr/webext/content_scripts/panel_gc.js @@ -854,11 +854,11 @@ } else { this.xParent.getElementById("grammalecte_tooltip_db_search").style.display = "none"; } this.clearSuggestionBlock(); this.xTooltipSuggBlock.textContent = "Recherche de graphies possibles…"; - oGrammalecteBackgroundPort.getSpellSuggestions(xNodeErr.textContent, xNodeErr.dataset.error_id); + oGrammalecteBackgroundPort.getSpellSuggestions(xNodeErr.textContent, "__GrammalectePanel__", xNodeErr.dataset.error_id); } this.xTooltipArrow.style.display = "block"; this.xTooltip.style.display = "block"; } catch (e) {