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 "/<wbr />" replacing
fix empty post without additional content body

* discard buggy "simplification"
Этот коммит содержится в:
samogot
2016-05-28 02:31:02 +03:00
коммит произвёл Harrison Healey
родитель c7615920df
Коммит e1bebb2d77
6 изменённых файлов: 81 добавлений и 38 удалений

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

@@ -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 "/<wbr />"
output = output.replace(/\//g, '/<wbr />');
// 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 <a> tags to "/<wbr />"
function insertLongLinkWbr(test) {
return test.replace(/\//g, (match, position, string) => {
return match + ((/a[^>]*>[^<]*$/).test(string.substr(0, position)) ? '<wbr />' : '');
});
}