Index: gc_lang/fr/webext/content_scripts/content_panels.css ================================================================== --- gc_lang/fr/webext/content_scripts/content_panels.css +++ gc_lang/fr/webext/content_scripts/content_panels.css @@ -115,11 +115,19 @@ margin: 10px 0; padding: 10px; background-color: hsla(0, 0%, 96%, 1); border-radius: 2px; } - +.grammalecte_lxg_list_of_tokens .num { + float: right; + margin: -12px 0 5px 10px; + padding: 5px 10px; + font-weight: bold; + border-radius: 0 0 4px 4px; + background-color: hsl(0, 50%, 50%); + color: hsl(0, 10%, 96%); +} .grammalecte_token { padding: 4px 0; } .grammalecte_token .separator { margin: 20px 0; Index: gc_lang/fr/webext/content_scripts/lxg_content.js ================================================================== --- gc_lang/fr/webext/content_scripts/lxg_content.js +++ gc_lang/fr/webext/content_scripts/lxg_content.js @@ -3,16 +3,19 @@ "use strict"; const oLxgPanelContent = { _xContentNode: createNode("div", {id: "grammalecte_lxg_panel_content"}), + + _nCount: 0, getNode: function () { return this._xContentNode; }, clear: function () { + this._nCount = 0; while (this._xContentNode.firstChild) { this._xContentNode.removeChild(this._xContentNode.firstChild); } }, @@ -27,11 +30,13 @@ }, addListOfTokens: function (lTokens) { try { if (lTokens) { + this._nCount += 1; let xNodeDiv = createNode("div", {className: "grammalecte_lxg_list_of_tokens"}); + xNodeDiv.appendChild(createNode("div", {className: "num", textContent: this._nCount})); for (let oToken of lTokens) { xNodeDiv.appendChild(this._createTokenNode(oToken)); } this._xContentNode.appendChild(xNodeDiv); } Index: gc_lang/fr/webext/gce_worker.js ================================================================== --- gc_lang/fr/webext/gce_worker.js +++ gc_lang/fr/webext/gce_worker.js @@ -249,22 +249,24 @@ // Lexicographer function getListOfTokens (sText, dInfo={}) { try { for (let sParagraph of text.getParagraph(sText)) { - let aElem = []; - let aRes = null; - for (let oToken of oTokenizer.genTokens(sParagraph)) { - aRes = oLxg.getInfoForToken(oToken); - if (aRes) { - aElem.push(aRes); - } - } - postMessage(createResponse("getListOfTokens", aElem, dInfo, false)); + if (sParagraph.trim() !== "") { + let aElem = []; + let aRes = null; + for (let oToken of oTokenizer.genTokens(sParagraph)) { + aRes = oLxg.getInfoForToken(oToken); + if (aRes) { + aElem.push(aRes); + } + } + postMessage(createResponse("getListOfTokens", aElem, dInfo, false)); + } } postMessage(createResponse("getListOfTokens", null, dInfo, true)); } catch (e) { helpers.logerror(e); postMessage(createResponse("getListOfTokens", createErrorResult(e, "no tokens"), dInfo, true, true)); } }