File tree Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " backstage-plugin-techdocs-addon-mathjax" ,
3- "version" : " 0.0.1 " ,
3+ "version" : " 0.0.2 " ,
44 "main" : " src/index.ts" ,
55 "types" : " src/index.ts" ,
66 "license" : " MIT" ,
Original file line number Diff line number Diff line change 11import { useEffect } from 'react' ;
22
3- export const MathjaxAddon = ( ) => {
4- useEffect ( ( ) => {
3+ function runTypeSet ( ) {
54 if ( typeof ( < any > window ) ?. MathJax !== "undefined" ) {
5+ console . log ( "MathJax was found and typeset is called!" ) ;
66 ( < any > window ) . MathJax . typeset ( ) ;
7+ return true ;
8+ }
9+ return false ;
10+ } ;
11+
12+
13+ export const MathjaxAddon = ( ) => {
14+ useEffect ( ( ) => {
15+
16+ if ( ! runTypeSet ( ) ) {
17+ console . log ( "No MathJax was found, now loading!" ) ;
18+ const script = document . createElement ( 'script' ) ;
19+ script . src = 'https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js' ;
20+ script . async = true ;
21+ document . body . appendChild ( script ) ;
22+ setTimeout ( ( ) => {
23+ runTypeSet ( ) ;
24+ } , 500 ) ;
725 } ;
826
927 } , [ ] ) ;
You can’t perform that action at this time.
0 commit comments