Add `suppressErrorRendering` option to avoid inserting 'Syntax error' message in diagram

This commit is contained in:
rhysd 2023-04-30 00:32:40 +09:00
parent 33c81d557e
commit 2c5d83fab3
3 changed files with 13 additions and 1 deletions

View File

@ -34,6 +34,7 @@ export interface MermaidConfig {
dompurifyConfig?: DOMPurify.Config;
wrap?: boolean;
fontSize?: number;
suppressErrorRendering?: boolean;
}
// TODO: More configs needs to be moved in here

View File

@ -152,6 +152,14 @@ const config: Partial<MermaidConfig> = {
*/
deterministicIDSeed: undefined,
/**
* This option suppresses inserting 'Syntax error' message in diagram. This option is useful when
* you want to control how to handle syntax error in your application.
*
* Default value: false
*/
suppressErrorRendering: false,
/** The object containing configurations specific for flowcharts */
flowchart: {
/**

View File

@ -511,7 +511,9 @@ const render = async function (
try {
await diag.renderer.draw(text, id, version, diag);
} catch (e) {
errorRenderer.draw(text, id, version);
if (!config.suppressErrorRendering) {
errorRenderer.draw(text, id, version);
}
throw e;
}
@ -617,6 +619,7 @@ function addA11yInfo(
* securityLevel: 'strict',
* startOnLoad: true,
* arrowMarkerAbsolute: false,
* suppressErrorRendering: false,
*
* er: {
* diagramPadding: 20,