From c3d3d67605978bfa60408c267c49e49558446ca9 Mon Sep 17 00:00:00 2001 From: yflory Date: Thu, 4 Apr 2019 11:42:59 +0200 Subject: [PATCH] Fix mermaid rendering when switching tabs --- www/common/diffMarked.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/www/common/diffMarked.js b/www/common/diffMarked.js index d77b9b48f..1e5db4188 100644 --- a/www/common/diffMarked.js +++ b/www/common/diffMarked.js @@ -275,15 +275,13 @@ define([ var Dom = domFromHTML($('
').append($div).html()); $content[0].normalize(); + $content.find('pre.mermaid[data-processed="true"]').remove(); var oldDom = domFromHTML($content[0].outerHTML); var patch = makeDiff(oldDom, Dom, id); if (typeof(patch) === 'string') { throw new Error(patch); } else { DD.apply($content[0], patch); - try { - Mermaid.init(); - } catch (e) { console.error(e); } var $mts = $content.find('media-tag:not(:has(*))'); $mts.each(function (i, el) { $(el).contextmenu(function (e) { @@ -318,6 +316,9 @@ define([ var target = document.getElementById($a.attr('data-href')); if (target) { target.scrollIntoView(); } }); + try { + Mermaid.init(); + } catch (e) { console.error(e); } } };