From 32159cc4a39f8514c91c4bf0896efb94d35d0915 Mon Sep 17 00:00:00 2001 From: silverwind Date: Sun, 16 Oct 2022 00:04:00 +0200 Subject: [PATCH] Fix mermaid-related bugs (#21431) --- web_src/js/bootstrap.js | 4 ++++ web_src/js/markup/mermaid.js | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/web_src/js/bootstrap.js b/web_src/js/bootstrap.js index 213c9e41df..b5db398545 100644 --- a/web_src/js/bootstrap.js +++ b/web_src/js/bootstrap.js @@ -25,6 +25,10 @@ function processWindowErrorEvent(e) { // 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. return; // ignore such nonsense error event } + + // Wait for upstream fix: https://github.com/microsoft/monaco-editor/issues/2962 + if (e.message.includes('Language id "vs.editor.nullLanguage" is not configured nor known')) return; + showGlobalErrorMessage(`JavaScript error: ${e.message} (${e.filename} @ ${e.lineno}:${e.colno}). Open browser console to see more details.`); } diff --git a/web_src/js/markup/mermaid.js b/web_src/js/markup/mermaid.js index 773c46e791..62de9a3aae 100644 --- a/web_src/js/markup/mermaid.js +++ b/web_src/js/markup/mermaid.js @@ -50,7 +50,7 @@ export async function renderMermaid() { // can't use bindFunctions here because we can't cross the iframe boundary. This // means js-based interactions won't work but they aren't intended to work either mermaid.mermaidAPI.render('mermaid', source, (svgStr) => { - const heightStr = (svgStr.match(/height="(.+?)"/) || [])[1]; + const heightStr = (svgStr.match(/viewBox="(.+?)"/) || ['', ''])[1].split(/\s+/)[3]; if (!heightStr) return displayError(el, new Error('Could not determine chart height')); const iframe = document.createElement('iframe'); iframe.classList.add('markup-render');