From 907d9fe664aafff0f09cf1197f7e83eb54309e0a Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Mon, 7 Dec 2020 20:02:58 +0100 Subject: [PATCH] Workaround for the misaligned caret in Safari caused by 0x200B --- .../files/js/3rdParty/redactor2/plugins/WoltLabSmiley.js | 7 +++++++ 1 file changed, 7 insertions(+) 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(" "); -- 2.20.1