You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@corinthia.apache.org by ja...@apache.org on 2015/02/23 12:39:25 UTC

[22/31] incubator-corinthia git commit: Display cursor when in empty footnote or endnote

Display cursor when in empty footnote or endnote


Project: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/commit/334338ea
Tree: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/tree/334338ea
Diff: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/diff/334338ea

Branch: refs/heads/experimentzip
Commit: 334338eaef816be7ab281e25c750689ac6c55605
Parents: 8ad49fd
Author: Peter Kelly <pe...@uxproductivity.com>
Authored: Wed Feb 18 14:55:39 2015 +0700
Committer: Peter Kelly <pe...@uxproductivity.com>
Committed: Wed Feb 18 14:56:14 2015 +0700

----------------------------------------------------------------------
 Editor/src/Position.js | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/334338ea/Editor/src/Position.js
----------------------------------------------------------------------
diff --git a/Editor/src/Position.js b/Editor/src/Position.js
index ab5cfca..0421367 100644
--- a/Editor/src/Position.js
+++ b/Editor/src/Position.js
@@ -690,6 +690,27 @@ var Position_atPoint;
                  height: rect.height };
     }
 
+    function zeroWidthMidRect(rect)
+    {
+        var mid = rect.left + rect.width/2;
+        return { left: mid,
+                 right: mid, // 0 width
+                 top: rect.top,
+                 bottom: rect.bottom,
+                 width: 0,
+                 height: rect.height };
+    }
+
+    function findNoteContainingPos(pos)
+    {
+        var node = Position_closestActualNode(pos);
+        for (; node != null; node = node.parentNode) {
+            if (isNoteNode(node))
+                return node;
+        }
+        return null;
+    }
+
     function exactRectAtPos(pos)
     {
         var node = pos.node;
@@ -753,6 +774,10 @@ var Position_atPoint;
         if (rect != null)
             return rect;
 
+        var noteNode = findNoteContainingPos(pos);
+        if ((noteNode != null) && !nodeHasContent(noteNode)) // In empty footnote or endnote
+            return zeroWidthMidRect(noteNode.getBoundingClientRect());
+
         var paragraph = Text_findParagraphBoundaries(pos);
 
         var backRect = null;