Skip to content

Commit

Permalink
resolves #1641 Mermaid background on span elements were missing
Browse files Browse the repository at this point in the history
  • Loading branch information
ggrossetie committed Sep 23, 2023
1 parent e229e29 commit c411e24
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
11 changes: 10 additions & 1 deletion diagrams.net/src/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,16 @@ export class Worker {
// const pageCount = parseInt(await page.mainFrame().$eval('#LoadingComplete', div => div.getAttribute('pageCount')))

if (task.isPng) {
await page.setContent(evalResult.svg)
await page.setContent(`<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
${evalResult.svg}
</body>
</html>`)
const container = await page.$('svg')
return await container.screenshot({
type: 'png',
Expand Down
13 changes: 11 additions & 2 deletions mermaid/src/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,20 @@ async function toPNG (page, svg) {
'puppeteer'
)
try {
await page.setContent(svg)
await page.setContent(`<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
${svg}
</body>
</html>`)
const container = await page.$('#container')
const result = await container.screenshot({
type: 'png',
omitBackground: true
omitBackground: true,
})
successfulSpan(span)
return result
Expand Down

0 comments on commit c411e24

Please sign in to comment.