From 6311d0d3f7753e63810291091635b22af1f72464 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Mon, 10 Feb 2020 16:42:42 +0100 Subject: [PATCH] Incorrect detection of Shift+Enter in iOS Safari --- .../files/js/3rdParty/redactor2/redactor.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/wcfsetup/install/files/js/3rdParty/redactor2/redactor.js b/wcfsetup/install/files/js/3rdParty/redactor2/redactor.js index 626949283a..06d0299b3b 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor2/redactor.js +++ b/wcfsetup/install/files/js/3rdParty/redactor2/redactor.js @@ -25,6 +25,15 @@ 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 = []; @@ -5713,9 +5722,13 @@ // 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 -- 2.20.1