instructure-react / react-tinymce

React TinyMCE component
181 stars 110 forks source link

Setting textarea name property #35

Open noirwave opened 8 years ago

noirwave commented 8 years ago

Hi. How can I set "name" property to textarea component with <TinyMCE/> component? I can set "content", "config" and what about the "name"? Thanks.

bw2 commented 7 years ago

Work-around using componentDidMount and document.getElementById

class RichTextEditor extends React.Component {
  static propTypes = {
    id: React.PropTypes.string.isRequired,
  }

  componentDidMount() {
    this.textAreaElement = document.getElementById(this.props.id)
    this.textAreaElement.name = this.props.id
  }

  render() {
    return <TinyMCE
      id={this.props.id}
      config={{
        forced_root_block: 'div',
        height: '500px',
        skin: 'lightgray',
        plugins: 'advlist autolink lists link image wordcount save contextmenu directionality textcolor colorpicker',
        menu: {},
        toolbar: 'bold italic underline | forecolor | bullist numlist outdent indent | fontselect',
        statusbar: false,
      }}
    />
  }
}

export default RichTextEditor