From 732fe46593ff27a62c6f64f3d495c3d5619ece1c Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Tue, 27 Jun 2023 12:18:22 +0200 Subject: [PATCH] Fix caret positioning outside editable. --- src/redakcja/static/js/wiki/caret.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/redakcja/static/js/wiki/caret.js b/src/redakcja/static/js/wiki/caret.js index 8b3cbd84..7026e2f5 100644 --- a/src/redakcja/static/js/wiki/caret.js +++ b/src/redakcja/static/js/wiki/caret.js @@ -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 ) ) -- 2.20.1