client/src/components/SlateEditor/index.js
changeset 194 d19ba6045e82
parent 191 3f71ad81a5a9
child 195 669b563563f5
equal deleted inserted replaced
193:99e342f9fb0c 194:d19ba6045e82
     2 import Plain from 'slate-plain-serializer';
     2 import Plain from 'slate-plain-serializer';
     3 import { Editor } from 'slate-react';
     3 import { Editor } from 'slate-react';
     4 import React from 'react';
     4 import React from 'react';
     5 import { withNamespaces } from 'react-i18next';
     5 import { withNamespaces } from 'react-i18next';
     6 import { connect } from 'react-redux';
     6 import { connect } from 'react-redux';
     7 import * as R from 'ramda';
       
     8 import HtmlSerializer from './HtmlSerializer';
     7 import HtmlSerializer from './HtmlSerializer';
     9 import { now } from '../../utils';
     8 import { now } from '../../utils';
    10 import Toolbar from './Toolbar';
     9 import Toolbar from './Toolbar';
    11 import { getAutoSubmit } from '../../selectors/authSelectors';
    10 import { getAutoSubmit } from '../../selectors/authSelectors';
    12 
    11 
    52    *
    51    *
    53    * @param {Change} change
    52    * @param {Change} change
    54    */
    53    */
    55 
    54 
    56   onChange = ({value, operations}) => {
    55   onChange = ({value, operations}) => {
    57 
       
    58     const oldState = R.clone(this.state);
       
    59 
    56 
    60     const newState = {
    57     const newState = {
    61       value
    58       value
    62     };
    59     };
    63 
    60 
    73       return false;
    70       return false;
    74     });
    71     });
    75 
    72 
    76     this.setState(newState, () => {
    73     this.setState(newState, () => {
    77       if (typeof this.props.onChange === 'function') {
    74       if (typeof this.props.onChange === 'function') {
    78         this.props.onChange(R.clone(this.state), oldState, {value, operations});
    75         this.props.onChange(this.state, {value, operations});
    79       }
    76       }
    80     })
    77     })
    81   }
    78   }
    82 
    79 
    83 
    80