Fixed adding a quote from selected text not purging the selection
authorAlexander Ebert <ebert@woltlab.com>
Tue, 31 Mar 2015 12:41:52 +0000 (14:41 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Tue, 31 Mar 2015 12:41:52 +0000 (14:41 +0200)
wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js

index 46204aea268b6b320b86ca596af9aa333f30ae90..d92af6f14f0150562af1e35080393def4034ec4d 100644 (file)
@@ -2074,6 +2074,8 @@ RedactorPlugins.wbbcode = function() {
                                // assign a unique id in order to recognize the inserted quote
                                $html = $html.replace(/<blockquote/, '<blockquote id="' + $id + '"');
                                
+                               var $originalRange = window.getSelection().getRangeAt(0).cloneRange();
+                               
                                this.wutil.restoreSelection();
                                var $selection = window.getSelection().getRangeAt(0);
                                var $current = $selection.startContainer;
@@ -2094,6 +2096,8 @@ RedactorPlugins.wbbcode = function() {
                                
                                this.insert.html($html, false);
                                
+                               $originalRange.deleteContents();
+                               
                                $quote = this.$editor.find('#' + $id);
                                if ($quote.length) {
                                        // quote may be empty if $innerHTML was empty, fix it