Remove duplicated conversion from enableRichText
`enableRichText` would convert the editor state between rich and md versions explicitly, but then it would also call `createEditorState`, which can do the same thing. This removes the duplication, and also supplies the right arguments to `createEditorState` so it can do its work correctly.
This commit is contained in:
parent
a02508023b
commit
f5c477bbc8
1 changed files with 5 additions and 8 deletions
|
@ -686,17 +686,14 @@ export default class MessageComposerInput extends React.Component {
|
||||||
enableRichtext(enabled: boolean) {
|
enableRichtext(enabled: boolean) {
|
||||||
if (enabled === this.state.isRichTextEnabled) return;
|
if (enabled === this.state.isRichTextEnabled) return;
|
||||||
|
|
||||||
let editorState = null;
|
|
||||||
if (enabled) {
|
|
||||||
editorState = this.mdToRichEditorState(this.state.editorState);
|
|
||||||
} else {
|
|
||||||
editorState = this.richToMdEditorState(this.state.editorState);
|
|
||||||
}
|
|
||||||
|
|
||||||
Analytics.setRichtextMode(enabled);
|
Analytics.setRichtextMode(enabled);
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
editorState: this.createEditorState(enabled, editorState),
|
editorState: this.createEditorState(
|
||||||
|
enabled,
|
||||||
|
this.state.editorState,
|
||||||
|
this.state.isRichTextEnabled,
|
||||||
|
),
|
||||||
isRichTextEnabled: enabled,
|
isRichTextEnabled: enabled,
|
||||||
}, ()=>{
|
}, ()=>{
|
||||||
this._editor.focus();
|
this._editor.focus();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue