From 2faa3c17ee0451d3f817dbc4fadcc0859ab62d83 Mon Sep 17 00:00:00 2001 From: chris <kokosias@yahoo.gr> Date: Fri, 18 Sep 2020 14:44:39 +0300 Subject: [PATCH] set active --- .../components/comments/ConnectedComment.js | 18 +++++++++++++++++- .../src/ui/comments/CommentBox.js | 1 + 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/wax-prosemirror-components/src/components/comments/ConnectedComment.js b/wax-prosemirror-components/src/components/comments/ConnectedComment.js index 15cf17eb5..68e919490 100644 --- a/wax-prosemirror-components/src/components/comments/ConnectedComment.js +++ b/wax-prosemirror-components/src/components/comments/ConnectedComment.js @@ -7,10 +7,26 @@ import CommentBox from '../../ui/comments/CommentBox'; export default ({ key, comment, dataBox, top, commentId, commentData }) => { const MemorizedComponent = memo(() => { + const { + view, + view: { + main: { + props: { user }, + }, + }, + app, + activeView, + } = useContext(WaxContext); + let active = false; + + const commentPlugin = app.PmPlugins.get('commentPlugin'); + const activeComment = commentPlugin.getState(activeView.state).comment; + + if (activeComment && commentId === activeComment.attrs.id) active = true; return ( <CommentBox key={commentId} - comment={commentData} + active={active} dataBox={commentId} top={top} commentId={commentId} diff --git a/wax-prosemirror-components/src/ui/comments/CommentBox.js b/wax-prosemirror-components/src/ui/comments/CommentBox.js index 47593084d..c89620ae1 100644 --- a/wax-prosemirror-components/src/ui/comments/CommentBox.js +++ b/wax-prosemirror-components/src/ui/comments/CommentBox.js @@ -79,6 +79,7 @@ const CommentBox = props => { <Wrapper style={style} active={active} + data-box={commentId} className={className} onClick={onClickWrapper} top={top} -- GitLab