mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-02 23:26:44 +02:00
fix: handle undefined edge list in insertEdge to prevent runtime error
Fixes a runtime error in cose-bilkent layout caused by insertEdge calling .filter() on an undefined edge list. Now defaults to an empty array to prevent the crash. on-behalf-of: @Mermaid-Chart <hello@mermaidchart.com>
This commit is contained in:
@@ -115,6 +115,18 @@ export const render = async (
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
layoutResult.edges.forEach((positionedEdge) => {
|
||||||
|
const edge = data4Layout.edges.find((e) => e.id === positionedEdge.id);
|
||||||
|
if (edge) {
|
||||||
|
// Update the edge data with positioned coordinates
|
||||||
|
edge.points = [
|
||||||
|
{ x: positionedEdge.startX, y: positionedEdge.startY },
|
||||||
|
{ x: positionedEdge.midX, y: positionedEdge.midY },
|
||||||
|
{ x: positionedEdge.endX, y: positionedEdge.endY },
|
||||||
|
];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Step 4: Insert and position edges
|
// Step 4: Insert and position edges
|
||||||
log.debug('Inserting and positioning edges');
|
log.debug('Inserting and positioning edges');
|
||||||
|
|
||||||
@@ -134,10 +146,7 @@ export const render = async (
|
|||||||
if (positionedEdge) {
|
if (positionedEdge) {
|
||||||
log.debug('APA01 positionedEdge', positionedEdge);
|
log.debug('APA01 positionedEdge', positionedEdge);
|
||||||
// Create edge path with positioned coordinates
|
// Create edge path with positioned coordinates
|
||||||
const edgeWithPath = {
|
const edgeWithPath = { ...edge };
|
||||||
...edge,
|
|
||||||
points: positionedEdge.points,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Insert the edge path
|
// Insert the edge path
|
||||||
const paths = insertEdge(
|
const paths = insertEdge(
|
||||||
|
@@ -128,6 +128,7 @@ export interface Edge {
|
|||||||
thickness?: 'normal' | 'thick' | 'invisible' | 'dotted';
|
thickness?: 'normal' | 'thick' | 'invisible' | 'dotted';
|
||||||
look?: string;
|
look?: string;
|
||||||
isUserDefinedId?: boolean;
|
isUserDefinedId?: boolean;
|
||||||
|
points?: Point[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface RectOptions {
|
export interface RectOptions {
|
||||||
|
Reference in New Issue
Block a user