From 12ee85a9163257b91f2ece867e2a765af542ecb5 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Tue, 20 Oct 2015 18:33:07 +0200 Subject: [PATCH] Added a work-around for IE breaking quotes on list insert --- .../3rdParty/redactor/plugins/wmonkeypatch.js | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) 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. * -- 2.20.1