From 391f3de12577731678d3f4ee7845c4edaa1a5619 Mon Sep 17 00:00:00 2001
From: chris <kokosias@yahoo.gr>
Date: Sat, 15 Apr 2017 01:35:11 +0300
Subject: [PATCH] comment box in correct vertical position for both editors

---
 .../SimpleEditor/panes/Comments/CommentBoxList.js     | 11 +++++++++--
 .../SimpleEditor/panes/Notes/NotesProvider.js         |  1 -
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/app/components/SimpleEditor/panes/Comments/CommentBoxList.js b/app/components/SimpleEditor/panes/Comments/CommentBoxList.js
index 164b313..26e62aa 100644
--- a/app/components/SimpleEditor/panes/Comments/CommentBoxList.js
+++ b/app/components/SimpleEditor/panes/Comments/CommentBoxList.js
@@ -77,11 +77,15 @@ class CommentBoxList extends Component {
 
     this.calculateTops(entries, activeEntry)
   }
+  // TODO move to helper section??
+  hasCssClass (element, className) {
+    return element.className && new RegExp('(^|\\s)' + className + '(\\s|$)').test(element.className)
+  }
 
   calculateTops (entries, active) {
     let result = []
     let boxes = []
-
+    let self = this
     _.each(entries, function (entry, pos) {
       // initialize annotationTop and boxHeight, as there is a chance that
       // annotation and box elements are not found by the selector
@@ -96,7 +100,10 @@ class CommentBoxList extends Component {
       // get position of annotation in editor
       const annotationEl = document.querySelector('span[data-id="' + entry.id + '"]')
 
-      if (annotationEl) annotationTop = parseInt(annotationEl.offsetTop)
+      if (annotationEl) {
+        annotationTop = (self.hasCssClass(annotationEl.offsetParent, 'sc-isolated-node'))
+        ? annotationEl.offsetParent.offsetTop + annotationEl.offsetTop : annotationEl.offsetTop
+      }
 
       // get height of this comment box
       const boxEl = document.querySelector('li[data-comment="' + entry.id + '"]')
diff --git a/app/components/SimpleEditor/panes/Notes/NotesProvider.js b/app/components/SimpleEditor/panes/Notes/NotesProvider.js
index 67ad0c3..dd0f5c3 100644
--- a/app/components/SimpleEditor/panes/Notes/NotesProvider.js
+++ b/app/components/SimpleEditor/panes/Notes/NotesProvider.js
@@ -100,7 +100,6 @@ class NotesProvider extends TOCProvider {
 
     if (notes.mini && notes.mini.length > 0) {
       let findIndex = _.findIndex(notes.main, ['id', note.id])
-      console.log('index', findIndex)
       let surface = this.config.miniEditorContext.surfaceManager.getSurface('body')
       let container = surface.getContainer()
       // let nodePos = container.getPosition(lastNote.id, 'strict')
-- 
GitLab