Skip to content

Commit

Permalink
#3074 Using regular title as a fallback for the accessibility title w…
Browse files Browse the repository at this point in the history
…hen no dedicated accessibility title is present
  • Loading branch information
knsv committed May 24, 2022
1 parent 6eef26f commit b82b2d2
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 39 deletions.
6 changes: 3 additions & 3 deletions cypress/platform/knsv.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@



<div class="mermaid" style="width: 50%;">
<div class="mermaid2" style="width: 50%;">
journey
title Adding journey diagram functionality to mermaid
accTitle: Adding acc journey diagram functionality to mermaid
Expand Down Expand Up @@ -67,10 +67,10 @@
commit
commit
</div>
<div class="mermaid2" style="width: 50%;">
<div class="mermaid" style="width: 50%;">
sequenceDiagram
title: My Sequence Diagram Title
accTitle: My Sequence Diagram
accTitle: My Acc Sequence Diagram
accDescr: My Sequence Diagram Description

Alice->>John: Hello John, how are you?
Expand Down
14 changes: 13 additions & 1 deletion src/commonDb.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
import { sanitizeText as _sanitizeText } from './diagrams/common/common';
import { getConfig } from './config';
let title = '';
let diagramTitle = '';
let description = '';
const sanitizeText = (txt) => _sanitizeText(txt, getConfig());

export const clear = function () {
title = '';
description = '';
diagramTitle = '';
};

export const setAccTitle = function (txt) {
title = sanitizeText(txt).replace(/^\s+/g, '');
};

export const getAccTitle = function () {
return title;
return title || diagramTitle;
};

export const setAccDescription = function (txt) {
Expand All @@ -25,9 +27,19 @@ export const getAccDescription = function () {
return description;
};

export const setDiagramTitle = function (txt) {
diagramTitle = sanitizeText(txt);
};

export const getDiagramTitle = function () {
return diagramTitle;
};

export default {
setAccTitle,
getAccTitle,
setDiagramTitle,
getDiagramTitle: getDiagramTitle,
getAccDescription,
setAccDescription,
clear,
Expand Down
10 changes: 2 additions & 8 deletions src/diagrams/gantt/ganttDb.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import {
getAccDescription,
setAccDescription,
clear as commonClear,
setDiagramTitle,
getDiagramTitle,
} from '../../commonDb';

let dateFormat = '';
Expand Down Expand Up @@ -627,14 +629,6 @@ export const bindFunctions = function (element) {
});
};

const setDiagramTitle = function (txt) {
title = sanitizeText(txt);
};

const getDiagramTitle = function () {
return title;
};

export default {
parseDirective,
getConfig: () => configApi.getConfig().gantt,
Expand Down
11 changes: 2 additions & 9 deletions src/diagrams/pie/pieDb.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import common from '../common/common';
import {
setAccTitle,
getAccTitle,
setDiagramTitle,
getDiagramTitle,
getAccDescription,
setAccDescription,
clear as commonClear,
Expand Down Expand Up @@ -52,15 +54,6 @@ const clear = function () {
commonClear();
};

export const setDiagramTitle = function (txt) {
let sanitizedText = common.sanitizeText(txt, configApi.getConfig());
title = sanitizedText;
};

export const getDiagramTitle = function () {
return title;
};

export default {
parseDirective,
getConfig: () => configApi.getConfig().pie,
Expand Down
13 changes: 3 additions & 10 deletions src/diagrams/sequence/sequenceDb.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { sanitizeText } from '../common/common';
import {
setAccTitle,
getAccTitle,
setDiagramTitle,
getDiagramTitle,
getAccDescription,
setAccDescription,
clear as commonClear,
Expand Down Expand Up @@ -331,15 +333,6 @@ export const getActorProperty = function (actor, key) {
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) {
if (param instanceof Array) {
param.forEach(function (item) {
Expand Down Expand Up @@ -452,6 +445,7 @@ export default {
getActorProperty,
getAccTitle,
getDiagramTitle,
setDiagramTitle,
parseDirective,
getConfig: () => configApi.getConfig().sequence,
clear,
Expand All @@ -461,7 +455,6 @@ export default {
PLACEMENT,
addNote,
setAccTitle,
setDiagramTitle,
apply,
setAccDescription,
getAccDescription,
Expand Down
10 changes: 2 additions & 8 deletions src/diagrams/user-journey/journeyDb.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import common from '../common/common';
import {
setAccTitle,
getAccTitle,
setDiagramTitle,
getDiagramTitle,
getAccDescription,
setAccDescription,
clear as commonClear,
Expand Down Expand Up @@ -122,14 +124,6 @@ const getActors = function () {
return updateActors();
};

const setDiagramTitle = function (txt) {
title = sanitizeText(txt);
};

const getDiagramTitle = function () {
return title;
};

export default {
parseDirective,
getConfig: () => configApi.getConfig().journey,
Expand Down

0 comments on commit b82b2d2

Please sign in to comment.