hook handler

This commit is contained in:
okbel
2018-03-01 19:59:02 -03:00
parent bc273d16f7
commit 11b98370b6
2 changed files with 13 additions and 11 deletions
@@ -11,7 +11,7 @@ class Editor extends React.Component {
handleRef = ref => (this.ref = ref);
componentDidMount() {
const { onChange, actions, classNames } = this.props;
const { onChange, actions, classNames, isReply } = this.props;
init({
element: this.ref,
@@ -37,17 +37,19 @@ class Editor extends React.Component {
});
// To edit comments and have the previous html comment
if (this.props.comment && this.props.comment.richTextBody) {
if (this.props.comment && this.props.comment.richTextBody && !isReply) {
this.ref.content.innerHTML = this.props.comment.richTextBody;
}
this.clearInputHook = this.props.registerHook(
'postSubmit',
(res, handleBodyChange) => {
this.ref.content.innerHTML = '';
handleBodyChange('', { richTextBody: '' });
}
);
if (this.props.registerHook) {
this.clearInputHook = this.props.registerHook(
'postSubmit',
(res, handleBodyChange) => {
this.ref.content.innerHTML = '';
handleBodyChange('', { richTextBody: '' });
}
);
}
}
componentWillUnmount() {
@@ -49,6 +49,6 @@ export default class CheckToxicityHook extends React.Component {
CheckToxicityHook.propTypes = {
notify: PropTypes.func.isRequired,
registerHook: PropTypes.func.isRequired,
unregisterHook: PropTypes.func.isRequired,
registerHook: PropTypes.func,
unregisterHook: PropTypes.func,
};