tsConversion: errorRenderer

This commit is contained in:
Sidharth Vinod
2022-08-21 00:58:52 +05:30
parent 95dbbb350b
commit c9cd56914f
3 changed files with 223 additions and 10 deletions

View File

@@ -2,28 +2,24 @@
import { select } from 'd3';
import { log } from './logger';
const conf = {};
let conf = {};
/**
* Merges the value of `conf` with the passed `cnf`
*
* @param {object} cnf Config to merge
*/
export const setConf = function (cnf) {
const keys = Object.keys(cnf);
keys.forEach(function (key) {
conf[key] = cnf[key];
});
export const setConf = function (cnf: any) {
conf = { ...conf, ...cnf };
};
/**
* Draws a an info picture in the tag with id: id based on the graph definition in text.
*
* @param {string} id The text for the error
* @param {string} ver The version
* @param {string} mermaidVersion The version
*/
export const draw = (id, ver) => {
export const draw = (id: string, mermaidVersion: string) => {
try {
log.debug('Renering svg for syntax error\n');
@@ -86,13 +82,14 @@ export const draw = (id, ver) => {
.attr('y', 400)
.attr('font-size', '100px')
.style('text-anchor', 'middle')
.text('mermaid version ' + ver);
.text('mermaid version ' + mermaidVersion);
svg.attr('height', 100);
svg.attr('width', 400);
svg.attr('viewBox', '768 0 512 512');
} catch (e) {
log.error('Error while rendering info diagram');
// @ts-ignore
log.error(e.message);
}
};