Skip to content

Commit

Permalink
Commenting out the MathJax experiment for now.
Browse files Browse the repository at this point in the history
  • Loading branch information
kenmonks committed Nov 19, 2024
1 parent 04be1bc commit c26fb67
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
12 changes: 12 additions & 0 deletions instructor.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,18 @@
<script type="module" src="lde/src/experimental/lde-debug.js"></script>
<link rel="shortcut icon" href="lurchmath/favicon.ico">
<link rel="stylesheet" href="lurchmath/main-app-styles.css">
<!-- <script>
MathJax = {
tex: {
inlineMath: [['$', '$'], ['\\(', '\\)']]
},
svg: {
fontCache: 'global'
}
}
</script>
<script type="text/javascript" id="MathJax-script"
src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js"></script> -->
</head>

<body onbeforeunload='return unloadmsg()'>
Expand Down
20 changes: 18 additions & 2 deletions lurchmath/expository-math.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import { Atom } from './atoms.js'
import { represent } from './notation.js'
import { appSettings } from './settings-install.js'
import { Dialog, TextInputItem, LongTextInputItem } from './dialog.js'
import { Dialog, TextInputItem, LongTextInputItem, HTMLItem } from './dialog.js'
import { MathItem } from './math-live.js'
import { escapeLatex } from './utilities.js'

Expand Down Expand Up @@ -72,6 +72,16 @@ export class ExpositoryMath extends Atom {
const textSelector = mode == 'Advanced'
? 'textarea[type="text"]'
: 'input[type="text"]'
// const mathjaxPreview = new HTMLItem('<div id="mathjaxPreview"></div>')
// dialog.addItem( mathjaxPreview )
// mathjaxPreview.onShow = () => {
// const jaxinthebox = dialog.querySelector( '#mathjaxPreview' )
// jaxinthebox.innerHTML = `$$${dialog.get( 'latex' )}$$`
// // set MathJax rendering to svg in the dialog to avoid conflict with
// // standard TinyMCE .tox css on dialogs for chtml
// MathJax.typeset()
// }

const mathLivePreview = new MathItem( 'preview',
mode == 'Advanced' ? '' : 'Math editor' )
mathLivePreview.finishSetup = () => {
Expand All @@ -83,15 +93,21 @@ export class ExpositoryMath extends Atom {
mathLivePreview.setValue( latex )
}
dialog.addItem( mathLivePreview )

// initialize dialog with data from the atom
dialog.setInitialData( { latex } )
dialog.setDefaultFocus( 'latex' )
// utility: is the current latex empty?
const empty = () => dialog.get( 'latex' ).trim() == ''
// if they edit the Lurch notation or latex, keep them in sync
dialog.onChange = ( _, component ) => {
if ( component.name == 'latex' )
if ( component.name == 'latex' ) {
mathLivePreview.setValue( dialog.get( 'latex' ) )
// get the dom element and render it on load
// const jaxinthebox = dialog.querySelector( '#mathjaxPreview' )
// jaxinthebox.innerHTML = `$$${dialog.get( 'latex' )}$$`
// MathJax.typeset()
}
if ( component.name == 'preview' )
dialog.querySelector( textSelector ).value =
mathLivePreview.mathLiveEditor.value
Expand Down

0 comments on commit c26fb67

Please sign in to comment.