mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-18 06:49:47 +02:00
add parial parts to info graph
This commit is contained in:
@@ -77,3 +77,5 @@ export type DrawDefinition = (
|
|||||||
* @param type -
|
* @param type -
|
||||||
*/
|
*/
|
||||||
export type ParseDirectiveDefinition = (statement: string, context: string, type: string) => void;
|
export type ParseDirectiveDefinition = (statement: string, context: string, type: string) => void;
|
||||||
|
|
||||||
|
export type SVG = d3.Selection<HTMLFrameElement, unknown, HTMLElement, unknown>;
|
||||||
|
@@ -2,7 +2,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 type { DrawDefinition } from '../../diagram-api/types.js';
|
import type { DrawDefinition, SVG } from '../../diagram-api/types.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draws a an info picture in the tag with id: id based on the graph definition in text.
|
* Draws a an info picture in the tag with id: id based on the graph definition in text.
|
||||||
@@ -13,20 +13,25 @@ import type { DrawDefinition } from '../../diagram-api/types.js';
|
|||||||
*/
|
*/
|
||||||
export const draw: DrawDefinition = (text, id, version) => {
|
export const draw: DrawDefinition = (text, id, version) => {
|
||||||
try {
|
try {
|
||||||
log.debug('Rendering info diagram\n' + text);
|
log.debug('rendering info diagram\n' + text);
|
||||||
|
|
||||||
const securityLevel = getConfig().securityLevel;
|
const securityLevel = getConfig().securityLevel;
|
||||||
// Handle root and Document for when rendering in sandbox mode
|
// handle root and document for when rendering in sandbox mode
|
||||||
let sandboxElement;
|
let sandboxElement: SVG | undefined;
|
||||||
if (securityLevel === 'sandbox') {
|
if (securityLevel === 'sandbox') {
|
||||||
sandboxElement = select('#i' + id);
|
sandboxElement = select('#i' + id);
|
||||||
}
|
}
|
||||||
const root =
|
let root;
|
||||||
securityLevel === 'sandbox'
|
if (securityLevel === 'sandbox' && sandboxElement !== undefined) {
|
||||||
? select(sandboxElement.nodes()[0].contentDocument.body)
|
root = select(sandboxElement.nodes()[0].contentDocument!.body);
|
||||||
: select('body');
|
} else {
|
||||||
|
root = select('body');
|
||||||
|
}
|
||||||
|
|
||||||
|
// @ts-ignore - TODO: figure out how to resolve this
|
||||||
const svg = root.select('#' + id);
|
const svg = root.select('#' + id);
|
||||||
|
svg.attr('height', 100);
|
||||||
|
svg.attr('width', 400);
|
||||||
|
|
||||||
const g = svg.append('g');
|
const g = svg.append('g');
|
||||||
|
|
||||||
@@ -37,9 +42,6 @@ export const draw: DrawDefinition = (text, id, version) => {
|
|||||||
.attr('font-size', '32px')
|
.attr('font-size', '32px')
|
||||||
.style('text-anchor', 'middle')
|
.style('text-anchor', 'middle')
|
||||||
.text('v ' + version);
|
.text('v ' + version);
|
||||||
|
|
||||||
svg.attr('height', 100);
|
|
||||||
svg.attr('width', 400);
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log.error('error while rendering info diagram', e);
|
log.error('error while rendering info diagram', e);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user