Skip to content
Next Next commit
fixed on order to support redux form
  • Loading branch information
Avidan Feldman committed Nov 22, 2016
commit 70652da251a78e998bc9a42fb936cda756e0d434
16 changes: 12 additions & 4 deletions lib/components/TinyMCE.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,25 @@ const TinyMCE = React.createClass({
},

componentWillReceiveProps(nextProps) {
if (!isEqual(this.props.config, nextProps.config)) {
this._init(nextProps.config, nextProps.content);
}
if (!isEqual(this.props.id, nextProps.id)) {
this.id = nextProps.id;
}
if (!isEqual(this.props.config, nextProps.config) || !isEqual(this.props.id, nextProps.id)) {
this._init(clone(nextProps.config), nextProps.content);
return;
}

const editor = tinymce.EditorManager.get(this.id);
if (!isEqual(editor.getContent({format: 'html'}), nextProps.content)) {
editor.setContent(nextProps.content);

editor.selection.select(editor.getBody(), true);
editor.selection.collapse(false);
}
},

shouldComponentUpdate(nextProps) {
return (
!isEqual(this.props.content, nextProps.content) ||
!isEqual(this.props.config, nextProps.config)
);
},
Expand Down