From 1dfb478dddacd09826417a7df1269008e5672692 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niccol=C3=B2=20Scatena?= Date: Thu, 25 Mar 2021 01:52:35 +0100 Subject: [PATCH] Fix typesetting after like and bump to v1.0.1 --- _files/js/inforge/bbmath/mathjax-loader.js | 21 ++++++++++++--------- addon.json | 4 ++-- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/_files/js/inforge/bbmath/mathjax-loader.js b/_files/js/inforge/bbmath/mathjax-loader.js index 2653ede..dfe5d46 100644 --- a/_files/js/inforge/bbmath/mathjax-loader.js +++ b/_files/js/inforge/bbmath/mathjax-loader.js @@ -25,21 +25,24 @@ window.MathJax = { document.head.appendChild(script); })(); -function retypesetMathjax(post) +var retypesetDisabled = false; + +function retypesetMathjax() { - $(post).off('DOMSubtreeModified', postModifiedHandler); + $(this).off('DOMSubtreeModified', retypesetMathjax); + if (retypesetDisabled) { + setTimeout(retypesetMathjax, 500); + return; + } + retypesetDisabled = true; + $(this).on('DOMSubtreeModified', retypesetMathjax); window.MathJax.typesetPromise().then(() => { - $(post).on('DOMSubtreeModified', postModifiedHandler); + retypesetDisabled = false; }).catch((err) => console.log(err.message)); } -function postModifiedHandler() -{ - retypesetMathjax(this); -} - $(window).on('load', function() { $('article.message, article.resourceBody-main, blockquote.message-body').each(function() { - $(this).on('DOMSubtreeModified', postModifiedHandler); + $(this).on('DOMSubtreeModified', retypesetMathjax); }); }); diff --git a/addon.json b/addon.json index 8b843f9..6b767ae 100644 --- a/addon.json +++ b/addon.json @@ -2,8 +2,8 @@ "legacy_addon_id": "", "title": "[Inforge] BbMath", "description": "Add BBCode to support equations and inline math.", - "version_id": 1000070, - "version_string": "1.0.0", + "version_id": 1000170, + "version_string": "1.0.1", "dev": "Inforge", "dev_url": "https://www.inforge.net", "faq_url": "https://github.com/InforgeNet/BbMath/wiki/Frequently-Asked-Questions",