mirror of https://github.com/status-im/codimd.git
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
|
@ -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) => {
|
|
||||||
mermaidError = err
|
|
||||||
}
|
|
||||||
|
|
||||||
if (window.mermaidAPI.parse($value.text())) {
|
|
||||||
$ele.addClass('mermaid')
|
$ele.addClass('mermaid')
|
||||||
$ele.html($value.text())
|
$ele.html($value.text())
|
||||||
window.mermaid.init(undefined, $ele)
|
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 New Issue