summaryrefslogtreecommitdiffstats
path: root/web/react/components/post_right.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_right.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_right.jsx')
-rw-r--r--web/react/components/post_right.jsx29
1 files changed, 25 insertions, 4 deletions
diff --git a/web/react/components/post_right.jsx b/web/react/components/post_right.jsx
index ad8b54012..10a9400f5 100644
--- a/web/react/components/post_right.jsx
+++ b/web/react/components/post_right.jsx
@@ -56,6 +56,7 @@ RhsHeaderPost = React.createClass({
RootPost = React.createClass({
render: function() {
+ var allowTextFormatting = config.AllowTextFormatting;
var post = this.props.post;
var message = utils.textToJsx(post.message);
var isOwner = UserStore.getCurrentId() == post.user_id;
@@ -76,6 +77,11 @@ RootPost = React.createClass({
channelName = (channel.type === 'D') ? "Private Message" : channel.display_name;
}
+ var messageHolder = <p>{message}</p>;
+ if (allowTextFormatting) {
+ messageHolder = <div>{message}</div>;
+ }
+
return (
<div className={"post post--root " + currentUserCss}>
<div className="post-right-channel__name">{ channelName }</div>
@@ -101,7 +107,7 @@ RootPost = React.createClass({
</li>
</ul>
<div className="post-body">
- <p>{message}</p>
+ {messageHolder}
{ post.filenames && post.filenames.length > 0 ?
<FileAttachmentList
filenames={post.filenames}
@@ -119,6 +125,7 @@ RootPost = React.createClass({
CommentPost = React.createClass({
render: function() {
+ var allowTextFormatting = config.AllowTextFormatting;
var post = this.props.post;
var commentClass = "post";
@@ -138,6 +145,11 @@ CommentPost = React.createClass({
var message = utils.textToJsx(post.message);
var timestamp = UserStore.getCurrentUser().update_at;
+ var messageHolder = <p>{message}</p>;
+ if (allowTextFormatting) {
+ messageHolder = <div>{message}</div>;
+ }
+
return (
<div className={commentClass + " " + currentUserCss}>
<div className="post-profile-img__container">
@@ -160,7 +172,7 @@ CommentPost = React.createClass({
</li>
</ul>
<div className="post-body">
- <p>{message}</p>
+ {messageHolder}
{ post.filenames && post.filenames.length > 0 ?
<FileAttachmentList
filenames={post.filenames}
@@ -273,11 +285,20 @@ module.exports = React.createClass({
root_post = post_list.posts[selected_post.root_id];
}
+ var rootPostKey = root_post.id
+ if (root_post.lastEditDate != undefined)
+ rootPostKey += root_post.lastEditDate;
+
var posts_array = [];
for (var postId in post_list.posts) {
var cpost = post_list.posts[postId];
if (cpost.root_id == root_post.id) {
+ var cpostKey = cpost.id
+ if (cpost.lastEditDate != undefined)
+ cpostKey += cpost.lastEditDate;
+
+ cpost.cpostKey = cpostKey;
posts_array.push(cpost);
}
}
@@ -300,10 +321,10 @@ module.exports = React.createClass({
<div className="sidebar-right__body">
<RhsHeaderPost fromSearch={this.props.fromSearch} isMentionSearch={this.props.isMentionSearch} />
<div className="post-right__scroll">
- <RootPost post={root_post} commentCount={posts_array.length}/>
+ <RootPost key={rootPostKey} post={root_post} commentCount={posts_array.length}/>
<div className="post-right-comments-container">
{ posts_array.map(function(cpost) {
- return <CommentPost ref={cpost.id} key={cpost.id} post={cpost} selected={ (cpost.id == selected_post.id) } />
+ return <CommentPost ref={cpost.id} key={cpost.cpostKey} post={cpost} selected={ (cpost.id == selected_post.id) } />
})}
</div>
<div className="post-create__container">