#5237 pass css node style like bgColor, borderColor, borderWeight for roughjs

This commit is contained in:
Ashish Jain 2024-05-15 11:20:10 +02:00
parent 20f9e503cb
commit e8018ed779
2 changed files with 33 additions and 0 deletions

View File

@ -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

View File

@ -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