From: Alexander Ebert Date: Mon, 27 Jan 2014 01:17:12 +0000 (+0100) Subject: CKEditor: Fix for strange selection bug in Firefox X-Git-Tag: 2.0.2~9 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=ae13de61ccd752815f0cfb15c2ddc850f9fa5d4f;p=GitHub%2FWoltLab%2FWCF.git CKEditor: Fix for strange selection bug in Firefox --- diff --git a/wcfsetup/install/files/js/WCF.Message.js b/wcfsetup/install/files/js/WCF.Message.js index 7c5748932d..c698005d1f 100644 --- a/wcfsetup/install/files/js/WCF.Message.js +++ b/wcfsetup/install/files/js/WCF.Message.js @@ -745,7 +745,17 @@ WCF.Message.QuickReply = Class.extend({ } if ($.browser.ckeditor) { - this._messageField.ckeditorGet().insertText(data.returnValues.template); + var $ckEditor = this._messageField.ckeditorGet(); + + // work-around for a strange selection bug in Firefox: http://www.woltlab.com/forum/index.php/Thread/220522-Zitat-Fehler/ + if ($ckEditor.getSelection().getStartElement() === null) { + // range is broken, set it to end of text: http://stackoverflow.com/a/16308194 + var $range = $ckEditor.createRange(); + $range.moveToPosition($range.root, CKEDITOR.POSITION_BEFORE_END); + $ckEditor.getSelection().selectRanges([ $range ]); + } + + $ckEditor.insertText(data.returnValues.template); } else { this._messageField.val(data.returnValues.template);