Merge pull request #608 from SISheogorath/fix/mermaid
Use mermaidAPI in mermaid scope
This commit is contained in:
commit
b3c66d4a10
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) => {
|
|
||||||
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 a new issue