From 070eaa4c521387f231c27cacc23d64e87c1fe34f Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Thu, 5 Jan 2017 19:14:28 +0100 Subject: [PATCH] Fixed a few Safari bugs --- .../redactor2/plugins/WoltLabAttachment.js | 15 ++++++++++++++- .../3rdParty/redactor2/plugins/WoltLabSmiley.js | 3 +++ .../js/WoltLabSuite/Core/Ui/Redactor/Code.js | 3 +++ .../js/WoltLabSuite/Core/Ui/Redactor/Quote.js | 3 +++ .../js/WoltLabSuite/Core/Ui/Redactor/Spoiler.js | 3 +++ 5 files changed, 26 insertions(+), 1 deletion(-) diff --git a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabAttachment.js b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabAttachment.js index 3cab79e2b2..42717057e3 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabAttachment.js +++ b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabAttachment.js @@ -24,7 +24,20 @@ $.Redactor.prototype.WoltLabAttachment = function() { this.buffer.set(); if (data.url) { - this.insert.html(''); + var id = 'wcfImgAttachment' + this.uuid; + var img = elById(id); + if (img) img.removeAttribute('id'); + + this.insert.html(''); + + window.setTimeout((function () { + // Safari does not properly update the caret position on insert + var img = elById(id); + if (img) { + img.removeAttribute('id'); + this.caret.after(img); + } + }).bind(this), 10); } else { // non-image attachment diff --git a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabSmiley.js b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabSmiley.js index 56636b6bbf..3704e64653 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabSmiley.js +++ b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabSmiley.js @@ -29,6 +29,9 @@ $.Redactor.prototype.WoltLabSmiley = function() { smiley = elById(id); smiley.removeAttribute('id'); + // Safari does not properly update the caret position on insert + this.caret.after(smiley); + //noinspection SillyAssignmentJS smiley.outerHTML = smiley.outerHTML; } diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Redactor/Code.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Redactor/Code.js index 9fd764832b..33e8bb8a59 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Redactor/Code.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Redactor/Code.js @@ -61,6 +61,9 @@ define(['EventHandler', 'EventKey', 'Language', 'StringUtil', 'Dom/Util', 'Ui/Di this._setTitle(pre); pre.addEventListener(WCF_CLICK_EVENT, this._callbackEdit); + + // work-around for Safari + this._editor.caret.end(pre); } }, diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Redactor/Quote.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Redactor/Quote.js index 114ed2def2..c540136512 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Redactor/Quote.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Redactor/Quote.js @@ -116,6 +116,9 @@ define(['Core', 'EventHandler', 'EventKey', 'Language', 'StringUtil', 'Dom/Util' this._setTitle(quote); quote.addEventListener(WCF_CLICK_EVENT, this._callbackEdit); + + // work-around for Safari + this._editor.caret.end(quote); } }, diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Redactor/Spoiler.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Redactor/Spoiler.js index 5f953f7203..47fbd612a3 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Redactor/Spoiler.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Redactor/Spoiler.js @@ -54,6 +54,9 @@ define(['EventHandler', 'EventKey', 'Language', 'StringUtil', 'Dom/Util', 'Ui/Di this._setTitle(spoiler); spoiler.addEventListener(WCF_CLICK_EVENT, this._callbackEdit); + + // work-around for Safari + this._editor.caret.end(spoiler); } }, -- 2.20.1