From: Alexander Ebert Date: Mon, 23 May 2016 12:35:25 +0000 (+0200) Subject: Fixed check for caret position when inserting smilies X-Git-Tag: 2.1.11~16 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=7cfbdf62a59d30b520852e0990b32975476b90f7;p=GitHub%2FWoltLab%2FWCF.git Fixed check for caret position when inserting smilies --- 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);