You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-11-20 16:22:28 +03:00
pass caret to history manager upon initial render
otherwise caret is put at editor start when undoing last step
This commit is contained in:
@@ -315,9 +315,7 @@ export default class MessageEditor extends React.Component {
|
|||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this._createEditorModel();
|
this._createEditorModel();
|
||||||
// initial render of model
|
// initial render of model
|
||||||
this._updateEditorState();
|
this._updateEditorState(this._getInitialCaretPosition());
|
||||||
// initial caret position
|
|
||||||
this._initializeCaret();
|
|
||||||
// attach input listener by hand so React doesn't proxy the events,
|
// attach input listener by hand so React doesn't proxy the events,
|
||||||
// as the proxied event doesn't support inputType, which we need.
|
// as the proxied event doesn't support inputType, which we need.
|
||||||
this._editorRef.addEventListener("input", this._onInput, true);
|
this._editorRef.addEventListener("input", this._onInput, true);
|
||||||
@@ -350,7 +348,7 @@ export default class MessageEditor extends React.Component {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
_initializeCaret() {
|
_getInitialCaretPosition() {
|
||||||
const {editState} = this.props;
|
const {editState} = this.props;
|
||||||
let caretPosition;
|
let caretPosition;
|
||||||
if (editState.hasEditorState()) {
|
if (editState.hasEditorState()) {
|
||||||
@@ -362,7 +360,7 @@ export default class MessageEditor extends React.Component {
|
|||||||
// otherwise, set it at the end
|
// otherwise, set it at the end
|
||||||
caretPosition = this.model.getPositionAtEnd();
|
caretPosition = this.model.getPositionAtEnd();
|
||||||
}
|
}
|
||||||
setCaretPosition(this._editorRef, this.model, caretPosition);
|
return caretPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|||||||
Reference in New Issue
Block a user