Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 3f1b57b

Browse files
committed
Fix cursor bug, persist editor mode & rte default
1 parent 5199cd0 commit 3f1b57b

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/components/views/rooms/MessageComposerInput.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,14 @@ export default class MessageComposerInput extends React.Component {
7474
this.handleKeyCommand = this.handleKeyCommand.bind(this);
7575
this.onChange = this.onChange.bind(this);
7676

77+
let isRichtextEnabled = window.localStorage.getItem('mx_editor_rte_enabled');
78+
if(isRichtextEnabled == null) {
79+
isRichtextEnabled = 'true';
80+
}
81+
isRichtextEnabled = isRichtextEnabled === 'true';
82+
7783
this.state = {
78-
isRichtextEnabled: false, // TODO enable by default when RTE is mature enough
84+
isRichtextEnabled: isRichtextEnabled,
7985
editorState: null
8086
};
8187

@@ -104,11 +110,14 @@ export default class MessageComposerInput extends React.Component {
104110
RichText.getScopedMDDecorators(this.props),
105111
compositeDecorator = new CompositeDecorator(decorators);
106112

113+
let editorState = null;
107114
if (contentState) {
108-
return EditorState.createWithContent(contentState, compositeDecorator);
115+
editorState = EditorState.createWithContent(contentState, compositeDecorator);
109116
} else {
110-
return EditorState.createEmpty(compositeDecorator);
117+
editorState = EditorState.createEmpty(compositeDecorator);
111118
}
119+
120+
return EditorState.moveFocusToEnd(editorState);
112121
}
113122

114123
componentWillMount() {
@@ -359,6 +368,8 @@ export default class MessageComposerInput extends React.Component {
359368
});
360369
}
361370

371+
window.localStorage.setItem('mx_editor_rte_enabled', enabled);
372+
362373
this.setState({
363374
isRichtextEnabled: enabled
364375
});

0 commit comments

Comments
 (0)