From e80bb086d23fd519fc4dd0f8cc4487aafbf3d59e Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Mon, 8 Jul 2019 16:43:09 +0200 Subject: [PATCH] Incorrect event handling in button callbacks --- .../files/js/3rdParty/redactor2/redactor.js | 3 +++ .../WoltLabSuite/Core/Ui/Redactor/Spoiler.js | 23 ++++++++++++------- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/wcfsetup/install/files/js/3rdParty/redactor2/redactor.js b/wcfsetup/install/files/js/3rdParty/redactor2/redactor.js index 6d0c4aab85..6482b3f7d5 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor2/redactor.js +++ b/wcfsetup/install/files/js/3rdParty/redactor2/redactor.js @@ -1691,6 +1691,9 @@ if (e instanceof Event) { e.preventDefault(); } + else if (e && e.originalEvent) { + e.originalEvent.preventDefault(); + } args = (typeof args === 'undefined') ? btnName : args; diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Redactor/Spoiler.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Redactor/Spoiler.js index 57561cf5d0..a27f31a5a0 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Redactor/Spoiler.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Redactor/Spoiler.js @@ -65,13 +65,20 @@ define(['EventHandler', 'EventKey', 'Language', 'StringUtil', 'Dom/Util', 'Ui/Di this._editor.button.toggle({}, 'woltlab-spoiler', 'func', 'block.format'); var spoiler = this._editor.selection.block(); - if (spoiler && spoiler.nodeName === 'WOLTLAB-SPOILER') { - this._setTitle(spoiler); - - spoiler.addEventListener(WCF_CLICK_EVENT, this._callbackEdit); - - // work-around for Safari - this._editor.caret.end(spoiler); + if (spoiler) { + // iOS Safari might set the caret inside the spoiler. + if (spoiler.nodeName === 'P') { + spoiler = spoiler.parentNode; + } + + if (spoiler.nodeName === 'WOLTLAB-SPOILER') { + this._setTitle(spoiler); + + spoiler.addEventListener(WCF_CLICK_EVENT, this._callbackEdit); + + // work-around for Safari + this._editor.caret.end(spoiler); + } } }, @@ -204,4 +211,4 @@ define(['EventHandler', 'EventKey', 'Language', 'StringUtil', 'Dom/Util', 'Ui/Di }; return UiRedactorSpoiler; -}); \ No newline at end of file +}); -- 2.20.1