This commit is contained in:
Knut Sveidqvist 2022-04-30 16:14:43 +02:00
parent fdd7af9089
commit ed56e4858a
4 changed files with 19 additions and 38 deletions

View File

@ -2,6 +2,13 @@ import { log } from '../../logger';
import mermaidAPI from '../../mermaidAPI';
import * as configApi from '../../config';
import common from '../common/common';
import {
setTitle,
getTitle,
getAccDescription,
setAccDescription,
clear as commonClear,
} from '../../commonDb';
let entities = {};
let relationships = [];
@ -68,29 +75,11 @@ const addRelationship = function (entA, rolA, entB, rSpec) {
const getRelationships = () => relationships;
// Keep this - TODO: revisit...allow the diagram to have a title
const setTitle = function (txt) {
let sanitizedText = common.sanitizeText(txt, configApi.getConfig());
title = sanitizedText;
};
const getTitle = function () {
return title;
};
const setAccDescription = function (txt) {
let sanitizedText = common.sanitizeText(txt, configApi.getConfig());
description = sanitizedText;
};
const getAccDescription = function () {
return description;
};
const clear = function () {
entities = {};
relationships = [];
title = '';
commonClear();
};
export default {

View File

@ -5,6 +5,13 @@ import * as configApi from '../../config';
import utils from '../../utils';
import mermaidAPI from '../../mermaidAPI';
import common from '../common/common';
import {
setTitle,
getTitle,
getAccDescription,
setAccDescription,
clear as commonClear,
} from '../../commonDb';
let dateFormat = '';
let axisFormat = '';
@ -52,6 +59,7 @@ export const clear = function () {
topAxis = false;
lastOrder = 0;
links = {};
commonClear();
};
export const setAxisFormat = function (txt) {
@ -113,22 +121,6 @@ export const getLinks = function () {
return links;
};
export const setTitle = function (txt) {
title = sanitizeText(txt);
};
export const getTitle = function () {
return title;
};
export const setAccDescription = function (txt) {
accDescription = sanitizeText(txt);
};
export const getAccDescription = function () {
return accDescription;
};
export const addSection = function (txt) {
currentSection = txt;
sections.push(txt);

View File

@ -175,7 +175,7 @@ describe('when parsing a gantt diagram it', function () {
it('should allow for a accessibility title and multiline description (accDescr)', function () {
const expectedTitle = 'Gantt Diagram';
const expectedAccDescription = `Tasks for Q4 row1
row2`;
row2`;
const ganttString = `gantt
accTitle: ${expectedTitle}
accDescr {

View File

@ -29,7 +29,7 @@ describe('state diagram, ', function () {
});
it('simple with accDescription', function () {
const str = `stateDiagram-v2\n
accDescription a simple description of the diagram
accDescr: a simple description of the diagram
State1 : this is another string
[*] --> State1
State1 --> [*]
@ -41,7 +41,7 @@ describe('state diagram, ', function () {
});
it('simple with title', function () {
const str = `stateDiagram-v2\n
title a simple title of the diagram
accTitle: a simple title of the diagram
State1 : this is another string
[*] --> State1
State1 --> [*]