#3074 Using regular title as a fallback for the accessibility title when no dedicated accessibility title is present

This commit is contained in:
Knut Sveidqvist
2022-05-24 18:52:37 +02:00
parent 6eef26f107
commit b82b2d2b78
6 changed files with 25 additions and 39 deletions

View File

@@ -1,12 +1,14 @@
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) {
@@ -14,7 +16,7 @@ export const setAccTitle = function (txt) {
};
export const getAccTitle = function () {
return title;
return title || diagramTitle;
};
export const setAccDescription = function (txt) {
@@ -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,