corinthia-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmke...@apache.org
Subject incubator-corinthia git commit: Display cursor when in empty footnote or endnote
Date Wed, 18 Feb 2015 07:57:08 GMT
Repository: incubator-corinthia
Updated Branches:
  refs/heads/master 8ad49fd75 -> 334338eae


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/master
Commit: 334338eaef816be7ab281e25c750689ac6c55605
Parents: 8ad49fd
Author: Peter Kelly <peter@uxproductivity.com>
Authored: Wed Feb 18 14:55:39 2015 +0700
Committer: Peter Kelly <peter@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;


Mime
View raw message