mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-24 09:49:46 +02:00
refactor: Revert type change for renderer
This commit is contained in:
@@ -58,7 +58,7 @@ export class Diagram {
|
||||
}
|
||||
|
||||
async render(id: string, version: string) {
|
||||
await this.renderer.draw(this.text, id, version, this, null);
|
||||
await this.renderer.draw(this.text, id, version, this);
|
||||
}
|
||||
|
||||
getParser() {
|
||||
|
@@ -100,8 +100,7 @@ export type DrawDefinition = (
|
||||
text: string,
|
||||
id: string,
|
||||
version: string,
|
||||
diagramObject: Diagram,
|
||||
error: Error | null,
|
||||
diagramObject: Diagram
|
||||
) => void | Promise<void>;
|
||||
|
||||
export interface ParserDefinition {
|
||||
|
@@ -17,14 +17,12 @@ export const draw = (
|
||||
id: string,
|
||||
version: string,
|
||||
_diagramObject: Diagram,
|
||||
error: Error | null = null
|
||||
error?: Error
|
||||
) => {
|
||||
log.debug('renering svg for syntax error\n');
|
||||
|
||||
const svg: SVG = selectSvgElement(id);
|
||||
|
||||
const g: Group = svg.append('g');
|
||||
if (error && error.message?.includes('KaTeX')) {
|
||||
if (error?.message?.includes('KaTeX')) {
|
||||
const title = error.message.split(': ')[0];
|
||||
const body = error.message.replace(/[A-z]*:/, '').replace('KaTeX parse ', '');
|
||||
g.append('foreignObject')
|
||||
@@ -36,7 +34,10 @@ export const draw = (
|
||||
.html(`<div style="font-size: 26px; margin-bottom: 8px">${title}</div><div>${body}</div>`);
|
||||
svg.attr('height', 100);
|
||||
svg.attr('width', 500);
|
||||
} else {
|
||||
svg.attr('viewBox', '0 0 500 100');
|
||||
return;
|
||||
}
|
||||
|
||||
svg.attr('viewBox', '0 0 2412 512');
|
||||
configureSvgSize(svg, 100, 512, true);
|
||||
|
||||
@@ -96,7 +97,6 @@ export const draw = (
|
||||
.attr('font-size', '100px')
|
||||
.style('text-anchor', 'middle')
|
||||
.text(`mermaid version ${version}`);
|
||||
}
|
||||
};
|
||||
|
||||
export const renderer = { draw };
|
||||
|
@@ -435,7 +435,7 @@ const render = async function (
|
||||
// -------------------------------------------------------------------------------
|
||||
// Draw the diagram with the renderer
|
||||
try {
|
||||
await diag.renderer.draw(text, id, version, diag, null);
|
||||
await diag.renderer.draw(text, id, version, diag);
|
||||
} catch (e: any) {
|
||||
errorRenderer.draw(text, id, version, diag, e);
|
||||
throw e;
|
||||
|
Reference in New Issue
Block a user