fix typo and add linkify descriptions

pull/21833/head
Matthew Hodgson 2016-04-01 02:23:29 +01:00
parent 4d959fc33b
commit 62d04c38ef
1 changed files with 17 additions and 2 deletions

View File

@ -20,6 +20,11 @@ var React = require('react');
var MatrixClientPeg = require('../../../MatrixClientPeg');
var linkify = require('linkifyjs');
var linkifyElement = require('linkifyjs/element');
var linkifyMatrix = require('../../../linkify-matrix');
linkifyMatrix(linkify);
module.exports = React.createClass({
displayName: 'LinkPreviewWidget',
@ -29,7 +34,7 @@ module.exports = React.createClass({
getInitialState: function() {
return {
preview: null;
preview: null
};
},
@ -41,6 +46,16 @@ module.exports = React.createClass({
});
},
componentDidMount: function() {
if (this.refs.description)
linkifyElement(this.refs.description, linkifyMatrix.options);
},
componentDidUpdate: function() {
if (this.refs.description)
linkifyElement(this.refs.description, linkifyMatrix.options);
},
render: function() {
var p = this.state.preview;
if (!p) return <div/>;
@ -54,7 +69,7 @@ module.exports = React.createClass({
<div className="mx_LinkPreviewWidget_caption">
<div className="mx_LinkPreviewWidget_title"><a href={ this.props.link } target="_blank">{ p["og:title"] }</a></div>
<div className="mx_LinkPreviewWidget_siteName">{ p["og:site_name"] ? (" - " + p["og:site_name"]) : null }</div>
<div className="mx_LinkPreviewWidget_description">
<div className="mx_LinkPreviewWidget_description" ref="description">
{ p["og:description"] }
</div>
</div>