Skip to content

Commit d418ac7

Browse files
committed
Render flowchart
1 parent 4fa01ca commit d418ac7

3 files changed

Lines changed: 50 additions & 0 deletions

File tree

package-lock.json

Lines changed: 24 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
"@types/node": "^10.12.21",
4545
"@types/vscode": "^1.36.0",
4646
"css-loader": "^3.1.0",
47+
"flowchart.js": "^1.12.2",
4748
"glob": "^7.1.4",
4849
"ignore-loader": "^0.1.2",
4950
"jquery": "^3.4.1",

src/page.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import './style.css';
77
import * as $ from 'jquery';
88

99
import * as mermaid from 'mermaid';
10+
import * as flowchart from 'flowchart.js';
1011
import * as S from 'string';
1112

1213
const mermaids = $('span.mermaid.raw');
@@ -29,3 +30,27 @@ mermaids.each((key, value) => {
2930
}
3031
})
3132

33+
const flows = $('span.flow-chart.raw')
34+
flows.removeClass('raw')
35+
flows.each((key, value) => {
36+
try {
37+
var $value = $(value)
38+
var $ele = $(value).parent().parent()
39+
40+
const chart = flowchart.parse($value.text())
41+
$value.html('')
42+
chart.drawSVG(value, {
43+
'line-width': 2,
44+
'fill': 'none',
45+
'font-size': '16px',
46+
'font-family': "'Andale Mono', monospace"
47+
})
48+
$ele.addClass('flow-chart')
49+
$value.children().unwrap().unwrap()
50+
} catch (err) {
51+
// $value.unwrap()
52+
// $value.parent().append(`<div class="alert alert-warning">${S(err).escapeHTML().s}</div>`)
53+
// console.warn(err)
54+
$ele.addClass('flow-chart')
55+
}
56+
})

0 commit comments

Comments
 (0)