0.1.0-2 • Published 7 years ago

mx-dynamic-semantic v0.1.0-2

Weekly downloads
4
License
MIT
Repository
github
Last release
7 years ago

react-wysiwyg

npm version Download Count

Simple React component for a rich editor text and the conversion to render HTML

Install

npm install mx-react-wysiwyg --save

Example

import { Wysiwyg, ConvertToHTML } from "mx-react-wysiwyg";
import 'semantic-ui-css/semantic.min.css';

class App extends Component {

  constructor(){
    super()
    this.state = {
      content: null
    }
  }

  updateValue(content){
    this.setState({content})
  }

  render {

    const { content } = this.state

    return (
      <div>
      <Wysiwyg
        onChange={this.updateValue.bind(this)}
        value={this.state.value}
      />

      <ConvertToHTML
        html={this.state.value}
      />
      </div>
    );
  }
}

Props

Wysiwyg props

FormatRequiredWhat it does ?
onChange{function}YESTakes a function that return the content of the editor
valueObjectNOYou can make Wysiwyg a controlled component by giving it a draft-js map value
boldBoolNOdefault to true pass it to false to disable bold style
underlineBoolNOdefault to true pass it to false to disable underline style
italicBoolNOdefault to true pass it to false to disable italic style
h1, h2, h3, h4, h5, h6BoolNOdefault to true pass it to false to disable h1, etc... style
blockQuoteBoolNOdefault to true pass it to false to disable blockquote style
listBoolNOdefault to true pass it to false to disable list style
numberedListBoolNOdefault to true pass it to false to disable list numbered style
codeBoolNOdefault to true pass it to false to disable code style

ConvertToHTML props

FormatRequiredWhat it does ?
htmlObjectYESObject from the Wysiwyg editor

Contributors

  • Francois Aubeut (@MeXaaR)

MIT Licensed