Properly handling [code] insert if text has been selected
authorAlexander Ebert <ebert@woltlab.com>
Sun, 4 Jan 2015 16:38:04 +0000 (17:38 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Sun, 4 Jan 2015 16:38:04 +0000 (17:38 +0100)
wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js

index 746593fb876f568ef78e9f8b4e15e3164f355d22..96afe664ac0ab925e5df1efc10b7534747e737b8 100644 (file)
@@ -1793,10 +1793,14 @@ RedactorPlugins.wbbcode = function() {
                        var $button = this.modal.createActionButton(this.lang.get('save'));
                        
                        if (isInsert) {
+                               this.selection.get();
+                               var $selectedText = this.selection.getText();
+                               
                                this.selection.save();
                                this.modal.show();
                                
-                               $('#redactorCodeBox').focus();
+                               var $codeBox = $('#redactorCodeBox').focus();
+                               $codeBox.val($selectedText);
                                
                                $button.click($.proxy(function() {
                                        var $codeBox = $('#redactorCodeBox');
@@ -1812,6 +1816,8 @@ RedactorPlugins.wbbcode = function() {
                                        this.wutil.adjustSelectionForBlockElement();
                                        this.wutil.saveSelection();
                                        var $html = this.wbbcode.convertToHtml($bbcode);
+                                       
+                                       this.buffer.set();
                                        this.insert.html($html, false);
                                        
                                        // set caret after code listing