From 92438db6b332890664a40beba9fae0107fb97107 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Wed, 27 Aug 2014 22:35:55 +0200 Subject: [PATCH] Added util method to replace editor contents --- .../js/3rdParty/redactor/plugins/wutil.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wutil.js b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wutil.js index 3e05818331..aaab56e5c6 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wutil.js +++ b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wutil.js @@ -329,5 +329,24 @@ RedactorPlugins.wutil = { */ selectionEndOfEditor: function() { this.selectionEnd(this.$editor.children(':last')[0]); + }, + + /** + * Replaces the current content with the provided value. + * + * @param string value + */ + replaceText: function(value) { + var $wasInWysiwygMode = false; + if (this.inWysiwygMode()) { + this.toggle(); + $wasInWysiwygMode = true; + } + + this.$source.val(value); + + if ($wasInWysiwygMode) { + this.toggle(); + } } }; -- 2.20.1