mirror of
https://github.com/vale981/riot-katex
synced 2025-03-04 16:51:37 -05:00
reinstate the rerun safeguard
This commit is contained in:
parent
aab8fbc5d3
commit
b18a8a7a74
1 changed files with 6 additions and 3 deletions
|
@ -7,7 +7,7 @@
|
||||||
if (window.hasRun) {
|
if (window.hasRun) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// window.hasRun = true;
|
window.hasRun = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set up math delimiters.
|
* Set up math delimiters.
|
||||||
|
@ -18,6 +18,10 @@
|
||||||
{left: "\\[", right: "\\]", display: true}
|
{left: "\\[", right: "\\]", display: true}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Render math in a node if it hasn't already be done
|
||||||
|
* and register an event on the edit button.
|
||||||
|
*/
|
||||||
function renderMath(node) {
|
function renderMath(node) {
|
||||||
let li = node.closest('li');
|
let li = node.closest('li');
|
||||||
|
|
||||||
|
@ -43,18 +47,17 @@
|
||||||
// render with KaTeX as soon as the message appears
|
// render with KaTeX as soon as the message appears
|
||||||
function listen_on_chat_element() {
|
function listen_on_chat_element() {
|
||||||
const chat_elem = document.querySelector('.mx_RoomView_MessageList');
|
const chat_elem = document.querySelector('.mx_RoomView_MessageList');
|
||||||
//renderMathInElement(chat_elem, math_config);
|
|
||||||
for(let node of chat_elem.querySelectorAll('.mx_MTextBody')) {
|
for(let node of chat_elem.querySelectorAll('.mx_MTextBody')) {
|
||||||
renderMath(node);
|
renderMath(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
const callback = function(mutationsList, observer) {
|
const callback = function(mutationsList, observer) {
|
||||||
// Use traditional 'for loops' for IE 11
|
|
||||||
for(let mutation of mutationsList) {
|
for(let mutation of mutationsList) {
|
||||||
if(mutation.type === 'attributes' && mutation.attributeName === 'class') {
|
if(mutation.type === 'attributes' && mutation.attributeName === 'class') {
|
||||||
let node = mutation.target.querySelector('.mx_MTextBody');
|
let node = mutation.target.querySelector('.mx_MTextBody');
|
||||||
renderMath(node);
|
renderMath(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mutation.type === 'childList' && mutation.addedNodes.length > 0) {
|
if (mutation.type === 'childList' && mutation.addedNodes.length > 0) {
|
||||||
for(let node of mutation.addedNodes) {
|
for(let node of mutation.addedNodes) {
|
||||||
node = node.querySelector('.mx_MTextBody');
|
node = node.querySelector('.mx_MTextBody');
|
||||||
|
|
Loading…
Add table
Reference in a new issue