2023-08-29 10:14:04 +00:00
|
|
|
const MATHJAX_STUB = `
|
2023-11-07 11:52:06 +00:00
|
|
|
window.MathJax = {
|
2023-08-29 10:14:04 +00:00
|
|
|
startup: {
|
|
|
|
promise: Promise.resolve()
|
2023-11-07 11:52:06 +00:00
|
|
|
},
|
2023-10-25 11:11:14 +00:00
|
|
|
svgStylesheet: () => document.createElement("STYLE"),
|
|
|
|
typesetPromise: (elements) => {
|
|
|
|
for (const element of elements) {
|
|
|
|
// This will keep math delimeters around the text
|
|
|
|
element.classList.add('MathJax')
|
|
|
|
}
|
|
|
|
return Promise.resolve()
|
|
|
|
},
|
|
|
|
tex2svgPromise: (content) => {
|
|
|
|
const text = document.createElement('SPAN')
|
|
|
|
text.classList.add('MathJax')
|
|
|
|
text.innerText = content
|
|
|
|
return Promise.resolve(text)
|
|
|
|
},
|
|
|
|
getMetricsFor: () => ({}),
|
|
|
|
texReset: () => {},
|
2023-08-29 10:14:04 +00:00
|
|
|
}
|
|
|
|
`
|
|
|
|
|
|
|
|
export const interceptMathJax = () => {
|
2023-11-07 11:52:06 +00:00
|
|
|
// NOTE: this is just a URL to be intercepted with the stub, not the real (versioned) MathJax URL
|
|
|
|
const url = '/js/libs/mathjax-3/es5/tex-svg-full.js'
|
2023-08-29 10:14:04 +00:00
|
|
|
cy.window().then(win => {
|
2023-11-07 11:52:06 +00:00
|
|
|
win.metaAttributesCache.set('ol-mathJax3Path', url)
|
2023-08-29 10:14:04 +00:00
|
|
|
})
|
2023-11-07 11:52:06 +00:00
|
|
|
cy.intercept('GET', url, MATHJAX_STUB).as('mathjax-load-request')
|
2023-08-29 10:14:04 +00:00
|
|
|
}
|