Feature/browserstack (#902)

Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
This commit is contained in:
Tilman Vatteroth 2021-01-06 13:09:33 +01:00 committed by GitHub
parent 900affeac2
commit 887c3b9dd3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 404 additions and 86 deletions

View file

@ -46,11 +46,15 @@ export const MarkmapFrame: React.FC<MarkmapFrameProps> = ({ code }) => {
}
const actualContainer = diagramContainer.current
import('./markmap-loader').then(({ markmapLoader }) => {
const svg: SVGSVGElement = document.createElementNS('http://www.w3.org/2000/svg', 'svg')
svg.setAttribute('width', '100%')
actualContainer.querySelectorAll('svg').forEach(child => child.remove())
actualContainer.appendChild(svg)
markmapLoader(svg, code)
try {
const svg: SVGSVGElement = document.createElementNS('http://www.w3.org/2000/svg', 'svg')
svg.setAttribute('width', '100%')
actualContainer.querySelectorAll('svg').forEach(child => child.remove())
actualContainer.appendChild(svg)
markmapLoader(svg, code)
} catch(error) {
console.error(error)
}
}).catch(() => {
console.error('error while loading markmap')
})

View file

@ -47,21 +47,21 @@ export const MermaidChart: React.FC<MermaidChartProps> = ({ code }) => {
if (!diagramContainer.current) {
return
}
try {
import('mermaid').then((mermaid) => {
if (!diagramContainer.current) {
return
}
mermaid.default.parse(code)
delete diagramContainer.current.dataset.processed
diagramContainer.current.textContent = code
mermaid.default.init(diagramContainer.current)
setError(undefined)
}).catch(() => showError('Error while loading mermaid'))
} catch (error) {
const message = (error as MermaidParseError).str
showError(message || t('renderer.mermaid.unknownError'))
}
import('mermaid').then((mermaid) => {
try {
if (!diagramContainer.current) {
return
}
mermaid.default.parse(code)
delete diagramContainer.current.dataset.processed
diagramContainer.current.textContent = code
mermaid.default.init(diagramContainer.current)
setError(undefined)
} catch (error) {
const message = (error as MermaidParseError).str
showError(message || t('renderer.mermaid.unknownError'))
}
}).catch(() => showError('Error while loading mermaid'))
}, [code, showError, t])
return <Fragment>