From: Alexander Ebert Date: Mon, 27 Jun 2022 16:53:37 +0000 (+0200) Subject: Force restore saved selections after inserting links into the editor X-Git-Tag: 5.5.0_RC_3~14^2~2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=dd829b643d403f403fae8748a8f00e2e448af490;p=GitHub%2FWoltLab%2FWCF.git Force restore saved selections after inserting links into the editor Redactor‘s selection handling is very fragile and “forgetting” to restore the selection can cause some very strange side-effects. The user will start typing inside a selection marker, which will not cause any visual effects, but the content will get lost once the editor removes the markers. See https://www.woltlab.com/community/thread/296022-einf%C3%BCgen-von-links-im-editor-unter-ipados/ See https://www.woltlab.com/community/thread/296116-einf%C3%BCgen-von-links-im-editor-unter-ipados-text-verschwindet/ See https://www.woltlab.com/community/thread/294753-text-wird-beim-speichern-abgeschnitten/ --- diff --git a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabLink.js b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabLink.js index 6ec4016b34..89ad814ba7 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabLink.js +++ b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabLink.js @@ -121,8 +121,15 @@ $.Redactor.prototype.WoltLabLink = function() { this.selection.save(); // Closing the dialog might move the focus somewhere else. + // + // On iPadOS the focus handling is inconsistent with iOS and + // causes the marker to persist in the editor, causing strange + // side-effects. window.setTimeout(() => { - if (document.activeElement !== this.core.editor()[0]) { + if ( + document.activeElement !== this.core.editor()[0] + || this.core.editor()[0].querySelector(".redactor-selection-marker") !== null + ) { this.selection.restore(); } }, 0);