You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-11-08 21:42:24 +03:00
Fix cursor bug, persist editor mode & rte default
This commit is contained in:
@@ -74,8 +74,14 @@ export default class MessageComposerInput extends React.Component {
|
|||||||
this.handleKeyCommand = this.handleKeyCommand.bind(this);
|
this.handleKeyCommand = this.handleKeyCommand.bind(this);
|
||||||
this.onChange = this.onChange.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 = {
|
this.state = {
|
||||||
isRichtextEnabled: false, // TODO enable by default when RTE is mature enough
|
isRichtextEnabled: isRichtextEnabled,
|
||||||
editorState: null
|
editorState: null
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -104,11 +110,14 @@ export default class MessageComposerInput extends React.Component {
|
|||||||
RichText.getScopedMDDecorators(this.props),
|
RichText.getScopedMDDecorators(this.props),
|
||||||
compositeDecorator = new CompositeDecorator(decorators);
|
compositeDecorator = new CompositeDecorator(decorators);
|
||||||
|
|
||||||
|
let editorState = null;
|
||||||
if (contentState) {
|
if (contentState) {
|
||||||
return EditorState.createWithContent(contentState, compositeDecorator);
|
editorState = EditorState.createWithContent(contentState, compositeDecorator);
|
||||||
} else {
|
} else {
|
||||||
return EditorState.createEmpty(compositeDecorator);
|
editorState = EditorState.createEmpty(compositeDecorator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return EditorState.moveFocusToEnd(editorState);
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillMount() {
|
componentWillMount() {
|
||||||
@@ -359,6 +368,8 @@ export default class MessageComposerInput extends React.Component {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
window.localStorage.setItem('mx_editor_rte_enabled', enabled);
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
isRichtextEnabled: enabled
|
isRichtextEnabled: enabled
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user