remove a11y from individual diagrams; now happens in mermaidAPI render

This commit is contained in:
Ashley Engelund (weedySeaDragon @ github)
2022-11-17 12:28:11 -08:00
parent 29efc116f3
commit 0adc6a6112
17 changed files with 0 additions and 154 deletions

View File

@@ -310,38 +310,6 @@ describe('Gantt diagram', () => {
); );
}); });
it('should render accessibility tags', function () {
const expectedTitle = 'Gantt Diagram';
const expectedAccDescription = 'Tasks for Q4';
renderGraph(
`
gantt
accTitle: ${expectedTitle}
accDescr: ${expectedAccDescription}
dateFormat YYYY-MM-DD
section Section
A task :a1, 2014-01-01, 30d
`,
{}
);
cy.get('svg').should((svg) => {
const el = svg.get(0);
const children = Array.from(el.children);
const titleEl = children.find(function (node) {
return node.tagName === 'title';
});
const descriptionEl = children.find(function (node) {
return node.tagName === 'desc';
});
expect(titleEl).to.exist;
expect(titleEl.textContent).to.equal(expectedTitle);
expect(descriptionEl).to.exist;
expect(descriptionEl.textContent).to.equal(expectedAccDescription);
});
});
it('should render a gantt diagram with tick is 15 minutes', () => { it('should render a gantt diagram with tick is 15 minutes', () => {
imgSnapshotTest( imgSnapshotTest(
` `

View File

@@ -46,69 +46,4 @@ describe('Requirement diagram', () => {
); );
cy.get('svg'); cy.get('svg');
}); });
it('should render accessibility tags', function () {
const expectedTitle = 'Gantt Diagram';
const expectedAccDescription = 'Tasks for Q4';
renderGraph(
`
requirementDiagram
accTitle: ${expectedTitle}
accDescr: ${expectedAccDescription}
requirement test_req {
id: 1
text: the test text.
risk: high
verifymethod: test
}
functionalRequirement test_req2 {
id: 1.1
text: the second test text.
risk: low
verifymethod: inspection
}
performanceRequirement test_req3 {
id: 1.2
text: the third test text.
risk: medium
verifymethod: demonstration
}
element test_entity {
type: simulation
}
element test_entity2 {
type: word doc
docRef: reqs/test_entity
}
test_entity - satisfies -> test_req2
test_req - traces -> test_req2
test_req - contains -> test_req3
test_req <- copies - test_entity2
`,
{}
);
cy.get('svg').should((svg) => {
const el = svg.get(0);
const children = Array.from(el.children);
const titleEl = children.find(function (node) {
return node.tagName === 'title';
});
const descriptionEl = children.find(function (node) {
return node.tagName === 'desc';
});
expect(titleEl).to.exist;
expect(titleEl.textContent).to.equal(expectedTitle);
expect(descriptionEl).to.exist;
expect(descriptionEl.textContent).to.equal(expectedAccDescription);
});
});
}); });

View File

@@ -8,7 +8,6 @@ import * as configApi from '../../config';
import assignWithDepth from '../../assignWithDepth'; import assignWithDepth from '../../assignWithDepth';
import { wrapLabel, calculateTextWidth, calculateTextHeight } from '../../utils'; import { wrapLabel, calculateTextWidth, calculateTextHeight } from '../../utils';
import { configureSvgSize } from '../../setupGraphViewbox'; import { configureSvgSize } from '../../setupGraphViewbox';
import { addSVGa11yTitleDescription } from '../../accessibility';
let globalBoundaryMaxX = 0, let globalBoundaryMaxX = 0,
globalBoundaryMaxY = 0; globalBoundaryMaxY = 0;
@@ -676,7 +675,6 @@ export const draw = function (_text, id, _version, diagObj) {
(height + extraVertForTitle) (height + extraVertForTitle)
); );
addSVGa11yTitleDescription(parser.yy, diagram, id);
log.debug(`models:`, box); log.debug(`models:`, box);
}; };

View File

@@ -7,7 +7,6 @@ import { curveLinear } from 'd3';
import { interpolateToCurve, getStylesFromArray } from '../../utils'; import { interpolateToCurve, getStylesFromArray } from '../../utils';
import { setupGraphViewbox } from '../../setupGraphViewbox'; import { setupGraphViewbox } from '../../setupGraphViewbox';
import common from '../common/common'; import common from '../common/common';
import { addSVGa11yTitleDescription } from '../../accessibility';
let idCache = {}; let idCache = {};
@@ -452,7 +451,6 @@ export const draw = function (text, id, _version, diagObj) {
} }
} }
addSVGa11yTitleDescription(diagObj.db, svg, id);
// If node has a link, wrap it in an anchor SVG object. // If node has a link, wrap it in an anchor SVG object.
// const keys = Object.keys(classes); // const keys = Object.keys(classes);
// keys.forEach(function(key) { // keys.forEach(function(key) {

View File

@@ -5,7 +5,6 @@ import { log } from '../../logger';
import svgDraw from './svgDraw'; import svgDraw from './svgDraw';
import { configureSvgSize } from '../../setupGraphViewbox'; import { configureSvgSize } from '../../setupGraphViewbox';
import { getConfig } from '../../config'; import { getConfig } from '../../config';
import { addSVGa11yTitleDescription } from '../../accessibility';
let idCache = {}; let idCache = {};
const padding = 20; const padding = 20;
@@ -272,7 +271,6 @@ export const draw = function (text, id, _version, diagObj) {
const vBox = `${svgBounds.x - padding} ${svgBounds.y - padding} ${width} ${height}`; const vBox = `${svgBounds.x - padding} ${svgBounds.y - padding} ${width} ${height}`;
log.debug(`viewBox ${vBox}`); log.debug(`viewBox ${vBox}`);
diagram.attr('viewBox', vBox); diagram.attr('viewBox', vBox);
addSVGa11yTitleDescription(diagObj.db, diagram, id);
}; };
export default { export default {

View File

@@ -5,7 +5,6 @@ import { getConfig } from '../../config';
import { log } from '../../logger'; import { log } from '../../logger';
import erMarkers from './erMarkers'; import erMarkers from './erMarkers';
import { configureSvgSize } from '../../setupGraphViewbox'; import { configureSvgSize } from '../../setupGraphViewbox';
import { addSVGa11yTitleDescription } from '../../accessibility';
import { parseGenericTypes } from '../common/common'; import { parseGenericTypes } from '../common/common';
import { v4 as uuid4 } from 'uuid'; import { v4 as uuid4 } from 'uuid';
@@ -656,8 +655,6 @@ export const draw = function (text, id, _version, diagObj) {
configureSvgSize(svg, height, width, conf.useMaxWidth); configureSvgSize(svg, height, width, conf.useMaxWidth);
svg.attr('viewBox', `${svgBounds.x - padding} ${svgBounds.y - padding} ${width} ${height}`); svg.attr('viewBox', `${svgBounds.x - padding} ${svgBounds.y - padding} ${width} ${height}`);
addSVGa11yTitleDescription(diagObj.db, svg, id);
}; // draw }; // draw
/** /**

View File

@@ -337,22 +337,6 @@ describe('when parsing ER diagram it...', function () {
expect(erDb.getAccDescription()).toBe('this graph is about stuff'); expect(erDb.getAccDescription()).toBe('this graph is about stuff');
}); });
it('should allow for a accessibility title and multi line description (accDescr)', function () {
const teacherRole = 'is teacher of';
const line1 = `TEACHER }o--o{ STUDENT : "${teacherRole}"`;
erDiagram.parser.parse(
`erDiagram
accTitle: graph title
accDescr {
this graph is about stuff
}\n
${line1}`
);
expect(erDb.getAccTitle()).toBe('graph title');
expect(erDb.getAccDescription()).toBe('this graph is about stuff');
});
it('should allow more than one relationship between the same two entities', function () { it('should allow more than one relationship between the same two entities', function () {
const line1 = 'CAR ||--o{ PERSON : "insured for"'; const line1 = 'CAR ||--o{ PERSON : "insured for"';
const line2 = 'CAR }o--|| PERSON : "owned by"'; const line2 = 'CAR }o--|| PERSON : "owned by"';

View File

@@ -10,7 +10,6 @@ import { log } from '../../logger';
import common, { evaluate } from '../common/common'; import common, { evaluate } from '../common/common';
import { interpolateToCurve, getStylesFromArray } from '../../utils'; import { interpolateToCurve, getStylesFromArray } from '../../utils';
import { setupGraphViewbox } from '../../setupGraphViewbox'; import { setupGraphViewbox } from '../../setupGraphViewbox';
import { addSVGa11yTitleDescription } from '../../accessibility';
const conf = {}; const conf = {};
export const setConf = function (cnf) { export const setConf = function (cnf) {
@@ -430,9 +429,6 @@ export const draw = function (text, id, _version, diagObj) {
// Set up an SVG group so that we can translate the final graph. // Set up an SVG group so that we can translate the final graph.
const svg = root.select(`[id="${id}"]`); const svg = root.select(`[id="${id}"]`);
// Adds title and description to the flow chart
addSVGa11yTitleDescription(diagObj.db, svg, id);
// Run the renderer. This is what draws the final graph. // Run the renderer. This is what draws the final graph.
const element = root.select('#' + id + ' g'); const element = root.select('#' + id + ' g');
render(element, g, ['point', 'circle', 'cross'], 'flowchart', id); render(element, g, ['point', 'circle', 'cross'], 'flowchart', id);

View File

@@ -8,7 +8,6 @@ import common, { evaluate } from '../common/common';
import { interpolateToCurve, getStylesFromArray } from '../../utils'; import { interpolateToCurve, getStylesFromArray } from '../../utils';
import { setupGraphViewbox } from '../../setupGraphViewbox'; import { setupGraphViewbox } from '../../setupGraphViewbox';
import flowChartShapes from './flowChartShapes'; import flowChartShapes from './flowChartShapes';
import { addSVGa11yTitleDescription } from '../../accessibility';
const conf = {}; const conf = {};
export const setConf = function (cnf) { export const setConf = function (cnf) {
@@ -417,9 +416,6 @@ export const draw = function (text, id, _version, diagObj) {
// Set up an SVG group so that we can translate the final graph. // Set up an SVG group so that we can translate the final graph.
const svg = root.select(`[id="${id}"]`); const svg = root.select(`[id="${id}"]`);
// Adds title and description to the flow chart
addSVGa11yTitleDescription(diagObj.db, svg, id);
// Run the renderer. This is what draws the final graph. // Run the renderer. This is what draws the final graph.
const element = root.select('#' + id + ' g'); const element = root.select('#' + id + ' g');
render(element, g); render(element, g);

View File

@@ -19,7 +19,6 @@ import {
import common from '../common/common'; import common from '../common/common';
import { getConfig } from '../../config'; import { getConfig } from '../../config';
import { configureSvgSize } from '../../setupGraphViewbox'; import { configureSvgSize } from '../../setupGraphViewbox';
import { addSVGa11yTitleDescription } from '../../accessibility';
export const setConf = function () { export const setConf = function () {
log.debug('Something is calling, setConf, remove the call'); log.debug('Something is calling, setConf, remove the call');
@@ -116,8 +115,6 @@ export const draw = function (text, id, version, diagObj) {
.attr('y', conf.titleTopMargin) .attr('y', conf.titleTopMargin)
.attr('class', 'titleText'); .attr('class', 'titleText');
addSVGa11yTitleDescription(diagObj.db, svg, id);
/** /**
* @param tasks * @param tasks
* @param pageWidth * @param pageWidth

View File

@@ -1,7 +1,6 @@
import { select } from 'd3'; import { select } from 'd3';
import { getConfig, setupGraphViewbox } from '../../diagram-api/diagramAPI'; import { getConfig, setupGraphViewbox } from '../../diagram-api/diagramAPI';
import { log } from '../../logger'; import { log } from '../../logger';
import { addSVGa11yTitleDescription } from '../../accessibility';
let allCommitsDict = {}; let allCommitsDict = {};
@@ -512,9 +511,6 @@ export const draw = function (txt, id, ver, diagObj) {
const diagram = select(`[id="${id}"]`); const diagram = select(`[id="${id}"]`);
// Adds title and description to the flow chart
addSVGa11yTitleDescription(diagObj.db, diagram, id);
drawCommits(diagram, allCommitsDict, false); drawCommits(diagram, allCommitsDict, false);
if (gitGraphConfig.showBranches) { if (gitGraphConfig.showBranches) {
drawBranches(diagram, branches); drawBranches(diagram, branches);

View File

@@ -3,7 +3,6 @@ import { select, scaleOrdinal, pie as d3pie, arc } from 'd3';
import { log } from '../../logger'; import { log } from '../../logger';
import { configureSvgSize } from '../../setupGraphViewbox'; import { configureSvgSize } from '../../setupGraphViewbox';
import * as configApi from '../../config'; import * as configApi from '../../config';
import { addSVGa11yTitleDescription } from '../../accessibility';
let conf = configApi.getConfig(); let conf = configApi.getConfig();
@@ -53,7 +52,6 @@ export const draw = (txt, id, _version, diagObj) => {
const diagram = root.select('#' + id); const diagram = root.select('#' + id);
configureSvgSize(diagram, height, width, conf.pie.useMaxWidth); configureSvgSize(diagram, height, width, conf.pie.useMaxWidth);
addSVGa11yTitleDescription(diagObj.db, diagram, id);
// Set viewBox // Set viewBox
elem.setAttribute('viewBox', '0 0 ' + width + ' ' + height); elem.setAttribute('viewBox', '0 0 ' + width + ' ' + height);

View File

@@ -6,7 +6,6 @@ import { configureSvgSize } from '../../setupGraphViewbox';
import common from '../common/common'; import common from '../common/common';
import markers from './requirementMarkers'; import markers from './requirementMarkers';
import { getConfig } from '../../config'; import { getConfig } from '../../config';
import { addSVGa11yTitleDescription } from '../../accessibility';
let conf = {}; let conf = {};
let relCnt = 0; let relCnt = 0;
@@ -363,8 +362,6 @@ export const draw = (text, id, _version, diagObj) => {
configureSvgSize(svg, height, width, conf.useMaxWidth); configureSvgSize(svg, height, width, conf.useMaxWidth);
svg.attr('viewBox', `${svgBounds.x - padding} ${svgBounds.y - padding} ${width} ${height}`); svg.attr('viewBox', `${svgBounds.x - padding} ${svgBounds.y - padding} ${width} ${height}`);
// Adds title and description to the requirements diagram
addSVGa11yTitleDescription(diagObj.db, svg, id);
}; };
export default { export default {

View File

@@ -9,11 +9,8 @@ import * as configApi from '../../config';
import assignWithDepth from '../../assignWithDepth'; import assignWithDepth from '../../assignWithDepth';
import utils from '../../utils'; import utils from '../../utils';
import { configureSvgSize } from '../../setupGraphViewbox'; import { configureSvgSize } from '../../setupGraphViewbox';
import { addSVGa11yTitleDescription } from '../../accessibility';
import Diagram from '../../Diagram'; import Diagram from '../../Diagram';
// FIXME insert a11y title and desc
let conf = {}; let conf = {};
export const bounds = { export const bounds = {
@@ -906,7 +903,6 @@ export const draw = function (_text: string, id: string, _version: string, diagO
(height + extraVertForTitle) (height + extraVertForTitle)
); );
addSVGAccessibilityFields(diagObj.db, diagram, id);
log.debug(`models:`, bounds.models); log.debug(`models:`, bounds.models);
}; };

View File

@@ -5,7 +5,6 @@ import { render } from '../../dagre-wrapper/index.js';
import { log } from '../../logger'; import { log } from '../../logger';
import { configureSvgSize } from '../../setupGraphViewbox'; import { configureSvgSize } from '../../setupGraphViewbox';
import common from '../common/common'; import common from '../common/common';
import { addSVGa11yTitleDescription } from '../../accessibility';
import { import {
DEFAULT_DIAGRAM_DIRECTION, DEFAULT_DIAGRAM_DIRECTION,
DEFAULT_NESTED_DOC_DIR, DEFAULT_NESTED_DOC_DIR,
@@ -472,7 +471,6 @@ export const draw = function (text, id, _version, diag) {
label.insertBefore(rect, label.firstChild); label.insertBefore(rect, label.firstChild);
// } // }
} }
addSVGa11yTitleDescription(diag.db, svg, id);
}; };
export default { export default {

View File

@@ -6,7 +6,6 @@ import common from '../common/common';
import { drawState, addTitleAndBox, drawEdge } from './shapes'; import { drawState, addTitleAndBox, drawEdge } from './shapes';
import { getConfig } from '../../config'; import { getConfig } from '../../config';
import { configureSvgSize } from '../../setupGraphViewbox'; import { configureSvgSize } from '../../setupGraphViewbox';
import { addSVGa11yTitleDescription } from '../../accessibility';
// TODO Move conf object to main conf in mermaidAPI // TODO Move conf object to main conf in mermaidAPI
let conf; let conf;
@@ -97,7 +96,6 @@ export const draw = function (text, id, _version, diagObj) {
'viewBox', 'viewBox',
`${bounds.x - conf.padding} ${bounds.y - conf.padding} ` + width + ' ' + height `${bounds.x - conf.padding} ${bounds.y - conf.padding} ` + width + ' ' + height
); );
addSVGa11yTitleDescription(diagObj.db, diagram, id);
}; };
const getLabelWidth = (text) => { const getLabelWidth = (text) => {
return text ? text.length * conf.fontSizeFactor : 1; return text ? text.length * conf.fontSizeFactor : 1;

View File

@@ -3,8 +3,6 @@ import { select } from 'd3';
import svgDraw from './svgDraw'; import svgDraw from './svgDraw';
import { getConfig } from '../../config'; import { getConfig } from '../../config';
import { configureSvgSize } from '../../setupGraphViewbox'; import { configureSvgSize } from '../../setupGraphViewbox';
import { addSVGa11yTitleDescription } from '../../accessibility';
// FIXME insert a11y title and desc
export const setConf = function (cnf) { export const setConf = function (cnf) {
const keys = Object.keys(cnf); const keys = Object.keys(cnf);
@@ -122,8 +120,6 @@ export const draw = function (text, id, version, diagObj) {
diagram.attr('viewBox', `${box.startx} -25 ${width} ${height + extraVertForTitle}`); diagram.attr('viewBox', `${box.startx} -25 ${width} ${height + extraVertForTitle}`);
diagram.attr('preserveAspectRatio', 'xMinYMin meet'); diagram.attr('preserveAspectRatio', 'xMinYMin meet');
diagram.attr('height', height + extraVertForTitle + 25); diagram.attr('height', height + extraVertForTitle + 25);
addSVGAccessibilityFields(diagObj.db, diagram, id);
}; };
export const bounds = { export const bounds = {