mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-10-10 09:39:38 +02:00
feat: add accDescription along with test page
This commit is contained in:
@@ -1,7 +1,11 @@
|
||||
import mermaidAPI from '../../mermaidAPI';
|
||||
import * as configApi from '../../config';
|
||||
import common from '../common/common';
|
||||
|
||||
const sanitizeText = (txt) => common.sanitizeText(txt, configApi.getConfig());
|
||||
|
||||
let title = '';
|
||||
let description = '';
|
||||
let currentSection = '';
|
||||
|
||||
const sections = [];
|
||||
@@ -20,14 +24,22 @@ export const clear = function () {
|
||||
rawTasks.length = 0;
|
||||
};
|
||||
|
||||
export const setTitle = function (txt) {
|
||||
title = txt;
|
||||
const setTitle = function (txt) {
|
||||
title = sanitizeText(txt);
|
||||
};
|
||||
|
||||
export const getTitle = function () {
|
||||
const getTitle = function () {
|
||||
return title;
|
||||
};
|
||||
|
||||
const setAccDescription = function (txt) {
|
||||
description = sanitizeText(txt);
|
||||
};
|
||||
|
||||
const getAccDescription = function () {
|
||||
return description;
|
||||
};
|
||||
|
||||
export const addSection = function (txt) {
|
||||
currentSection = txt;
|
||||
sections.push(txt);
|
||||
@@ -123,6 +135,8 @@ export default {
|
||||
clear,
|
||||
setTitle,
|
||||
getTitle,
|
||||
setAccDescription,
|
||||
getAccDescription,
|
||||
addSection,
|
||||
getSections,
|
||||
getTasks,
|
||||
|
@@ -4,6 +4,7 @@ import journeyDb from './journeyDb';
|
||||
import svgDraw from './svgDraw';
|
||||
import { getConfig } from '../../config';
|
||||
import { configureSvgSize } from '../../utils';
|
||||
import addSVGAccessibilityFields from '../../accessibility';
|
||||
|
||||
parser.yy = journeyDb;
|
||||
|
||||
@@ -100,6 +101,7 @@ export const draw = function (text, id) {
|
||||
.attr('font-weight', 'bold')
|
||||
.attr('y', 25);
|
||||
}
|
||||
|
||||
const height = box.stopy - box.starty + 2 * conf.diagramMarginY;
|
||||
const width = LEFT_MARGIN + box.stopx + 2 * conf.diagramMarginX;
|
||||
|
||||
@@ -120,6 +122,8 @@ export const draw = function (text, id) {
|
||||
diagram.attr('viewBox', `${box.startx} -25 ${width} ${height + extraVertForTitle}`);
|
||||
diagram.attr('preserveAspectRatio', 'xMinYMin meet');
|
||||
diagram.attr('height', height + extraVertForTitle + 25);
|
||||
|
||||
addSVGAccessibilityFields(parser.yy, diagram, id);
|
||||
};
|
||||
|
||||
export const bounds = {
|
||||
|
@@ -25,6 +25,7 @@
|
||||
|
||||
"journey" return 'journey';
|
||||
"title"\s[^#\n;]+ return 'title';
|
||||
"accDescription"\s[^#\n;]+ return 'accDescription';
|
||||
"section"\s[^#:\n;]+ return 'section';
|
||||
[^#:\n;]+ return 'taskName';
|
||||
":"[^#\n;]+ return 'taskData';
|
||||
@@ -64,6 +65,7 @@ directive
|
||||
|
||||
statement
|
||||
: title {yy.setTitle($1.substr(6));$$=$1.substr(6);}
|
||||
| accDescription {yy.setAccDescription($1.substring(15));$$=$1.substring(15);}
|
||||
| section {yy.addSection($1.substr(8));$$=$1.substr(8);}
|
||||
| taskName taskData {yy.addTask($1, $2);$$='task';}
|
||||
| directive
|
||||
|
Reference in New Issue
Block a user