From: Alexander Ebert Date: Mon, 19 Sep 2016 08:02:56 +0000 (+0200) Subject: Fixed caret position after paste X-Git-Tag: 3.0.0_Beta_1~92 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=547a2c54c5817aa7839fa4b1667ad403fe92ac8b;p=GitHub%2FWoltLab%2FWCF.git Fixed caret position after paste --- diff --git a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabPaste.js b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabPaste.js index 208d03ef76..0330a762ba 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabPaste.js +++ b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabPaste.js @@ -111,12 +111,11 @@ $.Redactor.prototype.WoltLabPaste = function() { var transparentGif = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7'; var mpInsert = this.paste.insert; this.paste.insert = (function(html, data) { - var pastedImages = []; + var div = elCreate('div'); + div.innerHTML = html; + var pastedImages = []; if (!data.pre && !data.text) { - var div = elCreate('div'); - div.innerHTML = html; - elBySelAll('img', div, (function(img) { var src = img.src; if (src.indexOf('data:image') === 0 && src !== transparentGif) { @@ -132,11 +131,19 @@ $.Redactor.prototype.WoltLabPaste = function() { elHide(img); } }).bind(this)); - - html = div.innerHTML; } - mpInsert.call(this, html, data); + // fix selection marker + elBySelAll('.redactor-selection-marker', div, elRemove); + div.appendChild(elCreate('woltlab-selection-marker')); + + mpInsert.call(this, div.innerHTML, data); + + var marker = elBySel('woltlab-selection-marker', this.$editor[0]); + if (marker) { + this.caret.end(marker.previousElementSibling); + elRemove(marker); + } if (pastedImages.length) { window.setTimeout((function () {