From 1467d3dff549a76c37ffc43ce29d3fb456b50b44 Mon Sep 17 00:00:00 2001 From: chris <kokosias@yahoo.gr> Date: Thu, 25 Jun 2020 20:08:36 +0300 Subject: [PATCH] set active comment on creation --- .../src/components/comments/CommentBox.js | 2 +- wax-prosemirror-plugins/src/comments/ActiveComment.js | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/wax-prosemirror-components/src/components/comments/CommentBox.js b/wax-prosemirror-components/src/components/comments/CommentBox.js index bd639da7d..e17cc7489 100644 --- a/wax-prosemirror-components/src/components/comments/CommentBox.js +++ b/wax-prosemirror-components/src/components/comments/CommentBox.js @@ -94,7 +94,7 @@ export default ({ comment, view, top, dataBox }) => { ref={commentInput} placeholder="add a new comment" onKeyPress={handleKeyDown} - // autoFocus + autoFocus /> <button onClick={saveComment}>Post</button> <button>Cancel</button> diff --git a/wax-prosemirror-plugins/src/comments/ActiveComment.js b/wax-prosemirror-plugins/src/comments/ActiveComment.js index b2396b8cb..5c7c63bab 100644 --- a/wax-prosemirror-plugins/src/comments/ActiveComment.js +++ b/wax-prosemirror-plugins/src/comments/ActiveComment.js @@ -6,8 +6,6 @@ import { DocumentHelpers } from "wax-prosemirror-utilities"; const activeComment = new PluginKey("activeComment"); const getComment = state => { - if (state.selection.from !== state.selection.to) return; - const commentMark = state.schema.marks["comment"]; const commentOnSelection = DocumentHelpers.findMark(state, commentMark); @@ -42,6 +40,12 @@ const getComment = state => { }; } } + if ( + state.selection.from !== state.selection.to && + commentOnSelection && + commentOnSelection.attrs.conversation.length + ) + return; return commentOnSelection; }; -- GitLab