From: Alexander Ebert Date: Mon, 7 Dec 2020 19:02:58 +0000 (+0100) Subject: Workaround for the misaligned caret in Safari caused by 0x200B X-Git-Tag: 5.3.2~53 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=907d9fe664aafff0f09cf1197f7e83eb54309e0a;p=GitHub%2FWoltLab%2FWCF.git Workaround for the misaligned caret in Safari caused by 0x200B --- diff --git a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabSmiley.js b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabSmiley.js index 08d505c265..dd14d4e514 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabSmiley.js +++ b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabSmiley.js @@ -29,6 +29,13 @@ $.Redactor.prototype.WoltLabSmiley = function() { smiley = elById(id); smiley.removeAttribute('id'); + // Check if there is a zero-width whitespace after the smiley, Safari does + // not like them that much (caret will be placed inside a character). + const nextSibling = smiley.nextSibling; + if (nextSibling && nextSibling.nodeType === Node.TEXT_NODE && nextSibling.textContent === "\u200B") { + nextSibling.remove(); + } + smiley.parentNode.insertBefore(document.createTextNode(" "), smiley); const whitespace = document.createTextNode(" ");