diff --git a/wax-prosemirror-components/src/components/comments/CommentBox.js b/wax-prosemirror-components/src/components/comments/CommentBox.js index f790aa2f1958c57de2960bc4f7c5784c502358fe..301591f51427b2aab4391f3835bced54be175dbd 100644 --- a/wax-prosemirror-components/src/components/comments/CommentBox.js +++ b/wax-prosemirror-components/src/components/comments/CommentBox.js @@ -30,9 +30,9 @@ const CommentBoxStyled = styled.div` export default ({ mark, view, top, dataComment }) => { const [animate, setAnimate] = useState(false); - const { view: { main }, app } = useContext(WaxContext); + const { view: { main }, app, activeView } = useContext(WaxContext); const activeCommentPlugin = app.PmPlugins.get("activeComment"); - const activeComment = activeCommentPlugin.getState(main.state).comment; + const activeComment = activeCommentPlugin.getState(activeView.state).comment; let active = false; if (activeComment && mark.attrs.id === activeComment.attrs.id) active = true; useEffect(() => { diff --git a/wax-prosemirror-components/src/components/comments/CommentComponent.js b/wax-prosemirror-components/src/components/comments/CommentComponent.js index 8152e223725d62e2e0198517ea93933381d87652..6746b4dc7a1fcb72e2512c3dbe73ba550b743341 100644 --- a/wax-prosemirror-components/src/components/comments/CommentComponent.js +++ b/wax-prosemirror-components/src/components/comments/CommentComponent.js @@ -13,7 +13,7 @@ import CommentsBoxList from "./CommentsBoxList"; import { each } from "lodash"; export default ({ area }) => { - const { view: { main }, app } = useContext(WaxContext); + const { view: { main }, app, activeView } = useContext(WaxContext); const activeCommentPlugin = app.PmPlugins.get("activeComment"); const [comments, setComments] = useState([]); const [position, setPosition] = useState(); @@ -30,7 +30,9 @@ export default ({ area }) => { each(comments[area], (comment, pos) => { const WaxSurface = main.dom.getBoundingClientRect(); const { attrs: { id } } = comment; - const activeComment = activeCommentPlugin.getState(main.state).comment; + const activeComment = activeCommentPlugin.getState(activeView.state) + .comment; + let isActive = false; if (activeComment && comment.attrs.id === activeComment.attrs.id) isActive = true; diff --git a/wax-prosemirror-components/src/components/notes/NoteEditorContainer.js b/wax-prosemirror-components/src/components/notes/NoteEditorContainer.js index a978fa279a90df4e18c7f8fe89515171513ebfc2..9acb8015c9b1340c4ddd630a51e2f4c52d58c893 100644 --- a/wax-prosemirror-components/src/components/notes/NoteEditorContainer.js +++ b/wax-prosemirror-components/src/components/notes/NoteEditorContainer.js @@ -26,6 +26,10 @@ const NoteStyled = styled.div` span.comment { border-bottom: 2px solid #ffab20; border-radius: 3px 3px 0 0; + + .active-comment { + background-color: #ffab20; + } } `; diff --git a/wax-prosemirror-services/src/NoteService/Editor.js b/wax-prosemirror-services/src/NoteService/Editor.js index 864917027753ae41b4912cc529f8012efa9f3ff9..f10e5ea5342043af49d58477db69cbe7e525e27f 100644 --- a/wax-prosemirror-services/src/NoteService/Editor.js +++ b/wax-prosemirror-services/src/NoteService/Editor.js @@ -15,14 +15,13 @@ export default ({ node, view }) => { const editorRef = useRef(); const context = useContext(WaxContext); const noteId = node.attrs.id; - useEffect(() => { const noteView = new EditorView( { mount: editorRef.current }, { state: EditorState.create({ doc: node, - plugins: [keymap(createKeyBindings())] + plugins: [keymap(createKeyBindings()), ...context.app.getPlugins()] }), // This is the magic part dispatchTransaction: tr => {