Fixed a few issues related to quotes and caret position
authorAlexander Ebert <ebert@woltlab.com>
Thu, 30 Oct 2014 16:53:34 +0000 (17:53 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Thu, 30 Oct 2014 16:53:34 +0000 (17:53 +0100)
wcfsetup/install/files/js/3rdParty/redactor/plugins/wutil.js
wcfsetup/install/files/js/WCF.Message.js

index 0780038e9b4f618d579e32bb462da20d9721a013..4c513f73b31270b7a1f79309ac971f21f85f9f02 100644 (file)
@@ -347,13 +347,17 @@ RedactorPlugins.wutil = function() {
                 * Sets the selection after the last direct children of the editor.
                 */
                selectionEndOfEditor: function() {
+                       this.focus.setEnd();
+                       
                        var $lastChild = this.$editor.children(':last')[0];
                        if ($lastChild.tagName === 'P') {
                                // sometimes the last <p> is just empty, causing the method to fail
                                if ($lastChild.innerHTML === '') {
-                                       $lastChild = $($lastChild).replaceWith($(this.opts.emptyHtml));
-                                       this.caret.setEnd($lastChild[0]);
+                                       $lastChild.remove();
+                                       $lastChild = $(this.opts.emptyHtml).appendTo(this.$editor);
                                }
+                               
+                               this.caret.setEnd($lastChild[0]);
                        }
                        else {
                                this.wutil.setCaretAfter($lastChild);
index 61b16e3a8cecfac61af5a9f4b2b899ec296885c8..f79ce501b2f257ff4d0013849d42259e452eb3a7 100644 (file)
@@ -896,7 +896,7 @@ WCF.Message.QuickReply = Class.extend({
                        
                        this._messageField.redactor('focus.setEnd');
                        this._messageField.redactor('wutil.insertDynamic', $html, data.returnValues.template);
-                       this._messageField.redactor('focus.setEnd');
+                       this._messageField.redactor('wutil.selectionEndOfEditor');
                        this._messageField.redactor('wbbcode._observeQuotes');
                }
                else {