mirror of https://github.com/status-im/codimd.git
Merge pull request #608 from SISheogorath/fix/mermaid
Use mermaidAPI in mermaid scope
This commit is contained in:
commit
b3c66d4a10
|
@ -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 New Issue