Refactored MarkdownControl to not use constructor and simplified render method
This commit is contained in:
parent
107e8f7104
commit
4020dfc912
@ -7,26 +7,21 @@ import { connect } from 'react-redux';
|
||||
import { switchVisualMode } from '../../actions/editor';
|
||||
|
||||
class MarkdownControl extends React.Component {
|
||||
constructor(props, context) {
|
||||
super(props, context);
|
||||
this.useVisualEditor = this.useVisualEditor.bind(this);
|
||||
this.useRawEditor = this.useRawEditor.bind(this);
|
||||
}
|
||||
|
||||
componentWillMount() {
|
||||
this.useRawEditor();
|
||||
processEditorPlugins(registry.getEditorComponents());
|
||||
}
|
||||
|
||||
useVisualEditor() {
|
||||
useVisualEditor = () => {
|
||||
this.props.switchVisualMode(true);
|
||||
}
|
||||
|
||||
useRawEditor() {
|
||||
useRawEditor = () => {
|
||||
this.props.switchVisualMode(false);
|
||||
}
|
||||
|
||||
renderEditor() {
|
||||
render() {
|
||||
const { editor, onChange, onAddMedia, getMedia, value } = this.props;
|
||||
if (editor.get('useVisualMode')) {
|
||||
return (
|
||||
@ -55,15 +50,6 @@ class MarkdownControl extends React.Component {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
|
||||
{this.renderEditor()}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
MarkdownControl.propTypes = {
|
||||
|
Loading…
x
Reference in New Issue
Block a user