Work-around for multiple formatting removing each other in Firefox
authorAlexander Ebert <ebert@woltlab.com>
Tue, 20 Jan 2015 23:38:30 +0000 (00:38 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Tue, 20 Jan 2015 23:38:30 +0000 (00:38 +0100)
wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js

index 9a24ff5ed412b4af69cb4c2b390dfd0640ca30db..6e752f255cc0caa9d99d54bd7236d127921c44dd 100644 (file)
@@ -596,6 +596,25 @@ RedactorPlugins.wmonkeypatch = function() {
                                $mpFormat.call(this, tag, type, value);
                        }).bind(this);
                        
+                       // inline.formatRemoveSameChildren;
+                       this.inline.formatRemoveSameChildren = (function($el, tag) {
+                               $el.children(tag).each((function(index, child) {
+                                       var $child = $(child);
+                                       if (!$child.hasClass('redactor-selection-marker')) {
+                                               // check if this represents a style
+                                               if (tag === 'span' && this.inline.type === 'style') {
+                                                       var $newProperty = this.inline.value.replace(/^([^:]+?):.*/, '$1');
+                                                       if (!child.style.getPropertyValue($newProperty)) {
+                                                               // child carries a different CSS property, skip
+                                                               return true;
+                                                       }
+                                               }
+                                               
+                                               $child.contents().unwrap();
+                                       }
+                               }).bind(this));
+                       }).bind(this);
+                       
                        var $mpRemoveStyleRule = this.inline.removeStyleRule;
                        this.inline.removeStyleRule = (function(name) {
                                if ($.browser.iOS) {