diff --git a/src/components/views/rooms/LinkPreviewWidget.js b/src/components/views/rooms/LinkPreviewWidget.js index e44717034a..d55d2e9a9d 100644 --- a/src/components/views/rooms/LinkPreviewWidget.js +++ b/src/components/views/rooms/LinkPreviewWidget.js @@ -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
; @@ -54,7 +69,7 @@ module.exports = React.createClass({