Convert pasted links into plain text in iOS Safari
authorAlexander Ebert <ebert@woltlab.com>
Thu, 8 Mar 2018 12:54:11 +0000 (13:54 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Thu, 8 Mar 2018 12:54:11 +0000 (13:54 +0100)
wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js

index b3a039ed08ea0e925e934714309223927a2dc019..ebc87094bb3f7159c3960be56e5ed9b3f367bd03 100644 (file)
@@ -1265,6 +1265,17 @@ RedactorPlugins.wmonkeypatch = function() {
                        this.paste.insert = (function(html) {
                                $fixSelection();
                                
+                               // iOS Safari will automatically convert a single pasted link into an anchor element
+                               if ($.browser.iOS) {
+                                       var div = $('<div />').html(html)[0];
+                                       if (div.childElementCount === 1) {
+                                               var link = div.children[0];
+                                               if (link.nodeName === 'A' && link.textContent === link.href) {
+                                                       html = link.textContent;
+                                               }
+                                       }
+                               }
+                               
                                $mpInsert.call(this, html);
                                
                                setTimeout((function() {