From 068cdd4811984b65341859b9df60ece918e18d48 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Mon, 23 Feb 2015 16:35:16 +0100 Subject: [PATCH] Improved keyboard navigation for nested quotes --- .../files/js/3rdParty/redactor/plugins/wbbcode.js | 4 ++-- .../files/js/3rdParty/redactor/plugins/wmonkeypatch.js | 4 ++-- .../install/files/js/3rdParty/redactor/plugins/wutil.js | 9 ++++++++- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js index 33ee10cd13..ebc5c2691a 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js +++ b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js @@ -1304,8 +1304,8 @@ RedactorPlugins.wbbcode = function() { } // remove

wrapping a quote or a div - data = data.replace(/

<(blockquote|div)/g, '<$1'); - data = data.replace(/<\/(blockquote|div)><\/p>/g, ''); + data = data.replace(/<(?:div|p)><(blockquote|div)/g, '<$1'); + data = data.replace(/<\/(blockquote|div)><\/(?:div|p)>/g, ''); WCF.System.Event.fireEvent('com.woltlab.wcf.redactor', 'afterConvertToHtml', { data: data }); diff --git a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js index 73cbe5f173..8dc8c15867 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js +++ b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js @@ -106,7 +106,7 @@ RedactorPlugins.wmonkeypatch = function() { var $setCaretBeforeOrAfter = (function(element, setBefore) { if (setBefore) { - if (element.previousElementSibling && element.previousElementSibling.tagName === 'P') { + if (element.previousElementSibling && (element.previousElementSibling.tagName === 'P' || element.previousElementSibling.tagName === 'DIV')) { this.caret.setEnd(element.previousElementSibling); } else { @@ -114,7 +114,7 @@ RedactorPlugins.wmonkeypatch = function() { } } else { - if (element.nextElementSibling && element.nextElementSibling.tagName === 'P') { + if (element.nextElementSibling && (element.nextElementSibling.tagName === 'P' || element.nextElementSibling.tagName === 'DIV')) { this.caret.setEnd(element.nextElementSibling); } else { diff --git a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wutil.js b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wutil.js index 26311b6c0e..12db841f99 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wutil.js +++ b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wutil.js @@ -928,7 +928,14 @@ RedactorPlugins.wutil = function() { * @param boolean setBefore */ _setCaret: function(element, setBefore) { - var $node = $(this.opts.emptyHtml); + var $node; + if ((element[0] || element).parentElement && (element[0] || element).parentElement.tagName === 'BLOCKQUOTE') { + $node = $('

' + this.opts.invisibleSpace + '
'); + } + else { + $node = $('

' + this.opts.invisibleSpace + '

'); + } + $node[(setBefore ? 'insertBefore' : 'insertAfter')](element); this.caret.setEnd($node[0]); }, -- 2.20.1