Incorrect event handling in button callbacks
authorAlexander Ebert <ebert@woltlab.com>
Mon, 8 Jul 2019 14:43:09 +0000 (16:43 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Mon, 8 Jul 2019 14:43:09 +0000 (16:43 +0200)
wcfsetup/install/files/js/3rdParty/redactor2/redactor.js
wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Redactor/Spoiler.js

index 6d0c4aab859ba064904062290b89f28b788f5229..6482b3f7d557fe1b976e64d451c8662b625b1421 100644 (file)
                                        if (e instanceof Event) {
                                                e.preventDefault();
                                        }
+                                       else if (e && e.originalEvent) {
+                                               e.originalEvent.preventDefault();
+                                       }
                                        
                                        args = (typeof args === 'undefined') ? btnName : args;
                                        
index 57561cf5d0d5768300e143e83f5927a857aefeaf..a27f31a5a00f453a95e83e8a8b4e535c0ea9509f 100644 (file)
@@ -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
+});