summaryrefslogtreecommitdiff
path: root/assets/js/components
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-11-30 21:05:57 -0500
committerFrederic Guillot <fred@kanboard.net>2016-11-30 21:05:57 -0500
commit858def555f4071e4744ea6a897c67443efbd91c8 (patch)
treec65a5d2980a6d5b7c74615eebd7579f09a3014bf /assets/js/components
parent700e226ba8508641fc559d1d2ddd1fd00a1eb79c (diff)
Fix selection bug with IE11 in text editor
Diffstat (limited to 'assets/js/components')
-rw-r--r--assets/js/components/text-editor.js17
1 files changed, 14 insertions, 3 deletions
diff --git a/assets/js/components/text-editor.js b/assets/js/components/text-editor.js
index 8b601c01..f94b72f8 100644
--- a/assets/js/components/text-editor.js
+++ b/assets/js/components/text-editor.js
@@ -118,10 +118,21 @@ KB.component('text-editor', function (containerElement, options) {
function insertText(replacedText) {
var result = false;
- selectionStart = textarea.selectionStart;
- selectionEnd = textarea.selectionEnd;
textarea.focus();
+ // Fix issue with IE11 (last line with wrong position)
+ if (textarea.value.length < textarea.selectionStart) {
+ selectionStart = textarea.value.length;
+ } else {
+ selectionStart = textarea.selectionStart;
+ }
+
+ if (textarea.selectionStart === textarea.selectionEnd) {
+ selectionEnd = selectionStart;
+ } else {
+ selectionEnd = textarea.selectionEnd;
+ }
+
if (document.queryCommandSupported('insertText')) {
result = document.execCommand('insertText', false, replacedText);
}
@@ -131,7 +142,7 @@ KB.component('text-editor', function (containerElement, options) {
document.execCommand('ms-beginUndoUnit');
} catch (error) {}
- textarea.value = replaceTextRange(textarea.value, textarea.selectionStart, textarea.selectionEnd, replacedText);
+ textarea.value = replaceTextRange(textarea.value, selectionStart, textarea.selectionEnd, replacedText);
try {
document.execCommand('ms-endUndoUnit');