Support for both htmlBody and original body

This commit is contained in:
okbel
2018-02-21 16:37:19 -03:00
parent 9cfa5b6a0f
commit bf1bae8999
11 changed files with 216 additions and 16 deletions
@@ -23,7 +23,8 @@ class CommentBox extends React.Component {
this.state = {
body: '',
loadingState: '',
// data: {@object} contains data that might be useful for plugins
data: {},
hooks: {
preSubmit: [],
postSubmit: [],
@@ -62,6 +63,7 @@ class CommentBox extends React.Component {
parent_id: parentId,
body: this.state.body,
tags: this.props.tags,
...this.state.data,
};
// Execute preSubmit Hooks
@@ -88,8 +90,14 @@ class CommentBox extends React.Component {
});
};
handleBodyChange = body => {
this.setState({ body });
handleBodyChange = (body, ...data) => {
this.setState(state => ({
body,
data: {
...state.data,
...data[0],
},
}));
};
registerHook = (hookType = '', hook = () => {}) => {
@@ -24,8 +24,8 @@ export default class DraftAreaContainer extends React.Component {
return `${STORAGE_PATH}_${this.props.id}`;
};
onChange = value => {
this.props.onChange && this.props.onChange(value);
onChange = (...args) => {
this.props.onChange && this.props.onChange(...args);
};
componentWillReceiveProps(nextProps) {