Merge pull request #1419 from hackmdio/bugfix/fix-graphviz-error-render

fix: catch viz.js render async error and recreate Viz instance
This commit is contained in:
Max Wu 2020-02-26 22:59:14 +08:00 committed by GitHub
commit 90898e700f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 2 deletions

View File

@ -31,7 +31,7 @@ require('prismjs/components/prism-gherkin')
require('./lib/common/login')
require('../vendor/md-toc')
const viz = new window.Viz()
let viz = new window.Viz()
const plantumlEncoder = require('plantuml-encoder')
const ui = getUIElements()
@ -379,8 +379,13 @@ export function finishView (view) {
$ele.addClass('graphviz')
$value.children().unwrap()
})
.catch(err => {
viz = new window.Viz()
$value.parent().append(`<div class="alert alert-warning">${escapeHTML(err)}</div>`)
console.warn(err)
})
} catch (err) {
$value.unwrap()
viz = new window.Viz()
$value.parent().append(`<div class="alert alert-warning">${escapeHTML(err)}</div>`)
console.warn(err)
}