You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-11-07 10:46:24 +03:00
Implement tab-complete for slash commands
This needed a new interface function `getOverrideSuffix()` so we didn't suffix commands at the start with ": ". All seems to work.
This commit is contained in:
@@ -42,6 +42,14 @@ class Entry {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {?string} The suffix to override whatever the default is, or null to
|
||||
* not do this.
|
||||
*/
|
||||
getOverrideSuffix() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when this entry is clicked.
|
||||
*/
|
||||
@@ -50,6 +58,26 @@ class Entry {
|
||||
}
|
||||
}
|
||||
|
||||
class CommandEntry extends Entry {
|
||||
constructor(command) {
|
||||
super(command);
|
||||
}
|
||||
|
||||
getKey() {
|
||||
return this.getText();
|
||||
}
|
||||
|
||||
getOverrideSuffix() {
|
||||
return " "; // force a space after the command.
|
||||
}
|
||||
}
|
||||
|
||||
CommandEntry.fromStrings = function(commandArray) {
|
||||
return commandArray.map(function(cmd) {
|
||||
return new CommandEntry(cmd);
|
||||
});
|
||||
}
|
||||
|
||||
class MemberEntry extends Entry {
|
||||
constructor(member) {
|
||||
super(member.name || member.userId);
|
||||
@@ -99,3 +127,4 @@ MemberEntry.fromMemberList = function(members) {
|
||||
|
||||
module.exports.Entry = Entry;
|
||||
module.exports.MemberEntry = MemberEntry;
|
||||
module.exports.CommandEntry = CommandEntry;
|
||||
|
||||
Reference in New Issue
Block a user