Fixed selection saving if no selection exists
authorAlexander Ebert <ebert@woltlab.com>
Mon, 24 Nov 2014 01:19:36 +0000 (02:19 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Mon, 24 Nov 2014 01:19:36 +0000 (02:19 +0100)
wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js

index f871ac72b2cddf2b5930fe7946f17571e462573a..c83b6db2407da5908c7767edbcb727587cc6a9fc 100644 (file)
@@ -57,7 +57,11 @@ RedactorPlugins.wmonkeypatch = function() {
                 * Saves current caret position.
                 */
                saveSelection: function() {
-                       this.wmonkeypatch._range = getSelection().getRangeAt(0);
+                       var $selection = getSelection();
+                       
+                       if ($selection.rangeCount) {
+                               this.wmonkeypatch._range = $selection.getRangeAt(0);
+                       }
                },
                
                /**