From c654fd6d1a27b1157e2f1d23f054811c3d60f3a2 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Mon, 23 Feb 2015 14:48:14 +0100 Subject: [PATCH] Improved clicks on quote margins for nested quotes --- .../3rdParty/redactor/plugins/wmonkeypatch.js | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) 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)); }, -- 2.20.1