From 7cfbdf62a59d30b520852e0990b32975476b90f7 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Mon, 23 May 2016 14:35:25 +0200 Subject: [PATCH] Fixed check for caret position when inserting smilies --- .../files/js/3rdParty/redactor/plugins/wbbcode.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js index 3472b31dd1..9323484801 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js +++ b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js @@ -234,7 +234,7 @@ RedactorPlugins.wbbcode = function() { this.wutil.restoreSelection(); var $selection = window.getSelection(); - if (!$selection.rangeCount) { + if (!$selection.rangeCount || !this.utils.isRedactorParent($selection.getRangeAt(0).startContainer)) { // ensures that we always have a valid selection this.focus.setEnd(); } @@ -263,19 +263,19 @@ RedactorPlugins.wbbcode = function() { } return false; - } + }; var $lastNode = $smiley; // add spaces as paddings - var $parent = $smiley.parentElement; + var $parent = $smiley.parentElement, $node; if (!$isSpace($smiley.previousSibling)) { - var $node = document.createTextNode('\u00A0'); + $node = document.createTextNode('\u00A0'); $parent.insertBefore($node, $smiley); } if (!$isSpace($smiley.nextSibling)) { - var $node = document.createTextNode('\u00A0'); + $node = document.createTextNode('\u00A0'); if ($parent.lastChild === $smiley) { $parent.appendChild($node); } @@ -287,7 +287,7 @@ RedactorPlugins.wbbcode = function() { } // force caret after the inserted smiley - var $range = document.createRange(); + $range = document.createRange(); $range.selectNode($lastNode); $range.collapse(false); -- 2.20.1