Use mermaidAPI in mermaid scope
Introduced bya5b7145527 (diff-67ae90c5144c55348a3cbdb078240454L532)
Fixes #600 Parse only throws error:167368d508 (diff-67ae90c5144c55348a3cbdb078240454)
This commit is contained in:
parent
f1475535a2
commit
09d2ba41cf
1 changed files with 4 additions and 12 deletions
|
@ -373,18 +373,10 @@ export function finishView (view) {
|
||||||
var $value = $(value)
|
var $value = $(value)
|
||||||
const $ele = $(value).closest('pre')
|
const $ele = $(value).closest('pre')
|
||||||
|
|
||||||
let mermaidError = null
|
window.mermaid.mermaidAPI.parse($value.text())
|
||||||
window.mermaid.parseError = (err, hash) => {
|
$ele.addClass('mermaid')
|
||||||
mermaidError = err
|
$ele.html($value.text())
|
||||||
}
|
window.mermaid.init(undefined, $ele)
|
||||||
|
|
||||||
if (window.mermaidAPI.parse($value.text())) {
|
|
||||||
$ele.addClass('mermaid')
|
|
||||||
$ele.html($value.text())
|
|
||||||
window.mermaid.init(undefined, $ele)
|
|
||||||
} else {
|
|
||||||
throw new Error(mermaidError)
|
|
||||||
}
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
$value.unwrap()
|
$value.unwrap()
|
||||||
$value.parent().append('<div class="alert alert-warning">' + err + '</div>')
|
$value.parent().append('<div class="alert alert-warning">' + err + '</div>')
|
||||||
|
|
Loading…
Reference in a new issue