mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 05:49:53 +08:00
upgrade Mermaid.js to v10
This commit is contained in:
parent
84891fb2f2
commit
06c712cb64
@ -73,7 +73,7 @@ class GraphRenderer extends VxWorker {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.doRender(this.nodesToRender);
|
this.doRender();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Interface 2.
|
// Interface 2.
|
||||||
|
@ -16,7 +16,7 @@ class Mermaid extends GraphRenderer {
|
|||||||
|
|
||||||
initialize(p_callback) {
|
initialize(p_callback) {
|
||||||
return super.initialize(() => {
|
return super.initialize(() => {
|
||||||
mermaid.mermaidAPI.initialize({
|
mermaid.initialize({
|
||||||
startOnLoad: false,
|
startOnLoad: false,
|
||||||
theme: this.theme
|
theme: this.theme
|
||||||
});
|
});
|
||||||
@ -26,12 +26,12 @@ class Mermaid extends GraphRenderer {
|
|||||||
|
|
||||||
// Render @p_node as Mermaid graph.
|
// Render @p_node as Mermaid graph.
|
||||||
// Return true on success.
|
// Return true on success.
|
||||||
renderOne(p_node, p_idx) {
|
async renderOne(p_node, p_idx) {
|
||||||
let graphSvg = null;
|
let graphSvg = null;
|
||||||
try {
|
try {
|
||||||
graphSvg = mermaid.mermaidAPI.render('vx-mermaid-graph-' + p_idx,
|
const { svg } = await mermaid.render('vx-mermaid-graph-' + p_idx,
|
||||||
p_node.textContent,
|
p_node.textContent);
|
||||||
function() {});
|
graphSvg = svg;
|
||||||
} catch (p_err) {
|
} catch (p_err) {
|
||||||
console.error('failed to render Mermaid', p_err);
|
console.error('failed to render Mermaid', p_err);
|
||||||
// Clean the container element, or Mermaid won't render the graph with
|
// Clean the container element, or Mermaid won't render the graph with
|
||||||
@ -72,12 +72,12 @@ class Mermaid extends GraphRenderer {
|
|||||||
|
|
||||||
// Render a graph from @p_text.
|
// Render a graph from @p_text.
|
||||||
// Will append a div to @p_container and return the div.
|
// Will append a div to @p_container and return the div.
|
||||||
renderTextInternal(p_container, p_text, p_idx) {
|
async renderTextInternal(p_container, p_text, p_idx) {
|
||||||
let graphSvg = null;
|
let graphSvg = null;
|
||||||
try {
|
try {
|
||||||
graphSvg = mermaid.mermaidAPI.render('vx-mermaid-graph-stand-alone-' + p_idx,
|
const { svg } = await mermaid.render('vx-mermaid-graph-stand-alone-' + p_idx,
|
||||||
p_text,
|
p_text);
|
||||||
function() {});
|
graphSvg = svg;
|
||||||
} catch (p_err) {
|
} catch (p_err) {
|
||||||
console.error('failed to render Mermaid', p_err);
|
console.error('failed to render Mermaid', p_err);
|
||||||
// Clean the container element, or Mermaid won't render the graph with
|
// Clean the container element, or Mermaid won't render the graph with
|
||||||
@ -104,20 +104,21 @@ class Mermaid extends GraphRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
p_container.appendChild(graphDiv);
|
p_container.appendChild(graphDiv);
|
||||||
|
console.log(graphDiv);
|
||||||
return graphDiv;
|
return graphDiv;
|
||||||
}
|
}
|
||||||
|
|
||||||
// p_callback(graphDiv).
|
// p_callback(graphDiv).
|
||||||
renderText(p_container, p_text, p_idx, p_callback) {
|
async renderText(p_container, p_text, p_idx, p_callback) {
|
||||||
if (!this.initialize(() => {
|
if (!this.initialize(async () => {
|
||||||
let graphDiv = this.renderTextInternal(p_container, p_text, p_idx);
|
let graphDiv = await this.renderTextInternal(p_container, p_text, p_idx);
|
||||||
p_callback(graphDiv);
|
p_callback(graphDiv);
|
||||||
})) {
|
})) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let graphDiv = this.renderTextInternal(p_container, p_text, p_idx);
|
let graphDiv = await this.renderTextInternal(p_container, p_text, p_idx);
|
||||||
|
console.log(graphDiv);
|
||||||
p_callback(graphDiv);
|
p_callback(graphDiv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
# [mermaid](https://github.com/mermaid-js/mermaid)
|
# [mermaid](https://github.com/mermaid-js/mermaid)
|
||||||
v9.4.3
|
v10.9.1
|
||||||
|
3235
src/data/extra/web/js/mermaid/mermaid.min.js
vendored
3235
src/data/extra/web/js/mermaid/mermaid.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user