mirror of
https://github.com/element-hq/element-web
synced 2024-11-28 12:28:50 +03:00
put caret after replaced part if no caretOffset is given by autocomplete
This commit is contained in:
parent
1a577eed11
commit
2c3453d307
2 changed files with 7 additions and 4 deletions
|
@ -28,7 +28,7 @@ export default class AutocompleteWrapperModel {
|
||||||
this._getAutocompleterComponent().onEscape(e);
|
this._getAutocompleterComponent().onEscape(e);
|
||||||
this._updateCallback({
|
this._updateCallback({
|
||||||
replacePart: new PlainPart(this._queryPart.text),
|
replacePart: new PlainPart(this._queryPart.text),
|
||||||
replaceCaret: this._queryOffset,
|
caretOffset: this._queryOffset,
|
||||||
close: true,
|
close: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ export default class AutocompleteWrapperModel {
|
||||||
if (!completion) {
|
if (!completion) {
|
||||||
this._updateCallback({
|
this._updateCallback({
|
||||||
replacePart: this._queryPart,
|
replacePart: this._queryPart,
|
||||||
replaceCaret: this._queryOffset,
|
caretOffset: this._queryOffset,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this._updateCallback({
|
this._updateCallback({
|
||||||
|
|
|
@ -123,7 +123,7 @@ export default class EditorModel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_onAutoComplete = ({replacePart, replaceCaret, close}) => {
|
_onAutoComplete = ({replacePart, caretOffset, close}) => {
|
||||||
if (replacePart) {
|
if (replacePart) {
|
||||||
this._replacePart(this._autoCompletePartIdx, replacePart);
|
this._replacePart(this._autoCompletePartIdx, replacePart);
|
||||||
}
|
}
|
||||||
|
@ -132,7 +132,10 @@ export default class EditorModel {
|
||||||
this._autoComplete = null;
|
this._autoComplete = null;
|
||||||
this._autoCompletePartIdx = null;
|
this._autoCompletePartIdx = null;
|
||||||
}
|
}
|
||||||
this._updateCallback(new DocumentPosition(index, replaceCaret));
|
if (caretOffset === undefined) {
|
||||||
|
caretOffset = replacePart.text.length;
|
||||||
|
}
|
||||||
|
this._updateCallback(new DocumentPosition(index, caretOffset));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in a new issue