client/src/components/SlateEditor/index.js
changeset 169 f98efa1bddd1
parent 168 ea92f4fe783d
child 170 7da1d5137b0b
equal deleted inserted replaced
168:ea92f4fe783d 169:f98efa1bddd1
   397 
   397 
   398   onKeyDown = (e, change) => {
   398   onKeyDown = (e, change) => {
   399 
   399 
   400     const {value} = this.state;
   400     const {value} = this.state;
   401 
   401 
   402     // if (e.key === 'Enter' && value.document.text === '') {
       
   403     //   change.removeChild()
       
   404     // }
       
   405 
       
   406     if (e.key === 'Enter' && value.document.text !== '') {
   402     if (e.key === 'Enter' && value.document.text !== '') {
   407       this.setState({enterKeyValue: 1})
   403       this.setState({enterKeyValue: 1})
   408     }
   404     }
   409 
   405 
   410     if (e.key !== 'Enter') {
   406     if (e.key !== 'Enter') {
   412         enterKeyValue: 0,
   408         enterKeyValue: 0,
   413       })
   409       })
   414 
   410 
   415     }
   411     }
   416 
   412 
       
   413     //TODO review the double enter case.
   417     if (e.key === 'Enter' && !this.props.isChecked && this.state.enterKeyValue === 1 && typeof this.props.onEnterKeyDown === 'function') {
   414     if (e.key === 'Enter' && !this.props.isChecked && this.state.enterKeyValue === 1 && typeof this.props.onEnterKeyDown === 'function') {
   418       e.preventDefault();
   415       e.preventDefault();
   419       this.props.onEnterKeyDown();
   416       this.props.onEnterKeyDown();
   420       this.setState({
   417       this.setState({
   421         enterKeyValue: 0,
   418         enterKeyValue: 0,