support autocomplete replacing text with multiple parts
and append ": " to user pills
This commit is contained in:
parent
599fccd9ce
commit
2ff2ff0e75
2 changed files with 19 additions and 19 deletions
|
@ -27,8 +27,7 @@ export default class AutocompleteWrapperModel {
|
|||
onEscape(e) {
|
||||
this._getAutocompleterComponent().onEscape(e);
|
||||
this._updateCallback({
|
||||
replacePart: this._partCreator.plain(this._queryPart.text),
|
||||
caretOffset: this._queryOffset,
|
||||
replaceParts: [this._partCreator.plain(this._queryPart.text)],
|
||||
close: true,
|
||||
});
|
||||
}
|
||||
|
@ -70,26 +69,24 @@ export default class AutocompleteWrapperModel {
|
|||
// cache the typed value and caret here
|
||||
// so we can restore it in onComponentSelectionChange when the value is undefined (meaning it should be the typed text)
|
||||
this._queryPart = part;
|
||||
this._queryOffset = offset;
|
||||
return this._updateQuery(part.text);
|
||||
}
|
||||
|
||||
onComponentSelectionChange(completion) {
|
||||
if (!completion) {
|
||||
this._updateCallback({
|
||||
replacePart: this._queryPart,
|
||||
caretOffset: this._queryOffset,
|
||||
replaceParts: [this._queryPart],
|
||||
});
|
||||
} else {
|
||||
this._updateCallback({
|
||||
replacePart: this._partForCompletion(completion),
|
||||
replaceParts: this._partForCompletion(completion),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
onComponentConfirm(completion) {
|
||||
this._updateCallback({
|
||||
replacePart: this._partForCompletion(completion),
|
||||
replaceParts: this._partForCompletion(completion),
|
||||
close: true,
|
||||
});
|
||||
}
|
||||
|
@ -101,16 +98,16 @@ export default class AutocompleteWrapperModel {
|
|||
switch (firstChr) {
|
||||
case "@": {
|
||||
if (completionId === "@room") {
|
||||
return this._partCreator.atRoomPill(completionId);
|
||||
return [this._partCreator.atRoomPill(completionId)];
|
||||
} else {
|
||||
return this._partCreator.userPill(text, completionId);
|
||||
return [this._partCreator.userPill(text, completionId), this._partCreator.plain(": ")];
|
||||
}
|
||||
}
|
||||
case "#":
|
||||
return this._partCreator.roomPill(completionId);
|
||||
return [this._partCreator.roomPill(completionId)];
|
||||
// used for emoji and command completion replacement
|
||||
default:
|
||||
return this._partCreator.plain(text);
|
||||
return [this._partCreator.plain(text)];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue