From 943a790b35f97f5c804f2cc940065dbb2a76b61e Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Sun, 4 Jan 2015 17:38:04 +0100 Subject: [PATCH] Properly handling [code] insert if text has been selected --- .../install/files/js/3rdParty/redactor/plugins/wbbcode.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js index 746593fb87..96afe664ac 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js +++ b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js @@ -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 -- 2.20.1