Fixed a few Safari bugs
authorAlexander Ebert <ebert@woltlab.com>
Thu, 5 Jan 2017 18:14:28 +0000 (19:14 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Thu, 5 Jan 2017 18:14:28 +0000 (19:14 +0100)
wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabAttachment.js
wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabSmiley.js
wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Redactor/Code.js
wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Redactor/Quote.js
wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Redactor/Spoiler.js

index 3cab79e2b2c8ba249634b83dabb8a69931d03b23..42717057e36c81a29eee55ea71b0c763a4324924 100644 (file)
@@ -24,7 +24,20 @@ $.Redactor.prototype.WoltLabAttachment = function() {
                        this.buffer.set();
                        
                        if (data.url) {
-                               this.insert.html('<img src="' + data.url + '" class="woltlabAttachment" data-attachment-id="' + attachmentId + '">');
+                               var id = 'wcfImgAttachment' + this.uuid;
+                               var img = elById(id);
+                               if (img) img.removeAttribute('id');
+                               
+                               this.insert.html('<img src="' + data.url + '" class="woltlabAttachment" data-attachment-id="' + attachmentId + '" id="' + id + '">');
+                               
+                               window.setTimeout((function () {
+                                       // Safari does not properly update the caret position on insert
+                                       var img = elById(id);
+                                       if (img) {
+                                               img.removeAttribute('id');
+                                               this.caret.after(img);
+                                       }
+                               }).bind(this), 10);
                        }
                        else {
                                // non-image attachment
index 56636b6bbf6c0ec0d90e222ab0ffc1d75d043186..3704e64653a2f0a2db5988b1c87c50e87d8b2206 100644 (file)
@@ -29,6 +29,9 @@ $.Redactor.prototype.WoltLabSmiley = function() {
                        smiley = elById(id);
                        smiley.removeAttribute('id');
                        
+                       // Safari does not properly update the caret position on insert
+                       this.caret.after(smiley);
+                       
                        //noinspection SillyAssignmentJS
                        smiley.outerHTML = smiley.outerHTML;
                }
index 9fd764832b4251af3ebf30adf969a3342db55443..33e8bb8a59d8144f57eb5aa201b32cb949a567cc 100644 (file)
@@ -61,6 +61,9 @@ define(['EventHandler', 'EventKey', 'Language', 'StringUtil', 'Dom/Util', 'Ui/Di
                                this._setTitle(pre);
                                
                                pre.addEventListener(WCF_CLICK_EVENT, this._callbackEdit);
+                               
+                               // work-around for Safari
+                               this._editor.caret.end(pre);
                        }
                },
                
index 114ed2def2cdedfa5d73dfef8c7475c4e372baf3..c5401365121b784b229d739cd7b3bdae55850562 100644 (file)
@@ -116,6 +116,9 @@ define(['Core', 'EventHandler', 'EventKey', 'Language', 'StringUtil', 'Dom/Util'
                                this._setTitle(quote);
                                
                                quote.addEventListener(WCF_CLICK_EVENT, this._callbackEdit);
+                               
+                               // work-around for Safari
+                               this._editor.caret.end(quote);
                        }
                },
                
index 5f953f720348ee936ba56739c5994efdbec4617d..47fbd612a36946d5423ccb9dac9c6321b1bfbb26 100644 (file)
@@ -54,6 +54,9 @@ define(['EventHandler', 'EventKey', 'Language', 'StringUtil', 'Dom/Util', 'Ui/Di
                                this._setTitle(spoiler);
                                
                                spoiler.addEventListener(WCF_CLICK_EVENT, this._callbackEdit);
+                               
+                               // work-around for Safari
+                               this._editor.caret.end(spoiler);
                        }
                },