From 4c9ae22b6207c477b92737f4e79901c7366a4792 Mon Sep 17 00:00:00 2001 From: hmhealey Date: Mon, 14 Sep 2015 15:08:13 -0400 Subject: Renamed text formatting tokens so that there should be significantly less chance of having conflicting tokens --- web/react/utils/text_formatting.jsx | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'web/react') diff --git a/web/react/utils/text_formatting.jsx b/web/react/utils/text_formatting.jsx index 2f93841f0..2c67d7a46 100644 --- a/web/react/utils/text_formatting.jsx +++ b/web/react/utils/text_formatting.jsx @@ -61,7 +61,7 @@ function autolinkUrls(text, tokens) { } const index = tokens.size; - const alias = `LINK${index}`; + const alias = `__MM_LINK${index}__`; tokens.set(alias, { value: `${linkText}`, @@ -91,7 +91,7 @@ function autolinkAtMentions(text, tokens) { const usernameLower = username.toLowerCase(); if (Constants.SPECIAL_MENTIONS.indexOf(usernameLower) !== -1 || UserStore.getProfileByUsername(usernameLower)) { const index = tokens.size; - const alias = `ATMENTION${index}`; + const alias = `__MM_ATMENTION${index}__`; tokens.set(alias, { value: `${mention}`, @@ -118,8 +118,8 @@ function highlightCurrentMentions(text, tokens) { var newTokens = new Map(); for (const [alias, token] of tokens) { if (mentionKeys.indexOf(token.originalText) !== -1) { - const index = newTokens.size; - const newAlias = `SELFMENTION${index}`; + const index = tokens.size + newTokens.size; + const newAlias = `__MM_SELFMENTION${index}__`; newTokens.set(newAlias, { value: `${alias}`, @@ -138,7 +138,7 @@ function highlightCurrentMentions(text, tokens) { // look for self mentions in the text function replaceCurrentMentionWithToken(fullMatch, prefix, mention) { const index = tokens.size; - const alias = `SELFMENTION${index}`; + const alias = `__MM_SELFMENTION${index}__`; tokens.set(alias, { value: `${mention}`, @@ -161,8 +161,8 @@ function autolinkHashtags(text, tokens) { var newTokens = new Map(); for (const [alias, token] of tokens) { if (token.originalText.startsWith('#')) { - const index = newTokens.size; - const newAlias = `HASHTAG${index}`; + const index = tokens.size + newTokens.size; + const newAlias = `__MM_HASHTAG${index}__`; newTokens.set(newAlias, { value: `${token.originalText}`, @@ -181,7 +181,7 @@ function autolinkHashtags(text, tokens) { // look for hashtags in the text function replaceHashtagWithToken(fullMatch, prefix, hashtag) { const index = tokens.size; - const alias = `HASHTAG${index}`; + const alias = `__MM_HASHTAG${index}__`; tokens.set(alias, { value: `${hashtag}`, @@ -200,8 +200,8 @@ function highlightSearchTerm(text, tokens, searchTerm) { var newTokens = new Map(); for (const [alias, token] of tokens) { if (token.originalText === searchTerm) { - const index = newTokens.size; - const newAlias = `SEARCH_TERM${index}`; + const index = tokens.size + newTokens.size; + const newAlias = `__MM_SEARCHTERM${index}__`; newTokens.set(newAlias, { value: `${alias}`, @@ -219,7 +219,7 @@ function highlightSearchTerm(text, tokens, searchTerm) { function replaceSearchTermWithToken(fullMatch, prefix, word) { const index = tokens.size; - const alias = `SEARCH_TERM${index}`; + const alias = `__MM_SEARCHTERM${index}__`; tokens.set(alias, { value: `${word}`, -- cgit v1.2.3-1-g7c22