Fixed textarea height and added support for [size]
authorAlexander Ebert <ebert@woltlab.com>
Mon, 6 Jul 2015 10:54:00 +0000 (12:54 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Mon, 6 Jul 2015 10:54:00 +0000 (12:54 +0200)
wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js
wcfsetup/install/files/js/3rdParty/redactor/redactor.js
wcfsetup/install/files/js/WoltLab/WCF/BBCode/ToHtml.js

index 7e5c6e2e7d41773da8de384d870b9a58a6592654..0f81bb4301ef8c222a4b1f8a2019c2632792b895 100644 (file)
@@ -501,16 +501,19 @@ RedactorPlugins.wmonkeypatch = function() {
                        // fixes an issue related to setSelectionRange on a hidden textarea in Firefox (NS_ERROR_FAILURE, #1984)
                        var $mpShowCode = this.code.showCode;
                        this.code.showCode = (function() {
-                               var $hiddenParent = null;
+                               var height = this.$editor.innerHeight(), hiddenParent = null;
                                if (!this.$textarea.is(':visible')) {
-                                       $hiddenParent = this.$textarea.parentsUntil(':visible').last();
-                                       $hiddenParent.show();
+                                       hiddenParent = this.$textarea.parentsUntil(':visible').last();
+                                       hiddenParent.show();
                                }
                                
                                $mpShowCode.call(this);
                                
-                               if ($hiddenParent !== null) {
-                                       $hiddenParent.hide();
+                               // jQuery's .height() seems to add the paddings
+                               this.$textarea[0].style.setProperty('height', height + 'px');
+                               
+                               if (hiddenParent !== null) {
+                                       hiddenParent.hide();
                                }
                        }).bind(this);
                },
index 3aa3de51ea83300885644b09ed6afd46f80032c5..4fccb0d3ec348eeaa79b83b07555d8862f79c4cb 100644 (file)
                                        else
                                        {
                                                this.$textarea.height(height).show().focus();
+                                               console.debug(height);
+                                               console.debug(this.$textarea[0].outerHTML);
                                                this.$textarea.on('keydown.redactor-textarea-indenting', this.code.textareaIndenting);
 
                                                $(window).scrollTop(scroll);
index 7d7d87af7515766cf6a5cc429f4198947ee2d621..00f312e58b1908ca2b6c87b8d8980e65a0618245 100644 (file)
@@ -84,6 +84,7 @@ define(['Core', 'EventHandler', 'Language', 'StringUtil', 'WoltLab/WCF/BBCode/Pa
                                email: this._replaceEmail.bind(this),
                                list: this._replaceList.bind(this),
                                quote: this._replaceQuote.bind(this),
+                               size: this._replaceSize.bind(this),
                                url: this._replaceUrl.bind(this),
                                img: this._replaceImage.bind(this)
                        };
@@ -439,12 +440,18 @@ define(['Core', 'EventHandler', 'Language', 'StringUtil', 'WoltLab/WCF/BBCode/Pa
                        }
                },
                
+               _replaceSize: function(stack, item, index) {
+                       if (!item.attributes.length || ~~item.attributes[0] === 0) {
+                               return [null, null];
+                       }
+                       
+                       return ['<span style="font-size: ' + ~~item.attributes[0] + 'pt">', '</span>'];
+               },
+               
                _replaceUrl: function(stack, item, index) {
                        // ignore url bbcode without arguments
                        if (!item.attributes.length) {
-                               stack[item.pair] = '';
-                               
-                               return '';
+                               return [null, null];
                        }
                        
                        return ['<a href="' + StringUtil.escapeHTML(item.attributes[0]) + '">', '</a>'];