diff --git a/.eslintignore b/.eslintignore index 6fecd9d9b..8a8c3a213 100644 --- a/.eslintignore +++ b/.eslintignore @@ -11,4 +11,5 @@ plugins/* !plugins/coral-plugin-mod !plugins/coral-plugin-love !plugins/coral-plugin-viewing-options +!plugins/coral-plugin-comment-content node_modules diff --git a/.gitignore b/.gitignore index abd490356..b3e0eaa73 100644 --- a/.gitignore +++ b/.gitignore @@ -24,5 +24,6 @@ plugins/* !plugins/coral-plugin-mod !plugins/coral-plugin-love !plugins/coral-plugin-viewing-options +!plugins/coral-plugin-comment-content **/node_modules/* diff --git a/client/coral-embed-stream/src/components/Comment.js b/client/coral-embed-stream/src/components/Comment.js index 92c59d936..a66b8a224 100644 --- a/client/coral-embed-stream/src/components/Comment.js +++ b/client/coral-embed-stream/src/components/Comment.js @@ -3,13 +3,13 @@ import React, {PropTypes} from 'react'; import PermalinkButton from 'coral-plugin-permalinks/PermalinkButton'; import AuthorName from 'coral-plugin-author-name/AuthorName'; import TagLabel from 'coral-plugin-tag-label/TagLabel'; -import Content from 'coral-plugin-commentcontent/CommentContent'; import PubDate from 'coral-plugin-pubdate/PubDate'; import {ReplyBox, ReplyButton} from 'coral-plugin-replies'; import FlagComment from 'coral-plugin-flags/FlagComment'; import {can} from 'coral-framework/services/perms'; import {TransitionGroup} from 'react-transition-group'; import cn from 'classnames'; +import styles from './Comment.css'; import { BestButton, @@ -18,14 +18,14 @@ import { commentIsBest, BestIndicator } from 'coral-plugin-best/BestButton'; -import Slot from 'coral-framework/components/Slot'; import LoadMore from './LoadMore'; +import {getEditableUntilDate} from './util'; import {TopRightMenu} from './TopRightMenu'; +import CommentContent from './CommentContent'; +import Slot from 'coral-framework/components/Slot'; import IgnoredCommentTombstone from './IgnoredCommentTombstone'; import {EditableCommentContent} from './EditableCommentContent'; import {getActionSummary, iPerformedThisAction} from 'coral-framework/utils'; -import {getEditableUntilDate} from './util'; -import styles from './Comment.css'; const isStaff = (tags) => !tags.every((t) => t.tag.name !== 'STAFF'); const hasTag = (tags, lookupTag) => !!tags.filter((t) => t.tag.name === lookupTag).length; @@ -466,8 +466,7 @@ export default class Comment extends React.Component { stopEditing={this.stopEditing} /> :
- - +
} diff --git a/client/coral-embed-stream/src/components/CommentContent.js b/client/coral-embed-stream/src/components/CommentContent.js new file mode 100644 index 000000000..4d56ec0d5 --- /dev/null +++ b/client/coral-embed-stream/src/components/CommentContent.js @@ -0,0 +1,19 @@ +import React from 'react'; + +const CommentContent = ({comment}) => { + const textbreaks = comment.body.split('\n'); + return
+ { + textbreaks.map((line, i) => { + return ( + + {line} +
+
+ ); + }) + } +
; +}; + +export default CommentContent; diff --git a/client/coral-framework/components/Slot.js b/client/coral-framework/components/Slot.js index 22a315623..ca246591b 100644 --- a/client/coral-framework/components/Slot.js +++ b/client/coral-framework/components/Slot.js @@ -4,10 +4,15 @@ import styles from './Slot.css'; import {connect} from 'react-redux'; import {getSlotElements} from 'coral-framework/helpers/plugins'; -function Slot ({fill, inline = false, className, plugin_config: config, ...rest}) { +function Slot ({fill, inline = false, className, plugin_config: config, defaultComponent: DefaultComponent, ...rest}) { + let children = getSlotElements(fill, {...rest, config}); + if (children.length === 0 && DefaultComponent) { + children = ; + } + return (
- {getSlotElements(fill, {...rest, config})} + {children}
); } diff --git a/client/coral-plugin-commentcontent/CommentContent.js b/client/coral-plugin-commentcontent/CommentContent.js deleted file mode 100644 index 501005b3d..000000000 --- a/client/coral-plugin-commentcontent/CommentContent.js +++ /dev/null @@ -1,17 +0,0 @@ -import React from 'react'; -const name = 'coral-plugin-commentcontent'; - -const Content = ({body, styles}) => { - const textbreaks = body.split('\n'); - return
- { - textbreaks.map((line, i) => - {line}
-
) - } -
; -}; - -export default Content; diff --git a/client/coral-plugin-commentcontent/__tests__/commentContent.spec.js b/client/coral-plugin-commentcontent/__tests__/commentContent.spec.js deleted file mode 100644 index 377726b6d..000000000 --- a/client/coral-plugin-commentcontent/__tests__/commentContent.spec.js +++ /dev/null @@ -1,11 +0,0 @@ -import React from 'react'; -import {shallow} from 'enzyme'; -import {expect} from 'chai'; -import CommentContent from '../CommentContent'; - -describe('CommentContent', () => { - it('should render content', () => { - const render = shallow(); - expect(render.contains('test')).to.be.truthy; - }); -}); diff --git a/client/coral-plugin-history/Comment.js b/client/coral-plugin-history/Comment.js index cb188e53e..888989737 100644 --- a/client/coral-plugin-history/Comment.js +++ b/client/coral-plugin-history/Comment.js @@ -1,8 +1,9 @@ import React, {PropTypes} from 'react'; import {Icon} from '../coral-ui'; import styles from './Comment.css'; +import Slot from 'coral-framework/components/Slot'; import PubDate from '../coral-plugin-pubdate/PubDate'; -import Content from '../coral-plugin-commentcontent/CommentContent'; +import CommentContent from '../coral-embed-stream/src/components/CommentContent'; import t from 'coral-framework/services/i18n'; @@ -10,9 +11,11 @@ const Comment = (props) => { return (
-

{t('createdisplay.if_you_dont_change_your_name')} diff --git a/plugins/coral-plugin-auth/client/components/FakeComment.js b/plugins/coral-plugin-auth/client/components/FakeComment.js index 390dd409b..5517b72aa 100644 --- a/plugins/coral-plugin-auth/client/components/FakeComment.js +++ b/plugins/coral-plugin-auth/client/components/FakeComment.js @@ -1,17 +1,17 @@ import React from 'react'; +import t from 'coral-framework/services/i18n'; import {ReplyButton} from 'coral-plugin-replies'; import PubDate from 'coral-plugin-pubdate/PubDate'; +import Slot from 'coral-framework/components/Slot'; import AuthorName from 'coral-plugin-author-name/AuthorName'; -import Content from 'coral-plugin-commentcontent/CommentContent'; import styles from 'coral-embed-stream/src/components/Comment.css'; -import t from 'coral-framework/services/i18n'; -export const FakeComment = ({username, created_at, body}) => ( +export const FakeComment = ({username, created_at, comment}) => (


- +