Upgrade viz.js to fix manual workaround and get smaller file size

This commit is contained in:
Wu Cheng-Han 2017-02-02 23:27:34 +08:00
parent f27fc90a74
commit 3df5507589
2 changed files with 13 additions and 22 deletions

View file

@ -115,7 +115,7 @@
"validator": "^6.2.0", "validator": "^6.2.0",
"velocity-animate": "^1.4.0", "velocity-animate": "^1.4.0",
"visibilityjs": "^1.2.4", "visibilityjs": "^1.2.4",
"viz.js": "^1.4.1", "viz.js": "^1.7.0",
"winston": "^2.3.0", "winston": "^2.3.0",
"xss": "^0.3.3" "xss": "^0.3.3"
}, },

View file

@ -345,7 +345,8 @@ export function finishView(view) {
}); });
//graphviz //graphviz
var graphvizs = view.find("div.graphviz.raw").removeClass("raw"); var graphvizs = view.find("div.graphviz.raw").removeClass("raw");
function parseGraphviz(key, value) { graphvizs.each(function (key, value) {
try {
var $value = $(value); var $value = $(value);
var $ele = $(value).parent().parent(); var $ele = $(value).parent().parent();
@ -355,21 +356,11 @@ export function finishView(view) {
$ele.addClass('graphviz'); $ele.addClass('graphviz');
$value.children().unwrap().unwrap(); $value.children().unwrap().unwrap();
}
graphvizs.each(function (key, value) {
try {
parseGraphviz(key, value);
} catch (err) { } catch (err) {
// workaround for graphviz not recover from error
try {
parseGraphviz(key, value);
} catch (err) {
var $value = $(value);
$value.unwrap(); $value.unwrap();
$value.parent().append('<div class="alert alert-warning">' + err + '</div>'); $value.parent().append('<div class="alert alert-warning">' + err + '</div>');
console.warn(err); console.warn(err);
} }
}
}); });
//mermaid //mermaid
const mermaids = view.find("div.mermaid.raw").removeClass("raw"); const mermaids = view.find("div.mermaid.raw").removeClass("raw");