mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-12 20:09:46 +02:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -210,6 +210,9 @@ function executeInPage(data) {
|
|||||||
, elContent
|
, elContent
|
||||||
, svg
|
, svg
|
||||||
, svgValue
|
, svgValue
|
||||||
|
, boundingBox
|
||||||
|
, width
|
||||||
|
, height
|
||||||
|
|
||||||
toRemove = document.getElementsByClassName('mermaid')
|
toRemove = document.getElementsByClassName('mermaid')
|
||||||
if (toRemove && toRemove.length) {
|
if (toRemove && toRemove.length) {
|
||||||
@@ -253,6 +256,32 @@ function executeInPage(data) {
|
|||||||
mermaid.init();
|
mermaid.init();
|
||||||
|
|
||||||
svg = document.querySelector('svg')
|
svg = document.querySelector('svg')
|
||||||
|
|
||||||
|
boundingBox = svg.getBoundingClientRect(); // the initial bonding box of the svg
|
||||||
|
width = boundingBox.width * 1.5; // adding the scale factor for consistency with output in chrome browser
|
||||||
|
height = boundingBox.height * 1.5; // adding the scale factor for consistency with output in chrome browser
|
||||||
|
|
||||||
|
// resizing the body to fit the svg
|
||||||
|
document.body.setAttribute(
|
||||||
|
'style'
|
||||||
|
, 'width: ' + width + '; height: ' + height + ';'
|
||||||
|
)
|
||||||
|
// resizing the svg via css for consistent display
|
||||||
|
svg.setAttribute(
|
||||||
|
'style'
|
||||||
|
, 'width: ' + width + '; height: ' + height + ';'
|
||||||
|
)
|
||||||
|
|
||||||
|
// set witdth and height attributes used to set the viewport when rending png image
|
||||||
|
svg.setAttribute(
|
||||||
|
'width'
|
||||||
|
, width
|
||||||
|
)
|
||||||
|
svg.setAttribute(
|
||||||
|
'height'
|
||||||
|
, height
|
||||||
|
)
|
||||||
|
|
||||||
svgValue = xmlSerializer.serializeToString(svg)
|
svgValue = xmlSerializer.serializeToString(svg)
|
||||||
|
|
||||||
return svgValue
|
return svgValue
|
||||||
|
Reference in New Issue
Block a user