Added util method to replace editor contents
authorAlexander Ebert <ebert@woltlab.com>
Wed, 27 Aug 2014 20:35:55 +0000 (22:35 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Wed, 27 Aug 2014 20:35:55 +0000 (22:35 +0200)
wcfsetup/install/files/js/3rdParty/redactor/plugins/wutil.js

index 3e058183312e1b0c6aa64f5d0682d7e77facced4..aaab56e5c63f07a55a68ca8621ac6ce55c74c126 100644 (file)
@@ -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();
+               }
        }
 };