mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-08-15 14:29:25 +02:00
Fixes for rendering tests
This commit is contained in:
5
cypress/fixtures/example.json
Normal file
5
cypress/fixtures/example.json
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"name": "Using fixtures to represent data",
|
||||||
|
"email": "hello@cypress.io",
|
||||||
|
"body": "Fixtures are a great way to mock data for responses to routes"
|
||||||
|
}
|
@@ -42,7 +42,8 @@ export const imgSnapshotTest = (graphStr, _options, api = false, validation) =>
|
|||||||
if (!options.fontSize) {
|
if (!options.fontSize) {
|
||||||
options.fontSize = '16px';
|
options.fontSize = '16px';
|
||||||
}
|
}
|
||||||
const useAppli = Cypress.env('useAppli');
|
// const useAppli = Cypress.env('useAppli');
|
||||||
|
const useAppli = false;
|
||||||
const branch = Cypress.env('codeBranch');
|
const branch = Cypress.env('codeBranch');
|
||||||
cy.log('Hello ' + useAppli ? 'Appli' : 'image-snapshot');
|
cy.log('Hello ' + useAppli ? 'Appli' : 'image-snapshot');
|
||||||
const name = (options.name || cy.state('runnable').fullTitle()).replace(/\s+/g, '-');
|
const name = (options.name || cy.state('runnable').fullTitle()).replace(/\s+/g, '-');
|
||||||
|
@@ -80,7 +80,7 @@ context('Sequence diagram', () => {
|
|||||||
loop Loopy
|
loop Loopy
|
||||||
Bob->>Alice: Pasten
|
Bob->>Alice: Pasten
|
||||||
end `,
|
end `,
|
||||||
{}
|
{ wrap: true }
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
context('font settings', () => {
|
context('font settings', () => {
|
||||||
|
@@ -64,7 +64,7 @@ journey
|
|||||||
commit
|
commit
|
||||||
commit
|
commit
|
||||||
</div>
|
</div>
|
||||||
<div class="mermaid" style="width: 50%;">
|
<div class="mermaid2" style="width: 50%;">
|
||||||
sequenceDiagram
|
sequenceDiagram
|
||||||
title: My Sequence Diagram Title
|
title: My Sequence Diagram Title
|
||||||
accTitle: My Acc Sequence Diagram
|
accTitle: My Acc Sequence Diagram
|
||||||
@@ -218,20 +218,41 @@ class Class10 {
|
|||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
<div class="mermaid" style="width: 100%;">
|
<div class="mermaid" style="width: 100%;">
|
||||||
graph LR
|
%%{init: {'config': {'wrap': true }}}%%
|
||||||
A[[subroutine shape test]]
|
sequenceDiagram
|
||||||
A -->|Get money| B[[Go shopping]]
|
participant A as Extremely utterly long line of longness which had previously overflown the actor box as it is much longer than what it should be
|
||||||
B --> C[[Let me think...<br />Do I want something for work,<br />something to spend every free second with,<br />or something to get around?]]
|
A->>Bob: Hola
|
||||||
C -->|One| D[[Laptop]]
|
Bob-->A: Pasten !
|
||||||
C -->|Two| E[[iPhone]]
|
|
||||||
C -->|Three| F[[Car<br/>wroom wroom]]
|
|
||||||
click A "index.html#link-clicked" "link test"
|
|
||||||
click B testClick "click test"
|
|
||||||
classDef someclass fill:#f96;
|
|
||||||
class A someclass;
|
|
||||||
class C someclass;
|
|
||||||
</div>
|
</div>
|
||||||
<div class="mermaid2" style="width: 100%;">
|
<div class="mermaid2" style="width: 100%;">
|
||||||
|
gitGraph
|
||||||
|
commit id: "ZERO"
|
||||||
|
branch develop
|
||||||
|
commit id:"A"
|
||||||
|
checkout main
|
||||||
|
commit id:"ONE"
|
||||||
|
checkout develop
|
||||||
|
commit id:"B"
|
||||||
|
branch featureA
|
||||||
|
commit id:"FIX"
|
||||||
|
commit id: "FIX-2"
|
||||||
|
checkout main
|
||||||
|
commit id:"TWO"
|
||||||
|
cherry-pick id:"A"
|
||||||
|
commit id:"THREE"
|
||||||
|
cherry-pick id:"FIX"
|
||||||
|
checkout develop
|
||||||
|
commit id:"C"
|
||||||
|
merge featureA
|
||||||
|
</div>
|
||||||
|
<div class="mermaid2" style="width: 100%;">
|
||||||
|
flowchart TD
|
||||||
|
A[Christmas] -->|Get money| B(Go shopping)
|
||||||
|
B --> C{Let me think}
|
||||||
|
C -->|One| D[Laptop]
|
||||||
|
C -->|Two| E[iPhone]
|
||||||
|
C -->|Three| F[fa:fa-car Car]
|
||||||
|
</div> <div class="mermaid2" style="width: 100%;">
|
||||||
classDiagram
|
classDiagram
|
||||||
Animal "1" <|-- Duck
|
Animal "1" <|-- Duck
|
||||||
Animal <|-- Fish
|
Animal <|-- Fish
|
||||||
@@ -292,7 +313,8 @@ graph LR
|
|||||||
htmlLabels: true,
|
htmlLabels: true,
|
||||||
},
|
},
|
||||||
sequence: {
|
sequence: {
|
||||||
mirrorActors: false,
|
// mirrorActors: false,'
|
||||||
|
wrap: false,
|
||||||
},
|
},
|
||||||
// gantt: { axisFormat: '%m/%d/%Y' },
|
// gantt: { axisFormat: '%m/%d/%Y' },
|
||||||
// sequence: {
|
// sequence: {
|
||||||
@@ -315,6 +337,7 @@ graph LR
|
|||||||
curve: 'cardinal',
|
curve: 'cardinal',
|
||||||
// securityLevel: 'sandbox',
|
// securityLevel: 'sandbox',
|
||||||
// themeVariables: {relationLabelColor: 'red'}
|
// themeVariables: {relationLabelColor: 'red'}
|
||||||
|
wrap: true,
|
||||||
});
|
});
|
||||||
function callback() {
|
function callback() {
|
||||||
alert('It worked');
|
alert('It worked');
|
||||||
|
@@ -1429,15 +1429,6 @@ function _Default value: At default, will mirror Global Config_
|
|||||||
|
|
||||||
Returns **[object][5]** The siteConfig
|
Returns **[object][5]** The siteConfig
|
||||||
|
|
||||||
## parse
|
|
||||||
|
|
||||||
### Parameters
|
|
||||||
|
|
||||||
- `text`
|
|
||||||
- `dia`
|
|
||||||
|
|
||||||
Returns **any**
|
|
||||||
|
|
||||||
## getSiteConfig
|
## getSiteConfig
|
||||||
|
|
||||||
## getSiteConfig
|
## getSiteConfig
|
||||||
@@ -1480,21 +1471,6 @@ Returns **any** The currentConfig merged with the sanitized conf
|
|||||||
|
|
||||||
Returns **any** The currentConfig
|
Returns **any** The currentConfig
|
||||||
|
|
||||||
## sanitize
|
|
||||||
|
|
||||||
## sanitize
|
|
||||||
|
|
||||||
| Function | Description | Type | Values |
|
|
||||||
| -------- | -------------------------------------- | ----------- | ------ |
|
|
||||||
| sanitize | Sets the siteConfig to desired values. | Put Request | None |
|
|
||||||
|
|
||||||
Ensures options parameter does not attempt to override siteConfig secure keys **Notes**: modifies
|
|
||||||
options in-place
|
|
||||||
|
|
||||||
### Parameters
|
|
||||||
|
|
||||||
- `options` **any** The potential setConfig parameter
|
|
||||||
|
|
||||||
## render
|
## render
|
||||||
|
|
||||||
Function that renders an svg with a graph from a chart definition. Usage example below.
|
Function that renders an svg with a graph from a chart definition. Usage example below.
|
||||||
@@ -1523,6 +1499,21 @@ $(function () {
|
|||||||
|
|
||||||
Returns **any**
|
Returns **any**
|
||||||
|
|
||||||
|
## sanitize
|
||||||
|
|
||||||
|
## sanitize
|
||||||
|
|
||||||
|
| Function | Description | Type | Values |
|
||||||
|
| -------- | -------------------------------------- | ----------- | ------ |
|
||||||
|
| sanitize | Sets the siteConfig to desired values. | Put Request | None |
|
||||||
|
|
||||||
|
Ensures options parameter does not attempt to override siteConfig secure keys **Notes**: modifies
|
||||||
|
options in-place
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
- `options` **any** The potential setConfig parameter
|
||||||
|
|
||||||
## addDirective
|
## addDirective
|
||||||
|
|
||||||
Pushes in a directive to the configuration
|
Pushes in a directive to the configuration
|
||||||
@@ -1533,6 +1524,8 @@ Pushes in a directive to the configuration
|
|||||||
|
|
||||||
## reset
|
## reset
|
||||||
|
|
||||||
|
## reset
|
||||||
|
|
||||||
| Function | Description | Type | Required | Values |
|
| Function | Description | Type | Required | Values |
|
||||||
| -------- | ---------------------------- | ----------- | -------- | ------ |
|
| -------- | ---------------------------- | ----------- | -------- | ------ |
|
||||||
| reset | Resets currentConfig to conf | Put Request | Required | None |
|
| reset | Resets currentConfig to conf | Put Request | Required | None |
|
||||||
|
@@ -19,13 +19,14 @@ import gitGraphDetector from '../diagrams/git/gitGraphDetector';
|
|||||||
// mindmapRenderer,
|
// mindmapRenderer,
|
||||||
// mindmapDetector
|
// mindmapDetector
|
||||||
// );
|
// );
|
||||||
registerDiagram(
|
const addDiagrams = () => {
|
||||||
'gitGraph',
|
registerDiagram(
|
||||||
gitGraphParser,
|
'gitGraph',
|
||||||
gitGraphDb,
|
gitGraphParser,
|
||||||
gitGraphRenderer,
|
gitGraphDb,
|
||||||
undefined,
|
gitGraphRenderer,
|
||||||
gitGraphDetector
|
undefined,
|
||||||
);
|
gitGraphDetector
|
||||||
const apa = { apa: 1 };
|
);
|
||||||
export default apa;
|
};
|
||||||
|
export default addDiagrams;
|
||||||
|
@@ -79,7 +79,7 @@ const diagrams = {
|
|||||||
flowDb.setGen('gen-1');
|
flowDb.setGen('gen-1');
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
flowchartV2: {
|
'flowchart-v2': {
|
||||||
db: flowDb,
|
db: flowDb,
|
||||||
renderer: flowRendererV2,
|
renderer: flowRendererV2,
|
||||||
parser: flowParser,
|
parser: flowParser,
|
||||||
|
@@ -19,7 +19,7 @@ const notes = [];
|
|||||||
let diagramTitle = '';
|
let diagramTitle = '';
|
||||||
let description = '';
|
let description = '';
|
||||||
let sequenceNumbersEnabled = false;
|
let sequenceNumbersEnabled = false;
|
||||||
let wrapEnabled = false;
|
let wrapEnabled;
|
||||||
|
|
||||||
export const parseDirective = function (statement, context, type) {
|
export const parseDirective = function (statement, context, type) {
|
||||||
mermaidAPI.parseDirective(this, statement, context, type);
|
mermaidAPI.parseDirective(this, statement, context, type);
|
||||||
|
@@ -847,9 +847,12 @@ const _drawTextCandidateFunc = (function () {
|
|||||||
function byTspan(content, g, x, y, width, height, textAttrs, conf) {
|
function byTspan(content, g, x, y, width, height, textAttrs, conf) {
|
||||||
const { actorFontSize, actorFontFamily, actorFontWeight } = conf;
|
const { actorFontSize, actorFontFamily, actorFontWeight } = conf;
|
||||||
|
|
||||||
|
let _actorFontSize =
|
||||||
|
actorFontSize && actorFontSize.replace ? actorFontSize.replace('px', '') : actorFontSize;
|
||||||
|
|
||||||
const lines = content.split(common.lineBreakRegex);
|
const lines = content.split(common.lineBreakRegex);
|
||||||
for (let i = 0; i < lines.length; i++) {
|
for (let i = 0; i < lines.length; i++) {
|
||||||
const dy = i * actorFontSize - (actorFontSize * (lines.length - 1)) / 2;
|
const dy = i * _actorFontSize - (_actorFontSize * (lines.length - 1)) / 2;
|
||||||
const text = g
|
const text = g
|
||||||
.append('text')
|
.append('text')
|
||||||
.attr('x', x + width / 2)
|
.attr('x', x + width / 2)
|
||||||
|
@@ -19,7 +19,7 @@ import { select } from 'd3';
|
|||||||
import { compile, serialize, stringify } from 'stylis';
|
import { compile, serialize, stringify } from 'stylis';
|
||||||
import pkg from '../package.json';
|
import pkg from '../package.json';
|
||||||
import * as configApi from './config';
|
import * as configApi from './config';
|
||||||
import apa from './diagram-api/diagram-orchestration';
|
import addDiagrams from './diagram-api/diagram-orchestration';
|
||||||
import classDb from './diagrams/class/classDb';
|
import classDb from './diagrams/class/classDb';
|
||||||
import flowDb from './diagrams/flowchart/flowDb';
|
import flowDb from './diagrams/flowchart/flowDb';
|
||||||
import flowRenderer from './diagrams/flowchart/flowRenderer';
|
import flowRenderer from './diagrams/flowchart/flowRenderer';
|
||||||
@@ -515,6 +515,7 @@ function initialize(options) {
|
|||||||
|
|
||||||
updateRendererConfigs(config);
|
updateRendererConfigs(config);
|
||||||
setLogLevel(config.logLevel);
|
setLogLevel(config.logLevel);
|
||||||
|
addDiagrams();
|
||||||
}
|
}
|
||||||
|
|
||||||
const mermaidAPI = Object.freeze({
|
const mermaidAPI = Object.freeze({
|
||||||
|
Reference in New Issue
Block a user