mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-17 08:34:54 -04:00
Optimize viz.js async rendering through webpack chunk
This commit is contained in:
parent
d3315506dc
commit
56c5378939
8 changed files with 36 additions and 35 deletions
|
@ -288,21 +288,25 @@ function finishView(view) {
|
|||
}
|
||||
});
|
||||
//graphviz
|
||||
var graphvizs = view.find(".graphviz.raw").removeClass("raw");
|
||||
graphvizs.each(function (key, value) {
|
||||
try {
|
||||
var $value = $(value);
|
||||
var $ele = $(value).parent().parent();
|
||||
require.ensure(["viz.js"], function(require) {
|
||||
var Viz = require("viz.js");
|
||||
var graphvizs = view.find(".graphviz.raw").removeClass("raw");
|
||||
graphvizs.each(function (key, value) {
|
||||
try {
|
||||
var $value = $(value);
|
||||
var $ele = $(value).parent().parent();
|
||||
|
||||
var graphviz = Viz($value.text());
|
||||
$value.html(graphviz);
|
||||
var graphviz = Viz($value.text());
|
||||
$value.html(graphviz);
|
||||
|
||||
$ele.addClass('graphviz');
|
||||
$value.children().unwrap().unwrap();
|
||||
} catch (err) {
|
||||
console.warn(err);
|
||||
}
|
||||
});
|
||||
$ele.addClass('graphviz');
|
||||
$value.children().unwrap().unwrap();
|
||||
} catch (err) {
|
||||
console.warn(err);
|
||||
}
|
||||
});
|
||||
|
||||
})
|
||||
//mermaid
|
||||
var mermaids = view.find(".mermaid.raw").removeClass("raw");
|
||||
mermaids.each(function (key, value) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue