mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-18 17:25:16 -04:00
Upgrade viz.js to fix manual workaround and get smaller file size
This commit is contained in:
parent
f27fc90a74
commit
3df5507589
2 changed files with 13 additions and 22 deletions
|
@ -345,30 +345,21 @@ export function finishView(view) {
|
|||
});
|
||||
//graphviz
|
||||
var graphvizs = view.find("div.graphviz.raw").removeClass("raw");
|
||||
function parseGraphviz(key, value) {
|
||||
var $value = $(value);
|
||||
var $ele = $(value).parent().parent();
|
||||
|
||||
var graphviz = Viz($value.text());
|
||||
if (!graphviz) throw Error('viz.js output empty graph');
|
||||
$value.html(graphviz);
|
||||
|
||||
$ele.addClass('graphviz');
|
||||
$value.children().unwrap().unwrap();
|
||||
}
|
||||
graphvizs.each(function (key, value) {
|
||||
try {
|
||||
parseGraphviz(key, value);
|
||||
var $value = $(value);
|
||||
var $ele = $(value).parent().parent();
|
||||
|
||||
var graphviz = Viz($value.text());
|
||||
if (!graphviz) throw Error('viz.js output empty graph');
|
||||
$value.html(graphviz);
|
||||
|
||||
$ele.addClass('graphviz');
|
||||
$value.children().unwrap().unwrap();
|
||||
} catch (err) {
|
||||
// workaround for graphviz not recover from error
|
||||
try {
|
||||
parseGraphviz(key, value);
|
||||
} catch (err) {
|
||||
var $value = $(value);
|
||||
$value.unwrap();
|
||||
$value.parent().append('<div class="alert alert-warning">' + err + '</div>');
|
||||
console.warn(err);
|
||||
}
|
||||
$value.unwrap();
|
||||
$value.parent().append('<div class="alert alert-warning">' + err + '</div>');
|
||||
console.warn(err);
|
||||
}
|
||||
});
|
||||
//mermaid
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue