Autocomplete based on names and aliases
This commit is contained in:
parent
489e8992cf
commit
0afb960150
|
@ -253,6 +253,7 @@
|
||||||
this.input.filter('[data-supports-slash-commands="true"]').atwho({
|
this.input.filter('[data-supports-slash-commands="true"]').atwho({
|
||||||
at: '/',
|
at: '/',
|
||||||
alias: 'commands',
|
alias: 'commands',
|
||||||
|
searchKey: 'search',
|
||||||
displayTpl: function(value) {
|
displayTpl: function(value) {
|
||||||
var tpl = '<li>/${name}';
|
var tpl = '<li>/${name}';
|
||||||
if (value.aliases.length > 0) {
|
if (value.aliases.length > 0) {
|
||||||
|
@ -283,6 +284,21 @@
|
||||||
sorter: this.DefaultOptions.sorter,
|
sorter: this.DefaultOptions.sorter,
|
||||||
filter: this.DefaultOptions.filter,
|
filter: this.DefaultOptions.filter,
|
||||||
beforeInsert: this.DefaultOptions.beforeInsert,
|
beforeInsert: this.DefaultOptions.beforeInsert,
|
||||||
|
beforeSave: function(commands) {
|
||||||
|
return $.map(commands, function(c) {
|
||||||
|
var search = c.name;
|
||||||
|
if (c.aliases.length > 0) {
|
||||||
|
search = search + " " + c.aliases.join(" ");
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
name: c.name,
|
||||||
|
aliases: c.aliases,
|
||||||
|
params: c.params,
|
||||||
|
description: c.description,
|
||||||
|
search: search
|
||||||
|
};
|
||||||
|
});
|
||||||
|
},
|
||||||
matcher: function(flag, subtext, should_startWithSpace, acceptSpaceBar) {
|
matcher: function(flag, subtext, should_startWithSpace, acceptSpaceBar) {
|
||||||
var regexp = /(?:^|\n)\/([A-Za-z_]*)$/gi
|
var regexp = /(?:^|\n)\/([A-Za-z_]*)$/gi
|
||||||
var match = regexp.exec(subtext);
|
var match = regexp.exec(subtext);
|
||||||
|
|
Loading…
Reference in New Issue