Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/assets/javascripts/lib/mermaid.js')
-rw-r--r--app/assets/javascripts/lib/mermaid.js11
1 files changed, 7 insertions, 4 deletions
diff --git a/app/assets/javascripts/lib/mermaid.js b/app/assets/javascripts/lib/mermaid.js
index c72561ce69d..bbc1d8ae1e1 100644
--- a/app/assets/javascripts/lib/mermaid.js
+++ b/app/assets/javascripts/lib/mermaid.js
@@ -6,17 +6,20 @@ const setIframeRenderedSize = (h, w) => {
window.parent.postMessage({ h, w }, origin);
};
-const drawDiagram = (source) => {
+const drawDiagram = async (source) => {
const element = document.getElementById('app');
const insertSvg = (svgCode) => {
// eslint-disable-next-line no-unsanitized/property
element.innerHTML = svgCode;
- const height = parseInt(element.firstElementChild.getAttribute('height'), 10);
- const width = parseInt(element.firstElementChild.style.maxWidth, 10);
+ element.firstElementChild.removeAttribute('height');
+ const { height, width } = element.firstElementChild.getBoundingClientRect();
+
setIframeRenderedSize(height, width);
};
- mermaid.mermaidAPI.render('mermaid', source, insertSvg);
+
+ const { svg } = await mermaid.mermaidAPI.render('mermaid', source);
+ insertSvg(svg);
};
const darkModeEnabled = () => getParameterByName('darkMode') === 'true';