Caret placement for raw bbcodes was incorrect
authorAlexander Ebert <ebert@woltlab.com>
Thu, 24 May 2018 10:39:08 +0000 (12:39 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Thu, 24 May 2018 10:39:08 +0000 (12:39 +0200)
wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabInsert.js

index 8882b76120797d042c8fb170b4b6d3742d26c0ab..50e31529bb5a42fd50b55b17049503c61efd9a31 100644 (file)
@@ -78,7 +78,7 @@ $.Redactor.prototype.WoltLabInsert = function() {
                                this.selection.saveInstant();
                        }).bind(this);
                        
-                       this.placeHtml = (function(html) {
+                       this.insert.placeHtml = (function(html) {
                                var hasBbcodeMarker = false;
                                html.forEach(function(fragment) {
                                        if (fragment instanceof Element && fragment.classList.contains('woltlab-bbcode-marker')) {
@@ -91,8 +91,10 @@ $.Redactor.prototype.WoltLabInsert = function() {
                                marker = this.insert.node(marker);
                                
                                $(marker).before(html);
-                               this.selection.restore();
-                               if (!hasBbcodeMarker) this.caret.after(marker);
+                               if (!hasBbcodeMarker) {
+                                       this.selection.restore();
+                                       this.caret.after(marker);
+                               }
                                $(marker).remove();
                        }).bind(this);
                }