2

My math-field freeze(can't type inside it) with Mathquill Matheditor when I try to translate Mathquill equation into LaTeX language.

<span id="math-field" class="mathquill-textbox" />
<textarea id="latex" name="content" />

This is the current mathquill script that I use: https://github.com/jipsen/matheditor/blob/master/mathquill.js

Here is the original script from Mathquill.com's front page that does nothing:

<p>Type math here: <span id="math-field"></span></p>
<p>LaTeX of what you typed: <span id="latex"></span></p>

<script>
var mathFieldSpan = document.getElementById('math-field');
var latexSpan = document.getElementById('latex');

var MQ = MathQuill.getInterface(2); // for backcompat
var mathField = MQ.MathField(mathFieldSpan, {
  spaceBehavesLikeTab: true, // configurable
  handlers: {
    edit: function() { // useful event handlers
      latexSpan.textContent = mathField.latex(); // simple API
    }
  }
});
</script>
Zecret
  • 360
  • 1
  • 4
  • 19

1 Answers1

2

I am providing the HTML and script below.

HTML:

<p>Type math here:
        <span id="math-field" maxlength="20"></span>
</p>
<p>LaTeX of what you typed:
        <span id="latex"></span>
</p>

JAVASCRIPT:

var mathField;
let mathFieldSpan = document.getElementById('math-field');
let latexSpan = document.getElementById('latex');
let MQ = MathQuill.getInterface(2); 

let config = {
    spaceBehavesLikeTab: true,
    restrictMismatchedBrackets: true,
    supSubsRequireOperand: true,
    handlers: {
        edit: function () { // useful event handlers
            var enteredMath = mathField.latex(); // Get entered math in LaTeX format
            latexSpan.textContent = enteredMath; // simple API
        }
    }
};
mathField = MQ.MathField(mathFieldSpan, config);