mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-10-23 16:04:12 +02:00
Compare commits
2 Commits
renovate/m
...
fix-flowch
Author | SHA1 | Date | |
---|---|---|---|
![]() |
015af7603e | ||
![]() |
c810fab231 |
@@ -1,5 +0,0 @@
|
|||||||
---
|
|
||||||
'mermaid': patch
|
|
||||||
---
|
|
||||||
|
|
||||||
fix: Correct viewBox casing and make SVGs responsive
|
|
5
.changeset/eager-pigs-help.md
Normal file
5
.changeset/eager-pigs-help.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'mermaid': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: Handle backslash parsing in math formulas within new flowchart shape syntax
|
@@ -99,7 +99,6 @@ export const openURLAndVerifyRendering = (
|
|||||||
cy.visit(url);
|
cy.visit(url);
|
||||||
cy.window().should('have.property', 'rendered', true);
|
cy.window().should('have.property', 'rendered', true);
|
||||||
cy.get('svg').should('be.visible');
|
cy.get('svg').should('be.visible');
|
||||||
cy.get('svg').should('not.have.attr', 'viewbox');
|
|
||||||
|
|
||||||
if (validation) {
|
if (validation) {
|
||||||
cy.get('svg').should(validation);
|
cy.get('svg').should(validation);
|
||||||
|
10
package.json
10
package.json
@@ -67,7 +67,7 @@
|
|||||||
"@argos-ci/cypress": "^6.1.3",
|
"@argos-ci/cypress": "^6.1.3",
|
||||||
"@changesets/changelog-github": "^0.5.1",
|
"@changesets/changelog-github": "^0.5.1",
|
||||||
"@changesets/cli": "^2.29.7",
|
"@changesets/cli": "^2.29.7",
|
||||||
"@cspell/eslint-plugin": "^9.2.2",
|
"@cspell/eslint-plugin": "^8.19.4",
|
||||||
"@cypress/code-coverage": "^3.14.6",
|
"@cypress/code-coverage": "^3.14.6",
|
||||||
"@eslint/js": "^9.26.0",
|
"@eslint/js": "^9.26.0",
|
||||||
"@rollup/plugin-typescript": "^12.1.4",
|
"@rollup/plugin-typescript": "^12.1.4",
|
||||||
@@ -95,16 +95,16 @@
|
|||||||
"esbuild": "^0.25.10",
|
"esbuild": "^0.25.10",
|
||||||
"eslint": "^9.26.0",
|
"eslint": "^9.26.0",
|
||||||
"eslint-config-prettier": "^10.1.8",
|
"eslint-config-prettier": "^10.1.8",
|
||||||
"eslint-plugin-cypress": "^5.2.0",
|
"eslint-plugin-cypress": "^4.3.0",
|
||||||
"eslint-plugin-html": "^8.1.3",
|
"eslint-plugin-html": "^8.1.3",
|
||||||
"eslint-plugin-jest": "^29.0.1",
|
"eslint-plugin-jest": "^28.14.0",
|
||||||
"eslint-plugin-jsdoc": "^61.1.5",
|
"eslint-plugin-jsdoc": "^50.8.0",
|
||||||
"eslint-plugin-json": "^4.0.1",
|
"eslint-plugin-json": "^4.0.1",
|
||||||
"eslint-plugin-lodash": "^8.0.0",
|
"eslint-plugin-lodash": "^8.0.0",
|
||||||
"eslint-plugin-markdown": "^5.1.0",
|
"eslint-plugin-markdown": "^5.1.0",
|
||||||
"eslint-plugin-no-only-tests": "^3.3.0",
|
"eslint-plugin-no-only-tests": "^3.3.0",
|
||||||
"eslint-plugin-tsdoc": "^0.4.0",
|
"eslint-plugin-tsdoc": "^0.4.0",
|
||||||
"eslint-plugin-unicorn": "^61.0.2",
|
"eslint-plugin-unicorn": "^59.0.1",
|
||||||
"express": "^5.1.0",
|
"express": "^5.1.0",
|
||||||
"globals": "^16.4.0",
|
"globals": "^16.4.0",
|
||||||
"globby": "^14.1.0",
|
"globby": "^14.1.0",
|
||||||
|
@@ -144,6 +144,16 @@ describe('when parsing directions', function () {
|
|||||||
expect(data4Layout.nodes[0].shape).toEqual('rounded');
|
expect(data4Layout.nodes[0].shape).toEqual('rounded');
|
||||||
expect(data4Layout.nodes[0].label).toEqual('DD');
|
expect(data4Layout.nodes[0].label).toEqual('DD');
|
||||||
});
|
});
|
||||||
|
it('should handle mathematical formulas with backslashes in quoted strings', function () {
|
||||||
|
const res = flow.parser.parse(`flowchart TB
|
||||||
|
A@{ shape: rect, label: "$$\\sin x$$"}`);
|
||||||
|
|
||||||
|
const data4Layout = flow.parser.yy.getData();
|
||||||
|
|
||||||
|
expect(data4Layout.nodes.length).toBe(1);
|
||||||
|
expect(data4Layout.nodes[0].shape).toEqual('rect');
|
||||||
|
expect(data4Layout.nodes[0].label).toEqual('$$\\sin x$$');
|
||||||
|
});
|
||||||
it('should be possible to link to a node with more data', function () {
|
it('should be possible to link to a node with more data', function () {
|
||||||
const res = flow.parser.parse(`flowchart TB
|
const res = flow.parser.parse(`flowchart TB
|
||||||
A --> D@{
|
A --> D@{
|
||||||
|
@@ -53,6 +53,7 @@ accDescr\s*"{"\s* { this.begin("acc_descr_multilin
|
|||||||
// console.log('shapeData', yytext);
|
// console.log('shapeData', yytext);
|
||||||
const re = /\n\s*/g;
|
const re = /\n\s*/g;
|
||||||
yytext = yytext.replace(re,"<br/>");
|
yytext = yytext.replace(re,"<br/>");
|
||||||
|
yytext = yytext.replace(/\\/g, "\\\\");
|
||||||
return 'SHAPE_DATA'}
|
return 'SHAPE_DATA'}
|
||||||
<shapeData>[^}^"]+ {
|
<shapeData>[^}^"]+ {
|
||||||
// console.log('shapeData', yytext);
|
// console.log('shapeData', yytext);
|
||||||
|
@@ -16,7 +16,7 @@ const draw: DrawDefinition = (_text, id, _version, diagram: Diagram) => {
|
|||||||
const svgWidth = bitWidth * bitsPerRow + 2;
|
const svgWidth = bitWidth * bitsPerRow + 2;
|
||||||
const svg: SVG = selectSvgElement(id);
|
const svg: SVG = selectSvgElement(id);
|
||||||
|
|
||||||
svg.attr('viewBox', `0 0 ${svgWidth} ${svgHeight}`);
|
svg.attr('viewbox', `0 0 ${svgWidth} ${svgHeight}`);
|
||||||
configureSvgSize(svg, svgHeight, svgWidth, config.useMaxWidth);
|
configureSvgSize(svg, svgHeight, svgWidth, config.useMaxWidth);
|
||||||
|
|
||||||
for (const [word, packet] of words.entries()) {
|
for (const [word, packet] of words.entries()) {
|
||||||
|
@@ -2,7 +2,6 @@ import type { Diagram } from '../../Diagram.js';
|
|||||||
import type { RadarDiagramConfig } from '../../config.type.js';
|
import type { RadarDiagramConfig } from '../../config.type.js';
|
||||||
import type { DiagramRenderer, DrawDefinition, SVG, SVGGroup } from '../../diagram-api/types.js';
|
import type { DiagramRenderer, DrawDefinition, SVG, SVGGroup } from '../../diagram-api/types.js';
|
||||||
import { selectSvgElement } from '../../rendering-util/selectSvgElement.js';
|
import { selectSvgElement } from '../../rendering-util/selectSvgElement.js';
|
||||||
import { configureSvgSize } from '../../setupGraphViewbox.js';
|
|
||||||
import type { RadarDB, RadarAxis, RadarCurve } from './types.js';
|
import type { RadarDB, RadarAxis, RadarCurve } from './types.js';
|
||||||
|
|
||||||
const draw: DrawDefinition = (_text, id, _version, diagram: Diagram) => {
|
const draw: DrawDefinition = (_text, id, _version, diagram: Diagram) => {
|
||||||
@@ -54,9 +53,11 @@ const drawFrame = (svg: SVG, config: Required<RadarDiagramConfig>): SVGGroup =>
|
|||||||
x: config.marginLeft + config.width / 2,
|
x: config.marginLeft + config.width / 2,
|
||||||
y: config.marginTop + config.height / 2,
|
y: config.marginTop + config.height / 2,
|
||||||
};
|
};
|
||||||
configureSvgSize(svg, totalHeight, totalWidth, config.useMaxWidth ?? true);
|
// Initialize the SVG
|
||||||
|
svg
|
||||||
svg.attr('viewBox', `0 0 ${totalWidth} ${totalHeight}`);
|
.attr('viewbox', `0 0 ${totalWidth} ${totalHeight}`)
|
||||||
|
.attr('width', totalWidth)
|
||||||
|
.attr('height', totalHeight);
|
||||||
// g element to center the radar chart
|
// g element to center the radar chart
|
||||||
return svg.append('g').attr('transform', `translate(${center.x}, ${center.y})`);
|
return svg.append('g').attr('transform', `translate(${center.x}, ${center.y})`);
|
||||||
};
|
};
|
||||||
|
613
pnpm-lock.yaml
generated
613
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user