diff --git a/editors/editoria/src/config/config.js b/editors/editoria/src/config/config.js index 26becea374e9167d3fb68405bdcad87124a8305d..40a9d1d2eb638721603cd94c19d4f4c45ecfd6e5 100644 --- a/editors/editoria/src/config/config.js +++ b/editors/editoria/src/config/config.js @@ -42,7 +42,6 @@ export default { ], RulesService: [emDash, ellipsis], - CommentsService: { groups: ["main", "notes"] }, ShortCutsService: {}, PmPlugins: [columnResizing(), tableEditing(), invisibles([hardBreak()])], diff --git a/wax-prosemirror-components/src/components/comments/CommentComponent.js b/wax-prosemirror-components/src/components/comments/CommentComponent.js index 5bafdacf3789e6d3fe4507f09881280ba20882d3..7c305d7ee86ee35339710452d409c8c8c89f4c68 100644 --- a/wax-prosemirror-components/src/components/comments/CommentComponent.js +++ b/wax-prosemirror-components/src/components/comments/CommentComponent.js @@ -12,24 +12,30 @@ import { DocumentHelpers } from "wax-prosemirror-utilities"; import CommentsBoxList from "./CommentsBoxList"; export default ({ area }) => { - const { view: { main } } = useContext(WaxContext); + const { view: { main }, activeView } = useContext(WaxContext); const [comments, setComments] = useState([]); useEffect( () => { - setComments(updateComments(main, area)); + setComments(updateComments(main)); }, - [JSON.stringify(updateComments(main, area))] + [JSON.stringify(updateComments(main))] ); const CommentComponent = useMemo( - () => <CommentsBoxList comments={comments[area] || []} view={main} />, + () => ( + <CommentsBoxList + comments={comments[area] || []} + area={area} + view={main} + /> + ), [comments[area] || []] ); return <Fragment>{CommentComponent}</Fragment>; }; -const updateComments = (view, area) => { +const updateComments = view => { if (view) { const nodes = DocumentHelpers.findChildrenByMark( view.state.doc, diff --git a/wax-prosemirror-components/src/components/comments/CommentsBoxList.js b/wax-prosemirror-components/src/components/comments/CommentsBoxList.js index 6795f49e36232273722077f5221d4da4571d672c..4bc0f5e87437e5ef635ee06c6a89cc5e0a3ac85f 100644 --- a/wax-prosemirror-components/src/components/comments/CommentsBoxList.js +++ b/wax-prosemirror-components/src/components/comments/CommentsBoxList.js @@ -2,7 +2,7 @@ import React, { Fragment, useState, useEffect, useCallback } from "react"; import { each } from "lodash"; import CommentBox from "./CommentBox"; -export default ({ comments, view }) => { +export default ({ comments, view, area }) => { const [position, setPosition] = useState(); const setTops = useCallback(() => { @@ -14,14 +14,16 @@ export default ({ comments, view }) => { let top = 0; const allCommentsTop = {}; - each(comments, (entry, pos) => { + each(comments, (comment, pos) => { const WaxSurface = view.dom.getBoundingClientRect(); - const id = entry.attrs.id; + const { attrs: { id } } = comment; let isActive = false; - // if (entry.id === active) isActive = true + // if (comment.id === active) isActive = true commentEl = document.getElementById(id); //annotation top + console.log(commentEl.getBoundingClientRect().top, commentEl.offsetTop); annotationTop = commentEl.getBoundingClientRect().top - WaxSurface.top; + // get height of this comment box const boxEl = document.querySelector(`div[data-comment="comment-${id}"]`); if (boxEl) boxHeight = parseInt(boxEl.offsetHeight); @@ -41,12 +43,12 @@ export default ({ comments, view }) => { } } // store where the box ends to be aware of overlaps in the next box - entry.endHeight = top + boxHeight + 2; + comment.endHeight = top + boxHeight + 2; result[pos] = top; // if active, move as many boxes above as needed to bring it to the annotation's height if (isActive) { - entry.endHeight = annotationTop + boxHeight + 2; + comment.endHeight = annotationTop + boxHeight + 2; result[pos] = annotationTop; let b = true; @@ -88,10 +90,10 @@ export default ({ comments, view }) => { return ( <Fragment> {comments.map(comment => { - const id = comment.attrs.id; + const { attrs: { id } } = comment; return ( <CommentBox - key={comment.attrs.id} + key={id} mark={comment} view={view} top={position[id]} diff --git a/wax-prosemirror-components/src/components/notes/NoteEditorContainer.js b/wax-prosemirror-components/src/components/notes/NoteEditorContainer.js index 3ca362cfd478e3df4ada1d0f0736bc296a97daf5..fa78e434fdac68ad12716a77b63492ee726a37bc 100644 --- a/wax-prosemirror-components/src/components/notes/NoteEditorContainer.js +++ b/wax-prosemirror-components/src/components/notes/NoteEditorContainer.js @@ -8,6 +8,7 @@ const NoteEditorContainerStyled = styled.div` flex-direction: row; min-height: 40px; width: 100%; + position: relative; `; const NoteStyled = styled.div` diff --git a/wax-prosemirror-layouts/src/layouts/EditoriaLayout.js b/wax-prosemirror-layouts/src/layouts/EditoriaLayout.js index f5dc5c63524362af1fff3fe00f9af2116516c87b..3f815e45c5200bc1597bc9ccc516c801c6fc2066 100644 --- a/wax-prosemirror-layouts/src/layouts/EditoriaLayout.js +++ b/wax-prosemirror-layouts/src/layouts/EditoriaLayout.js @@ -163,6 +163,7 @@ const NotesAreaContainer = styled.div` width: 100%; height: 100%; overflow-y: scroll; + position: absolute; `; const NotesContainer = styled.div` @@ -172,6 +173,7 @@ const NotesContainer = styled.div` padding: 0 0 10px 5px; height: 100%; width: 65%; + position: relative; `; const CommentsContainer = styled.div`