From 4a44c8efd1f5b30eeb33f5af4d3ad5ef64ade90f Mon Sep 17 00:00:00 2001
From: chris <kokosias@yahoo.gr>
Date: Mon, 13 Apr 2020 11:41:27 +0300
Subject: [PATCH] comment boxes tops based on areas

---
 .../src/components/comments/CommentsBoxList.js  | 17 ++++++++++++++---
 .../src/layouts/EditoriaLayout.js               |  2 +-
 wax-prosemirror-schema/src/marks/commentMark.js |  2 +-
 3 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/wax-prosemirror-components/src/components/comments/CommentsBoxList.js b/wax-prosemirror-components/src/components/comments/CommentsBoxList.js
index 4bc0f5e87..88e6b2095 100644
--- a/wax-prosemirror-components/src/components/comments/CommentsBoxList.js
+++ b/wax-prosemirror-components/src/components/comments/CommentsBoxList.js
@@ -19,10 +19,21 @@ export default ({ comments, view, area }) => {
       const { attrs: { id } } = comment;
       let isActive = false;
       // 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;
+      if (area === "main") {
+        commentEl = document.querySelector(`span[data-id="${id}"]`);
+        annotationTop = commentEl.getBoundingClientRect().top - WaxSurface.top;
+      } else {
+        const panelWrapper = document.getElementsByClassName("panelWrapper");
+        const panelWrapperHeight = panelWrapper[0].getBoundingClientRect()
+          .height;
+        commentEl = document
+          .querySelector("#notes-container")
+          .querySelector(`span[data-id="${id}"]`);
+        annotationTop =
+          commentEl.getBoundingClientRect().top - panelWrapperHeight - 50;
+      }
 
       // get height of this comment box
       const boxEl = document.querySelector(`div[data-comment="comment-${id}"]`);
diff --git a/wax-prosemirror-layouts/src/layouts/EditoriaLayout.js b/wax-prosemirror-layouts/src/layouts/EditoriaLayout.js
index 3f815e45c..972f6437d 100644
--- a/wax-prosemirror-layouts/src/layouts/EditoriaLayout.js
+++ b/wax-prosemirror-layouts/src/layouts/EditoriaLayout.js
@@ -210,7 +210,7 @@ const hasNotes = main => {
 const withNotes = () => {
   return (
     <NotesAreaContainer>
-      <NotesContainer>
+      <NotesContainer id="notes-container">
         <NotesArea />
       </NotesContainer>
       <CommentsContainer>
diff --git a/wax-prosemirror-schema/src/marks/commentMark.js b/wax-prosemirror-schema/src/marks/commentMark.js
index 0c1531304..2fc3ba73b 100644
--- a/wax-prosemirror-schema/src/marks/commentMark.js
+++ b/wax-prosemirror-schema/src/marks/commentMark.js
@@ -23,7 +23,7 @@ const comment = {
       "span",
       {
         class: "comment",
-        id: node.attrs.id,
+        "data-id": node.attrs.id,
         "data-group": node.attrs.group,
         "data-conversation": JSON.stringify(node.attrs.conversation)
       }
-- 
GitLab