mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-01-14 06:43:25 +08:00
Small fix
This commit is contained in:
parent
08fbed7c47
commit
39598baaa3
@ -1,45 +1,20 @@
|
|||||||
import { select } from 'd3';
|
|
||||||
import type { SVG } from '../diagram-api/types.js';
|
import type { SVG } from '../diagram-api/types.js';
|
||||||
import { getConfig } from '../diagram-api/diagramAPI.js';
|
import { getConfig } from '../diagram-api/diagramAPI.js';
|
||||||
import type { LayoutData, NonClusterNode } from './types.js';
|
import type { LayoutData } from './types.js';
|
||||||
import type { SVGGroup } from '../diagram-api/types.js';
|
|
||||||
import { insertNode } from './rendering-elements/nodes.js';
|
import { insertNode } from './rendering-elements/nodes.js';
|
||||||
|
|
||||||
type Node = LayoutData['nodes'][number];
|
export async function insertElementsForSize(el: SVG, data: LayoutData) {
|
||||||
|
|
||||||
interface LabelData {
|
|
||||||
width: number;
|
|
||||||
height: number;
|
|
||||||
wrappingWidth?: number;
|
|
||||||
labelNode?: SVGGElement | null;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface NodeWithVertex extends Omit<Node, 'domId'> {
|
|
||||||
children?: unknown[];
|
|
||||||
labelData?: LabelData;
|
|
||||||
domId?: Node['domId'] | SVGGroup | d3.Selection<SVGAElement, unknown, Element | null, unknown>;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// export function insertElementsForSize(el: SVGElement, data: LayoutData): void {
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param el
|
|
||||||
* @param data
|
|
||||||
*/
|
|
||||||
export function insertElementsForSize(el: SVG, data: LayoutData) {
|
|
||||||
const nodesElem = el.insert('g').attr('class', 'nodes');
|
const nodesElem = el.insert('g').attr('class', 'nodes');
|
||||||
el.insert('g').attr('class', 'edges');
|
el.insert('g').attr('class', 'edges');
|
||||||
data.nodes.forEach(async (item) => {
|
for (const item of data.nodes) {
|
||||||
if (!item.isGroup) {
|
if (!item.isGroup) {
|
||||||
const node = item as NonClusterNode;
|
const node = item;
|
||||||
const config = getConfig();
|
const config = getConfig();
|
||||||
const newNode = await insertNode(nodesElem, node, { config, dir: node.dir });
|
const newNode = await insertNode(nodesElem, node, { config, dir: node.dir });
|
||||||
|
|
||||||
const boundingBox = newNode.node()!.getBBox();
|
const boundingBox = newNode.node()!.getBBox();
|
||||||
item.domId = newNode.attr('id');
|
item.domId = newNode.attr('id');
|
||||||
item.width = boundingBox.width;
|
item.width = boundingBox.width;
|
||||||
item.height = boundingBox.height;
|
item.height = boundingBox.height;
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user