diff --git a/lib/react/message.jsx b/lib/react/message.jsx index 6391af4..9e9f447 100644 --- a/lib/react/message.jsx +++ b/lib/react/message.jsx @@ -70,6 +70,10 @@ var Chatroom = React.createClass({ }); var ChatMessage = React.createClass({ + mixins: [ + ReactAutolink + ], + componentDidMount() { this.interval = setInterval(this.forceUpdate.bind(this), 1000); }, @@ -78,6 +82,13 @@ var ChatMessage = React.createClass({ clearInterval(this.interval); }, + messageContent: function () { + return this.autolink(this.props.message.content, { + target: "_blank", + rel: "nofollow" + }); + }, + render() { let deleteButton; let currentUser = this.props.currentUser; @@ -105,7 +116,7 @@ var ChatMessage = React.createClass({ {$.timeago(this.props.message.createdAt)} -

{this.props.message.content}

+

{this.messageContent()}

); diff --git a/public/js/autolinker.min.js b/public/js/autolinker.min.js new file mode 100644 index 0000000..c077618 --- /dev/null +++ b/public/js/autolinker.min.js @@ -0,0 +1 @@ +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react")):"function"==typeof define&&define.amd?define(["react"],e):"object"==typeof exports?exports.ReactAutolink=e(require("react")):t.ReactAutolink=e(t.React)}(this,function(t){return function(t){function e(n){if(r[n])return r[n].exports;var o=r[n]={exports:{},id:n,loaded:!1};return t[n].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var r={};return e.m=t,e.c=r,e.p="",e(0)}([function(t,e,r){"use strict";var n=function(t){return t&&t.__esModule?t["default"]:t},o=n(r(2)),u=n(r(1)),a=function(){var t=/((?:https?:\/\/)?(?:(?:[a-z0-9]?(?:[a-z0-9\-]{1,61}[a-z0-9])?\.[^\.|\s])+[a-z\.]*[a-z]+|(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3})(?::\d{1,5})*[a-z0-9.,_\/~#&=;%+?\-\\(\\)]*)/gi,e=function(t,e){return t.slice(0,e.length)===e};return{autolink:function(r){var n=void 0===arguments[1]?{}:arguments[1];return r?r.split(t).map(function(r){var a=r.match(t);if(a){var i=a[0],c=i.split("/");return""!==c[1]&&c[0].length<5?r:o.createElement("a",u({href:e(i,"http")?i:"http://"+i},n),i)}return r}):[]}}};t.exports=a()},function(t,e,r){"use strict";function n(t){if(null==t)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(t)}t.exports=Object.assign||function(t,e){for(var r,o,u=n(t),a=1;a + \ No newline at end of file