diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/behaviors/markdown/render_sandboxed_mermaid.js | 11 | ||||
-rw-r--r-- | app/assets/javascripts/lib/mermaid.js | 7 |
2 files changed, 14 insertions, 4 deletions
diff --git a/app/assets/javascripts/behaviors/markdown/render_sandboxed_mermaid.js b/app/assets/javascripts/behaviors/markdown/render_sandboxed_mermaid.js index bd9e41ac0ba..22e9b2b9709 100644 --- a/app/assets/javascripts/behaviors/markdown/render_sandboxed_mermaid.js +++ b/app/assets/javascripts/behaviors/markdown/render_sandboxed_mermaid.js @@ -72,11 +72,14 @@ function fixElementSource(el) { export function getSandboxFrameSrc() { const path = joinPaths(gon.relative_url_root || '', SANDBOX_FRAME_PATH); - if (!darkModeEnabled()) { - return path; + let absoluteUrl = relativePathToAbsolute(path, getBaseURL()); + if (darkModeEnabled()) { + absoluteUrl = setUrlParams({ darkMode: darkModeEnabled() }, absoluteUrl); } - const absoluteUrl = relativePathToAbsolute(path, getBaseURL()); - return setUrlParams({ darkMode: darkModeEnabled() }, absoluteUrl); + if (window.gon?.relative_url_root) { + absoluteUrl = setUrlParams({ relativeRootPath: window.gon.relative_url_root }, absoluteUrl); + } + return absoluteUrl; } function renderMermaidEl(el, source) { diff --git a/app/assets/javascripts/lib/mermaid.js b/app/assets/javascripts/lib/mermaid.js index bbc1d8ae1e1..5e62a023777 100644 --- a/app/assets/javascripts/lib/mermaid.js +++ b/app/assets/javascripts/lib/mermaid.js @@ -1,6 +1,13 @@ import mermaid from 'mermaid'; import { getParameterByName } from '~/lib/utils/url_utility'; +import { resetServiceWorkersPublicPath } from '~/lib/utils/webpack'; +const resetWebpackPublicPath = () => { + window.gon = { relative_url_root: getParameterByName('relativeRootPath') }; + resetServiceWorkersPublicPath(); +}; + +resetWebpackPublicPath(); const setIframeRenderedSize = (h, w) => { const { origin } = window.location; window.parent.postMessage({ h, w }, origin); |