Skip to content

Commit 32159cc

Browse files
authored
Fix mermaid-related bugs (#21431)
1 parent 8e8b536 commit 32159cc

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

web_src/js/bootstrap.js

+4
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ function processWindowErrorEvent(e) {
2525
// If a script inserts a newly created (and content changed) element into DOM, there will be a nonsense error event reporting: Script error: line 0, col 0.
2626
return; // ignore such nonsense error event
2727
}
28+
29+
// Wait for upstream fix: https://github.com/microsoft/monaco-editor/issues/2962
30+
if (e.message.includes('Language id "vs.editor.nullLanguage" is not configured nor known')) return;
31+
2832
showGlobalErrorMessage(`JavaScript error: ${e.message} (${e.filename} @ ${e.lineno}:${e.colno}). Open browser console to see more details.`);
2933
}
3034

web_src/js/markup/mermaid.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export async function renderMermaid() {
5050
// can't use bindFunctions here because we can't cross the iframe boundary. This
5151
// means js-based interactions won't work but they aren't intended to work either
5252
mermaid.mermaidAPI.render('mermaid', source, (svgStr) => {
53-
const heightStr = (svgStr.match(/height="(.+?)"/) || [])[1];
53+
const heightStr = (svgStr.match(/viewBox="(.+?)"/) || ['', ''])[1].split(/\s+/)[3];
5454
if (!heightStr) return displayError(el, new Error('Could not determine chart height'));
5555
const iframe = document.createElement('iframe');
5656
iframe.classList.add('markup-render');

0 commit comments

Comments
 (0)