From 547a2c54c5817aa7839fa4b1667ad403fe92ac8b Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Mon, 19 Sep 2016 10:02:56 +0200 Subject: [PATCH] Fixed caret position after paste --- .../redactor2/plugins/WoltLabPaste.js | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) 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 () { -- 2.20.1