diff --git a/manifest.json b/manifest.json index 61e5264..a3b8677 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 2, "name": "Riot KaTeX", - "version": "1.0.7", + "version": "1.0.8", "description": "Renders formulas on riot chat instances chats using KaTeX.", diff --git a/riot-katex.js b/riot-katex.js index 3007df1..60f8d53 100644 --- a/riot-katex.js +++ b/riot-katex.js @@ -31,22 +31,19 @@ let li = node.closest('li'); - // we have already rendered this element - if (li.getAttribute('originalContent')) { + let contentNodes = li.querySelectorAll('.mx_EventTile_body'); + + if (!content) { return; } - let og_content = (' ' + node.textContent).slice(1); - li.setAttribute('originalContent', og_content); - renderMathInElement(node); + for (let content of contentNodes) { + if(content.getAttribute('originalContent') || content.getAttribute('editing')) // already rendered + continue; - let edit_button = li.querySelector('.mx_MessageActionBar_maskButton[title="Edit"]'); - if (edit_button) { - li.querySelector('.mx_MessageActionBar_maskButton[title="Edit"]') - .addEventListener("click", event => { - event.target.closest('li').setAttribute('originalContent', ''); - node.textContent = og_content; - }); + let og_content = (' ' + content.textContent).slice(1); + content.setAttribute('originalContent', og_content); + renderMathInElement(content); } }