Setting caret after creating list
[fnpeditor.git] / modules / documentCanvas / canvas / canvas.js
index c2b579b..7143b79 100644 (file)
@@ -434,6 +434,9 @@ $.extend(Cursor.prototype, {
     getSelectionAnchor: function() {
         return this.getSelectionBoundry('anchor');
     },
+    getSelectionFocus: function() {
+        return this.getSelectionBoundry('focus');
+    },
     getSelectionBoundry: function(which) {
         var selection = window.getSelection(),
             anchorElement = this.canvas.getDocumentElement(selection.anchorNode),
@@ -450,6 +453,14 @@ $.extend(Cursor.prototype, {
                 offsetAtEnd: anchorElement && anchorElement.getText().length === selection.anchorOffset
             };
         }
+        if(which === 'focus') {
+            return {
+                element: focusElement,
+                offset: selection.focusOffset,
+                offsetAtBeginning: selection.focusOffset === 0,
+                offsetAtEnd: focusElement && focusElement.getText().length === selection.focusOffset
+            };
+        }
         
         var element,
             offset;