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';
|
import { switchVisualMode } from '../../actions/editor';
|
||||||
|
|
||||||
class MarkdownControl extends React.Component {
|
class MarkdownControl extends React.Component {
|
||||||
constructor(props, context) {
|
|
||||||
super(props, context);
|
|
||||||
this.useVisualEditor = this.useVisualEditor.bind(this);
|
|
||||||
this.useRawEditor = this.useRawEditor.bind(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
componentWillMount() {
|
componentWillMount() {
|
||||||
this.useRawEditor();
|
this.useRawEditor();
|
||||||
processEditorPlugins(registry.getEditorComponents());
|
processEditorPlugins(registry.getEditorComponents());
|
||||||
}
|
}
|
||||||
|
|
||||||
useVisualEditor() {
|
useVisualEditor = () => {
|
||||||
this.props.switchVisualMode(true);
|
this.props.switchVisualMode(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
useRawEditor() {
|
useRawEditor = () => {
|
||||||
this.props.switchVisualMode(false);
|
this.props.switchVisualMode(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
renderEditor() {
|
render() {
|
||||||
const { editor, onChange, onAddMedia, getMedia, value } = this.props;
|
const { editor, onChange, onAddMedia, getMedia, value } = this.props;
|
||||||
if (editor.get('useVisualMode')) {
|
if (editor.get('useVisualMode')) {
|
||||||
return (
|
return (
|
||||||
@ -55,15 +50,6 @@ class MarkdownControl extends React.Component {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
|
||||||
return (
|
|
||||||
<div>
|
|
||||||
|
|
||||||
{this.renderEditor()}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MarkdownControl.propTypes = {
|
MarkdownControl.propTypes = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user