From e1bebb2d776b12d6e1461e06f318e79fcb93ea2c Mon Sep 17 00:00:00 2001 From: samogot Date: Sat, 28 May 2016 02:31:02 +0300 Subject: PLT-2321 Move the toggle icon next to the link being previewed (#3071) * PLT-2321 Move the toggle icon next to the link being previewed only applicable to one-line messages started with link * remove useless "Youtube" header when no title is available * allow breaking long links instead of toggle * simplify "/" to "/" replacing fix empty post without additional content body * discard buggy "simplification" --- webapp/utils/text_formatting.jsx | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'webapp/utils') diff --git a/webapp/utils/text_formatting.jsx b/webapp/utils/text_formatting.jsx index 623fe0660..a4622ad9e 100644 --- a/webapp/utils/text_formatting.jsx +++ b/webapp/utils/text_formatting.jsx @@ -34,6 +34,8 @@ export function formatText(text, options = {}) { output = replaceNewlines(output); } + output = insertLongLinkWbr(output); + return output; } @@ -76,6 +78,9 @@ export function doFormatText(text, options) { }); } + //replace all "/" to "/" + output = output.replace(/\//g, '/'); + // reinsert tokens with formatted versions of the important words and phrases output = replaceTokens(output, tokens); @@ -425,3 +430,10 @@ export function handleClick(e) { browserHistory.push(linkAttribute.value); } } + +//replace all "/" inside tags to "/" +function insertLongLinkWbr(test) { + return test.replace(/\//g, (match, position, string) => { + return match + ((/a[^>]*>[^<]*$/).test(string.substr(0, position)) ? '' : ''); + }); +} \ No newline at end of file -- cgit v1.2.3-1-g7c22