Skip to content

Commit

Permalink
updated imageSquare shape
Browse files Browse the repository at this point in the history
  • Loading branch information
omkarht committed Sep 24, 2024
1 parent fd37294 commit 6a649d3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
8 changes: 3 additions & 5 deletions packages/mermaid/src/diagrams/flowchart/flowDb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,9 @@ export const addVertex = function (
if (!doc.label?.trim() && vertex.text === id) {
vertex.text = '';
}
if (doc?.constraint) {
vertex.constraint = doc.constraint;
} else {
vertex.constraint = 'off';
}
}
if (doc?.constraint) {
vertex.constraint = doc.constraint;
}
if (doc.w) {
vertex.assetWidth = Number(doc.w);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,18 @@ export const imageSquare = async (
const defaultWidth = flowchart?.wrappingWidth;
node.defaultWidth = flowchart?.wrappingWidth;

const imageWidth = Math.max(
const imageRawWidth = Math.max(
node.label ? (defaultWidth ?? 0) : 0,
node?.assetWidth ?? imageNaturalWidth
);

const imageWidth =
node.constraint === 'on'
? node?.assetHeight
? node.assetHeight * node.imageAspectRatio
: imageRawWidth
: imageRawWidth;

const imageHeight =
node.constraint === 'on'
? imageWidth / node.imageAspectRatio
Expand Down

0 comments on commit 6a649d3

Please sign in to comment.