summaryrefslogtreecommitdiffstats
path: root/web/react/utils
diff options
context:
space:
mode:
Diffstat (limited to 'web/react/utils')
-rw-r--r--web/react/utils/channel_intro_mssages.jsx5
-rw-r--r--web/react/utils/constants.jsx3
-rw-r--r--web/react/utils/text_formatting.jsx26
3 files changed, 12 insertions, 22 deletions
diff --git a/web/react/utils/channel_intro_mssages.jsx b/web/react/utils/channel_intro_mssages.jsx
index b3f868456..161c79761 100644
--- a/web/react/utils/channel_intro_mssages.jsx
+++ b/web/react/utils/channel_intro_mssages.jsx
@@ -3,6 +3,7 @@
// See License.txt for license information.
const Utils = require('./utils.jsx');
+const InviteMemberModal = require('../components/invite_member_modal.jsx');
const UserProfile = require('../components/user_profile.jsx');
const ChannelStore = require('../stores/channel_store.jsx');
const Constants = require('../utils/constants.jsx');
@@ -109,8 +110,7 @@ export function createDefaultIntroMessage(channel) {
<a
className='intro-links'
href='#'
- data-toggle='modal'
- data-target='#invite_member'
+ onClick={InviteMemberModal.show}
>
<i className='fa fa-user-plus'></i>{'Invite others to this team'}
</a>
@@ -213,6 +213,7 @@ export function createStandardIntroMessage(channel) {
>
<i className='fa fa-user-plus'></i>{'Invite others to this ' + uiType}
</a>
+
</div>
);
}
diff --git a/web/react/utils/constants.jsx b/web/react/utils/constants.jsx
index 39be577df..b8d346ba7 100644
--- a/web/react/utils/constants.jsx
+++ b/web/react/utils/constants.jsx
@@ -39,7 +39,8 @@ module.exports = {
RECIEVED_LOGS: null,
RECIEVED_ALL_TEAMS: null,
- TOGGLE_IMPORT_THEME_MODAL: null
+ TOGGLE_IMPORT_THEME_MODAL: null,
+ TOGGLE_INVITE_MEMBER_MODAL: null
}),
PayloadSources: keyMirror({
diff --git a/web/react/utils/text_formatting.jsx b/web/react/utils/text_formatting.jsx
index 2de858a17..ac26107cc 100644
--- a/web/react/utils/text_formatting.jsx
+++ b/web/react/utils/text_formatting.jsx
@@ -64,22 +64,6 @@ export function doFormatText(text, options) {
return output;
}
-export function doFormatEmoticons(text) {
- const tokens = new Map();
-
- let output = Emoticons.handleEmoticons(text, tokens);
- output = replaceTokens(output, tokens);
-
- return output;
-}
-
-export function doFormatMentions(text) {
- const tokens = new Map();
- let output = autolinkAtMentions(text, tokens);
- output = replaceTokens(output, tokens);
- return output;
-}
-
export function sanitizeHtml(text) {
let output = text;
@@ -182,11 +166,15 @@ function autolinkAtMentions(text, tokens) {
}
let output = text;
- output = output.replace(/(^|\s)(@([a-z0-9.\-_]*))/gi, replaceAtMentionWithToken);
+ output = output.replace(/(^|[^a-z0-9])(@([a-z0-9.\-_]*))/gi, replaceAtMentionWithToken);
return output;
}
+function escapeRegex(text) {
+ return text.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
+}
+
function highlightCurrentMentions(text, tokens) {
let output = text;
@@ -226,7 +214,7 @@ function highlightCurrentMentions(text, tokens) {
}
for (const mention of UserStore.getCurrentMentionKeys()) {
- output = output.replace(new RegExp(`(^|\\W)(${mention})\\b`, 'gi'), replaceCurrentMentionWithToken);
+ output = output.replace(new RegExp(`(^|\\W)(${escapeRegex(mention)})\\b`, 'gi'), replaceCurrentMentionWithToken);
}
return output;
@@ -306,7 +294,7 @@ function highlightSearchTerm(text, tokens, searchTerm) {
return prefix + alias;
}
- return output.replace(new RegExp(`()(${searchTerm})`, 'gi'), replaceSearchTermWithToken);
+ return output.replace(new RegExp(`()(${escapeRegex(searchTerm)})`, 'gi'), replaceSearchTermWithToken);
}
function replaceTokens(text, tokens) {