mirror of
https://github.com/wassname/talk.git
synced 2026-07-25 13:30:59 +08:00
hook to clear text after submiting a comment
This commit is contained in:
@@ -49,6 +49,6 @@ export default class CheckSpamHook extends React.Component {
|
||||
|
||||
CheckSpamHook.propTypes = {
|
||||
notify: PropTypes.func.isRequired,
|
||||
registerHook: PropTypes.func.isRequired,
|
||||
unregisterHook: PropTypes.func.isRequired,
|
||||
registerHook: PropTypes.func,
|
||||
unregisterHook: PropTypes.func,
|
||||
};
|
||||
|
||||
@@ -40,6 +40,18 @@ class Editor extends React.Component {
|
||||
if (this.props.comment && this.props.comment.richTextBody) {
|
||||
this.ref.content.innerHTML = this.props.comment.richTextBody;
|
||||
}
|
||||
|
||||
this.clearInputHook = this.props.registerHook(
|
||||
'postSubmit',
|
||||
(res, handleBodyChange) => {
|
||||
this.ref.content.innerHTML = '';
|
||||
handleBodyChange('', { richTextBody: '' });
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
this.props.unregisterHook(this.clearInputHook);
|
||||
}
|
||||
|
||||
render() {
|
||||
@@ -85,6 +97,8 @@ Editor.propTypes = {
|
||||
comment: PropTypes.object,
|
||||
classNames: PropTypes.object,
|
||||
actions: PropTypes.array,
|
||||
registerHook: PropTypes.func,
|
||||
unregisterHook: PropTypes.func,
|
||||
};
|
||||
|
||||
export default Editor;
|
||||
|
||||
Reference in New Issue
Block a user