added hashtags for comments

This commit is contained in:
Isaac Blinder
2019-04-29 14:04:08 -04:00
parent e95284521f
commit 27d3da4949
3 changed files with 53 additions and 33 deletions

41
package-lock.json generated
View File

@@ -5392,8 +5392,7 @@
}, },
"ansi-regex": { "ansi-regex": {
"version": "2.1.1", "version": "2.1.1",
"bundled": true, "bundled": true
"optional": true
}, },
"aproba": { "aproba": {
"version": "1.2.0", "version": "1.2.0",
@@ -5411,13 +5410,11 @@
}, },
"balanced-match": { "balanced-match": {
"version": "1.0.0", "version": "1.0.0",
"bundled": true, "bundled": true
"optional": true
}, },
"brace-expansion": { "brace-expansion": {
"version": "1.1.11", "version": "1.1.11",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"balanced-match": "^1.0.0", "balanced-match": "^1.0.0",
"concat-map": "0.0.1" "concat-map": "0.0.1"
@@ -5430,18 +5427,15 @@
}, },
"code-point-at": { "code-point-at": {
"version": "1.1.0", "version": "1.1.0",
"bundled": true, "bundled": true
"optional": true
}, },
"concat-map": { "concat-map": {
"version": "0.0.1", "version": "0.0.1",
"bundled": true, "bundled": true
"optional": true
}, },
"console-control-strings": { "console-control-strings": {
"version": "1.1.0", "version": "1.1.0",
"bundled": true, "bundled": true
"optional": true
}, },
"core-util-is": { "core-util-is": {
"version": "1.0.2", "version": "1.0.2",
@@ -5544,8 +5538,7 @@
}, },
"inherits": { "inherits": {
"version": "2.0.3", "version": "2.0.3",
"bundled": true, "bundled": true
"optional": true
}, },
"ini": { "ini": {
"version": "1.3.5", "version": "1.3.5",
@@ -5555,7 +5548,6 @@
"is-fullwidth-code-point": { "is-fullwidth-code-point": {
"version": "1.0.0", "version": "1.0.0",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"number-is-nan": "^1.0.0" "number-is-nan": "^1.0.0"
} }
@@ -5568,20 +5560,17 @@
"minimatch": { "minimatch": {
"version": "3.0.4", "version": "3.0.4",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"brace-expansion": "^1.1.7" "brace-expansion": "^1.1.7"
} }
}, },
"minimist": { "minimist": {
"version": "0.0.8", "version": "0.0.8",
"bundled": true, "bundled": true
"optional": true
}, },
"minipass": { "minipass": {
"version": "2.3.5", "version": "2.3.5",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"safe-buffer": "^5.1.2", "safe-buffer": "^5.1.2",
"yallist": "^3.0.0" "yallist": "^3.0.0"
@@ -5598,7 +5587,6 @@
"mkdirp": { "mkdirp": {
"version": "0.5.1", "version": "0.5.1",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"minimist": "0.0.8" "minimist": "0.0.8"
} }
@@ -5671,8 +5659,7 @@
}, },
"number-is-nan": { "number-is-nan": {
"version": "1.0.1", "version": "1.0.1",
"bundled": true, "bundled": true
"optional": true
}, },
"object-assign": { "object-assign": {
"version": "4.1.1", "version": "4.1.1",
@@ -5682,7 +5669,6 @@
"once": { "once": {
"version": "1.4.0", "version": "1.4.0",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"wrappy": "1" "wrappy": "1"
} }
@@ -5758,8 +5744,7 @@
}, },
"safe-buffer": { "safe-buffer": {
"version": "5.1.2", "version": "5.1.2",
"bundled": true, "bundled": true
"optional": true
}, },
"safer-buffer": { "safer-buffer": {
"version": "2.1.2", "version": "2.1.2",
@@ -5789,7 +5774,6 @@
"string-width": { "string-width": {
"version": "1.0.2", "version": "1.0.2",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"code-point-at": "^1.0.0", "code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0", "is-fullwidth-code-point": "^1.0.0",
@@ -5807,7 +5791,6 @@
"strip-ansi": { "strip-ansi": {
"version": "3.0.1", "version": "3.0.1",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"ansi-regex": "^2.0.0" "ansi-regex": "^2.0.0"
} }
@@ -5846,13 +5829,11 @@
}, },
"wrappy": { "wrappy": {
"version": "1.0.2", "version": "1.0.2",
"bundled": true, "bundled": true
"optional": true
}, },
"yallist": { "yallist": {
"version": "3.0.3", "version": "3.0.3",
"bundled": true, "bundled": true
"optional": true
} }
} }
}, },

View File

@@ -9,6 +9,7 @@ import Linkify from 'react-linkify'
import Popover from '@material-ui/core/Popover' import Popover from '@material-ui/core/Popover'
import { getTranslate, getActiveLanguage } from 'react-localize-redux' import { getTranslate, getActiveLanguage } from 'react-localize-redux'
import {Map} from 'immutable' import {Map} from 'immutable'
import { push } from 'connected-react-router'
import { Comment } from 'core/domain/comments' import { Comment } from 'core/domain/comments'
@@ -32,6 +33,7 @@ import { Card, CardActions, CardHeader, CardMedia, CardContent } from '@material
import Grow from '@material-ui/core/Grow' import Grow from '@material-ui/core/Grow'
import ClickAwayListener from '@material-ui/core/ClickAwayListener' import ClickAwayListener from '@material-ui/core/ClickAwayListener'
import classNames from 'classnames' import classNames from 'classnames'
import reactStringReplace from 'react-string-replace'
// - Import app components // - Import app components
import UserAvatar from 'components/userAvatar' import UserAvatar from 'components/userAvatar'
@@ -41,6 +43,7 @@ import UserAvatar from 'components/userAvatar'
// - Import actions // - Import actions
import * as commentActions from 'store/actions/commentActions' import * as commentActions from 'store/actions/commentActions'
import * as userActions from 'store/actions/userActions' import * as userActions from 'store/actions/userActions'
import * as globalActions from 'store/actions/globalActions'
import { ICommentComponentProps } from './ICommentComponentProps' import { ICommentComponentProps } from './ICommentComponentProps'
import { ICommentComponentState } from './ICommentComponentState' import { ICommentComponentState } from './ICommentComponentState'
@@ -305,7 +308,7 @@ export class CommentComponent extends Component<ICommentComponentProps, IComment
/** /**
* Comment object from props * Comment object from props
*/ */
const { comment, classes, fullName, avatar, translate , editorStatus} = this.props const { comment, classes, fullName, avatar, translate , editorStatus, goTo, setHomeTitle} = this.props
const { openMenu, anchorEl } = this.state const { openMenu, anchorEl } = this.state
@@ -373,7 +376,27 @@ export class CommentComponent extends Component<ICommentComponentProps, IComment
onChange={this.handleOnChange} onChange={this.handleOnChange}
className={classes.textField} className={classes.textField}
fullWidth={true} fullWidth={true}
/> : <div className={classNames('animate2-top10', classes.commentBody)}>{this.state.text}</div>} /> : <div className={classNames('animate2-top10', classes.commentBody)}>{
<Linkify properties={{ target: '_blank', style: { color: 'blue' } }}>
{reactStringReplace(this.state.text, /#(\w+)/g, (match: string, i: string) => (
<NavLink
style={{ color: 'green' }}
key={match + i}
to={`/tag/${match}`}
onClick={evt => {
evt.preventDefault()
goTo!(`/tag/${match}`)
setHomeTitle!(`#${match}`)
}}
>
#{match}
</NavLink>
))}
</Linkify>}
</div>}
<div style={{ display: (editorStatus ? 'flex' : 'none'), flexDirection: 'row-reverse' }}> <div style={{ display: (editorStatus ? 'flex' : 'none'), flexDirection: 'row-reverse' }}>
<Button color='primary' disabled={this.state.editDisabled} <Button color='primary' disabled={this.state.editDisabled}
@@ -418,9 +441,11 @@ const mapDispatchToProps = (dispatch: any, ownProps: ICommentComponentProps) =>
update: (comment: Comment) => { update: (comment: Comment) => {
dispatch(commentActions.dbUpdateComment(comment)) dispatch(commentActions.dbUpdateComment(comment))
}, },
goTo: (url: string) => dispatch(push(url)),
openEditor: () => dispatch(commentActions.openCommentEditor({ id: ownProps.comment.id, postId: ownProps.comment.postId })), openEditor: () => dispatch(commentActions.openCommentEditor({ id: ownProps.comment.id, postId: ownProps.comment.postId })),
closeEditor: () => dispatch(commentActions.closeCommentEditor({ id: ownProps.comment.id, postId: ownProps.comment.postId })), closeEditor: () => dispatch(commentActions.closeCommentEditor({ id: ownProps.comment.id, postId: ownProps.comment.postId })),
getUserInfo: () => dispatch(userActions.dbGetUserInfoByUserId(ownProps.comment.userId!, '')) setHomeTitle: (title: string) => dispatch(globalActions.setHeaderTitle(title || '')),
getUserInfo: () => dispatch(userActions.dbGetUserInfoByUserId(ownProps.comment.userId!, '')),
} }
} }

View File

@@ -54,6 +54,20 @@ export interface ICommentComponentProps {
*/ */
update?: (comment: Comment) => any update?: (comment: Comment) => any
/**
* Redirect to {url} route
*
* @memberof IPostComponentProps
*/
goTo?: (url: string) => any
/**
* Set tile of top bar
*
* @memberof IPostComponentProps
*/
setHomeTitle?: (title: string) => any
/** /**
* Delete comment * Delete comment
* *