From 5b9710ce9a26875005e70d2bdab3d881958db399 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Thu, 27 Mar 2014 20:08:18 +0100 Subject: [PATCH] Fixed BBCodes on init, properly clear storage on edit cancel --- .../js/3rdParty/redactor/plugins/wbbcode.js | 18 +++++++----------- .../js/3rdParty/redactor/plugins/wutil.js | 8 ++++++++ wcfsetup/install/files/js/WCF.Message.js | 12 ++++-------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js index 7fc2e3808d..0ec0169f8c 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js +++ b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js @@ -18,6 +18,13 @@ RedactorPlugins.wbbcode = { this.dropdownShow(e, btnName); }, this)); this.buttonAwesome('wsmiley', 'fa-smile-o'); + + this.opts.initCallback = $.proxy(function() { + if (this.$source.val().length) { + this.toggle(); + this.toggle(); + } + }, this); }, /** @@ -89,17 +96,6 @@ RedactorPlugins.wbbcode = { return true; }, - /** - * Overwrites $.Redactor.buildContent() to handle BBCode -> HTML on init - */ - buildContent: function() { - if (this.opts.textareamode) this.content = $.trim(this.$source.val()); - else { - this._convertToHtml(); - this.content = $.trim(this.$source.html()); - } - }, - /** * Overwrites $.Redactor.toggle() to transform the source mode into a BBCode view. * diff --git a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wutil.js b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wutil.js index 2d5b59c097..9ea65907f7 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wutil.js +++ b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wutil.js @@ -34,6 +34,14 @@ RedactorPlugins.wutil = { // prevent Redactor's own autosave this.setOption('autosave', false); + + // disable autosave on destroy + var $mpDestroy = this.destroy; + var self = this; + this.destroy = function() { + self.autosaveDisable(); + $mpDestroy.call(self); + }; }, /** diff --git a/wcfsetup/install/files/js/WCF.Message.js b/wcfsetup/install/files/js/WCF.Message.js index f36592e370..2dea0f1d9a 100644 --- a/wcfsetup/install/files/js/WCF.Message.js +++ b/wcfsetup/install/files/js/WCF.Message.js @@ -1219,14 +1219,10 @@ WCF.Message.InlineEditor = Class.extend({ _cancel: function() { var $container = this._container[this._activeElementID].removeClass('jsInvalidQuoteTarget'); - // remove ckEditor - try { - var $ckEditor = $('#' + this._messageEditorIDPrefix + $container.data('objectID')).ckeditorGet(); - $ckEditor.destroy(); - } - catch (e) { - // CKEditor might be not initialized yet, ignore - } + // remove editor + var $target = $('#' + this._messageEditorIDPrefix + $container.data('objectID')); + $target.redactor('autosavePurge'); + $target.redactor('destroy'); // restore message var $messageBody = $container.find('.messageBody'); -- 2.20.1