From: Alexander Ebert Date: Fri, 24 Apr 2015 18:46:10 +0000 (+0200) Subject: Fixed pasting of contents into empty quotes X-Git-Tag: 2.1.4~53 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=8594b9f6d96093b8e34c73e84b68dfa252c61f45;p=GitHub%2FWoltLab%2FWCF.git Fixed pasting of contents into empty quotes --- diff --git a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js index b94530da41..6719d5a471 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js +++ b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js @@ -2071,7 +2071,7 @@ RedactorPlugins.wbbcode = function() { } else { $html = this.wbbcode.convertToHtml($openTag + $id + $closingTag); - $html = $html.replace($id, $innerHTML.replace(/^

/, '').replace(/<\/p>$/, '')); + $html = $html.replace($id, html.replace(/^

/, '').replace(/<\/p>$/, '')); } $html = $html.replace(/^

/, '').replace(/<\/p>$/, ''); @@ -2088,6 +2088,8 @@ RedactorPlugins.wbbcode = function() { if (!window.getSelection().rangeCount) { this.wutil.selectionEndOfEditor(); } + + this.wutil.saveSelection(); } } diff --git a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js index 7512287caf..70ccdf695a 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js +++ b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js @@ -1085,9 +1085,39 @@ RedactorPlugins.wmonkeypatch = function() { } }).bind(this); + var $fixSelection = function() { + var $selection = window.getSelection(); + if (!$selection.rangeCount) { + return; + } + + var $range = $selection.getRangeAt(0); + if (!$range.collapsed) { + return; + } + + var $element = $range.startContainer; + if ($element.nodeType === Node.ELEMENT_NODE && $element.tagName === 'DIV') { + var $parentNode = $element.parentNode; + if ($parentNode !== null && $parentNode.tagName === 'BLOCKQUOTE' && $parentNode.classList.contains('quoteBox')) { + var $endContainer = $range.startContainer.childNodes[$range.startContainer.childNodes.length - 1]; + var $newRange = document.createRange(); + $newRange.setStart($range.startContainer.childNodes[0], 0); + + $newRange.setEnd($endContainer, $endContainer.length); + $newRange.collapse(false); + + $selection.removeAllRanges(); + $selection.addRange($newRange); + } + } + }; + // paste.insert var $mpInsert = this.paste.insert; this.paste.insert = (function(html) { + $fixSelection(); + $mpInsert.call(this, html); setTimeout((function() {