mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-02-04 07:13:25 +08:00
chore: Cleanup dataFetcher
This commit is contained in:
parent
b1b5ad3c9b
commit
3c6ae36611
@ -35,7 +35,7 @@ import {
|
|||||||
} from './stateCommon.js';
|
} from './stateCommon.js';
|
||||||
|
|
||||||
// List of nodes created from the parsed diagram statement items
|
// List of nodes created from the parsed diagram statement items
|
||||||
let nodeDb = {};
|
let nodeDb = new Map();
|
||||||
|
|
||||||
let graphItemCount = 0; // used to construct ids, etc.
|
let graphItemCount = 0; // used to construct ids, etc.
|
||||||
|
|
||||||
@ -104,7 +104,6 @@ const setupDoc = (parentParsedItem, doc, diagramStates, nodes, edges, altFlag, l
|
|||||||
look,
|
look,
|
||||||
};
|
};
|
||||||
edges.push(edgeData);
|
edges.push(edgeData);
|
||||||
//g.setEdge(item.state1.id, item.state2.id, edgeData, graphItemCount);
|
|
||||||
graphItemCount++;
|
graphItemCount++;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -229,6 +228,7 @@ function getStylesFromDbInfo(dbInfoItem) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const dataFetcher = (
|
export const dataFetcher = (
|
||||||
parent,
|
parent,
|
||||||
parsedItem,
|
parsedItem,
|
||||||
@ -259,17 +259,17 @@ export const dataFetcher = (
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add the node to our list (nodeDb)
|
// Add the node to our list (nodeDb)
|
||||||
if (!nodeDb[itemId]) {
|
if (!nodeDb.get(itemId)) {
|
||||||
nodeDb[itemId] = {
|
nodeDb.set(itemId, {
|
||||||
id: itemId,
|
id: itemId,
|
||||||
shape,
|
shape,
|
||||||
description: common.sanitizeText(itemId, getConfig()),
|
description: common.sanitizeText(itemId, getConfig()),
|
||||||
cssClasses: `${classStr} ${CSS_DIAGRAM_STATE}`,
|
cssClasses: `${classStr} ${CSS_DIAGRAM_STATE}`,
|
||||||
cssStyles: style,
|
cssStyles: style,
|
||||||
};
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const newNode = nodeDb[itemId];
|
const newNode = nodeDb.get(itemId);
|
||||||
|
|
||||||
// Save data for description and group so that for instance a statement without description overwrites
|
// Save data for description and group so that for instance a statement without description overwrites
|
||||||
// one with description @todo TODO What does this mean? If important, add a test for it
|
// one with description @todo TODO What does this mean? If important, add a test for it
|
||||||
@ -305,7 +305,6 @@ export const dataFetcher = (
|
|||||||
} else {
|
} else {
|
||||||
newNode.shape = SHAPE_STATE;
|
newNode.shape = SHAPE_STATE;
|
||||||
}
|
}
|
||||||
//newNode.shape = SHAPE_STATE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// group
|
// group
|
||||||
@ -315,12 +314,7 @@ export const dataFetcher = (
|
|||||||
newNode.isGroup = true;
|
newNode.isGroup = true;
|
||||||
newNode.dir = getDir(parsedItem);
|
newNode.dir = getDir(parsedItem);
|
||||||
newNode.shape = parsedItem.type === DIVIDER_TYPE ? SHAPE_DIVIDER : SHAPE_GROUP;
|
newNode.shape = parsedItem.type === DIVIDER_TYPE ? SHAPE_DIVIDER : SHAPE_GROUP;
|
||||||
newNode.cssClasses =
|
newNode.cssClasses = `${newNode.cssClasses} ${CSS_DIAGRAM_CLUSTER} ${altFlag ? CSS_DIAGRAM_CLUSTER_ALT : ''}`;
|
||||||
newNode.cssClasses +
|
|
||||||
' ' +
|
|
||||||
CSS_DIAGRAM_CLUSTER +
|
|
||||||
' ' +
|
|
||||||
(altFlag ? CSS_DIAGRAM_CLUSTER_ALT : '');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is what will be added to the graph
|
// This is what will be added to the graph
|
||||||
@ -436,6 +430,6 @@ export const dataFetcher = (
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const reset = () => {
|
export const reset = () => {
|
||||||
nodeDb = {};
|
nodeDb.clear();
|
||||||
graphItemCount = 0;
|
graphItemCount = 0;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user