From e3520aa876626b4c660ffc9ff7de65f63a94fbb4 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Tue, 29 Jul 2014 11:51:05 +0200 Subject: [PATCH] Disable automatic synchronization editor -> textarea If you want to force a sync, you must call it with this.sync(undefined, true), otherwise the method call is a no-op. --- .../js/3rdParty/redactor/plugins/wbbcode.js | 1 + .../3rdParty/redactor/plugins/wmonkeypatch.js | 31 ++++++++++++++++--- .../js/3rdParty/redactor/plugins/wutil.js | 2 +- 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js index 44f467c324..1b7ae923ff 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js +++ b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js @@ -135,6 +135,7 @@ RedactorPlugins.wbbcode = { */ toggle: function(direct) { if (this.opts.visual) { + this.sync(undefined, true); this.toggleCode(direct); this._convertFromHtml(); diff --git a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js index e7d407c903..f677a052fa 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js +++ b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js @@ -65,6 +65,13 @@ RedactorPlugins.wmonkeypatch = { $mpDestroy.call(self); }; + var $mpSync = this.sync; + this.sync = function(e, forceSync) { + if (forceSync === true) { + $mpSync.call(self, e); + } + }; + // handle indent/outdent var $mpButtonActiveObserver = this.buttonActiveObserver; this.buttonActiveObserver = function(e, btnName) { @@ -77,11 +84,28 @@ RedactorPlugins.wmonkeypatch = { } this.$toolbar.find('a.re-indent, a.re-outdent').addClass('redactor_button_disabled'); + // image editing var $mpImageResizeControls = this.imageResizeControls; this.imageResizeControls = function($image) { if (!$image.data('attachmentID')) { $mpImageResizeControls.call(self, $image); } + + return false; + }; + + var $mpImageEdit = this.imageEdit; + this.imageEdit = function(image) { + $mpImageEdit.call(self, image); + + $('#redactor_image_source').val($(image).prop('src')); + }; + + var $mpImageSave = this.imageSave; + this.imageSave = function(el) { + $(el).prop('src', $('#redactor_image_source').val()); + + $mpImageSave.call(self, el); }; this.setOption('modalOpenedCallback', $.proxy(this.modalOpenedCallback, this)); @@ -229,7 +253,7 @@ RedactorPlugins.wmonkeypatch = { '
' + '
' + '
' - + '
' + + '
' + '
' + '
' + '
' @@ -370,8 +394,7 @@ RedactorPlugins.wmonkeypatch = { * * @see $.Redactor.inlineEachNodes() */ - inlineEachNodes: function(callback) - { + inlineEachNodes: function(callback) { var range = this.getRange(), node = this.getElement(), nodes = this.getNodes(), @@ -402,4 +425,4 @@ RedactorPlugins.wmonkeypatch = { }, this ) ); } -} \ No newline at end of file +}; diff --git a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wutil.js b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wutil.js index 924698a3d8..1d58a84642 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wutil.js +++ b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wutil.js @@ -304,7 +304,7 @@ RedactorPlugins.wutil = { * Synchronizes editor's source textarea. */ wSync: function() { - this.sync(); + this.sync(undefined, true); this.$source.val(this.cleanHtml(this.$source.val())); this._convertFromHtml(); } -- 2.20.1