mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-10-03 22:29:38 +02:00
add configureSvgSize
in infoRenderer
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import { select } from 'd3';
|
import { select } from 'd3';
|
||||||
import { log } from '../../logger.js';
|
import { log } from '../../logger.js';
|
||||||
import { getConfig } from '../../config.js';
|
import { getConfig } from '../../config.js';
|
||||||
|
import { configureSvgSize } from '../../setupGraphViewbox.js';
|
||||||
import type { DrawDefinition, HTML, SVG } from '../../diagram-api/types.js';
|
import type { DrawDefinition, HTML, SVG } from '../../diagram-api/types.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -15,7 +16,6 @@ const draw: DrawDefinition = (text, id, version) => {
|
|||||||
log.debug('rendering info diagram\n' + text);
|
log.debug('rendering info diagram\n' + text);
|
||||||
|
|
||||||
const { securityLevel } = getConfig();
|
const { securityLevel } = getConfig();
|
||||||
|
|
||||||
// handle root and document for when rendering in sandbox mode
|
// handle root and document for when rendering in sandbox mode
|
||||||
let doc: Document = document;
|
let doc: Document = document;
|
||||||
if (securityLevel === 'sandbox') {
|
if (securityLevel === 'sandbox') {
|
||||||
@@ -26,19 +26,19 @@ const draw: DrawDefinition = (text, id, version) => {
|
|||||||
securityLevel === 'sandbox' ? select(doc.body as HTMLIFrameElement) : select('body');
|
securityLevel === 'sandbox' ? select(doc.body as HTMLIFrameElement) : select('body');
|
||||||
|
|
||||||
const svg: SVG = root.select(`#${id}`);
|
const svg: SVG = root.select(`#${id}`);
|
||||||
svg.attr('height', 100);
|
configureSvgSize(svg, 100, 400, true);
|
||||||
svg.attr('width', 400);
|
|
||||||
|
|
||||||
const g = svg.append('g');
|
svg
|
||||||
g.append('text') // text label for the x axis
|
.append('g')
|
||||||
|
.append('text')
|
||||||
.attr('x', 100)
|
.attr('x', 100)
|
||||||
.attr('y', 40)
|
.attr('y', 40)
|
||||||
.attr('class', 'version')
|
.attr('class', 'version')
|
||||||
.attr('font-size', '32px')
|
.attr('font-size', 32)
|
||||||
.style('text-anchor', 'middle')
|
.style('text-anchor', 'middle')
|
||||||
.text(`v${version}`);
|
.text(`v${version}`);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log.error('error while rendering info diagram\n', e);
|
log.error('error while rendering info diagram', e);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user