Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
aa607bb3bf
@ -2291,11 +2291,8 @@ angular.module('myApp.controllers', ['myApp.i18n'])
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
done[userID] = true
|
done[userID] = true
|
||||||
var user = AppUsersManager.getUser(userID)
|
mentionUsers.push(AppUsersManager.getUser(userID))
|
||||||
if (user.username) {
|
SearchIndexManager.indexObject(userID, AppUsersManager.getUserSearchText(userID), mentionIndex)
|
||||||
mentionUsers.push(user)
|
|
||||||
SearchIndexManager.indexObject(user.id, AppUsersManager.getUserSearchText(user.id), mentionIndex)
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
safeReplaceObject($scope.mentions, {
|
safeReplaceObject($scope.mentions, {
|
||||||
|
@ -1227,7 +1227,7 @@ angular.module('izhukov.utils', [])
|
|||||||
var soundcloudRegExp = /^https?:\/\/(?:soundcloud\.com|snd\.sc)\/([a-zA-Z0-9%\-\_]+)\/([a-zA-Z0-9%\-\_]+)/i
|
var soundcloudRegExp = /^https?:\/\/(?:soundcloud\.com|snd\.sc)\/([a-zA-Z0-9%\-\_]+)\/([a-zA-Z0-9%\-\_]+)/i
|
||||||
var spotifyRegExp = /(https?:\/\/(open\.spotify\.com|play\.spotify\.com|spoti\.fi)\/(.+)|spotify:(.+))/i
|
var spotifyRegExp = /(https?:\/\/(open\.spotify\.com|play\.spotify\.com|spoti\.fi)\/(.+)|spotify:(.+))/i
|
||||||
|
|
||||||
var markdownRegExp = /(^|\s)(````?)([\s\S]+?)(````?)([\s\n\.,:?!;]|$)|(^|\s)`([^\n]+?)`([\s\.,:?!;]|$)/
|
var markdownRegExp = /(^|\s)(````?)([\s\S]+?)(````?)([\s\n\.,:?!;]|$)|(^|\s)`([^\n]+?)`([\s\.,:?!;]|$)|@(\d+)\s*\((.+?)\)/
|
||||||
|
|
||||||
var siteHashtags = {
|
var siteHashtags = {
|
||||||
Telegram: 'tg://search_hashtag?hashtag={1}',
|
Telegram: 'tg://search_hashtag?hashtag={1}',
|
||||||
@ -1391,7 +1391,7 @@ angular.module('izhukov.utils', [])
|
|||||||
}
|
}
|
||||||
|
|
||||||
function parseMarkdown (text, entities) {
|
function parseMarkdown (text, entities) {
|
||||||
if (text.indexOf('`') == -1) {
|
if (text.indexOf('`') == -1 && text.indexOf('@') == -1) {
|
||||||
return text.trim()
|
return text.trim()
|
||||||
}
|
}
|
||||||
var raw = text
|
var raw = text
|
||||||
@ -1403,7 +1403,7 @@ angular.module('izhukov.utils', [])
|
|||||||
matchIndex = rawOffset + match.index
|
matchIndex = rawOffset + match.index
|
||||||
newText.push(raw.substr(0, match.index))
|
newText.push(raw.substr(0, match.index))
|
||||||
|
|
||||||
var text = (match[3] || match[7])
|
var text = (match[3] || match[7] || match[10])
|
||||||
rawOffset -= text.length
|
rawOffset -= text.length
|
||||||
text = text.replace(/^\s+|\s+$/g, '')
|
text = text.replace(/^\s+|\s+$/g, '')
|
||||||
rawOffset += text.length
|
rawOffset += text.length
|
||||||
@ -1424,7 +1424,7 @@ angular.module('izhukov.utils', [])
|
|||||||
length: text.length
|
length: text.length
|
||||||
})
|
})
|
||||||
rawOffset -= match[2].length + match[4].length
|
rawOffset -= match[2].length + match[4].length
|
||||||
} else { // code
|
} else if (match[7]) { // code
|
||||||
newText.push(match[6] + text + match[8])
|
newText.push(match[6] + text + match[8])
|
||||||
entities.push({
|
entities.push({
|
||||||
_: 'messageEntityCode',
|
_: 'messageEntityCode',
|
||||||
@ -1432,6 +1432,16 @@ angular.module('izhukov.utils', [])
|
|||||||
length: text.length
|
length: text.length
|
||||||
})
|
})
|
||||||
rawOffset -= 2
|
rawOffset -= 2
|
||||||
|
} else if (match[10]) { // custom mention
|
||||||
|
console.log(match);
|
||||||
|
newText.push(text)
|
||||||
|
entities.push({
|
||||||
|
_: 'messageEntityMentionName',
|
||||||
|
user_id: match[9],
|
||||||
|
offset: matchIndex,
|
||||||
|
length: text.length
|
||||||
|
})
|
||||||
|
rawOffset -= match[0] - text.length
|
||||||
}
|
}
|
||||||
raw = raw.substr(match.index + match[0].length)
|
raw = raw.substr(match.index + match[0].length)
|
||||||
rawOffset += match.index + match[0].length
|
rawOffset += match.index + match[0].length
|
||||||
@ -1446,6 +1456,8 @@ angular.module('izhukov.utils', [])
|
|||||||
if (!entities.length) {
|
if (!entities.length) {
|
||||||
newText = newText.trim()
|
newText = newText.trim()
|
||||||
}
|
}
|
||||||
|
console.warn(dT(), newText, entities);
|
||||||
|
// throw new Error(11);
|
||||||
return newText
|
return newText
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1584,6 +1596,21 @@ angular.module('izhukov.utils', [])
|
|||||||
)
|
)
|
||||||
break
|
break
|
||||||
|
|
||||||
|
case 'messageEntityMentionName':
|
||||||
|
if (!options.noLinks) {
|
||||||
|
skipEntity = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
var username = entityText.substr(1)
|
||||||
|
html.push(
|
||||||
|
'<a href="#/im?p=u',
|
||||||
|
encodeURIComponent(entity.user_id),
|
||||||
|
'">',
|
||||||
|
encodeEntities(entityText),
|
||||||
|
'</a>'
|
||||||
|
)
|
||||||
|
break
|
||||||
|
|
||||||
case 'messageEntityHashtag':
|
case 'messageEntityHashtag':
|
||||||
var contextUrl = !options.noLinks && siteHashtags[contextSite]
|
var contextUrl = !options.noLinks && siteHashtags[contextSite]
|
||||||
if (!contextUrl) {
|
if (!contextUrl) {
|
||||||
@ -1780,6 +1807,12 @@ angular.module('izhukov.utils', [])
|
|||||||
)
|
)
|
||||||
break
|
break
|
||||||
|
|
||||||
|
case 'messageEntityMentionName':
|
||||||
|
code.push(
|
||||||
|
'@', entity.user_id, ' (', entityText, ')'
|
||||||
|
)
|
||||||
|
break
|
||||||
|
|
||||||
default:
|
default:
|
||||||
skipEntity = true
|
skipEntity = true
|
||||||
}
|
}
|
||||||
|
@ -777,7 +777,7 @@ MessageComposer.prototype.setUpAutoComplete = function () {
|
|||||||
EmojiHelper.pushPopularEmoji(code)
|
EmojiHelper.pushPopularEmoji(code)
|
||||||
}
|
}
|
||||||
if (mention = target.attr('data-mention')) {
|
if (mention = target.attr('data-mention')) {
|
||||||
self.onMentionSelected(mention)
|
self.onMentionSelected(mention, target.attr('data-name'))
|
||||||
}
|
}
|
||||||
if (command = target.attr('data-command')) {
|
if (command = target.attr('data-command')) {
|
||||||
if (self.onCommandSelected) {
|
if (self.onCommandSelected) {
|
||||||
@ -903,7 +903,7 @@ MessageComposer.prototype.onKeyEvent = function (e) {
|
|||||||
return cancelEvent(e)
|
return cancelEvent(e)
|
||||||
}
|
}
|
||||||
if (mention = currentSel.attr('data-mention')) {
|
if (mention = currentSel.attr('data-mention')) {
|
||||||
this.onMentionSelected(mention)
|
this.onMentionSelected(mention, currentSel.attr('data-name'))
|
||||||
return cancelEvent(e)
|
return cancelEvent(e)
|
||||||
}
|
}
|
||||||
if (command = currentSel.attr('data-command')) {
|
if (command = currentSel.attr('data-command')) {
|
||||||
@ -1272,7 +1272,14 @@ MessageComposer.prototype.onMentionsUpdated = function (username) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageComposer.prototype.onMentionSelected = function (username) {
|
MessageComposer.prototype.onMentionSelected = function (username, firstName) {
|
||||||
|
var hasUsername = true;
|
||||||
|
if (username.charAt(0) == '#') {
|
||||||
|
hasUsername = false;
|
||||||
|
username = username.substr(1);
|
||||||
|
firstName = firstName.replace(/\(\)@/, '')
|
||||||
|
}
|
||||||
|
|
||||||
if (this.richTextareaEl) {
|
if (this.richTextareaEl) {
|
||||||
var textarea = this.richTextareaEl[0]
|
var textarea = this.richTextareaEl[0]
|
||||||
if (!this.isActive) {
|
if (!this.isActive) {
|
||||||
@ -1293,9 +1300,9 @@ MessageComposer.prototype.onMentionSelected = function (username) {
|
|||||||
} else {
|
} else {
|
||||||
newValuePrefix = prefix + '@' + username
|
newValuePrefix = prefix + '@' + username
|
||||||
}
|
}
|
||||||
textarea.value = newValue
|
|
||||||
|
|
||||||
var html
|
var html
|
||||||
|
if (hasUsername) {
|
||||||
if (suffix.length) {
|
if (suffix.length) {
|
||||||
this.selId = (this.selId || 0) + 1
|
this.selId = (this.selId || 0) + 1
|
||||||
html = this.getRichHtml(newValuePrefix) + ' <span id="composer_sel' + this.selId + '"></span>' + this.getRichHtml(suffix)
|
html = this.getRichHtml(newValuePrefix) + ' <span id="composer_sel' + this.selId + '"></span>' + this.getRichHtml(suffix)
|
||||||
@ -1306,7 +1313,13 @@ MessageComposer.prototype.onMentionSelected = function (username) {
|
|||||||
this.richTextareaEl.html(html)
|
this.richTextareaEl.html(html)
|
||||||
setRichFocus(textarea)
|
setRichFocus(textarea)
|
||||||
}
|
}
|
||||||
}else {
|
} else {
|
||||||
|
this.selId = (this.selId || 0) + 1
|
||||||
|
html = this.getRichHtml(newValuePrefix) + ' (<span id="composer_sel' + this.selId + '">' + encodeEntities(firstName) + '</span>) ' + this.getRichHtml(suffix)
|
||||||
|
this.richTextareaEl.html(html)
|
||||||
|
setRichFocus(textarea, $('#composer_sel' + this.selId)[0], true)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
var textarea = this.textareaEl[0]
|
var textarea = this.textareaEl[0]
|
||||||
var fullValue = textarea.value
|
var fullValue = textarea.value
|
||||||
var pos = this.isActive ? getFieldSelection(textarea) : fullValue.length
|
var pos = this.isActive ? getFieldSelection(textarea) : fullValue.length
|
||||||
@ -1314,15 +1327,26 @@ MessageComposer.prototype.onMentionSelected = function (username) {
|
|||||||
var prefix = fullValue.substr(0, pos)
|
var prefix = fullValue.substr(0, pos)
|
||||||
var matches = prefix.match(/@([A-Za-z0-9\-\+\*_]*)$/)
|
var matches = prefix.match(/@([A-Za-z0-9\-\+\*_]*)$/)
|
||||||
|
|
||||||
|
var newValuePrefix
|
||||||
|
var newValue
|
||||||
|
var newPos
|
||||||
|
var newPosTo
|
||||||
if (matches && matches[0]) {
|
if (matches && matches[0]) {
|
||||||
var newValue = prefix.substr(0, matches.index) + '@' + username + ' ' + suffix
|
newValuePrefix = prefix.substr(0, matches.index) + '@' + username
|
||||||
var newPos = matches.index + username.length + 2
|
|
||||||
} else {
|
} else {
|
||||||
var newValue = prefix + ':' + username + ': ' + suffix
|
newValuePrefix = prefix + '@' + username
|
||||||
var newPos = prefix.length + username.length + 2
|
}
|
||||||
|
|
||||||
|
if (hasUsername) {
|
||||||
|
newValue = newValuePrefix + '@' + username + ' ' + suffix
|
||||||
|
newPos = matches.index + username.length + 2
|
||||||
|
} else {
|
||||||
|
newValue = newValuePrefix + '@' + username + ' (' + firstName + ') ' + suffix
|
||||||
|
newPos = matches.index + username.length + 2
|
||||||
|
newPosTo = newPos + firstName.length
|
||||||
}
|
}
|
||||||
textarea.value = newValue
|
textarea.value = newValue
|
||||||
setFieldSelection(textarea, newPos)
|
setFieldSelection(textarea, newPos, newPosTo)
|
||||||
}
|
}
|
||||||
|
|
||||||
this.hideSuggestions()
|
this.hideSuggestions()
|
||||||
|
@ -1258,6 +1258,17 @@ angular.module('myApp.services')
|
|||||||
if (!options.viaBotID) {
|
if (!options.viaBotID) {
|
||||||
text = RichTextProcessor.parseMarkdown(text, entities)
|
text = RichTextProcessor.parseMarkdown(text, entities)
|
||||||
}
|
}
|
||||||
|
var sendEntites = entities
|
||||||
|
if (entities.length) {
|
||||||
|
sendEntites = angular.copy(entities)
|
||||||
|
angular.forEach(sendEntites, function (entity) {
|
||||||
|
if (entity._ == 'messageEntityMentionName') {
|
||||||
|
entity._ = 'inputMessageEntityMentionName'
|
||||||
|
entity.user_id = AppUsersManager.getUserInput(entity.user_id)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
if (!text.length) {
|
if (!text.length) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -1308,7 +1319,7 @@ angular.module('myApp.services')
|
|||||||
reply_to_msg_id: replyToMsgID,
|
reply_to_msg_id: replyToMsgID,
|
||||||
via_bot_id: options.viaBotID,
|
via_bot_id: options.viaBotID,
|
||||||
reply_markup: options.reply_markup,
|
reply_markup: options.reply_markup,
|
||||||
entities: entities,
|
entities: sendEntites,
|
||||||
views: asChannel && 1,
|
views: asChannel && 1,
|
||||||
pending: true
|
pending: true
|
||||||
}
|
}
|
||||||
|
@ -2,10 +2,10 @@
|
|||||||
|
|
||||||
<ul ng-switch-when="mentions" class="composer_dropdown">
|
<ul ng-switch-when="mentions" class="composer_dropdown">
|
||||||
<li ng-repeat="user in mentionUsers">
|
<li ng-repeat="user in mentionUsers">
|
||||||
<a class="composer_mention_option" data-mention="{{user.username}}">
|
<a class="composer_mention_option" data-mention="{{user.username.length > 0 ? user.username : ('#' + user.id)}}" data-name="{{user.first_name}}">
|
||||||
<span class="composer_user_photo" my-peer-photolink="user.id" img-class="composer_user_photo"></span>
|
<span class="composer_user_photo" my-peer-photolink="user.id" img-class="composer_user_photo"></span>
|
||||||
<span class="composer_user_name" ng-bind-html="user.rFullName"></span>
|
<span class="composer_user_name" ng-bind-html="user.rFullName"></span>
|
||||||
<span class="composer_user_mention" ng-bind="'@' + user.username"></span>
|
<span class="composer_user_mention" ng-if="user.username.length > 0" ng-bind="'@' + user.username"></span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user