From 2f4c0848112acb7667aff660631affea5227ff0f Mon Sep 17 00:00:00 2001 From: okbel Date: Thu, 22 Feb 2018 11:24:37 -0300 Subject: [PATCH] Comment previous edit --- .../src/tabs/stream/components/CommentForm.js | 1 + .../src/tabs/stream/components/DraftArea.js | 2 ++ .../components/EditableCommentContent.js | 1 + .../src/tabs/stream/containers/DraftArea.js | 1 + .../client/components/CommentContent.js | 26 ++++++++++++------- .../client/components/Editor.js | 6 +++++ 6 files changed, 28 insertions(+), 9 deletions(-) diff --git a/client/coral-embed-stream/src/tabs/stream/components/CommentForm.js b/client/coral-embed-stream/src/tabs/stream/components/CommentForm.js index a9ea8f150..ff005bb31 100644 --- a/client/coral-embed-stream/src/tabs/stream/components/CommentForm.js +++ b/client/coral-embed-stream/src/tabs/stream/components/CommentForm.js @@ -112,6 +112,7 @@ export class CommentForm extends React.Component { disabled={disableTextArea} charCountEnable={this.props.charCountEnable} maxCharCount={this.props.maxCharCount} + comment={this.props.comment} />
{this.props.buttonContainerStart} diff --git a/client/coral-embed-stream/src/tabs/stream/components/DraftArea.js b/client/coral-embed-stream/src/tabs/stream/components/DraftArea.js index c1678d0a7..2e45cf97c 100644 --- a/client/coral-embed-stream/src/tabs/stream/components/DraftArea.js +++ b/client/coral-embed-stream/src/tabs/stream/components/DraftArea.js @@ -38,6 +38,7 @@ export default class DraftArea extends React.Component { charCountEnable, maxCharCount, onChange, + comment, } = this.props; const tASettings = { @@ -47,6 +48,7 @@ export default class DraftArea extends React.Component { onChange, rows, disabled, + comment, }; return ( diff --git a/client/coral-embed-stream/src/tabs/stream/components/EditableCommentContent.js b/client/coral-embed-stream/src/tabs/stream/components/EditableCommentContent.js index 257860342..75f0d1246 100644 --- a/client/coral-embed-stream/src/tabs/stream/components/EditableCommentContent.js +++ b/client/coral-embed-stream/src/tabs/stream/components/EditableCommentContent.js @@ -140,6 +140,7 @@ export class EditableCommentContent extends React.Component { return (
); } diff --git a/plugins/talk-plugin-rte/client/components/CommentContent.js b/plugins/talk-plugin-rte/client/components/CommentContent.js index 28a7d67fe..e9f33fee5 100644 --- a/plugins/talk-plugin-rte/client/components/CommentContent.js +++ b/plugins/talk-plugin-rte/client/components/CommentContent.js @@ -1,15 +1,23 @@ import React from 'react'; +import PropTypes from 'prop-types'; import { name } from '../../package.json'; -const CommentContent = ({ comment }) => { - return comment.htmlBody ? ( -
- ) : ( -
{comment.body}
- ); +class CommentContent extends React.Component { + render() { + const { comment } = this.props; + return comment.htmlBody ? ( +
+ ) : ( +
{comment.body}
+ ); + } +} + +CommentContent.propTypes = { + comment: PropTypes.object.isRequired, }; export default CommentContent; diff --git a/plugins/talk-plugin-rte/client/components/Editor.js b/plugins/talk-plugin-rte/client/components/Editor.js index 8d2d84f00..a6bc4240a 100644 --- a/plugins/talk-plugin-rte/client/components/Editor.js +++ b/plugins/talk-plugin-rte/client/components/Editor.js @@ -36,10 +36,16 @@ class Editor extends React.Component { button: cn(styles.button, classNames.button, `${pluginName}-button`), }, }); + + // To edit comments and have the previous html comment + if (this.props.comment && this.props.comment.htmlBody) { + this.ref.content.innerHTML = this.props.comment.htmlBody; + } } render() { const { id, classNames } = this.props; + console.log(this.props); return (