-
-
Notifications
You must be signed in to change notification settings - Fork 7.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
make errorRenderer.draw be optional #3205
Comments
Further, errorRenderer creates an SVG with the same ID as the rendered node and sets a style which now affects the rendered node (in case the calling code uses it. E.g. to put the exception text in it). |
Same issue here for Docusaurus integration. We render Mermaid diagrams on a React app and already handle thrown errors with We don't need the weird bomb icon + error message text being appended at the end of the DOM 😅 Other related issues:
A workaround is to remove the error as soon as it is added to the DOM, cf solution proposed by @sidharthv96 in mermaid-js/mermaid-live-editor#1288 My adapted version for Docusaurus integration (facebook/docusaurus#9305): try {
return await mermaid.render(id, text);
} catch (e) {
document.querySelector(`#d${id}`)?.remove();
throw e;
} Of course it would be much cleaner if there was a way to make the https://github.com/mermaid-js/mermaid/blob/develop/packages/mermaid/src/mermaidAPI.ts#L478 // -------------------------------------------------------------------------------
// Draw the diagram with the renderer
try {
await diag.renderer.draw(text, id, version, diag);
} catch (e) {
errorRenderer.draw(text, id, version);
throw e;
} Is there a good reason to not add Here's a more visual illustration of the problem, showing the Mermaid error being displayed twice (by me, and by Mermaid). I want to render Mermaid errors on my own. |
#4359 is almost there. But some minor issues. |
I hide those errors with CSS. Ideally I would like to see these error rendering off by default. |
For anyone searching,
|
Is your feature request related to a problem? Please describe.
I'm using a mermaid plugin in TiddlyWiki which is an HTML/javascript based wiki. In particular, it allows a live preview of the content. So As I create a mermaid drawing I can see how it looks like and correct mistakes. The problem is that as I type, there are errors of course. The live preview will show them, which is fine, but errorRenderer also adds them at the bottom of the HTML where they accumulate (since it's an HTML wiki the page is not reloaded)
Describe the solution you'd like
Making the rendering of errors be optional/configurable
The text was updated successfully, but these errors were encountered: