summaryrefslogtreecommitdiffstats
path: root/web/react/components/post_body.jsx
diff options
context:
space:
mode:
authorReed Garmsen <rgarmsen2295@gmail.com>2015-07-08 11:34:34 -0700
committerReed Garmsen <rgarmsen2295@gmail.com>2015-08-12 11:19:42 -0700
commitd293bc0b799a679cd27ed4ef6e818b0ca96998d9 (patch)
tree6b12bb2d447cbe9cf24f0ea66ec096e6233c87d7 /web/react/components/post_body.jsx
parent95e6626f9f59b876479d8267b6c95105345e661d (diff)
downloadchat-d293bc0b799a679cd27ed4ef6e818b0ca96998d9.tar.gz
chat-d293bc0b799a679cd27ed4ef6e818b0ca96998d9.tar.bz2
chat-d293bc0b799a679cd27ed4ef6e818b0ca96998d9.zip
Implemented basic text formatting package using a modfied version of the marked js library. Supports *bold*, _italics_, and `code`
Diffstat (limited to 'web/react/components/post_body.jsx')
-rw-r--r--web/react/components/post_body.jsx25
1 files changed, 20 insertions, 5 deletions
diff --git a/web/react/components/post_body.jsx b/web/react/components/post_body.jsx
index 860c96d84..bf039d79b 100644
--- a/web/react/components/post_body.jsx
+++ b/web/react/components/post_body.jsx
@@ -4,6 +4,7 @@
var FileAttachmentList = require('./file_attachment_list.jsx');
var UserStore = require('../stores/user_store.jsx');
var utils = require('../utils/utils.jsx');
+var formatText = require('../../static/js/marked/lib/marked.js');
module.exports = React.createClass({
componentWillReceiveProps: function(nextProps) {
@@ -19,6 +20,7 @@ module.exports = React.createClass({
var filenames = this.props.post.filenames;
var parentPost = this.props.parentPost;
var inner = utils.textToJsx(this.state.message);
+ var allowTextFormatting = config.AllowTextFormatting;
var comment = "";
var reply = "";
@@ -50,11 +52,20 @@ module.exports = React.createClass({
}
}
- comment = (
- <p className="post-link">
- <span>Commented on {name}{apostrophe} message: <a className="theme" onClick={this.props.handleCommentClick}>{message}</a></span>
- </p>
- );
+ if (allowTextFormatting) {
+ message = formatText(message, {sanitize: true, mangle: false, gfm: true, breaks: true, tables: false, smartypants: true, renderer: utils.customMarkedRenderer({disable: true})});
+ comment = (
+ <p className="post-link">
+ <span>Commented on {name}{apostrophe} message: <a className="theme" onClick={this.props.handleCommentClick} dangerouslySetInnerHTML={{__html: message}} /></span>
+ </p>
+ );
+ } else {
+ comment = (
+ <p className="post-link">
+ <span>Commented on {name}{apostrophe} message: <a className="theme" onClick={this.props.handleCommentClick}>{message}</a></span>
+ </p>
+ );
+ }
postClass += " post-comment";
}
@@ -67,7 +78,11 @@ module.exports = React.createClass({
return (
<div className="post-body">
{ comment }
+ {allowTextFormatting ?
+ <div key={post.id+"_message"} className={postClass}><span>{inner}</span></div>
+ :
<p key={post.id+"_message"} className={postClass}><span>{inner}</span></p>
+ }
{ filenames && filenames.length > 0 ?
<FileAttachmentList
filenames={filenames}