Dirty work-around for iOS Safari's selection
authorAlexander Ebert <ebert@woltlab.com>
Wed, 28 Oct 2015 13:55:57 +0000 (14:55 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Wed, 28 Oct 2015 13:55:57 +0000 (14:55 +0100)
wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js

index 72494756e46f47a49be46e2051b7f64ce937ac02..8606c10e0a4991ae789c7fcbb17fc66f3aa81e53 100644 (file)
@@ -1276,8 +1276,11 @@ RedactorPlugins.wmonkeypatch = function() {
                                }
                                
                                // iOS sometimes pastes right into the marker, this work-around will unwrap the pasted content
-                               if ($.browser.iOS && marker.innerHTML.length) {
+                               var fixApple = false;
+                               if ($.browser.iOS && marker.innerHTML.replace(/\u200b/g, '').length) {
                                        marker.outerHTML = marker.innerHTML;
+                                       
+                                       fixApple = true;
                                }
                                else {
                                        marker.parentNode.removeChild(marker);
@@ -1291,6 +1294,12 @@ RedactorPlugins.wmonkeypatch = function() {
                                else {
                                        this.selection.implicitRange = null;
                                }
+                               
+                               if ($.browser.iOS && fixApple) {
+                                       window.setTimeout((function() {
+                                               this.focus.setEnd();
+                                       }).bind(this), 10);
+                               }
                        }).bind(this);
                        
                        // selection.removeMarkers