mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-18 06:49:47 +02:00
use body of document instead of document itself in infoRenderer
This commit is contained in:
@@ -79,6 +79,6 @@ export type DrawDefinition = (
|
|||||||
*/
|
*/
|
||||||
export type ParseDirectiveDefinition = (statement: string, context: string, type: string) => void;
|
export type ParseDirectiveDefinition = (statement: string, context: string, type: string) => void;
|
||||||
|
|
||||||
export type HTML = d3.Selection<HTMLIFrameElement, unknown, Element, unknown>;
|
export type HTML = d3.Selection<HTMLIFrameElement, unknown, Element | null, unknown>;
|
||||||
|
|
||||||
export type SVG = d3.Selection<SVGSVGElement, unknown, Element, unknown>;
|
export type SVG = d3.Selection<SVGSVGElement, unknown, Element | null, unknown>;
|
||||||
|
@@ -15,18 +15,16 @@ 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 sandboxElement: HTML | undefined;
|
|
||||||
let document: Document | null | undefined;
|
let document: Document | null | undefined;
|
||||||
if (securityLevel === 'sandbox') {
|
if (securityLevel === 'sandbox') {
|
||||||
sandboxElement = select('#i' + id);
|
const sandboxElement: HTML = select('#i' + id);
|
||||||
document = sandboxElement.nodes()[0].contentDocument;
|
document = sandboxElement.node()?.contentDocument;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @ts-ignore - figure out how to assign HTML to document type
|
|
||||||
const root: HTML =
|
const root: HTML =
|
||||||
sandboxElement !== undefined && document !== undefined && document !== null
|
document !== undefined && document !== null
|
||||||
? select(document)
|
? select(document.body as HTMLIFrameElement)
|
||||||
: select('body');
|
: select('body');
|
||||||
|
|
||||||
const svg: SVG = root.select('#' + id);
|
const svg: SVG = root.select('#' + id);
|
||||||
@@ -34,7 +32,6 @@ const draw: DrawDefinition = (text, id, version) => {
|
|||||||
svg.attr('width', 400);
|
svg.attr('width', 400);
|
||||||
|
|
||||||
const g = svg.append('g');
|
const g = svg.append('g');
|
||||||
|
|
||||||
g.append('text') // text label for the x axis
|
g.append('text') // text label for the x axis
|
||||||
.attr('x', 100)
|
.attr('x', 100)
|
||||||
.attr('y', 40)
|
.attr('y', 40)
|
||||||
@@ -43,7 +40,7 @@ const draw: DrawDefinition = (text, id, version) => {
|
|||||||
.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', e);
|
log.error('error while rendering info diagram\n', e);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user