Fixed @@@wcf_empty_line@@@ appearing when wrapping text with a quote
authorAlexander Ebert <ebert@woltlab.com>
Sun, 18 Jan 2015 11:08:07 +0000 (12:08 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Sun, 18 Jan 2015 11:08:07 +0000 (12:08 +0100)
wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js

index 5d23b53442140052ee18ca8191c7824cb1be29f1..abb0e8b16437bd6023e69706c9062553b8658010 100644 (file)
@@ -10,6 +10,8 @@ if (!RedactorPlugins) var RedactorPlugins = {};
 RedactorPlugins.wbbcode = function() {
        "use strict";
        
+       var $skipOnSyncReplacementOnce = false;
+       
        return {
                /**
                 * Initializes the RedactorPlugins.wbbcode plugin.
@@ -41,10 +43,16 @@ RedactorPlugins.wbbcode = function() {
                        this.opts.pasteCallback = $.proxy(this.wbbcode._pasteCallback, this);
                        
                        var $mpCleanOnSync = this.clean.onSync;
-                       this.clean.onSync = function(html) {
-                               html = html.replace(/<p><br([^>]+)?><\/p>/g, '<p>@@@wcf_empty_line@@@</p>');
-                               return $mpCleanOnSync.call(self, html);
-                       };
+                       this.clean.onSync = (function(html) {
+                               if ($skipOnSyncReplacementOnce === true) {
+                                       $skipOnSyncReplacementOnce = false;
+                               }
+                               else {
+                                       html = html.replace(/<p><br([^>]+)?><\/p>/g, '<p>@@@wcf_empty_line@@@</p>');
+                               }
+                               
+                               return $mpCleanOnSync.call(this, html);
+                       }).bind(this);
                        
                        if (this.wutil.getOption('woltlab.autosaveOnce')) {
                                this.wutil.saveTextToStorage();
@@ -1696,6 +1704,7 @@ RedactorPlugins.wbbcode = function() {
                                        var $link = WCF.String.escapeHTML($('#redactorQuoteLink').val());
                                        
                                        this.selection.restore();
+                                       $skipOnSyncReplacementOnce = true;
                                        var $html = this.selection.getHtml();
                                        if (this.utils.isEmpty($html)) {
                                                $html = '';