Convert pasted links into plain text in iOS Safari
authorAlexander Ebert <ebert@woltlab.com>
Thu, 8 Mar 2018 13:24:31 +0000 (14:24 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Thu, 8 Mar 2018 13:24:31 +0000 (14:24 +0100)
wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabPaste.js

index a92236276e7b3b21444557d4fce00195f0289027..24368f0c9b84cdf53612bf7a1c97c6401b800f1c 100644 (file)
@@ -11,6 +11,11 @@ $.Redactor.prototype.WoltLabPaste = function() {
                        
                        var firefoxPlainText = null;
                        
+                       var isIosSafari = false;
+                       require(['Environment'], function (Environment) {
+                               isIosSafari = (Environment.platform() === 'ios' && Environment.browser() === 'safari');
+                       });
+                       
                        var mpInit = this.paste.init;
                        this.paste.init = (function (e) {
                                firefoxPlainText = null;
@@ -77,6 +82,17 @@ $.Redactor.prototype.WoltLabPaste = function() {
                                        return firefoxPlainText;
                                }
                                
+                               if (isIosSafari) {
+                                       var div = elCreate('div');
+                                       div.innerHTML = returnValue;
+                                       if (div.childElementCount === 1) {
+                                               var link = div.children[0];
+                                               if (link.nodeName === 'A' && link.textContent === link.href) {
+                                                       returnValue = link.textContent;
+                                               }
+                                       }
+                               }
+                               
                                return returnValue;
                        }).bind(this);