mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-01-28 07:03:17 +08:00
#5237 pass css node style like bgColor, borderColor, borderWeight for roughjs
This commit is contained in:
parent
20f9e503cb
commit
e8018ed779
@ -760,6 +760,34 @@ function insertOrUpdateNode(nodes, nodeData) {
|
||||
if (!nodeData.id || nodeData.id === '</join></fork>' || nodeData.id === '</choice>') {
|
||||
return;
|
||||
}
|
||||
|
||||
//Populate node style attributes if nodeData has classes defined
|
||||
if (nodeData.classes) {
|
||||
nodeData.classes.split(' ').forEach((cssClass) => {
|
||||
if (classes[cssClass]) {
|
||||
classes[cssClass].styles.forEach((style) => {
|
||||
// Populate nodeData with style attributes specifically to be used by rough.js
|
||||
if (style && style.startsWith('fill:')) {
|
||||
nodeData.backgroundColor = style.replace('fill:', '');
|
||||
}
|
||||
if (style && style.startsWith('stroke:')) {
|
||||
nodeData.borderColor = style.replace('stroke:', '');
|
||||
}
|
||||
if (style && style.startsWith('stroke-width:')) {
|
||||
nodeData.borderWidth = style.replace('stroke-width:', '');
|
||||
}
|
||||
|
||||
nodeData.style += style + ';';
|
||||
});
|
||||
classes[cssClass].textStyles.forEach((style) => {
|
||||
nodeData.labelStyle += style + ';';
|
||||
if (style && style.startsWith('fill:')) {
|
||||
nodeData.labelTextColor = style.replace('fill:', '');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
const existingNodeData = nodes.find((node) => node.id === nodeData.id);
|
||||
if (existingNodeData) {
|
||||
//update the existing nodeData
|
||||
|
@ -44,6 +44,11 @@ interface Node {
|
||||
useRough?: boolean;
|
||||
useHtmlLabels?: boolean;
|
||||
centerLabel?: boolean;
|
||||
|
||||
//Node style properties
|
||||
backgroundColor?: string;
|
||||
borderColor?: string;
|
||||
labelTextColor?: string;
|
||||
}
|
||||
|
||||
// Common properties for any edge in the system
|
||||
|
Loading…
x
Reference in New Issue
Block a user