Fix caret positioning outside editable.
authorRadek Czajka <rczajka@rczajka.pl>
Tue, 27 Jun 2023 10:18:22 +0000 (12:18 +0200)
committerRadek Czajka <rczajka@rczajka.pl>
Tue, 27 Jun 2023 10:18:22 +0000 (12:18 +0200)
src/redakcja/static/js/wiki/caret.js

index 8b3cbd8..7026e2f 100644 (file)
@@ -28,12 +28,15 @@ class Caret {
             
             var selection = window.getSelection();
             if (!selection.isCollapsed) return;
+            var anchorNode = selection.anchorNode;
+            // Is selection still inside a node?
+            if (!$(anchorNode).closest('[x-node]')) return;
             
             self.singleClick = true;
             setTimeout(function() {
                 if (self.singleClick) {
                     self.element.insertBefore(
-                        selection.anchorNode.splitText(
+                        anchorNode.splitText(
                             selection.anchorOffset
                         )
                     )