Use more aggressive selection saving on iOS
authorAlexander Ebert <ebert@woltlab.com>
Tue, 30 Aug 2016 18:26:56 +0000 (20:26 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Tue, 30 Aug 2016 18:26:56 +0000 (20:26 +0200)
wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabCaret.js

index 61c65f08e69d5f9589b13beb1f79c83e6379cc04..45ae8a2ac00ef8e654cf83381e86b5119ff57bcb 100644 (file)
@@ -81,8 +81,8 @@ $.Redactor.prototype.WoltLabCaret = function() {
                                internalRange = null;
                        };
                        
-                       this.$editor[0].addEventListener('keyup', saveRange);
-                       this.$editor[0].addEventListener('mouseup', function () {
+                       editor.addEventListener('keyup', saveRange);
+                       editor.addEventListener('mouseup', function () {
                                if (selection.rangeCount) {
                                        saveRange();
                                }
@@ -125,6 +125,18 @@ $.Redactor.prototype.WoltLabCaret = function() {
                                
                                saveRange();
                        }).bind(this);
+                       
+                       require(['Environment'], (function (Environment) {
+                               if (Environment.platform() === 'ios') {
+                                       editor.addEventListener('focus', function () {
+                                               document.addEventListener('selectionchange', saveRange);
+                                       });
+                                       
+                                       editor.addEventListener('blur', function () {
+                                               document.removeEventListener('selectionchange', saveRange);
+                                       })
+                               }
+                       }).bind(this));
                },
                
                _handleEditorClick: function (event) {