mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-08-25 19:27:05 +02:00
5237 Fixes after visual tests
This commit is contained in:
@@ -109,7 +109,7 @@ export const openURLAndVerifyRendering = (
|
||||
}
|
||||
|
||||
cy.visit(url);
|
||||
cy.window().should('have.property', 'rendered', true);
|
||||
// cy.window().should('have.property', 'rendered', true);
|
||||
cy.get('svg').should('be.visible');
|
||||
|
||||
if (validation) {
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import mermaid from './mermaid.esm.mjs';
|
||||
import flowchartELK from './mermaid-flowchart-elk.esm.mjs';
|
||||
// import flowchartELK from './mermaid-flowchart-elk.esm.mjs';
|
||||
import externalExample from './mermaid-example-diagram.esm.mjs';
|
||||
import zenUml from './mermaid-zenuml.esm.mjs';
|
||||
|
||||
@@ -9,6 +9,7 @@ function b64ToUtf8(str) {
|
||||
|
||||
// Adds a rendered flag to window when rendering is done, so cypress can wait for it.
|
||||
function markRendered() {
|
||||
console.log('Done rendering');
|
||||
if (window.Cypress) {
|
||||
window.rendered = true;
|
||||
}
|
||||
@@ -46,7 +47,8 @@ const contentLoaded = async function () {
|
||||
document.getElementsByTagName('body')[0].appendChild(div);
|
||||
}
|
||||
|
||||
await mermaid.registerExternalDiagrams([externalExample, zenUml, flowchartELK]);
|
||||
// await mermaid.registerExternalDiagrams([externalExample, zenUml, flowchartELK]);
|
||||
await mermaid.registerExternalDiagrams([externalExample, zenUml]);
|
||||
mermaid.initialize(graphObj.mermaid);
|
||||
await mermaid.run();
|
||||
}
|
||||
|
@@ -61,7 +61,7 @@
|
||||
]
|
||||
},
|
||||
"devDependencies": {
|
||||
"@applitools/eyes-cypress": "^3.42.3",
|
||||
"@applitools/eyes-cypress": "^3.44.4",
|
||||
"@cspell/eslint-plugin": "^8.6.0",
|
||||
"@cypress/code-coverage": "^3.12.30",
|
||||
"@rollup/plugin-typescript": "^11.1.6",
|
||||
@@ -85,7 +85,7 @@
|
||||
"cors": "^2.8.5",
|
||||
"cross-env": "^7.0.3",
|
||||
"cspell": "^8.6.0",
|
||||
"cypress": "^13.7.1",
|
||||
"cypress": "^13.11.0",
|
||||
"cypress-image-snapshot": "^4.0.1",
|
||||
"esbuild": "^0.20.2",
|
||||
"eslint": "^8.57.0",
|
||||
@@ -126,10 +126,5 @@
|
||||
},
|
||||
"nyc": {
|
||||
"report-dir": "coverage/cypress"
|
||||
},
|
||||
"pnpm": {
|
||||
"patchedDependencies": {
|
||||
"cytoscape@3.28.1": "patches/cytoscape@3.28.1.patch"
|
||||
}
|
||||
}
|
||||
}
|
@@ -2,7 +2,7 @@
|
||||
import flowParser from './parser/flow.jison';
|
||||
import flowDb from './flowDb.js';
|
||||
import flowRendererV2 from './flowRenderer-v2.js';
|
||||
import flowRendererV3 from './flowRenderer-v3-unified.js';
|
||||
// import flowRendererV3 from './flowRenderer-v3-unified.js';
|
||||
import flowStyles from './styles.js';
|
||||
import type { MermaidConfig } from '../../config.type.js';
|
||||
import { setConfig } from '../../diagram-api/diagramAPI.js';
|
||||
@@ -10,8 +10,8 @@ import { setConfig } from '../../diagram-api/diagramAPI.js';
|
||||
export const diagram = {
|
||||
parser: flowParser,
|
||||
db: flowDb,
|
||||
// renderer: flowRendererV2,
|
||||
renderer: flowRendererV3,
|
||||
renderer: flowRendererV2,
|
||||
// renderer: flowRendererV3,
|
||||
styles: flowStyles,
|
||||
init: (cnf: MermaidConfig) => {
|
||||
if (!cnf.flowchart) {
|
||||
@@ -20,7 +20,8 @@ export const diagram = {
|
||||
cnf.flowchart.arrowMarkerAbsolute = cnf.arrowMarkerAbsolute;
|
||||
// flowchart-v2 uses dagre-wrapper, which doesn't have access to flowchart cnf
|
||||
setConfig({ flowchart: { arrowMarkerAbsolute: cnf.arrowMarkerAbsolute } });
|
||||
flowRendererV3.setConf(cnf.flowchart);
|
||||
flowRendererV2.setConf(cnf.flowchart);
|
||||
// flowRendererV3.setConf(cnf.flowchart);
|
||||
flowDb.clear();
|
||||
flowDb.setGen('gen-2');
|
||||
},
|
||||
|
@@ -324,7 +324,7 @@ export const dataFetcher = (parent, parsedItem, diagramStates, nodes, edges, alt
|
||||
domId: stateDomId(itemId, graphItemCount, NOTE),
|
||||
type: newNode.type,
|
||||
isGroup: newNode.type === 'group',
|
||||
padding: 0, //getConfig().flowchart.padding
|
||||
padding: getConfig().flowchart.padding,
|
||||
look,
|
||||
position: parsedItem.note.position,
|
||||
};
|
||||
|
@@ -133,6 +133,7 @@ g.stateGroup line {
|
||||
|
||||
.cluster-label, .nodeLabel {
|
||||
color: ${options.stateLabelColor};
|
||||
// line-height: 1;
|
||||
}
|
||||
|
||||
.statediagram-cluster rect.outer {
|
||||
|
@@ -183,7 +183,7 @@ const recursiveRender = async (_elem, graph, diagramType, id, parentCluster, sit
|
||||
const halfPadding = node?.padding / 2 || 0;
|
||||
const labelHeight = node?.labelBBox?.height || 0;
|
||||
const offsetY = labelHeight - halfPadding || 0;
|
||||
node.y += offsetY + (parent?.offsetY / 2 || 0);
|
||||
// node.y += offsetY + (parent?.offsetY / 2 || 0);
|
||||
// node.offsetY = offsetY;
|
||||
insertCluster(clusters, node);
|
||||
|
||||
@@ -244,7 +244,7 @@ const recursiveRender = async (_elem, graph, diagramType, id, parentCluster, sit
|
||||
diff = n.diff;
|
||||
}
|
||||
});
|
||||
log.trace('Returning from recursive render XAX', elem, diff);
|
||||
log.warn('Returning from recursive render XAX', elem, diff);
|
||||
return { elem, diff };
|
||||
};
|
||||
/**
|
||||
|
@@ -177,7 +177,13 @@ const roundedWithTitle = (parent, node) => {
|
||||
themeVariables;
|
||||
|
||||
// Add outer g element
|
||||
const shapeSvg = parent.insert('g').attr('class', node.cssClasses).attr('id', node.id);
|
||||
const shapeSvg = parent
|
||||
.insert('g')
|
||||
.attr('class', node.cssClasses)
|
||||
.attr('id', node.id)
|
||||
.attr('data-et', 'node')
|
||||
.attr('data-node', 'true')
|
||||
.attr('data-id', node.id);
|
||||
|
||||
// add the rect
|
||||
const outerRectG = shapeSvg.insert('g', ':first-child');
|
||||
@@ -190,6 +196,7 @@ const roundedWithTitle = (parent, node) => {
|
||||
|
||||
// Get the size of the label
|
||||
let bbox = text.getBBox();
|
||||
|
||||
if (evaluate(siteConfig.flowchart.htmlLabels)) {
|
||||
const div = text.children[0];
|
||||
const dv = select(text);
|
||||
@@ -197,6 +204,7 @@ const roundedWithTitle = (parent, node) => {
|
||||
dv.attr('width', bbox.width);
|
||||
dv.attr('height', bbox.height);
|
||||
}
|
||||
|
||||
const padding = 0 * node.padding;
|
||||
const halfPadding = padding / 2;
|
||||
|
||||
@@ -216,9 +224,10 @@ const roundedWithTitle = (parent, node) => {
|
||||
// }
|
||||
const x = node.x - width / 2 - halfPadding;
|
||||
const y = node.y - node.height / 2 - halfPadding;
|
||||
const innerY = node.y - node.height / 2 - halfPadding + bbox.height - 1;
|
||||
const innerY = node.y - node.height / 2 - halfPadding + bbox.height + 2;
|
||||
const height = node.height + padding;
|
||||
const innerHeight = node.height + padding - bbox.height - 3;
|
||||
const innerHeight = node.height + padding - bbox.height - 6;
|
||||
const look = siteConfig.look;
|
||||
|
||||
// add the rect
|
||||
let rect;
|
||||
@@ -248,9 +257,16 @@ const roundedWithTitle = (parent, node) => {
|
||||
innerRect = shapeSvg.insert(() => roughInnerNode);
|
||||
} else {
|
||||
rect = outerRectG.insert('rect', ':first-child');
|
||||
let outerRectClass = 'outer';
|
||||
if (look === 'neo') {
|
||||
outerRectClass = 'outer state-shadow-neo';
|
||||
} else {
|
||||
outerRectClass = 'outer';
|
||||
}
|
||||
|
||||
// center the rect around its coordinate
|
||||
rect
|
||||
.attr('class', 'outer')
|
||||
.attr('class', outerRectClass)
|
||||
.attr('x', x)
|
||||
.attr('y', y)
|
||||
.attr('width', width)
|
||||
@@ -263,16 +279,9 @@ const roundedWithTitle = (parent, node) => {
|
||||
.attr('height', innerHeight);
|
||||
}
|
||||
|
||||
// Center the label
|
||||
label.attr(
|
||||
'transform',
|
||||
`translate(${node.x - bbox.width / 2}, ${
|
||||
node.y -
|
||||
node.height / 2 -
|
||||
node.padding +
|
||||
bbox.height / 2 -
|
||||
(evaluate(siteConfig.flowchart.htmlLabels) ? 5 : 3)
|
||||
})`
|
||||
`translate(${node.x - bbox.width / 2}, ${y + 1 - (evaluate(siteConfig.flowchart.htmlLabels) ? 0 : 3)})`
|
||||
);
|
||||
|
||||
const rectBox = rect.node().getBBox();
|
||||
|
@@ -103,6 +103,7 @@ export const clear = () => {
|
||||
};
|
||||
|
||||
export const positionNode = (node) => {
|
||||
console.log('Position node', node, node.diff);
|
||||
const el = nodeElems[node.id];
|
||||
|
||||
log.trace(
|
||||
@@ -111,8 +112,8 @@ export const positionNode = (node) => {
|
||||
node,
|
||||
'translate(' + (node.x - node.width / 2 - 5) + ', ' + node.width / 2 + ')'
|
||||
);
|
||||
|
||||
const diff = 0;
|
||||
// Handling of the case where teh label grows the cluster
|
||||
const diff = node.diff || 0;
|
||||
if (node.clusterNode) {
|
||||
el.attr(
|
||||
'transform',
|
||||
|
@@ -5,8 +5,12 @@ import type { Node, RectOptions } from '$root/rendering-util/types.d.ts';
|
||||
import { createRoundedRectPathD } from './roundedRectPath.js';
|
||||
import { userNodeOverrides } from '$root/rendering-util/rendering-elements/shapes/handdrawnStyles.js';
|
||||
import rough from 'roughjs';
|
||||
import { getConfig } from '$root/diagram-api/diagramAPI.js';
|
||||
|
||||
export const drawRect = async (parent: SVGAElement, node: Node, options: RectOptions) => {
|
||||
const { themeVariables, handdrawnSeed, look } = getConfig();
|
||||
const { nodeBorder, mainBkg } = themeVariables;
|
||||
|
||||
const { shapeSvg, bbox, halfPadding } = await labelHelper(
|
||||
parent,
|
||||
node,
|
||||
@@ -14,12 +18,13 @@ export const drawRect = async (parent: SVGAElement, node: Node, options: RectOpt
|
||||
true
|
||||
);
|
||||
|
||||
const totalWidth = bbox.width + node.padding;
|
||||
const totalHeight = bbox.height + node.padding;
|
||||
const x = -bbox.width / 2 - halfPadding;
|
||||
const y = -bbox.height / 2 - halfPadding;
|
||||
const totalWidth = Math.max(bbox.width + options.labelPaddingX * 2, node?.width || 0);
|
||||
const totalHeight = Math.max(bbox.height + options.labelPaddingY * 2, node?.height || 0);
|
||||
const x = -totalWidth / 2;
|
||||
const y = -totalHeight / 2;
|
||||
|
||||
let rect;
|
||||
node.look = look;
|
||||
let { rx, ry } = node;
|
||||
const { cssStyles } = node;
|
||||
|
||||
|
@@ -25,8 +25,8 @@ export const note = async (parent: SVGAElement, node: Node) => {
|
||||
let rect;
|
||||
const totalWidth = bbox.width + node.padding;
|
||||
const totalHeight = bbox.height + node.padding;
|
||||
const x = -bbox.width / 2 - halfPadding;
|
||||
const y = -bbox.height / 2 - halfPadding;
|
||||
const x = -totalWidth / 2;
|
||||
const y = -totalHeight / 2;
|
||||
|
||||
if (node.look === 'handdrawn') {
|
||||
// add the rect
|
||||
|
@@ -6,6 +6,8 @@ export const roundedRect = async (parent: SVGAElement, node: Node) => {
|
||||
rx: 5,
|
||||
ry: 5,
|
||||
classes: '',
|
||||
labelPaddingX: (node?.padding || 0) * 1,
|
||||
labelPaddingY: (node?.padding || 0) * 1,
|
||||
} as RectOptions;
|
||||
|
||||
return drawRect(parent, node, options);
|
||||
|
@@ -6,6 +6,8 @@ export const squareRect = async (parent: SVGAElement, node: Node) => {
|
||||
rx: 0,
|
||||
ry: 0,
|
||||
classes: '',
|
||||
labelPaddingX: (node?.padding || 0) * 2,
|
||||
labelPaddingY: (node?.padding || 0) * 1,
|
||||
} as RectOptions;
|
||||
return drawRect(parent, node, options);
|
||||
};
|
||||
|
@@ -99,6 +99,8 @@ interface Edge {
|
||||
interface RectOptions {
|
||||
rx: number;
|
||||
ry: number;
|
||||
labelPaddingX: number;
|
||||
labelPaddingY: number;
|
||||
classes: string;
|
||||
}
|
||||
|
||||
|
@@ -34,7 +34,7 @@ class Theme {
|
||||
this.arrowheadColor = '#333333';
|
||||
this.fontFamily = '"trebuchet ms", verdana, arial, sans-serif';
|
||||
this.fontSize = '16px';
|
||||
this.labelBackground = 'rgba(232,232,232,0.6)';
|
||||
this.labelBackground = 'rgba(232,232,232,0.8)';
|
||||
this.textColor = '#333';
|
||||
this.THEME_COLOR_LIMIT = 12;
|
||||
|
||||
|
21867
pnpm-lock.yaml
generated
21867
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user