Socket
Socket
Sign inDemoInstall

abc-react-mathquill

Package Overview
Dependencies
3
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    abc-react-mathquill

React component wrapper for Mathquill


Version published
Weekly downloads
11
increased by120%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

React component wrapper for Mathquill

npm version

Editable Math Field

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')
  const [cmd, setCmd] = useState({id: 0, content: "\\sum})

  return (
    <div>
      <EditableMathField
        latex={latex}
        cmd={cmd}// program enter new command at current position cusor
        onChange={(mathField) => {
          setLatex(mathField.latex())
        }}
      />
      <p>{latex}</p>
    </div>
  )
}

Static Math Field

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>
)

Documentation

addStyles (function)

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

EditableMathField (React Element)

Wrapper for Mathquill MathField

Props

  • 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

StaticMathField (React Element)

Wrapper for Mathquill StaticField

Props

  • 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

FAQs

Last updated on 28 Nov 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc