mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-11-02 11:54:15 +01:00
add support for stereotype annotations for class diagrams
This commit is contained in:
@@ -45,6 +45,36 @@ export async function textHelper<T extends SVGGraphicsElement>(
|
||||
|
||||
labelGroup = shapeSvg.insert('g').attr('class', 'label-group text');
|
||||
await addText(labelGroup, node, 0, ['font-weight: bolder']);
|
||||
// Determine styling based on annotations
|
||||
let labelStyles = ['font-weight: bolder']; // Default bold style
|
||||
let labelClass = 'classTitle';
|
||||
|
||||
if (node.annotations && node.annotations.length > 0) {
|
||||
const annotation = node.annotations[0].toLowerCase();
|
||||
switch (annotation) {
|
||||
case 'abstract':
|
||||
labelClass = 'classTitle abstract';
|
||||
labelStyles = [];
|
||||
break;
|
||||
case 'enumeration':
|
||||
labelClass = 'classTitle enumeration';
|
||||
labelStyles = [];
|
||||
break;
|
||||
case 'interface':
|
||||
labelClass = 'classTitle interface';
|
||||
labelStyles = [];
|
||||
break;
|
||||
default:
|
||||
labelClass = 'classTitle';
|
||||
labelStyles = ['font-weight: bolder'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Apply the CSS class to the label group
|
||||
labelGroup.attr('class', `label-group text ${labelClass}`);
|
||||
|
||||
await addText(labelGroup, node, 0, labelStyles);
|
||||
const labelGroupBBox = labelGroup.node()!.getBBox();
|
||||
labelGroupHeight = labelGroupBBox.height;
|
||||
|
||||
|
||||
@@ -148,6 +148,18 @@ g.classGroup line {
|
||||
stroke: ${options.lineColor} !important;
|
||||
stroke-width: 1;
|
||||
}
|
||||
|
||||
.classTitle.abstract {
|
||||
font-style: italic;
|
||||
font-weight: normal;
|
||||
}
|
||||
.classTitle.enumeration {
|
||||
text-decoration: underline;
|
||||
font-weight: normal;
|
||||
}
|
||||
.classTitle.interface {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.edgeTerminals {
|
||||
font-size: 11px;
|
||||
|
||||
Reference in New Issue
Block a user