mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-01-28 07:03:17 +08:00
updated constraint property for node shape
This commit is contained in:
parent
1c8c95367d
commit
fd372941c7
@ -161,7 +161,11 @@ export const addVertex = function (
|
|||||||
if (!doc.label?.trim() && vertex.text === id) {
|
if (!doc.label?.trim() && vertex.text === id) {
|
||||||
vertex.text = '';
|
vertex.text = '';
|
||||||
}
|
}
|
||||||
vertex.constrainedImage = !!doc.constrainedImage;
|
if (doc?.constraint) {
|
||||||
|
vertex.constraint = doc.constraint;
|
||||||
|
} else {
|
||||||
|
vertex.constraint = 'off';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (doc.w) {
|
if (doc.w) {
|
||||||
vertex.assetWidth = Number(doc.w);
|
vertex.assetWidth = Number(doc.w);
|
||||||
@ -900,9 +904,7 @@ const addNodeFromVertex = (
|
|||||||
img: vertex.img,
|
img: vertex.img,
|
||||||
assetWidth: vertex.assetWidth,
|
assetWidth: vertex.assetWidth,
|
||||||
assetHeight: vertex.assetHeight,
|
assetHeight: vertex.assetHeight,
|
||||||
imageAspectRatio: vertex.imageAspectRatio,
|
constraint: vertex.constraint,
|
||||||
defaultWidth: vertex.defaultWidth,
|
|
||||||
constrainedImage: vertex.constrainedImage,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -19,7 +19,7 @@ export interface FlowVertex {
|
|||||||
assetHeight?: number;
|
assetHeight?: number;
|
||||||
defaultWidth?: number;
|
defaultWidth?: number;
|
||||||
imageAspectRatio?: number;
|
imageAspectRatio?: number;
|
||||||
constrainedImage?: boolean;
|
constraint?: 'on' | 'off';
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface FlowText {
|
export interface FlowText {
|
||||||
|
@ -30,7 +30,8 @@ export const imageSquare = async (
|
|||||||
node.label ? (defaultWidth ?? 0) : 0,
|
node.label ? (defaultWidth ?? 0) : 0,
|
||||||
node?.assetWidth ?? imageNaturalWidth
|
node?.assetWidth ?? imageNaturalWidth
|
||||||
);
|
);
|
||||||
const imageHeight = node.constrainedImage
|
const imageHeight =
|
||||||
|
node.constraint === 'on'
|
||||||
? imageWidth / node.imageAspectRatio
|
? imageWidth / node.imageAspectRatio
|
||||||
: (node?.assetHeight ?? imageNaturalHeight);
|
: (node?.assetHeight ?? imageNaturalHeight);
|
||||||
node.width = Math.max(imageWidth, defaultWidth ?? 0);
|
node.width = Math.max(imageWidth, defaultWidth ?? 0);
|
||||||
|
@ -71,7 +71,7 @@ export interface Node {
|
|||||||
assetHeight?: number;
|
assetHeight?: number;
|
||||||
defaultWidth?: number;
|
defaultWidth?: number;
|
||||||
imageAspectRatio?: number;
|
imageAspectRatio?: number;
|
||||||
constrainedImage?: boolean;
|
constraint?: 'on' | 'off';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Common properties for any edge in the system
|
// Common properties for any edge in the system
|
||||||
|
@ -7,7 +7,7 @@ export interface NodeMetaData {
|
|||||||
img?: string;
|
img?: string;
|
||||||
w?: string;
|
w?: string;
|
||||||
h?: string;
|
h?: string;
|
||||||
constrainedImage?: boolean;
|
constraint?: 'on' | 'off';
|
||||||
}
|
}
|
||||||
import type { MermaidConfig } from './config.type.js';
|
import type { MermaidConfig } from './config.type.js';
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user