From 2b283c3cde45199bbf833999773d6ab5bbd85bfa Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Thu, 23 Feb 2017 12:52:07 +0100 Subject: [PATCH] Fixed initial caret position on iOS --- .../3rdParty/redactor2/plugins/WoltLabCaret.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabCaret.js b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabCaret.js index 01d2411bd7..42db675fca 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabCaret.js +++ b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabCaret.js @@ -14,11 +14,27 @@ $.Redactor.prototype.WoltLabCaret = function() { mpAfter.call(this, node); }).bind(this); + var iOS = false; + require(['Environment'], function (Environment) { + iOS = (Environment.platform() === 'ios'); + }); + var mpEnd = this.caret.end; this.caret.end = (function (node) { node = this.caret.prepare(node); + var useCustomRange = false; if (node.nodeType === Node.ELEMENT_NODE && node.lastChild && node.lastChild.nodeName === 'P') { + useCustomRange = true; + } + else if (iOS) { + var editor = this.core.editor()[0]; + if (node.parentNode === editor && editor.innerHTML === '


') { + useCustomRange = true; + } + } + + if (useCustomRange) { var selection = window.getSelection(); var range = document.createRange(); range.selectNodeContents(node.lastChild); -- 2.20.1