Fix mermaid rendering when switching tabs
This commit is contained in:
parent
50089701bb
commit
c3d3d67605
@ -275,15 +275,13 @@ define([
|
|||||||
|
|
||||||
var Dom = domFromHTML($('<div>').append($div).html());
|
var Dom = domFromHTML($('<div>').append($div).html());
|
||||||
$content[0].normalize();
|
$content[0].normalize();
|
||||||
|
$content.find('pre.mermaid[data-processed="true"]').remove();
|
||||||
var oldDom = domFromHTML($content[0].outerHTML);
|
var oldDom = domFromHTML($content[0].outerHTML);
|
||||||
var patch = makeDiff(oldDom, Dom, id);
|
var patch = makeDiff(oldDom, Dom, id);
|
||||||
if (typeof(patch) === 'string') {
|
if (typeof(patch) === 'string') {
|
||||||
throw new Error(patch);
|
throw new Error(patch);
|
||||||
} else {
|
} else {
|
||||||
DD.apply($content[0], patch);
|
DD.apply($content[0], patch);
|
||||||
try {
|
|
||||||
Mermaid.init();
|
|
||||||
} catch (e) { console.error(e); }
|
|
||||||
var $mts = $content.find('media-tag:not(:has(*))');
|
var $mts = $content.find('media-tag:not(:has(*))');
|
||||||
$mts.each(function (i, el) {
|
$mts.each(function (i, el) {
|
||||||
$(el).contextmenu(function (e) {
|
$(el).contextmenu(function (e) {
|
||||||
@ -318,6 +316,9 @@ define([
|
|||||||
var target = document.getElementById($a.attr('data-href'));
|
var target = document.getElementById($a.attr('data-href'));
|
||||||
if (target) { target.scrollIntoView(); }
|
if (target) { target.scrollIntoView(); }
|
||||||
});
|
});
|
||||||
|
try {
|
||||||
|
Mermaid.init();
|
||||||
|
} catch (e) { console.error(e); }
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user