summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarrison Healey <harrisonmhealey@gmail.com>2016-06-01 08:52:28 -0400
committerChristopher Speller <crspeller@gmail.com>2016-06-01 08:52:28 -0400
commit5f7ce2214a9fd91a0ab62312674f5cffd811f8ca (patch)
tree1321bba4c505031864b13a518895d0ed1f8a7be5
parenta163f8d9849393b9ff3fa33e94b76054071b03d7 (diff)
downloadchat-5f7ce2214a9fd91a0ab62312674f5cffd811f8ca.tar.gz
chat-5f7ce2214a9fd91a0ab62312674f5cffd811f8ca.tar.bz2
chat-5f7ce2214a9fd91a0ab62312674f5cffd811f8ca.zip
Improved internal links which use react-router (#3180)
-rw-r--r--webapp/utils/markdown.jsx6
-rw-r--r--webapp/utils/text_formatting.jsx8
2 files changed, 10 insertions, 4 deletions
diff --git a/webapp/utils/markdown.jsx b/webapp/utils/markdown.jsx
index 6691b57b2..b128bd3e8 100644
--- a/webapp/utils/markdown.jsx
+++ b/webapp/utils/markdown.jsx
@@ -149,13 +149,13 @@ class MattermostMarkdownRenderer extends marked.Renderer {
outHref = `http://${outHref}`;
}
- let output = '<a class="theme markdown__link" ';
+ let output = '<a class="theme markdown__link" href="' + outHref + '" rel="noreferrer"';
// special case for links that are inside the app
if (outHref.startsWith(global.location.origin)) {
- output += 'data-link="' + outHref.substring(global.location.origin.length) + '"';
+ output += ' data-link="' + outHref.substring(global.location.origin.length) + '"';
} else {
- output += 'href="' + outHref + '" target="_blank" rel="noreferrer"';
+ output += ' target="_blank"';
}
if (title) {
diff --git a/webapp/utils/text_formatting.jsx b/webapp/utils/text_formatting.jsx
index 21bfe5333..cc4a24d19 100644
--- a/webapp/utils/text_formatting.jsx
+++ b/webapp/utils/text_formatting.jsx
@@ -450,7 +450,13 @@ export function handleClick(e) {
} else if (hashtagAttribute) {
Utils.searchForTerm(hashtagAttribute.value);
} else if (linkAttribute) {
- browserHistory.push(linkAttribute.value);
+ const MIDDLE_MOUSE_BUTTON = 1;
+
+ if (!(e.button === MIDDLE_MOUSE_BUTTON || e.altKey || e.ctrlKey || e.metaKey || e.shiftKey)) {
+ e.preventDefault();
+
+ browserHistory.push(linkAttribute.value);
+ }
}
}