Synonym's React Mathquill
This is a fork of the react-mathquill project, which wraps MathQuill in React components.
We've made some updates to the underlying MathQuill library to add new features, remove the dependency on jQuery, and reduce bundle size.
- Run
npm install - Build with
npm run buildand make sure there are no errors - You can run the examples with
npm run start:exampleand navigate tohttp://localhost:8080/. Make sure that the editable math field works! - If you make a change to our fork of MathQuill, run the
./mathquill-build.shscript to bring in those changes. - IMPORTANT! Make sure you delete the
font-faceimports in the CSS filemathquill-basic.css! This causes some weird runtime error to occur due to a missing Node.js builtin function. Eventually we'll remove that manual step. - Bump the version in
package.jsonif you made changes - Deploy the package to npm with
npm publish
- Build of examples located at
src/examples/ - Play with the examples below at this Code Sandbox
import React, { useState } from 'react'
import { addStyles, EditableMathField } from 'react-mathquill'
// inserts the required css to the <head> block.
// you can skip this, if you want to do that by yourself.
addStyles()
const EditableMathExample = () => {
const [latex, setLatex] = useState('\\frac{1}{\\sqrt{2}}\\cdot 2')
return (
<div>
<EditableMathField
latex={latex}
onChange={(mathField) => {
setLatex(mathField.latex())
}}
/>
<p>{latex}</p>
</div>
)
}import React from 'react'
import { addStyles, StaticMathField } from 'react-mathquill'
// inserts the required css to the <head> block.
// you can skip this, if you want to do that by yourself.
addStyles()
const StaticMathExample = () => (
<StaticMathField>{'\\frac{1}{\\sqrt{2}}\\cdot 2'}</StaticMathField>
)This function, when called, will append a <style id="react-mathquill-styles"> tag to the <head> of the document.
The style tag includes all the required styles for Mathquill to work.
This function is not necessary, provided you include the styles in another way. See Mathquill Docs - Download and Load
Wrapper for Mathquill MathField
- latex: String - Initial latex value for the input field
- config: Object - A mathquill config object
- onChange(mathField) - A function that is called on change events.
- mathquillDidMount(mathField) - A function that is called when the Mathquill element is initalized.
Other props will be passed to the wrapping span element, this can be useful for custom classNames or styles
Wrapper for Mathquill StaticField
- children: String - A string of latex to render statically on the page
Other props will be passed to the wrapping span element, this can be useful for custom classNames or styles