From f2bfc25d6e3ead6314f58694712ef1e88c93bd1c Mon Sep 17 00:00:00 2001
From: Alexandros Georgantas <alexgeorg86@gmail.com>
Date: Tue, 28 Feb 2017 12:26:17 +0200
Subject: [PATCH] Correct postioning of the comment bubble

---
 .../SimpleEditor/elements/comment/CommentBubble.js | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/app/components/SimpleEditor/elements/comment/CommentBubble.js b/app/components/SimpleEditor/elements/comment/CommentBubble.js
index 47f99ca..5c79d60 100644
--- a/app/components/SimpleEditor/elements/comment/CommentBubble.js
+++ b/app/components/SimpleEditor/elements/comment/CommentBubble.js
@@ -59,19 +59,13 @@ class CommentBubble extends Tool {
       const overlayContainerLeft = overlayContainer.offsetLeft
       const left = documentElementWidth - overlayContainerLeft - 15
 
-      // const selection = this.getSelection()
-      // const container = surface.getContainer()
-      // const position = container.getPosition(surface.getDocument().get(selection.getNodeId()))
-
       // unhide it first, as the bubble has no height otherwise
       this.el.removeClass('sc-overlay-bubble-hidden')
 
-      // TODO getBoundingRectangleForSelection() doesn't exist anymore
-      // const hints = surface.getBoundingRectangleForSelection()
-      // const selectionHeight = hints.height
-
-      const selectionHeight = 20
-
+      let wsel = window.getSelection()
+      let wrange = wsel.getRangeAt(0)
+      const hints = wrange.getBoundingClientRect()
+      const selectionHeight = hints.height
       const bubbleHeight = this.el.getHeight()
       const cheat = 3
       const moveUp = (selectionHeight / 2) + (bubbleHeight / 2) + cheat
-- 
GitLab