From: Alexander Ebert Date: Wed, 27 Aug 2014 20:35:55 +0000 (+0200) Subject: Added util method to replace editor contents X-Git-Tag: 2.1.0_Alpha_1~384 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=92438db6b332890664a40beba9fae0107fb97107;p=GitHub%2FWoltLab%2FWCF.git Added util method to replace editor contents --- 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(); + } } };