mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-15 13:29:40 +02:00
Enable html labels for classDiagram-v2
This commit is contained in:
@@ -575,7 +575,14 @@ const class_box = (parent, node) => {
|
|||||||
const interfaceLabel = labelContainer
|
const interfaceLabel = labelContainer
|
||||||
.node()
|
.node()
|
||||||
.appendChild(createLabel(interfaceLabelText, node.labelStyle, true, true));
|
.appendChild(createLabel(interfaceLabelText, node.labelStyle, true, true));
|
||||||
const interfaceBBox = interfaceLabel.getBBox();
|
let interfaceBBox = interfaceLabel.getBBox();
|
||||||
|
if (getConfig().flowchart.htmlLabels) {
|
||||||
|
const div = interfaceLabel.children[0];
|
||||||
|
const dv = select(interfaceLabel);
|
||||||
|
interfaceBBox = div.getBoundingClientRect();
|
||||||
|
dv.attr('width', interfaceBBox.width);
|
||||||
|
dv.attr('height', interfaceBBox.height);
|
||||||
|
}
|
||||||
if (node.classData.annotations[0]) {
|
if (node.classData.annotations[0]) {
|
||||||
maxHeight += interfaceBBox.height + rowPadding;
|
maxHeight += interfaceBBox.height + rowPadding;
|
||||||
maxWidth += interfaceBBox.width;
|
maxWidth += interfaceBBox.width;
|
||||||
@@ -584,7 +591,14 @@ const class_box = (parent, node) => {
|
|||||||
const classTitleLabel = labelContainer
|
const classTitleLabel = labelContainer
|
||||||
.node()
|
.node()
|
||||||
.appendChild(createLabel(node.labelText, node.labelStyle, true, true));
|
.appendChild(createLabel(node.labelText, node.labelStyle, true, true));
|
||||||
const classTitleBBox = classTitleLabel.getBBox();
|
let classTitleBBox = classTitleLabel.getBBox();
|
||||||
|
if (getConfig().flowchart.htmlLabels) {
|
||||||
|
const div = classTitleLabel.children[0];
|
||||||
|
const dv = select(classTitleLabel);
|
||||||
|
classTitleBBox = div.getBoundingClientRect();
|
||||||
|
dv.attr('width', classTitleBBox.width);
|
||||||
|
dv.attr('height', classTitleBBox.height);
|
||||||
|
}
|
||||||
maxHeight += classTitleBBox.height + rowPadding;
|
maxHeight += classTitleBBox.height + rowPadding;
|
||||||
if (classTitleBBox.width > maxWidth) {
|
if (classTitleBBox.width > maxWidth) {
|
||||||
maxWidth = classTitleBBox.width;
|
maxWidth = classTitleBBox.width;
|
||||||
@@ -595,7 +609,14 @@ const class_box = (parent, node) => {
|
|||||||
const lbl = labelContainer
|
const lbl = labelContainer
|
||||||
.node()
|
.node()
|
||||||
.appendChild(createLabel(parsedText, node.labelStyle, true, true));
|
.appendChild(createLabel(parsedText, node.labelStyle, true, true));
|
||||||
const bbox = lbl.getBBox();
|
let bbox = lbl.getBBox();
|
||||||
|
if (getConfig().flowchart.htmlLabels) {
|
||||||
|
const div = lbl.children[0];
|
||||||
|
const dv = select(lbl);
|
||||||
|
bbox = div.getBoundingClientRect();
|
||||||
|
dv.attr('width', bbox.width);
|
||||||
|
dv.attr('height', bbox.height);
|
||||||
|
}
|
||||||
if (bbox.width > maxWidth) {
|
if (bbox.width > maxWidth) {
|
||||||
maxWidth = bbox.width;
|
maxWidth = bbox.width;
|
||||||
}
|
}
|
||||||
@@ -611,7 +632,14 @@ const class_box = (parent, node) => {
|
|||||||
const lbl = labelContainer
|
const lbl = labelContainer
|
||||||
.node()
|
.node()
|
||||||
.appendChild(createLabel(parsedText, node.labelStyle, true, true));
|
.appendChild(createLabel(parsedText, node.labelStyle, true, true));
|
||||||
const bbox = lbl.getBBox();
|
let bbox = lbl.getBBox();
|
||||||
|
if (getConfig().flowchart.htmlLabels) {
|
||||||
|
const div = lbl.children[0];
|
||||||
|
const dv = select(lbl);
|
||||||
|
bbox = div.getBoundingClientRect();
|
||||||
|
dv.attr('width', bbox.width);
|
||||||
|
dv.attr('height', bbox.height);
|
||||||
|
}
|
||||||
if (bbox.width > maxWidth) {
|
if (bbox.width > maxWidth) {
|
||||||
maxWidth = bbox.width;
|
maxWidth = bbox.width;
|
||||||
}
|
}
|
||||||
@@ -684,14 +712,14 @@ const class_box = (parent, node) => {
|
|||||||
verticalPos += classTitleBBox.height + rowPadding;
|
verticalPos += classTitleBBox.height + rowPadding;
|
||||||
});
|
});
|
||||||
//
|
//
|
||||||
let bbox;
|
// let bbox;
|
||||||
if (getConfig().flowchart.htmlLabels) {
|
// if (getConfig().flowchart.htmlLabels) {
|
||||||
const div = interfaceLabel.children[0];
|
// const div = interfaceLabel.children[0];
|
||||||
const dv = select(interfaceLabel);
|
// const dv = select(interfaceLabel);
|
||||||
bbox = div.getBoundingClientRect();
|
// bbox = div.getBoundingClientRect();
|
||||||
dv.attr('width', bbox.width);
|
// dv.attr('width', bbox.width);
|
||||||
dv.attr('height', bbox.height);
|
// dv.attr('height', bbox.height);
|
||||||
}
|
// }
|
||||||
// bbox = labelContainer.getBBox();
|
// bbox = labelContainer.getBBox();
|
||||||
|
|
||||||
// logger.info('Text 2', text2);
|
// logger.info('Text 2', text2);
|
||||||
|
Reference in New Issue
Block a user