PLT-1236 Added special handling for markdown links within mattermost (#2763)

* Added special handling for markdown links within mattermost

* Moved application of .app__body class to route components
Этот коммит содержится в:
Harrison Healey
2016-04-22 14:52:44 -04:00
коммит произвёл Corey Hulen
родитель e80bf13f48
Коммит f73daebb61
7 изменённых файлов: 29 добавлений и 18 удалений

Просмотреть файл

@@ -2,7 +2,6 @@
// See License.txt for license information.
import * as TextFormatting from './text_formatting.jsx';
import * as Utils from './utils.jsx';
import * as syntaxHightlighting from './syntax_hightlighting.jsx';
import marked from 'marked';
@@ -137,18 +136,20 @@ class MattermostMarkdownRenderer extends marked.Renderer {
outHref = `http://${outHref}`;
}
let output = '<a class="theme markdown__link" href="' + outHref + '"';
let output = '<a class="theme markdown__link" ';
// special case for links that are inside the app
if (outHref.startsWith(global.location.origin)) {
output += 'data-link="' + outHref.substring(global.location.origin.length) + '"';
} else {
output += 'href="' + outHref + '"';
}
if (title) {
output += ' title="' + title + '"';
}
if (outHref.lastIndexOf(Utils.getTeamURLFromAddressBar(), 0) === 0) {
output += '>';
} else {
output += ' target="_blank">';
}
output += outText + '</a>';
output += '>' + outText + '</a>';
return prefix + output + suffix;
}

Просмотреть файл

@@ -2,6 +2,7 @@
// See License.txt for license information.
import Autolinker from 'autolinker';
import {browserHistory} from 'react-router';
import Constants from './constants.jsx';
import * as Emoticons from './emoticons.jsx';
import * as Markdown from './markdown.jsx';
@@ -398,10 +399,13 @@ function replaceNewlines(text) {
export function handleClick(e) {
const mentionAttribute = e.target.getAttributeNode('data-mention');
const hashtagAttribute = e.target.getAttributeNode('data-hashtag');
const linkAttribute = e.target.getAttributeNode('data-link');
if (mentionAttribute) {
Utils.searchForTerm(mentionAttribute.value);
} else if (hashtagAttribute) {
Utils.searchForTerm(hashtagAttribute.value);
} else if (linkAttribute) {
browserHistory.push(linkAttribute.value);
}
}