From: Alexander Ebert Date: Tue, 20 Oct 2015 16:33:07 +0000 (+0200) Subject: Added a work-around for IE breaking quotes on list insert X-Git-Tag: 2.1.8~4 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=12ee85a9163257b91f2ece867e2a765af542ecb5;p=GitHub%2FWoltLab%2FWCF.git Added a work-around for IE breaking quotes on list insert --- diff --git a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js index e7bd0dcda1..870cfe9b67 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js +++ b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js @@ -36,6 +36,7 @@ RedactorPlugins.wmonkeypatch = function() { this.wmonkeypatch.keydown(); this.wmonkeypatch.keyup(); this.wmonkeypatch.link(); + this.wmonkeypatch.list(); this.wmonkeypatch.modal(); this.wmonkeypatch.paste(); this.wmonkeypatch.observe(); @@ -959,6 +960,40 @@ RedactorPlugins.wmonkeypatch = function() { }).bind(this); }, + /** + * Partially overwrites the 'list' module. + * + * - adds a wrapper div before inserting a list to prevent removal of
inside quotes + */ + list: function() { + // list.insert + var $mpInsert = this.list.insert; + this.list.insert = (function(cmd) { + var selection = window.getSelection(); + if (selection.rangeCount) { + var range = selection.getRangeAt(0); + + if (range.collapsed) { + var element = range.startContainer; + if (element.nodeType === Node.TEXT_NODE) { + element = element.parentNode; + } + + if (element.nodeName === 'DIV') { + if (element.parentNode.nodeName === 'BLOCKQUOTE') { + // wrap selection in another div to sabotage Redactor's parent block removal + var div = document.createElement('div'); + element.parentNode.insertBefore(div, element); + div.appendChild(element); + } + } + } + } + + $mpInsert.call(this, cmd); + }).bind(this); + }, + /** * Partially overwrites the 'modal' module. *