mirror of
https://github.com/gitbucket/gitbucket.git
synced 2026-05-07 20:07:30 +02:00
Add user name completion in the textarea
This commit is contained in:
@@ -9,6 +9,9 @@
|
||||
<script>
|
||||
$(function(){
|
||||
var emojis = @Html(gitbucket.core.util.EmojiUtil.emojis.map("\"" + _ + "\"").mkString("[", ", ", "]"));
|
||||
var users = [];
|
||||
|
||||
$.get('@path/_user/proposals', { query: '' }, function (data) { users = data.options; });
|
||||
|
||||
$('#@textareaId').textcomplete([
|
||||
{ // emoji strategy
|
||||
@@ -26,21 +29,21 @@ $(function(){
|
||||
return ':' + value + ': ';
|
||||
},
|
||||
index: 1
|
||||
}//,
|
||||
// { // tech companies
|
||||
// id: 'tech-companies',
|
||||
// words: ['apple', 'google', 'facebook', 'github'],
|
||||
// match: /\b(\w{2,})$/,
|
||||
// search: function (term, callback) {
|
||||
// callback($.map(this.words, function (word) {
|
||||
// return word.indexOf(term) === 0 ? word : null;
|
||||
// }));
|
||||
// },
|
||||
// index: 1,
|
||||
// replace: function (word) {
|
||||
// return word + ' ';
|
||||
// }
|
||||
// }
|
||||
},
|
||||
{ // users
|
||||
id: 'user',
|
||||
//words: users,
|
||||
match: /\B@@([\-+\w]*)$/,
|
||||
search: function (term, callback) {
|
||||
callback($.map(users, function (word) {
|
||||
return word.indexOf(term) === 0 ? word : null;
|
||||
}));
|
||||
},
|
||||
index: 1,
|
||||
replace: function (word) {
|
||||
return '@@' + word + ' ';
|
||||
}
|
||||
}
|
||||
], {
|
||||
onKeydown: function (e, commands) {
|
||||
if (e.ctrlKey && e.keyCode === 74) { // CTRL-J
|
||||
|
||||
Reference in New Issue
Block a user