Updated monkeypatch to support `opts.keepStyleAttr`
authorAlexander Ebert <ebert@woltlab.com>
Fri, 20 Oct 2017 12:07:01 +0000 (14:07 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Fri, 20 Oct 2017 12:07:01 +0000 (14:07 +0200)
wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabKeydown.js

index 4375491f70f9bcf2d4e5176856fbf599aa09f3e2..15d8adab8bce804ccceab546d1255f59ab41f222 100644 (file)
@@ -691,8 +691,14 @@ $.Redactor.prototype.WoltLabKeydown = function() {
                                        this.code.syncFire = false;
                                        this.keydown.removeEmptyLists();
                                        
+                                       var filter = '';
+                                       if (this.opts.keepStyleAttr.length !== 0) {
+                                               filter = ',' + this.opts.keepStyleAttr.join(',');
+                                       }
+                                       
                                        // WoltLab modification: allow style tag on `<span>`
-                                       this.core.editor().find('*[style]').not('span, img, #redactor-image-box, #redactor-image-editter').removeAttr('style');
+                                       var $styleTags = this.core.editor().find('*[style]');
+                                       $styleTags.not('span, img, figure, iframe, #redactor-image-box, #redactor-image-editter, [data-redactor-style-cache], [data-redactor-span]' + filter).removeAttr('style');
                                        
                                        this.keydown.formatEmpty(e);