From: Alexander Ebert Date: Mon, 23 Feb 2015 13:48:14 +0000 (+0100) Subject: Improved clicks on quote margins for nested quotes X-Git-Tag: 2.1.0~56 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=c654fd6d1a27b1157e2f1d23f054811c3d60f3a2;p=GitHub%2FWoltLab%2FWCF.git Improved clicks on quote margins for nested quotes --- diff --git a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js index ba21de8d91..73cbe5f173 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js +++ b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js @@ -227,6 +227,32 @@ RedactorPlugins.wmonkeypatch = function() { this.caret.setEnd($firstChild); } } + else if (event.target.tagName === 'BLOCKQUOTE') { + var $range = (window.getSelection().rangeCount) ? window.getSelection().getRangeAt(0) : null; + if ($range !== null && $range.collapsed) { + // check if caret is now inside a quote + var $blockquote = null; + var $current = ($range.startContainer.nodeType === Node.TEXT_NODE) ? $range.startContainer.parentElement : $range.startContainer; + while ($current !== null && $current !== this.$editor[0]) { + if ($current.tagName === 'BLOCKQUOTE') { + $blockquote = $current; + break; + } + + $current = $current.parentElement; + } + + if ($blockquote !== null && $blockquote !== event.target) { + // click occured within inner quote margin, check if click happened before inner quote + if (event.pageY <= $($blockquote).offset().top) { + $setCaretBeforeOrAfter($blockquote, true); + } + else { + $setCaretBeforeOrAfter($blockquote, false); + } + } + } + } }).bind(this)); },