Incorrect detection of Shift+Enter in iOS Safari
authorAlexander Ebert <ebert@woltlab.com>
Mon, 10 Feb 2020 15:42:42 +0000 (16:42 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Mon, 10 Feb 2020 15:42:42 +0000 (16:42 +0100)
wcfsetup/install/files/js/3rdParty/redactor2/redactor.js

index 626949283a7d21e6f1ca67986bb4cf8ba366c0ea..06d0299b3bdd0f27aeb4e12d9ad6742d2f48eae0 100644 (file)
        
        var uuid = 0;
        
+       var Environment = null;
+       if (typeof window.require === 'function') {
+               // Load the Environment class for a better browser detection, guarded by a function check
+               // to avoid bricking any calls to this file in a different context.
+               require(['Environment'], function(Env) {
+                       Environment = Env;
+               });
+       }
+       
        // Plugin
        $.fn.redactor = function (options) {
                var val = [];
                                        
                                        // on Shift+Enter or Ctrl+Enter
                                        if (key === this.keyCode.ENTER && (e.ctrlKey || e.shiftKey)) {
-                                               e.preventDefault();
-                                               
-                                               return this.keydown.onShiftEnter(e);
+                                               // iOS Safari will report the shift key to be pressed, if the caret is at the
+                                               // front of the line and the next character should be an uppercase character.
+                                               if (Environment === null || Environment.platform() !== 'ios') {
+                                                       e.preventDefault();
+
+                                                       return this.keydown.onShiftEnter(e);
+                                               }
                                        }
                                        
                                        // on enter