mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-01-28 07:03:17 +08:00
#2732 Regression fixes for accessibility
This commit is contained in:
parent
da548f1970
commit
65143a0182
@ -298,8 +298,8 @@ describe('Gantt diagram', () => {
|
|||||||
renderGraph(
|
renderGraph(
|
||||||
`
|
`
|
||||||
gantt
|
gantt
|
||||||
title ${expectedTitle}
|
accTitle: ${expectedTitle}
|
||||||
accDescription ${expectedAccDescription}
|
accDescr: ${expectedAccDescription}
|
||||||
dateFormat YYYY-MM-DD
|
dateFormat YYYY-MM-DD
|
||||||
section Section
|
section Section
|
||||||
A task :a1, 2014-01-01, 30d
|
A task :a1, 2014-01-01, 30d
|
||||||
|
@ -53,8 +53,8 @@ describe('Requirement diagram', () => {
|
|||||||
renderGraph(
|
renderGraph(
|
||||||
`
|
`
|
||||||
requirementDiagram
|
requirementDiagram
|
||||||
title ${expectedTitle}
|
accTitle: ${expectedTitle}
|
||||||
accDescription ${expectedAccDescription}
|
accDescr: ${expectedAccDescription}
|
||||||
|
|
||||||
requirement test_req {
|
requirement test_req {
|
||||||
id: 1
|
id: 1
|
||||||
|
@ -658,7 +658,7 @@ context('Sequence diagram', () => {
|
|||||||
expect(svg).to.have.attr('width', '100%');
|
expect(svg).to.have.attr('width', '100%');
|
||||||
expect(svg).to.have.attr('height');
|
expect(svg).to.have.attr('height');
|
||||||
const height = parseFloat(svg.attr('height'));
|
const height = parseFloat(svg.attr('height'));
|
||||||
expect(height).to.be.within(920, 960);
|
expect(height).to.be.within(920, 971);
|
||||||
const style = svg.attr('style');
|
const style = svg.attr('style');
|
||||||
expect(style).to.match(/^max-width: [\d.]+px;$/);
|
expect(style).to.match(/^max-width: [\d.]+px;$/);
|
||||||
const maxWidthValue = parseFloat(style.match(/[\d.]+/g).join(''));
|
const maxWidthValue = parseFloat(style.match(/[\d.]+/g).join(''));
|
||||||
@ -697,7 +697,7 @@ context('Sequence diagram', () => {
|
|||||||
cy.get('svg').should((svg) => {
|
cy.get('svg').should((svg) => {
|
||||||
const height = parseFloat(svg.attr('height'));
|
const height = parseFloat(svg.attr('height'));
|
||||||
const width = parseFloat(svg.attr('width'));
|
const width = parseFloat(svg.attr('width'));
|
||||||
expect(height).to.be.within(920, 960);
|
expect(height).to.be.within(920, 971);
|
||||||
// use within because the absolute value can be slightly different depending on the environment ±5%
|
// use within because the absolute value can be slightly different depending on the environment ±5%
|
||||||
expect(width).to.be.within(820 * 0.95, 820 * 1.05);
|
expect(width).to.be.within(820 * 0.95, 820 * 1.05);
|
||||||
expect(svg).to.not.have.attr('style');
|
expect(svg).to.not.have.attr('style');
|
||||||
|
@ -36,6 +36,8 @@ describe('Pie Chart', () => {
|
|||||||
imgSnapshotTest(
|
imgSnapshotTest(
|
||||||
`
|
`
|
||||||
pie title Sports in Sweden
|
pie title Sports in Sweden
|
||||||
|
accTitle: This is a title
|
||||||
|
accDescr: This is a description
|
||||||
"Bandy" : 40
|
"Bandy" : 40
|
||||||
"Ice-Hockey" : 80
|
"Ice-Hockey" : 80
|
||||||
"Football" : 90
|
"Football" : 90
|
||||||
@ -49,6 +51,8 @@ describe('Pie Chart', () => {
|
|||||||
`
|
`
|
||||||
%%{init: { 'logLevel': 0} }%%
|
%%{init: { 'logLevel': 0} }%%
|
||||||
graph TD
|
graph TD
|
||||||
|
accTitle: This is a title
|
||||||
|
accDescr: This is a description
|
||||||
A[Christmas] -->|Get money| B(Go shopping)
|
A[Christmas] -->|Get money| B(Go shopping)
|
||||||
B --> C{Let me think}
|
B --> C{Let me think}
|
||||||
B --> G[/Another/]
|
B --> G[/Another/]
|
||||||
@ -72,6 +76,9 @@ describe('Pie Chart', () => {
|
|||||||
`
|
`
|
||||||
%%{init: { 'logLevel': 0, 'theme': '${theme}'} }%%
|
%%{init: { 'logLevel': 0, 'theme': '${theme}'} }%%
|
||||||
flowchart TD
|
flowchart TD
|
||||||
|
accTitle: This is a title
|
||||||
|
accDescr: This is a description
|
||||||
|
|
||||||
A[Christmas] -->|Get money| B(Go shopping)
|
A[Christmas] -->|Get money| B(Go shopping)
|
||||||
B --> C{Let me think}
|
B --> C{Let me think}
|
||||||
B --> G[Another]
|
B --> G[Another]
|
||||||
@ -95,6 +102,9 @@ describe('Pie Chart', () => {
|
|||||||
`
|
`
|
||||||
%%{init: { 'logLevel': 0, 'theme': '${theme}'} }%%
|
%%{init: { 'logLevel': 0, 'theme': '${theme}'} }%%
|
||||||
sequenceDiagram
|
sequenceDiagram
|
||||||
|
accTitle: This is a title
|
||||||
|
accDescr: This is a description
|
||||||
|
|
||||||
autonumber
|
autonumber
|
||||||
par Action 1
|
par Action 1
|
||||||
Alice->>John: Hello John, how are you?
|
Alice->>John: Hello John, how are you?
|
||||||
@ -122,6 +132,9 @@ describe('Pie Chart', () => {
|
|||||||
`
|
`
|
||||||
%%{init: { 'logLevel': 0, 'theme': '${theme}'} }%%
|
%%{init: { 'logLevel': 0, 'theme': '${theme}'} }%%
|
||||||
classDiagram
|
classDiagram
|
||||||
|
accTitle: This is a title
|
||||||
|
accDescr: This is a description
|
||||||
|
|
||||||
Animal "*" <|-- "1" Duck
|
Animal "*" <|-- "1" Duck
|
||||||
Animal "1" <|-- "10" Fish
|
Animal "1" <|-- "10" Fish
|
||||||
Animal <|-- Zebra
|
Animal <|-- Zebra
|
||||||
@ -168,6 +181,9 @@ describe('Pie Chart', () => {
|
|||||||
`
|
`
|
||||||
%%{init: { 'logLevel': 0, 'theme': '${theme}'} }%%
|
%%{init: { 'logLevel': 0, 'theme': '${theme}'} }%%
|
||||||
stateDiagram
|
stateDiagram
|
||||||
|
accTitle: This is a title
|
||||||
|
accDescr: This is a description
|
||||||
|
|
||||||
[*] --> Active
|
[*] --> Active
|
||||||
|
|
||||||
state Active {
|
state Active {
|
||||||
@ -200,6 +216,9 @@ stateDiagram
|
|||||||
`
|
`
|
||||||
%%{init: { 'logLevel': 0, 'theme': '${theme}'} }%%
|
%%{init: { 'logLevel': 0, 'theme': '${theme}'} }%%
|
||||||
stateDiagram-v2
|
stateDiagram-v2
|
||||||
|
accTitle: This is a title
|
||||||
|
accDescr: This is a description
|
||||||
|
|
||||||
[*] --> Active
|
[*] --> Active
|
||||||
|
|
||||||
state Active {
|
state Active {
|
||||||
@ -231,6 +250,9 @@ stateDiagram-v2
|
|||||||
imgSnapshotTest(
|
imgSnapshotTest(
|
||||||
`
|
`
|
||||||
erDiagram
|
erDiagram
|
||||||
|
accTitle: This is a title
|
||||||
|
accDescr: This is a description
|
||||||
|
|
||||||
CUSTOMER }|..|{ DELIVERY-ADDRESS : has
|
CUSTOMER }|..|{ DELIVERY-ADDRESS : has
|
||||||
CUSTOMER ||--o{ ORDER : places
|
CUSTOMER ||--o{ ORDER : places
|
||||||
CUSTOMER ||--o{ INVOICE : "liable for"
|
CUSTOMER ||--o{ INVOICE : "liable for"
|
||||||
@ -250,6 +272,9 @@ erDiagram
|
|||||||
`
|
`
|
||||||
%%{init: { 'logLevel': 0, 'theme': '${theme}'} }%%
|
%%{init: { 'logLevel': 0, 'theme': '${theme}'} }%%
|
||||||
journey
|
journey
|
||||||
|
accTitle: This is a title
|
||||||
|
accDescr: This is a description
|
||||||
|
|
||||||
title My working day
|
title My working day
|
||||||
section Go to work
|
section Go to work
|
||||||
Make tea: 5: Me
|
Make tea: 5: Me
|
||||||
@ -268,6 +293,9 @@ erDiagram
|
|||||||
imgSnapshotTest(
|
imgSnapshotTest(
|
||||||
`
|
`
|
||||||
gantt
|
gantt
|
||||||
|
accTitle: This is a title
|
||||||
|
accDescr: This is a description
|
||||||
|
|
||||||
dateFormat :YYYY-MM-DD
|
dateFormat :YYYY-MM-DD
|
||||||
title :Adding GANTT diagram functionality to mermaid
|
title :Adding GANTT diagram functionality to mermaid
|
||||||
excludes :excludes the named dates/days from being included in a charted task..
|
excludes :excludes the named dates/days from being included in a charted task..
|
||||||
|
@ -34,8 +34,8 @@
|
|||||||
"git0": "#550055"
|
"git0": "#550055"
|
||||||
} } }%%
|
} } }%%
|
||||||
gitGraph
|
gitGraph
|
||||||
accTitle: "Git Graph"
|
accTitle: "Git Graph"
|
||||||
accDescr {
|
accDescr {
|
||||||
Git Graph description.
|
Git Graph description.
|
||||||
Multiline description
|
Multiline description
|
||||||
}
|
}
|
||||||
|
@ -31,23 +31,24 @@
|
|||||||
|
|
||||||
|
|
||||||
<div class="mermaid" style="width: 50%;">
|
<div class="mermaid" style="width: 50%;">
|
||||||
graph LR
|
sequenceDiagram
|
||||||
subgraph id1 [title is set]
|
accTitle: This is a title
|
||||||
A-->B
|
accDescr: This is a description
|
||||||
end
|
|
||||||
subgraph id2 [title]
|
|
||||||
E
|
|
||||||
end
|
|
||||||
|
|
||||||
B-->C
|
autonumber
|
||||||
|
par Action 1
|
||||||
subgraph id3
|
Alice->>John: Hello John, how are you?
|
||||||
C-->D
|
and Action 2
|
||||||
end
|
Alice->>Bob: Hello Bob, how are you?
|
||||||
class id3,id2,A redBg;
|
end
|
||||||
class id3,A whiteTxt;
|
Alice->>+John: Hello John, how are you?
|
||||||
classDef redBg fill:#622;
|
Alice->>+John: John, can you hear me?
|
||||||
classDef whiteTxt color: white;
|
John-->>-Alice: Hi Alice, I can hear you!
|
||||||
|
Note right of John: John is perceptive
|
||||||
|
John-->>-Alice: I feel great!
|
||||||
|
loop Every minute
|
||||||
|
John-->Alice: Great!
|
||||||
|
end
|
||||||
</div>
|
</div>
|
||||||
<div class="mermaid2" style="width: 100%;">
|
<div class="mermaid2" style="width: 100%;">
|
||||||
journey
|
journey
|
||||||
|
@ -69,7 +69,7 @@ line
|
|||||||
statement
|
statement
|
||||||
:
|
:
|
||||||
| txt value { yy.addSection($1,yy.cleanupValue($2)); }
|
| txt value { yy.addSection($1,yy.cleanupValue($2)); }
|
||||||
| title title_value { $$=$2.trim();yy.setTitle($$); }
|
| title title_value { $$=$2.trim();yy.setPieTitle($$); }
|
||||||
| acc_title acc_title_value { $$=$2.trim();yy.setTitle($$); }
|
| acc_title acc_title_value { $$=$2.trim();yy.setTitle($$); }
|
||||||
| acc_descr acc_descr_value { $$=$2.trim();yy.setAccDescription($$); }
|
| acc_descr acc_descr_value { $$=$2.trim();yy.setAccDescription($$); }
|
||||||
| acc_descr_multiline_value { $$=$1.trim();yy.setAccDescription($$); } | section {yy.addSection($1.substr(8));$$=$1.substr(8);}
|
| acc_descr_multiline_value { $$=$1.trim();yy.setAccDescription($$); } | section {yy.addSection($1.substr(8));$$=$1.substr(8);}
|
||||||
|
@ -52,6 +52,15 @@ const clear = function () {
|
|||||||
commonClear();
|
commonClear();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const setPieTitle = function (txt) {
|
||||||
|
let sanitizedText = common.sanitizeText(txt, configApi.getConfig());
|
||||||
|
title = sanitizedText;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getPieTitle = function () {
|
||||||
|
return title;
|
||||||
|
};
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
parseDirective,
|
parseDirective,
|
||||||
getConfig: () => configApi.getConfig().pie,
|
getConfig: () => configApi.getConfig().pie,
|
||||||
@ -61,6 +70,8 @@ export default {
|
|||||||
clear,
|
clear,
|
||||||
setTitle,
|
setTitle,
|
||||||
getTitle,
|
getTitle,
|
||||||
|
setPieTitle,
|
||||||
|
getPieTitle,
|
||||||
setShowData,
|
setShowData,
|
||||||
getShowData,
|
getShowData,
|
||||||
getAccDescription,
|
getAccDescription,
|
||||||
|
@ -136,7 +136,7 @@ export const draw = (txt, id) => {
|
|||||||
|
|
||||||
svg
|
svg
|
||||||
.append('text')
|
.append('text')
|
||||||
.text(parser.yy.getTitle())
|
.text(parser.yy.getPieTitle())
|
||||||
.attr('x', 0)
|
.attr('x', 0)
|
||||||
.attr('y', -(height - 50) / 2)
|
.attr('y', -(height - 50) / 2)
|
||||||
.attr('class', 'pieTitleText');
|
.attr('class', 'pieTitleText');
|
||||||
|
@ -136,8 +136,8 @@ statement
|
|||||||
| link_statement 'NEWLINE'
|
| link_statement 'NEWLINE'
|
||||||
| properties_statement 'NEWLINE'
|
| properties_statement 'NEWLINE'
|
||||||
| details_statement 'NEWLINE'
|
| details_statement 'NEWLINE'
|
||||||
| title {yy.setTitle($1.substring(6));$$=$1.substring(6);}
|
| title {yy.setDiagramTitle($1.substring(6));$$=$1.substring(6);}
|
||||||
| legacy_title {yy.setTitle($1.substring(7));$$=$1.substring(7);}
|
| legacy_title {yy.setDiagramTitle($1.substring(7));$$=$1.substring(7);}
|
||||||
| acc_title acc_title_value { $$=$2.trim();yy.setTitle($$); }
|
| acc_title acc_title_value { $$=$2.trim();yy.setTitle($$); }
|
||||||
| acc_descr acc_descr_value { $$=$2.trim();yy.setAccDescription($$); }
|
| acc_descr acc_descr_value { $$=$2.trim();yy.setAccDescription($$); }
|
||||||
| acc_descr_multiline_value { $$=$1.trim();yy.setAccDescription($$); }
|
| acc_descr_multiline_value { $$=$1.trim();yy.setAccDescription($$); }
|
||||||
|
@ -14,7 +14,7 @@ let prevActor = undefined;
|
|||||||
let actors = {};
|
let actors = {};
|
||||||
let messages = [];
|
let messages = [];
|
||||||
const notes = [];
|
const notes = [];
|
||||||
let title = '';
|
let diagramTitle = '';
|
||||||
let description = '';
|
let description = '';
|
||||||
let sequenceNumbersEnabled = false;
|
let sequenceNumbersEnabled = false;
|
||||||
let wrapEnabled = false;
|
let wrapEnabled = false;
|
||||||
@ -144,6 +144,7 @@ export const clear = function () {
|
|||||||
actors = {};
|
actors = {};
|
||||||
messages = [];
|
messages = [];
|
||||||
sequenceNumbersEnabled = false;
|
sequenceNumbersEnabled = false;
|
||||||
|
diagramTitle = '';
|
||||||
commonClear();
|
commonClear();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -330,6 +331,15 @@ export const getActorProperty = function (actor, key) {
|
|||||||
return undefined;
|
return undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const setDiagramTitle = function (txt) {
|
||||||
|
let sanitizedText = sanitizeText(txt, configApi.getConfig());
|
||||||
|
diagramTitle = sanitizedText;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getDiagramTitle = function () {
|
||||||
|
return diagramTitle;
|
||||||
|
};
|
||||||
|
|
||||||
export const apply = function (param) {
|
export const apply = function (param) {
|
||||||
if (param instanceof Array) {
|
if (param instanceof Array) {
|
||||||
param.forEach(function (item) {
|
param.forEach(function (item) {
|
||||||
@ -441,6 +451,7 @@ export default {
|
|||||||
getActorKeys,
|
getActorKeys,
|
||||||
getActorProperty,
|
getActorProperty,
|
||||||
getTitle,
|
getTitle,
|
||||||
|
getDiagramTitle,
|
||||||
parseDirective,
|
parseDirective,
|
||||||
getConfig: () => configApi.getConfig().sequence,
|
getConfig: () => configApi.getConfig().sequence,
|
||||||
clear,
|
clear,
|
||||||
@ -450,6 +461,7 @@ export default {
|
|||||||
PLACEMENT,
|
PLACEMENT,
|
||||||
addNote,
|
addNote,
|
||||||
setTitle,
|
setTitle,
|
||||||
|
setDiagramTitle,
|
||||||
apply,
|
apply,
|
||||||
setAccDescription,
|
setAccDescription,
|
||||||
getAccDescription,
|
getAccDescription,
|
||||||
|
@ -612,7 +612,7 @@ export const draw = function (text, id) {
|
|||||||
const actors = parser.yy.getActors();
|
const actors = parser.yy.getActors();
|
||||||
const actorKeys = parser.yy.getActorKeys();
|
const actorKeys = parser.yy.getActorKeys();
|
||||||
const messages = parser.yy.getMessages();
|
const messages = parser.yy.getMessages();
|
||||||
const title = parser.yy.getTitle();
|
const title = parser.yy.getDiagramTitle();
|
||||||
|
|
||||||
const maxMessageWidthPerActor = getMaxMessageWidthPerActor(actors, messages);
|
const maxMessageWidthPerActor = getMaxMessageWidthPerActor(actors, messages);
|
||||||
conf.height = calculateActorMargins(actors, maxMessageWidthPerActor);
|
conf.height = calculateActorMargins(actors, maxMessageWidthPerActor);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user