summaryrefslogtreecommitdiffstats
path: root/web/react/utils
diff options
context:
space:
mode:
Diffstat (limited to 'web/react/utils')
-rw-r--r--web/react/utils/async_client.jsx2
-rw-r--r--web/react/utils/constants.jsx2
-rw-r--r--web/react/utils/emoticons.jsx50
-rw-r--r--web/react/utils/markdown.jsx12
-rw-r--r--web/react/utils/text_formatting.jsx9
-rw-r--r--web/react/utils/utils.jsx2
6 files changed, 45 insertions, 32 deletions
diff --git a/web/react/utils/async_client.jsx b/web/react/utils/async_client.jsx
index 7db3ef30d..a903f055b 100644
--- a/web/react/utils/async_client.jsx
+++ b/web/react/utils/async_client.jsx
@@ -1,4 +1,4 @@
-// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved.
+// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
var client = require('./client.jsx');
diff --git a/web/react/utils/constants.jsx b/web/react/utils/constants.jsx
index 8fd0ab79b..affc49196 100644
--- a/web/react/utils/constants.jsx
+++ b/web/react/utils/constants.jsx
@@ -1,4 +1,4 @@
-// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved.
+// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
var keyMirror = require('keymirror');
diff --git a/web/react/utils/emoticons.jsx b/web/react/utils/emoticons.jsx
index a7c837199..94bb91503 100644
--- a/web/react/utils/emoticons.jsx
+++ b/web/react/utils/emoticons.jsx
@@ -1,27 +1,27 @@
-// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved.
+// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
const emoticonPatterns = {
- smile: /:-?\)/g, // :)
- open_mouth: /:o/gi, // :o
- scream: /:-o/gi, // :-o
- smirk: /:-?]/g, // :]
- grinning: /:-?d/gi, // :D
- stuck_out_tongue_closed_eyes: /x-d/gi, // x-d
- stuck_out_tongue_winking_eye: /:-?p/gi, // :p
- rage: /:-?[\[@]/g, // :@
- frowning: /:-?\(/g, // :(
- sob: /:['’]-?\(|:'\(/g, // :`(
- kissing_heart: /:-?\*/g, // :*
- pensive: /:-?\//g, // :/
- confounded: /:-?s/gi, // :s
- flushed: /:-?\|/g, // :|
- relaxed: /:-?\$/g, // :$
- mask: /:-x/gi, // :-x
- heart: /<3|&lt;3/g, // <3
- broken_heart: /<\/3|&lt;&#x2F;3/g, // </3
- thumbsup: /:\+1:/g, // :+1:
- thumbsdown: /:\-1:/g // :-1:
+ smile: /(^|\s)(:-?\))($|\s)/g, // :)
+ open_mouth: /(^|\s)(:o)($|\s)/gi, // :o
+ scream: /(^|\s)(:-o)($|\s)/gi, // :-o
+ smirk: /(^|\s)(:-?])($|\s)/g, // :]
+ grinning: /(^|\s)(:-?d)($|\s)/gi, // :D
+ stuck_out_tongue_closed_eyes: /(^|\s)(x-d)($|\s)/gi, // x-d
+ stuck_out_tongue: /(^|\s)(:-?p)($|\s)/gi, // :p
+ rage: /(^|\s)(:-?[\[@])($|\s)/g, // :@
+ frowning: /(^|\s)(:-?\()($|\s)/g, // :(
+ sob: /(^|\s)(:['’]-?\(|:&#x27;\(|:&#39;\()($|\s)/g, // :`(
+ kissing_heart: /(^|\s)(:-?\*)($|\s)/g, // :*
+ pensive: /(^|\s)(:-?\/)($|\s)/g, // :/
+ confounded: /(^|\s)(:-?s)($|\s)/gi, // :s
+ flushed: /(^|\s)(:-?\|)($|\s)/g, // :|
+ relaxed: /(^|\s)(:-?\$)($|\s)/g, // :$
+ mask: /(^|\s)(:-x)($|\s)/gi, // :-x
+ heart: /(^|\s)(<3|&lt;3)($|\s)/g, // <3
+ broken_heart: /(^|\s)(<\/3|&lt;&#x2F;3)($|\s)/g, // </3
+ thumbsup: /(^|\s)(:\+1:)($|\s)/g, // :+1:
+ thumbsdown: /(^|\s)(:\-1:)($|\s)/g // :-1:
};
function initializeEmoticonMap() {
@@ -126,7 +126,7 @@ const emoticonMap = initializeEmoticonMap();
export function handleEmoticons(text, tokens) {
let output = text;
- function replaceEmoticonWithToken(match, name) {
+ function replaceEmoticonWithToken(match, prefix, name, suffix) {
if (emoticonMap[name]) {
const index = tokens.size;
const alias = `MM_EMOTICON${index}`;
@@ -136,18 +136,18 @@ export function handleEmoticons(text, tokens) {
originalText: match
});
- return alias;
+ return prefix + alias + suffix;
}
return match;
}
- output = output.replace(/:([a-zA-Z0-9_-]+):/g, replaceEmoticonWithToken);
+ output = output.replace(/(^|\s):([a-zA-Z0-9_-]+):($|\s)/g, replaceEmoticonWithToken);
$.each(emoticonPatterns, (name, pattern) => {
// this might look a bit funny, but since the name isn't contained in the actual match
// like with the named emoticons, we need to add it in manually
- output = output.replace(pattern, (match) => replaceEmoticonWithToken(match, name));
+ output = output.replace(pattern, (match, prefix, emoticon, suffix) => replaceEmoticonWithToken(match, prefix, name, suffix));
});
return output;
diff --git a/web/react/utils/markdown.jsx b/web/react/utils/markdown.jsx
index 7e88f8644..12d6dd424 100644
--- a/web/react/utils/markdown.jsx
+++ b/web/react/utils/markdown.jsx
@@ -1,7 +1,8 @@
-// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved.
+// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
const TextFormatting = require('./text_formatting.jsx');
+const Utils = require('./utils.jsx');
const marked = require('marked');
@@ -39,7 +40,14 @@ export class MattermostMarkdownRenderer extends marked.Renderer {
if (title) {
output += ' title="' + title + '"';
}
- output += ' target="_blank">' + text + '</a>';
+
+ if (outHref.lastIndexOf(Utils.getTeamURLFromAddressBar(), 0) === 0) {
+ output += '>';
+ } else {
+ output += ' target="_blank">';
+ }
+
+ output += text + '</a>';
return output;
}
diff --git a/web/react/utils/text_formatting.jsx b/web/react/utils/text_formatting.jsx
index 34e42cbae..2b6e6e14e 100644
--- a/web/react/utils/text_formatting.jsx
+++ b/web/react/utils/text_formatting.jsx
@@ -1,4 +1,4 @@
-// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved.
+// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
const Autolinker = require('autolinker');
@@ -96,8 +96,13 @@ function autolinkUrls(text, tokens) {
const index = tokens.size;
const alias = `MM_LINK${index}`;
+ var target = 'target="_blank"';
+ if (url.lastIndexOf(Utils.getTeamURLFromAddressBar(), 0) === 0) {
+ target = '';
+ }
+
tokens.set(alias, {
- value: `<a class='theme' target='_blank' href='${url}'>${linkText}</a>`,
+ value: `<a class="theme" ${target} href="${url}">${linkText}</a>`,
originalText: linkText
});
diff --git a/web/react/utils/utils.jsx b/web/react/utils/utils.jsx
index f79f3492f..f9166063e 100644
--- a/web/react/utils/utils.jsx
+++ b/web/react/utils/utils.jsx
@@ -1,4 +1,4 @@
-// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved.
+// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
var AppDispatcher = require('../dispatcher/app_dispatcher.jsx');