Connecting WL + publishing author.
[redakcja.git] / src / redakcja / static / js / wiki / caret.js
index 8b3cbd8..b2cf182 100644 (file)
@@ -28,12 +28,15 @@ class Caret {
             
             var selection = window.getSelection();
             if (!selection.isCollapsed) return;
             
             var selection = window.getSelection();
             if (!selection.isCollapsed) return;
+            var anchorNode = selection.anchorNode;
+            // Is selection still inside a node?
+            if (!$(anchorNode).closest('[x-node]').length) return;
             
             self.singleClick = true;
             setTimeout(function() {
                 if (self.singleClick) {
                     self.element.insertBefore(
             
             self.singleClick = true;
             setTimeout(function() {
                 if (self.singleClick) {
                     self.element.insertBefore(
-                        selection.anchorNode.splitText(
+                        anchorNode.splitText(
                             selection.anchorOffset
                         )
                     )
                             selection.anchorOffset
                         )
                     )