mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-15 21:39:40 +02:00
Adjust the class members with proper parsing
This commit is contained in:
@@ -20,7 +20,7 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>info below</h1>
|
<h1>info below</h1>
|
||||||
<div class="mermaid" style="width: 100%; height: 20%;">
|
<div class="mermaid2" style="width: 100%; height: 20%;">
|
||||||
%%{init: {'theme': 'base', 'fontFamily': 'arial', 'themeVariables': { 'primaryColor': '#ff0000'}}}%%
|
%%{init: {'theme': 'base', 'fontFamily': 'arial', 'themeVariables': { 'primaryColor': '#ff0000'}}}%%
|
||||||
classDiagram-v2
|
classDiagram-v2
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@
|
|||||||
classB : method2() int
|
classB : method2() int
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mermaid2" style="width: 100%; height: 20%;">
|
<div class="mermaid" style="width: 100%; height: 20%;">
|
||||||
classDiagram-v2
|
classDiagram-v2
|
||||||
|
|
||||||
classA -- classB : Inheritance
|
classA -- classB : Inheritance
|
||||||
@@ -65,6 +65,24 @@
|
|||||||
Galaxy --> "many" Star : Contains
|
Galaxy --> "many" Star : Contains
|
||||||
<<interface>> Customer
|
<<interface>> Customer
|
||||||
<<Service>> Galaxy
|
<<Service>> Galaxy
|
||||||
|
|
||||||
|
class BankAccount{
|
||||||
|
+String owner
|
||||||
|
+BigDecimal balance
|
||||||
|
+deposit(amount) bool
|
||||||
|
+withdrawl(amount) int
|
||||||
|
}
|
||||||
|
|
||||||
|
class Square~Shape~{
|
||||||
|
int id
|
||||||
|
List~int~ position
|
||||||
|
setPoints(List~int~ points)
|
||||||
|
getPoints() List~int~
|
||||||
|
}
|
||||||
|
|
||||||
|
Square : -List~string~ messages
|
||||||
|
Square : +setMessages(List~string~ messages)
|
||||||
|
Square : +getMessages() List~string~
|
||||||
</div>
|
</div>
|
||||||
<script src="./mermaid.js"></script>
|
<script src="./mermaid.js"></script>
|
||||||
<script>
|
<script>
|
||||||
|
@@ -5,6 +5,7 @@ import { getConfig } from '../config';
|
|||||||
import intersect from './intersect/index.js';
|
import intersect from './intersect/index.js';
|
||||||
import createLabel from './createLabel';
|
import createLabel from './createLabel';
|
||||||
import note from './shapes/note';
|
import note from './shapes/note';
|
||||||
|
import { parseMember } from '../diagrams/class/svgDraw';
|
||||||
|
|
||||||
const question = (parent, node) => {
|
const question = (parent, node) => {
|
||||||
const { shapeSvg, bbox } = labelHelper(parent, node, undefined, true);
|
const { shapeSvg, bbox } = labelHelper(parent, node, undefined, true);
|
||||||
@@ -569,7 +570,7 @@ const class_box = (parent, node) => {
|
|||||||
|
|
||||||
// 1. Create the labels
|
// 1. Create the labels
|
||||||
const interfaceLabelText = node.classData.annotations[0]
|
const interfaceLabelText = node.classData.annotations[0]
|
||||||
? '<<' + node.classData.annotations[0] + '>>'
|
? '«' + node.classData.annotations[0] + '»'
|
||||||
: '';
|
: '';
|
||||||
const interfaceLabel = labelContainer
|
const interfaceLabel = labelContainer
|
||||||
.node()
|
.node()
|
||||||
@@ -590,7 +591,10 @@ const class_box = (parent, node) => {
|
|||||||
}
|
}
|
||||||
const classAttributes = [];
|
const classAttributes = [];
|
||||||
node.classData.members.forEach(str => {
|
node.classData.members.forEach(str => {
|
||||||
const lbl = labelContainer.node().appendChild(createLabel(str, node.labelStyle, true, true));
|
const parsedText = parseMember(str).displayText;
|
||||||
|
const lbl = labelContainer
|
||||||
|
.node()
|
||||||
|
.appendChild(createLabel(parsedText, node.labelStyle, true, true));
|
||||||
const bbox = lbl.getBBox();
|
const bbox = lbl.getBBox();
|
||||||
if (bbox.width > maxWidth) {
|
if (bbox.width > maxWidth) {
|
||||||
maxWidth = bbox.width;
|
maxWidth = bbox.width;
|
||||||
@@ -599,9 +603,14 @@ const class_box = (parent, node) => {
|
|||||||
classAttributes.push(lbl);
|
classAttributes.push(lbl);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
maxHeight += lineHeight;
|
||||||
|
|
||||||
const classMethods = [];
|
const classMethods = [];
|
||||||
node.classData.methods.forEach(str => {
|
node.classData.methods.forEach(str => {
|
||||||
const lbl = labelContainer.node().appendChild(createLabel(str, node.labelStyle, true, true));
|
const parsedText = parseMember(str).displayText;
|
||||||
|
const lbl = labelContainer
|
||||||
|
.node()
|
||||||
|
.appendChild(createLabel(parsedText, node.labelStyle, true, true));
|
||||||
const bbox = lbl.getBBox();
|
const bbox = lbl.getBBox();
|
||||||
if (bbox.width > maxWidth) {
|
if (bbox.width > maxWidth) {
|
||||||
maxWidth = bbox.width;
|
maxWidth = bbox.width;
|
||||||
@@ -657,6 +666,7 @@ const class_box = (parent, node) => {
|
|||||||
verticalPos += classTitleBBox.height + rowPadding;
|
verticalPos += classTitleBBox.height + rowPadding;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
verticalPos += lineHeight;
|
||||||
bottomLine
|
bottomLine
|
||||||
.attr('class', 'divider')
|
.attr('class', 'divider')
|
||||||
.attr('x1', -maxWidth / 2 - halfPadding)
|
.attr('x1', -maxWidth / 2 - halfPadding)
|
||||||
|
Reference in New Issue
Block a user