Skip to content

Commit 3df5507

Browse files
committed
Upgrade viz.js to fix manual workaround and get smaller file size
1 parent f27fc90 commit 3df5507

2 files changed

Lines changed: 13 additions & 22 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@
115115
"validator": "^6.2.0",
116116
"velocity-animate": "^1.4.0",
117117
"visibilityjs": "^1.2.4",
118-
"viz.js": "^1.4.1",
118+
"viz.js": "^1.7.0",
119119
"winston": "^2.3.0",
120120
"xss": "^0.3.3"
121121
},

public/js/extra.js

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -345,30 +345,21 @@ export function finishView(view) {
345345
});
346346
//graphviz
347347
var graphvizs = view.find("div.graphviz.raw").removeClass("raw");
348-
function parseGraphviz(key, value) {
349-
var $value = $(value);
350-
var $ele = $(value).parent().parent();
351-
352-
var graphviz = Viz($value.text());
353-
if (!graphviz) throw Error('viz.js output empty graph');
354-
$value.html(graphviz);
355-
356-
$ele.addClass('graphviz');
357-
$value.children().unwrap().unwrap();
358-
}
359348
graphvizs.each(function (key, value) {
360349
try {
361-
parseGraphviz(key, value);
350+
var $value = $(value);
351+
var $ele = $(value).parent().parent();
352+
353+
var graphviz = Viz($value.text());
354+
if (!graphviz) throw Error('viz.js output empty graph');
355+
$value.html(graphviz);
356+
357+
$ele.addClass('graphviz');
358+
$value.children().unwrap().unwrap();
362359
} catch (err) {
363-
// workaround for graphviz not recover from error
364-
try {
365-
parseGraphviz(key, value);
366-
} catch (err) {
367-
var $value = $(value);
368-
$value.unwrap();
369-
$value.parent().append('<div class="alert alert-warning">' + err + '</div>');
370-
console.warn(err);
371-
}
360+
$value.unwrap();
361+
$value.parent().append('<div class="alert alert-warning">' + err + '</div>');
362+
console.warn(err);
372363
}
373364
});
374365
//mermaid

0 commit comments

Comments
 (0)