Skip to content

Commit 71ba1c0

Browse files
committed
Merge branch 'release/2017-12-21'
2 parents 835247a + 72f84a0 commit 71ba1c0

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

plugin.info.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
base dropfiles
22
author Michael Große
33
email dokuwiki@cosmocode.de
4-
date 2017-12-15
4+
date 2017-12-21
55
name dropfiles plugin
66
desc Allows to upload files by drang'n'drop into the editarea of a page
77
url https://dokuwiki.org/plugin:dropfiles

src/upload.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
jQuery(function () {
22
'use strict';
3+
4+
var $lastKnownCaretPosition = 0; // IE 11 fix
35
var $editarea = jQuery('#wiki__text');
46
var $filelisting = jQuery('.plugin__filelisting');
57
if (!$editarea.length && !$filelisting.length) {
@@ -154,6 +156,12 @@ jQuery(function () {
154156
$elements.on('dragenter', function (e) {
155157
e.preventDefault();
156158
e.stopPropagation();
159+
160+
if ($editarea[0].selectionStart !== $lastKnownCaretPosition) {
161+
// IE 11 fix
162+
$editarea[0].setSelectionRange($lastKnownCaretPosition, $lastKnownCaretPosition);
163+
}
164+
157165
});
158166

159167
$elements.on('drop',function (e) {
@@ -245,6 +253,7 @@ jQuery(function () {
245253
$editarea.text(prefix + syntax + postfix);
246254
var newCaretPos = caretPos+syntax.length;
247255
$editarea[0].setSelectionRange(newCaretPos, newCaretPos);
256+
$lastKnownCaretPosition = newCaretPos; // IE 11 fix
248257
}
249258

250259
/**
@@ -374,4 +383,10 @@ jQuery(function () {
374383
jQuery('body').append($widget);
375384
}
376385
bootstrapFuntionality();
386+
387+
$editarea.blur(function () {
388+
// IE 11 fix
389+
$lastKnownCaretPosition = $editarea[0].selectionStart;
390+
});
391+
377392
});

0 commit comments

Comments
 (0)