From: Alexander Ebert Date: Tue, 20 Oct 2015 18:21:58 +0000 (+0200) Subject: Dirty work-around to have Edge handled as IE X-Git-Tag: 2.1.8~2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=b89487b6c34ddebb62958cfa9f6d809eb2bcc2fe;p=GitHub%2FWoltLab%2FWCF.git Dirty work-around to have Edge handled as IE --- diff --git a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js index 870cfe9b67..72494756e4 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js +++ b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js @@ -925,6 +925,7 @@ RedactorPlugins.wmonkeypatch = function() { * Partially overwrites the 'link' module. * * - force consistent caret position upon link insert + * - inserting a link failed with Microsoft Edge, but forcing utils.browser('msie') to return true is potentially dangerous */ link: function() { // link.insert @@ -946,7 +947,39 @@ RedactorPlugins.wmonkeypatch = function() { // link.set var $mpSet = this.link.set; this.link.set = (function(text, link, target) { - $mpSet.call(this, text, link, target); + // work-around for Microsoft Edge + if (/\sEdge\//.test(window.navigator.userAgent)) { + text = $.trim(text.replace(/<|>/g, '')); + + this.selection.restore(); + var blocks = this.selection.getBlocks(); + + if (text === '' && link === '') return; + if (text === '' && link !== '') text = link; + + if (!this.link.$node) { + var $a = $('').text(text); + if (target !== '') $a.attr('target', target); + + $a = $(this.insert.node($a)); + + if (this.selection.getText().match(/\s$/)) + { + $a.after(" "); + } + + this.selection.selectElement($a); + + this.code.sync(); + this.core.setCallback('insertedLink', $a); + } + else { + $mpSet.call(this, text, link, target); + } + } + else { + $mpSet.call(this, text, link, target); + } var selection = window.getSelection(); if (selection.rangeCount) {