New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

draft-js-mathjax-plugin

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

draft-js-mathjax-plugin

Math editing support for DraftJS Plugins Editor

  • 1.3.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
464
decreased by-16.99%
Maintainers
1
Weekly downloads
 
Created
Source

DraftJS MathJax Plugin

This is a plugin for the draft-js-plugins-editor.

This plugin allows you to edit math rendered by mathjax. Give it a try!

It uses the traditional $ key to insert inline math and CTRL+M for block one. (Type \$ to insert the $ character)

demo

Installation

npm install draft-js-mathjax-plugin --save

Usage

import React, { Component } from 'react'
import { EditorState } from 'draft-js'
import Editor from 'draft-js-plugins-editor'
import createMathjaxPlugin from 'draft-js-mathjax-plugin'

const mathjaxPlugin = createMathjaxPlugin(/* optional configuration object */)

const plugins = [
  mathjaxPlugin,
]

export default class MyEditor extends Component {

  state = {
    editorState: EditorState.createEmpty(),
  }

  onChange = (editorState) => {
    this.setState({
      editorState,
    })
  }

  render() {
    return (
      <Editor
        editorState={this.state.editorState}
        onChange={this.onChange}
        plugins={plugins}
      />
    )
  }
}

Learn more draftjs-plugins

Optional configuration Object

  • macros: an object to define mathjax macros. Example:
 const mathjaxConfig = {
   macros: {
     bold: ['{\\bf #1}', 1],
   },
 }

see mathjax doc to find out how to define macros.

  • completion (default: 'auto'): 'none' | 'manual' | 'auto'.

If you choose manual, use ctrl-<space> to launch completion about the current tex command (if any).

Use (Shift)Tab to see each possible completion in turn.

  • script (default: 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js'):

url to load mathjax from the plugin

{                                                        
  jax: ['input/TeX', 'output/CommonHTML'],                                       
  TeX: {                                                                         
    extensions: ['autoload-all.js'],                                             
  },                                                                             
  messageStyles: 'none',                                                         
  showProcessingMessages: false,                                                 
  showMathMenu: false,                                                           
  showMathMenuMSIE: false,                                                       
  preview: 'none',                                                               
  delayStartupTypeset: true,                                                     
}

License

MIT

Keywords

FAQs

Package last updated on 09 May 2017

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc