From f9db0f66caafdfb47d956bbdb0cd723d4651fb35 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Tue, 10 Feb 2015 18:05:58 +0100 Subject: [PATCH] Improved work-around for pasting on iOS --- .../js/3rdParty/redactor/plugins/wmonkeypatch.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js index 29bfc4fe7a..ba21de8d91 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js +++ b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js @@ -1035,7 +1035,21 @@ RedactorPlugins.wmonkeypatch = function() { var $mpCreatePasteBox = this.paste.createPasteBox; this.paste.createPasteBox = (function() { if ($.browser.iOS) { - this.$pasteBox = $('
').html('').attr('contenteditable', 'true').css({ position: 'absolute', visibility: 'hidden' }); + var $top = 0; + if (window.getSelection().rangeCount) { + var $container = window.getSelection().getRangeAt(0).endContainer; + if ($container.nodeType !== Node.ELEMENT_NODE) { + $container = $container.parentElement; + } + $container = $($container); + + $top = $($container).offset().top; + } + else { + $top = $(window).scrollTop(); + } + + this.$pasteBox = $('
').html('').attr('contenteditable', 'true').css({ position: 'fixed', /*width: 0, */top: $top + 'px', /*left: '-9999px', */fontSize: '16px' }); this.$box.parent().append(this.$pasteBox); this.$pasteBox.focus(); -- 2.20.1