mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-11-17 19:24:10 +01:00
fix: preserve annotations and adjust styling for clarity
on-behalf-of: @Mermaid-Chart <hello@mermaidchart.com>
This commit is contained in:
@@ -36,16 +36,31 @@ export async function textHelper<T extends SVGGraphicsElement>(
|
|||||||
|
|
||||||
annotationGroup = shapeSvg.insert('g').attr('class', 'annotation-group text');
|
annotationGroup = shapeSvg.insert('g').attr('class', 'annotation-group text');
|
||||||
if (node.annotations.length > 0) {
|
if (node.annotations.length > 0) {
|
||||||
await addText(annotationGroup, { text: `` } as unknown as ClassMember, 0);
|
const annotation = node.annotations[0].toLowerCase();
|
||||||
|
let isSupported = false;
|
||||||
|
switch (annotation) {
|
||||||
|
case 'interface':
|
||||||
|
case 'abstract':
|
||||||
|
case 'enumeration':
|
||||||
|
isSupported = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (!isSupported) {
|
||||||
|
await addText(
|
||||||
|
annotationGroup,
|
||||||
|
{ text: `«${node.annotations[0]}»` } as unknown as ClassMember,
|
||||||
|
0,
|
||||||
|
[]
|
||||||
|
);
|
||||||
|
annotationGroup.style('opacity', '1');
|
||||||
|
}
|
||||||
const annotationGroupBBox = annotationGroup.node()!.getBBox();
|
const annotationGroupBBox = annotationGroup.node()!.getBBox();
|
||||||
annotationGroupHeight = annotationGroupBBox.height;
|
annotationGroupHeight = annotationGroupBBox.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
labelGroup = shapeSvg.insert('g').attr('class', 'label-group text');
|
labelGroup = shapeSvg.insert('g').attr('class', 'label-group text');
|
||||||
|
|
||||||
// Determine styling based on annotations
|
// Determine styling based on annotations
|
||||||
let labelStyles = ['font-weight: bolder']; // Default bold style
|
let labelStyles = [''];
|
||||||
let labelClass = '';
|
let labelClass = '';
|
||||||
if (node.annotations && node.annotations.length > 0) {
|
if (node.annotations && node.annotations.length > 0) {
|
||||||
const annotation = node.annotations[0].toLowerCase();
|
const annotation = node.annotations[0].toLowerCase();
|
||||||
@@ -63,7 +78,8 @@ export async function textHelper<T extends SVGGraphicsElement>(
|
|||||||
labelStyles = [];
|
labelStyles = [];
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
labelStyles = ['font-weight: bolder'];
|
labelClass = '';
|
||||||
|
labelStyles = [];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ const getStyles = (options) =>
|
|||||||
}
|
}
|
||||||
|
|
||||||
.classTitle {
|
.classTitle {
|
||||||
font-weight: bolder;
|
font-weight: normal;
|
||||||
}
|
}
|
||||||
.node rect,
|
.node rect,
|
||||||
.node circle,
|
.node circle,
|
||||||
|
|||||||
Reference in New Issue
Block a user