From: Alexander Ebert Date: Sun, 25 Dec 2016 12:36:58 +0000 (+0100) Subject: Fixed cmd+k link insertion on OSX Safari X-Git-Tag: 3.0.0_RC_3~47 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=c00f2013a8a3cd8600813cd2e98949e51a87cdd3;p=GitHub%2FWoltLab%2FWCF.git Fixed cmd+k link insertion on OSX Safari --- 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);