From 27d3da4949da185ed78c84514483e36bbea3f371 Mon Sep 17 00:00:00 2001 From: Isaac Blinder Date: Mon, 29 Apr 2019 14:04:08 -0400 Subject: [PATCH] added hashtags for comments --- package-lock.json | 41 +++++-------------- src/components/comment/CommentComponent.tsx | 31 ++++++++++++-- .../comment/ICommentComponentProps.ts | 14 +++++++ 3 files changed, 53 insertions(+), 33 deletions(-) diff --git a/package-lock.json b/package-lock.json index fe2cde2..78c1bb8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5392,8 +5392,7 @@ }, "ansi-regex": { "version": "2.1.1", - "bundled": true, - "optional": true + "bundled": true }, "aproba": { "version": "1.2.0", @@ -5411,13 +5410,11 @@ }, "balanced-match": { "version": "1.0.0", - "bundled": true, - "optional": true + "bundled": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, - "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -5430,18 +5427,15 @@ }, "code-point-at": { "version": "1.1.0", - "bundled": true, - "optional": true + "bundled": true }, "concat-map": { "version": "0.0.1", - "bundled": true, - "optional": true + "bundled": true }, "console-control-strings": { "version": "1.1.0", - "bundled": true, - "optional": true + "bundled": true }, "core-util-is": { "version": "1.0.2", @@ -5544,8 +5538,7 @@ }, "inherits": { "version": "2.0.3", - "bundled": true, - "optional": true + "bundled": true }, "ini": { "version": "1.3.5", @@ -5555,7 +5548,6 @@ "is-fullwidth-code-point": { "version": "1.0.0", "bundled": true, - "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -5568,20 +5560,17 @@ "minimatch": { "version": "3.0.4", "bundled": true, - "optional": true, "requires": { "brace-expansion": "^1.1.7" } }, "minimist": { "version": "0.0.8", - "bundled": true, - "optional": true + "bundled": true }, "minipass": { "version": "2.3.5", "bundled": true, - "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -5598,7 +5587,6 @@ "mkdirp": { "version": "0.5.1", "bundled": true, - "optional": true, "requires": { "minimist": "0.0.8" } @@ -5671,8 +5659,7 @@ }, "number-is-nan": { "version": "1.0.1", - "bundled": true, - "optional": true + "bundled": true }, "object-assign": { "version": "4.1.1", @@ -5682,7 +5669,6 @@ "once": { "version": "1.4.0", "bundled": true, - "optional": true, "requires": { "wrappy": "1" } @@ -5758,8 +5744,7 @@ }, "safe-buffer": { "version": "5.1.2", - "bundled": true, - "optional": true + "bundled": true }, "safer-buffer": { "version": "2.1.2", @@ -5789,7 +5774,6 @@ "string-width": { "version": "1.0.2", "bundled": true, - "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -5807,7 +5791,6 @@ "strip-ansi": { "version": "3.0.1", "bundled": true, - "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -5846,13 +5829,11 @@ }, "wrappy": { "version": "1.0.2", - "bundled": true, - "optional": true + "bundled": true }, "yallist": { "version": "3.0.3", - "bundled": true, - "optional": true + "bundled": true } } }, diff --git a/src/components/comment/CommentComponent.tsx b/src/components/comment/CommentComponent.tsx index 51bb89b..c0d0eaa 100644 --- a/src/components/comment/CommentComponent.tsx +++ b/src/components/comment/CommentComponent.tsx @@ -9,6 +9,7 @@ import Linkify from 'react-linkify' import Popover from '@material-ui/core/Popover' import { getTranslate, getActiveLanguage } from 'react-localize-redux' import {Map} from 'immutable' +import { push } from 'connected-react-router' 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 ClickAwayListener from '@material-ui/core/ClickAwayListener' import classNames from 'classnames' +import reactStringReplace from 'react-string-replace' // - Import app components import UserAvatar from 'components/userAvatar' @@ -41,6 +43,7 @@ import UserAvatar from 'components/userAvatar' // - Import actions import * as commentActions from 'store/actions/commentActions' import * as userActions from 'store/actions/userActions' +import * as globalActions from 'store/actions/globalActions' import { ICommentComponentProps } from './ICommentComponentProps' import { ICommentComponentState } from './ICommentComponentState' @@ -305,7 +308,7 @@ export class CommentComponent extends Component :
{this.state.text}
} + /> :
{ + + + {reactStringReplace(this.state.text, /#(\w+)/g, (match: string, i: string) => ( + { + evt.preventDefault() + goTo!(`/tag/${match}`) + setHomeTitle!(`#${match}`) + }} + > + #{match} + + + + ))} + } +
}