Keep url text intact when linkifying it

This commit is contained in:
khlieng 2015-05-12 22:48:10 +02:00
parent cb4b5e4f6f
commit 6b6a1172f9
4 changed files with 24 additions and 21 deletions

View File

@ -25,6 +25,6 @@
"react-router": "0.12.0",
"react": "0.12.2",
"react-infinite": "0.2.3",
"autolinker": "~0.15.2"
"autolinker": "khlieng/Autolinker.js"
}
}

View File

@ -84,9 +84,11 @@ var MessageBox = React.createClass({
lines.push(<MessageHeader key={key} message={message} />);
for (var i = 1; i < message.lines.length; i++) {
var line = Autolinker.link(message.lines[i], { keepOriginalText: true });
lines.push(
<p key={key + '-' + i} className={messageClass} style={innerStyle}>
<span dangerouslySetInnerHTML={{ __html: Autolinker.link(message.lines[i]) }}></span>
<span dangerouslySetInnerHTML={{ __html: line }}></span>
</p>
);
}

View File

@ -18,6 +18,7 @@ var MessageHeader = React.createClass({
var message = this.props.message;
var sender = null;
var messageClass = 'message';
var line = Autolinker.link(message.lines[0], { keepOriginalText: true });
if (message.from) {
sender = (
@ -38,7 +39,7 @@ var MessageHeader = React.createClass({
<p className={messageClass}>
<span className="message-time">{util.timestamp(message.time)}</span>
{sender}
<span dangerouslySetInnerHTML={{ __html: ' ' + Autolinker.link(message.lines[0]) }}></span>
<span dangerouslySetInnerHTML={{ __html: ' ' + line }}></span>
</p>
);
}

File diff suppressed because one or more lines are too long