Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | import Crowi from '../Crowi' export default class Mathjax { crowi: Crowi defaultUrl: string mathJaxConfigured: boolean constructor(crowi: Crowi) { this.crowi = crowi this.defaultUrl = '//cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?skipStartupTypeset=true' this.mathJaxConfigured = false const { env } = crowi.getConfig() if (env && env.MATHJAX) { this.mathJaxConfigured = true if (crowi.window.MathJax) { return } const document = crowi.document const head = document.getElementsByTagName('head')[0] const mathJaxConfig = document.createElement('script') mathJaxConfig.type = 'text/x-mathjax-config' mathJaxConfig.text = `MathJax.Hub.Config({ extensions: ["tex2jax.js"], jax: ["input/TeX", "output/SVG"], tex2jax: { inlineMath: [ ['$','$'] ], displayMath: [ ['$$','$$'] ], processEscapes: true }, showMathMenu: false, showMathMenuMSIE: false, showProcessingMessages: false, messageStyle: "none", skipStartupTypeset: true });` head.appendChild(mathJaxConfig) const script = document.createElement('script') script.type = 'text/javascript' script.src = this.defaultUrl head.appendChild(script) } this.process = this.process.bind(this) } process(html: string, dom: HTMLElement | undefined) { if (!this.mathJaxConfigured) { return html } if (typeof dom === 'undefined') { return html } const intervalId = setInterval(() => { if (this.crowi.window.MathJax) { const MathJax: any = this.crowi.window.MathJax MathJax.Hub.Queue(['Typeset', MathJax.Hub, dom.id]) clearInterval(intervalId) } }, 100) return html } } |