The editor attempted to edit lists outside of itself
authorAlexander Ebert <ebert@woltlab.com>
Fri, 29 Dec 2017 11:55:44 +0000 (12:55 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Fri, 29 Dec 2017 11:55:44 +0000 (12:55 +0100)
wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabList.js

index b881f1c3e3b4ee4f20e4fd77fecfc0268a7cab92..68528a5264e511426ef6e9ae7e383f5eb4ddff95 100644 (file)
@@ -16,6 +16,37 @@ $.Redactor.prototype.WoltLabList = function() {
                                
                                return returnValue;
                        }).bind(this);
+                       
+                       this.list.toggle = (function(type) {
+                               if (this.utils.inBlocks(['table', 'td', 'th', 'tr'])) {
+                                       return;
+                               }
+                               
+                               type = (type === 'orderedlist') ? 'ol' : type;
+                               type = (type === 'unorderedlist') ? 'ul' : type;
+                               
+                               type = type.toLowerCase();
+                               
+                               this.buffer.set();
+                               this.selection.save();
+                               
+                               var nodes = this.list._getBlocks();
+                               var block = this.selection.block();
+                               
+                               // WoltLab modification: the selector matches lists outside the editor
+                               //var $list = $(block).parents('ul, ol').last();
+                               var $list = $(block).parent().closest('ol, ul', this.core.editor()[0]);
+                               // WoltLab modification END
+                               if (nodes.length === 0 && $list.length !== 0) {
+                                       nodes = [$list.get(0)];
+                               }
+                               
+                               nodes = (this.list._isUnformat(type, nodes)) ? this.list._unformat(type, nodes) : this.list._format(type, nodes);
+                               
+                               this.selection.restore();
+                               
+                               return nodes;
+                       }).bind(this);
                }
        };
 };