mirror of https://github.com/zulip/zulip.git
refactor: Move echo.userMentionHandler code.
The userMentionHandler callback now closes on `message` inside of echo.apply_markdown(). This sets the stage for the next commit.
This commit is contained in:
parent
2539ed0563
commit
894282222a
|
@ -32,7 +32,22 @@ exports.contains_bugdown = function contains_bugdown(content) {
|
||||||
|
|
||||||
exports.apply_markdown = function apply_markdown(message) {
|
exports.apply_markdown = function apply_markdown(message) {
|
||||||
// Our python-markdown processor appends two \n\n to input
|
// Our python-markdown processor appends two \n\n to input
|
||||||
message.content = marked(message.raw_content + '\n\n').trim();
|
var options = {
|
||||||
|
userMentionHandler: function (name) {
|
||||||
|
var person = people.get_by_name(name);
|
||||||
|
if (person !== undefined) {
|
||||||
|
return '<span class="user-mention" data-user-email="' + person.email + '">' +
|
||||||
|
'@' + person.full_name +
|
||||||
|
'</span>';
|
||||||
|
} else if (name === 'all' || name === 'everyone') {
|
||||||
|
return '<span class="user-mention" data-user-email="*">' +
|
||||||
|
'@' + name +
|
||||||
|
'</span>';
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
message.content = marked(message.raw_content + '\n\n', options).trim();
|
||||||
};
|
};
|
||||||
|
|
||||||
function resend_message(message, row) {
|
function resend_message(message, row) {
|
||||||
|
@ -319,17 +334,6 @@ function handleAvatar(email) {
|
||||||
' title="' + email + '">';
|
' title="' + email + '">';
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleUserMentions(username) {
|
|
||||||
var person = people.get_by_name(username);
|
|
||||||
if (person !== undefined) {
|
|
||||||
return '<span class="user-mention" data-user-email="' + person.email + '">' +
|
|
||||||
'@' + person.full_name + '</span>';
|
|
||||||
} else if (username === 'all' || username === 'everyone') {
|
|
||||||
return '<span class="user-mention" data-user-email="*">' + '@' + username + '</span>';
|
|
||||||
}
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleStream(streamName) {
|
function handleStream(streamName) {
|
||||||
var stream = stream_data.get_sub(streamName);
|
var stream = stream_data.get_sub(streamName);
|
||||||
if (stream === undefined) {
|
if (stream === undefined) {
|
||||||
|
@ -497,7 +501,6 @@ $(function () {
|
||||||
emojiHandler: handleEmoji,
|
emojiHandler: handleEmoji,
|
||||||
avatarHandler: handleAvatar,
|
avatarHandler: handleAvatar,
|
||||||
unicodeEmojiHandler: handleUnicodeEmoji,
|
unicodeEmojiHandler: handleUnicodeEmoji,
|
||||||
userMentionHandler: handleUserMentions,
|
|
||||||
streamHandler: handleStream,
|
streamHandler: handleStream,
|
||||||
realmFilterHandler: handleRealmFilter,
|
realmFilterHandler: handleRealmFilter,
|
||||||
renderer: r,
|
renderer: r,
|
||||||
|
|
Loading…
Reference in New Issue