Fixed inserting quotes on Chrome for Android
authorAlexander Ebert <ebert@woltlab.com>
Thu, 12 Mar 2015 17:13:34 +0000 (18:13 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Thu, 12 Mar 2015 17:13:34 +0000 (18:13 +0100)
wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js

index d3632200c69e6dc9c07c70d81e89a4446c2e34de..7601edd752b8fd7f6d012ef601ca455431529228 100644 (file)
@@ -2036,6 +2036,24 @@ RedactorPlugins.wbbcode = function() {
                                // assign a unique id in order to recognize the inserted quote
                                $html = $html.replace(/<blockquote/, '<blockquote id="' + $id + '"');
                                
+                               this.wutil.restoreSelection();
+                               var $selection = window.getSelection().getRangeAt(0);
+                               var $current = $selection.startContainer;
+                               while ($current) {
+                                       var $parent = $current.parentNode;
+                                       if ($parent === this.$editor[0]) {
+                                               break;
+                                       }
+                                       
+                                       $current = $parent;
+                               }
+                               
+                               if ($current && $current.parentNode === this.$editor[0]) {
+                                       if ($current.innerHTML.length) {
+                                               this.wutil.setCaretAfter($current);
+                                       }
+                               }
+                               
                                this.insert.html($html, false);
                                
                                $quote = this.$editor.find('#' + $id);