mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-16 05:49:43 +02:00
Merge pull request #4718 from Yokozuna59/chore/standardized-error-definitions
standardized `error` diagram
This commit is contained in:
@@ -1,23 +1,15 @@
|
|||||||
import { DiagramDefinition } from '../../diagram-api/types.js';
|
import type { DiagramDefinition } from '../../diagram-api/types.js';
|
||||||
import styles from './styles.js';
|
import { renderer } from './errorRenderer.js';
|
||||||
import renderer from './errorRenderer.js';
|
|
||||||
export const diagram: DiagramDefinition = {
|
const diagram: DiagramDefinition = {
|
||||||
db: {
|
db: {},
|
||||||
clear: () => {
|
|
||||||
// Quite ok, clear needs to be there for error to work as a regular diagram
|
|
||||||
},
|
|
||||||
},
|
|
||||||
styles,
|
|
||||||
renderer,
|
renderer,
|
||||||
parser: {
|
parser: {
|
||||||
parser: { yy: {} },
|
parser: { yy: {} },
|
||||||
parse: () => {
|
parse: (): void => {
|
||||||
// no op
|
return;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
init: () => {
|
|
||||||
// no op
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default diagram;
|
export default diagram;
|
||||||
|
@@ -1,33 +1,23 @@
|
|||||||
/** Created by knut on 14-12-11. */
|
|
||||||
// @ts-ignore TODO: Investigate D3 issue
|
|
||||||
import { select } from 'd3';
|
|
||||||
import { log } from '../../logger.js';
|
import { log } from '../../logger.js';
|
||||||
import { getErrorMessage } from '../../utils.js';
|
import type { Group, SVG } from '../../diagram-api/types.js';
|
||||||
|
import { selectSvgElement } from '../../rendering-util/selectSvgElement.js';
|
||||||
/**
|
import { configureSvgSize } from '../../setupGraphViewbox.js';
|
||||||
* Merges the value of `conf` with the passed `cnf`
|
|
||||||
*
|
|
||||||
* @param cnf - Config to merge
|
|
||||||
*/
|
|
||||||
export const setConf = function () {
|
|
||||||
// no-op
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draws a an info picture in the tag with id: id based on the graph definition in text.
|
* Draws a an info picture in the tag with id: id based on the graph definition in text.
|
||||||
*
|
*
|
||||||
* @param _text - Mermaid graph definition.
|
* @param _text - Mermaid graph definition.
|
||||||
* @param id - The text for the error
|
* @param id - The text for the error
|
||||||
* @param mermaidVersion - The version
|
* @param version - The version
|
||||||
*/
|
*/
|
||||||
export const draw = (_text: string, id: string, mermaidVersion: string) => {
|
export const draw = (_text: string, id: string, version: string) => {
|
||||||
try {
|
log.debug('renering svg for syntax error\n');
|
||||||
log.debug('Renering svg for syntax error\n');
|
|
||||||
|
|
||||||
const svg = select('#' + id);
|
const svg: SVG = selectSvgElement(id);
|
||||||
|
svg.attr('viewBox', '768 0 912 512');
|
||||||
const g = svg.append('g');
|
configureSvgSize(svg, 100, 500, true);
|
||||||
|
|
||||||
|
const g: Group = svg.append('g');
|
||||||
g.append('path')
|
g.append('path')
|
||||||
.attr('class', 'error-icon')
|
.attr('class', 'error-icon')
|
||||||
.attr(
|
.attr(
|
||||||
@@ -83,18 +73,9 @@ export const draw = (_text: string, id: string, mermaidVersion: string) => {
|
|||||||
.attr('y', 400)
|
.attr('y', 400)
|
||||||
.attr('font-size', '100px')
|
.attr('font-size', '100px')
|
||||||
.style('text-anchor', 'middle')
|
.style('text-anchor', 'middle')
|
||||||
.text('mermaid version ' + mermaidVersion);
|
.text(`mermaid version ${version}`);
|
||||||
|
|
||||||
svg.attr('height', 100);
|
|
||||||
svg.attr('width', 500);
|
|
||||||
svg.attr('viewBox', '768 0 912 512');
|
|
||||||
} catch (e) {
|
|
||||||
log.error('Error while rendering info diagram');
|
|
||||||
log.error(getErrorMessage(e));
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default {
|
export const renderer = { draw };
|
||||||
setConf,
|
|
||||||
draw,
|
export default renderer;
|
||||||
};
|
|
||||||
|
@@ -1,3 +0,0 @@
|
|||||||
const getStyles = () => ``;
|
|
||||||
|
|
||||||
export default getStyles;
|
|
@@ -19,7 +19,6 @@ import classDiagram from './diagrams/class/styles.js';
|
|||||||
import flowchart from './diagrams/flowchart/styles.js';
|
import flowchart from './diagrams/flowchart/styles.js';
|
||||||
import flowchartElk from './diagrams/flowchart/elk/styles.js';
|
import flowchartElk from './diagrams/flowchart/elk/styles.js';
|
||||||
import er from './diagrams/er/styles.js';
|
import er from './diagrams/er/styles.js';
|
||||||
import error from './diagrams/error/styles.js';
|
|
||||||
import git from './diagrams/git/styles.js';
|
import git from './diagrams/git/styles.js';
|
||||||
import gantt from './diagrams/gantt/styles.js';
|
import gantt from './diagrams/gantt/styles.js';
|
||||||
import pie from './diagrams/pie/styles.js';
|
import pie from './diagrams/pie/styles.js';
|
||||||
@@ -86,7 +85,6 @@ describe('styles', () => {
|
|||||||
c4,
|
c4,
|
||||||
classDiagram,
|
classDiagram,
|
||||||
er,
|
er,
|
||||||
error,
|
|
||||||
flowchart,
|
flowchart,
|
||||||
flowchartElk,
|
flowchartElk,
|
||||||
gantt,
|
gantt,
|
||||||
|
Reference in New Issue
Block a user