From c00f2013a8a3cd8600813cd2e98949e51a87cdd3 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Sun, 25 Dec 2016 13:36:58 +0100 Subject: [PATCH] Fixed cmd+k link insertion on OSX Safari --- .../files/js/3rdParty/redactor2/plugins/WoltLabLink.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabLink.js b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabLink.js index 6c159b0517..8ece922a18 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabLink.js +++ b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabLink.js @@ -19,6 +19,10 @@ $.Redactor.prototype.WoltLabLink = function() { e.preventDefault(); } + // used to determine if selection needs to be restored later as + // Safari sometimes discards the selection when setting markers + var hasSelectedText = this.selection.is(); + this.selection.save(); // close tooltip @@ -49,8 +53,12 @@ $.Redactor.prototype.WoltLabLink = function() { // WoltLab END // build link + if (hasSelectedText) this.selection.restore(); + var link = this.link.buildLinkFromElement($el); + if (hasSelectedText) this.selection.save(); + // if link cut & paste inside editor browser added self host to a link link.url = this.link.removeSelfHostFromUrl(link.url); -- 2.20.1