Fixed internal editor selection not updated after clicking
authorAlexander Ebert <ebert@woltlab.com>
Fri, 14 Aug 2015 13:02:21 +0000 (15:02 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Fri, 14 Aug 2015 13:02:21 +0000 (15:02 +0200)
wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js

index b228996d8be91850f86a4beafc72918454866ac1..fb0bad1d7da5a9006f791863db91aa1a36dfb336 100644 (file)
@@ -150,13 +150,13 @@ RedactorPlugins.wbbcode = function() {
                        
                        // insert a new line if user clicked into the editor and the last children is a quote (same behavior as arrow down)
                        this.wutil.setOption('clickCallback', (function(event) {
-                               this.wutil.saveSelection();
-                               
                                if (event.target === this.$editor[0]) {
                                        if (this.$editor[0].lastElementChild && this.$editor[0].lastElementChild.tagName === 'BLOCKQUOTE') {
                                                this.wutil.setCaretAfter($(this.$editor[0].lastElementChild));
                                        }
                                }
+                               
+                               setTimeout(this.wutil.saveSelection.bind(this), 10);
                        }).bind(this));
                        
                        // drop ul to prevent being touched by this.clean.clearUnverifiedRemove()
@@ -212,6 +212,8 @@ RedactorPlugins.wbbcode = function() {
                        }
                        
                        if (this.opts.visual) {
+                               this.wutil.restoreSelection();
+                               
                                var $parentBefore = null;
                                if (window.getSelection().rangeCount && window.getSelection().getRangeAt(0).collapsed) {
                                        $parentBefore = window.getSelection().getRangeAt(0).startContainer;
@@ -268,6 +270,8 @@ RedactorPlugins.wbbcode = function() {
                                                $parent.insertBefore($node, $smiley.nextSibling);
                                        }
                                }
+                               
+                               this.wutil.saveSelection();
                        }
                        else {
                                this.wutil.insertAtCaret(' ' + smileyCode + ' ');