mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-17 14:29:48 +02:00
Fix padding for entities with no attributes
This commit is contained in:
@@ -32,7 +32,7 @@ export const setConf = function(cnf) {
|
|||||||
const drawAttributes = (groupNode, entityTextNode, attributes) => {
|
const drawAttributes = (groupNode, entityTextNode, attributes) => {
|
||||||
const heightPadding = conf.entityPadding / 3; // Padding internal to attribute boxes
|
const heightPadding = conf.entityPadding / 3; // Padding internal to attribute boxes
|
||||||
const widthPadding = conf.entityPadding / 3; // Ditto
|
const widthPadding = conf.entityPadding / 3; // Ditto
|
||||||
const attrFontSize = conf.fontSize * 0.8;
|
const attrFontSize = conf.fontSize * 0.85;
|
||||||
const labelBBox = entityTextNode.node().getBBox();
|
const labelBBox = entityTextNode.node().getBBox();
|
||||||
const attributeNodes = []; // Intermediate storage for attribute nodes created so that we can do a second pass
|
const attributeNodes = []; // Intermediate storage for attribute nodes created so that we can do a second pass
|
||||||
let maxTypeWidth = 0;
|
let maxTypeWidth = 0;
|
||||||
@@ -90,10 +90,15 @@ const drawAttributes = (groupNode, entityTextNode, attributes) => {
|
|||||||
const bBox = {
|
const bBox = {
|
||||||
width: Math.max(
|
width: Math.max(
|
||||||
conf.minEntityWidth,
|
conf.minEntityWidth,
|
||||||
Math.max(labelBBox.width + widthPadding * 2, maxTypeWidth + maxNameWidth + widthPadding * 4)
|
Math.max(
|
||||||
|
labelBBox.width + conf.entityPadding * 2,
|
||||||
|
maxTypeWidth + maxNameWidth + widthPadding * 4
|
||||||
|
)
|
||||||
),
|
),
|
||||||
height:
|
height:
|
||||||
attributes.length > 0 ? cumulativeHeight : Math.max(conf.minEntityHeight, cumulativeHeight)
|
attributes.length > 0
|
||||||
|
? cumulativeHeight
|
||||||
|
: Math.max(conf.minEntityHeight, labelBBox.height + conf.entityPadding * 2)
|
||||||
};
|
};
|
||||||
|
|
||||||
// There might be some spare width for padding out attributes if the entity name is very long
|
// There might be some spare width for padding out attributes if the entity name is very long
|
||||||
|
@@ -18,7 +18,7 @@
|
|||||||
"erDiagram" return 'ER_DIAGRAM';
|
"erDiagram" return 'ER_DIAGRAM';
|
||||||
"{" { this.begin("block"); return 'BLOCK_START'; }
|
"{" { this.begin("block"); return 'BLOCK_START'; }
|
||||||
<block>\s+ /* skip whitespace in block */
|
<block>\s+ /* skip whitespace in block */
|
||||||
<block>[A-Za-z][A-Za-z0-9\-_]+ { return 'ATTRIBUTE_WORD'; }
|
<block>[A-Za-z][A-Za-z0-9\-_]* { return 'ATTRIBUTE_WORD'; }
|
||||||
<block>[\n]+ /* nothing */
|
<block>[\n]+ /* nothing */
|
||||||
<block>"}" { this.popState(); return 'BLOCK_STOP'; }
|
<block>"}" { this.popState(); return 'BLOCK_STOP'; }
|
||||||
<block>. return yytext[0];
|
<block>. return yytext[0];
|
||||||
|
Reference in New Issue
Block a user