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

Fix cursor bug, persist editor mode & rte default #308

Merged
merged 1 commit into from
Jun 14, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions src/components/views/rooms/MessageComposerInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,14 @@ export default class MessageComposerInput extends React.Component {
this.handleKeyCommand = this.handleKeyCommand.bind(this);
this.onChange = this.onChange.bind(this);

let isRichtextEnabled = window.localStorage.getItem('mx_editor_rte_enabled');
if(isRichtextEnabled == null) {
isRichtextEnabled = 'true';
}
isRichtextEnabled = isRichtextEnabled === 'true';

this.state = {
isRichtextEnabled: false, // TODO enable by default when RTE is mature enough
isRichtextEnabled: isRichtextEnabled,
editorState: null
};

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

let editorState = null;
if (contentState) {
return EditorState.createWithContent(contentState, compositeDecorator);
editorState = EditorState.createWithContent(contentState, compositeDecorator);
} else {
return EditorState.createEmpty(compositeDecorator);
editorState = EditorState.createEmpty(compositeDecorator);
}

return EditorState.moveFocusToEnd(editorState);
}

componentWillMount() {
Expand Down Expand Up @@ -359,6 +368,8 @@ export default class MessageComposerInput extends React.Component {
});
}

window.localStorage.setItem('mx_editor_rte_enabled', enabled);

this.setState({
isRichtextEnabled: enabled
});
Expand Down