Fixed end of line issue on IE
This commit is contained in:
parent
00cfbea6f5
commit
33fb3573ee
@ -247,15 +247,13 @@ define([
|
|||||||
if(fileChanged === false) {
|
if(fileChanged === false) {
|
||||||
var selectionStart = self.selectionStart;
|
var selectionStart = self.selectionStart;
|
||||||
var selectionEnd = self.selectionEnd;
|
var selectionEnd = self.selectionEnd;
|
||||||
var range;
|
|
||||||
var selection = rangy.getSelection();
|
var selection = rangy.getSelection();
|
||||||
if(selection.rangeCount > 0) {
|
if(selection.rangeCount > 0) {
|
||||||
var selectionRange = selection.getRangeAt(0);
|
var selectionRange = selection.getRangeAt(0);
|
||||||
var element = selectionRange.startContainer;
|
var element = selectionRange.startContainer;
|
||||||
if((contentElt.compareDocumentPosition(element) & 0x10)) {
|
if((contentElt.compareDocumentPosition(element) & 0x10)) {
|
||||||
range = selectionRange;
|
|
||||||
var container = element;
|
var container = element;
|
||||||
var offset = range.startOffset;
|
var offset = selectionRange.startOffset;
|
||||||
do {
|
do {
|
||||||
while(element = element.previousSibling) {
|
while(element = element.previousSibling) {
|
||||||
if(element.textContent) {
|
if(element.textContent) {
|
||||||
@ -266,17 +264,20 @@ define([
|
|||||||
} while(element && element != inputElt);
|
} while(element && element != inputElt);
|
||||||
|
|
||||||
if(selection.isBackwards()) {
|
if(selection.isBackwards()) {
|
||||||
selectionStart = offset + (range + '').length;
|
selectionStart = offset + (selectionRange + '').length;
|
||||||
selectionEnd = offset;
|
selectionEnd = offset;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
selectionStart = offset;
|
selectionStart = offset;
|
||||||
selectionEnd = offset + (range + '').length;
|
selectionEnd = offset + (selectionRange + '').length;
|
||||||
}
|
}
|
||||||
if(selectionStart === selectionEnd && selectionStart > textContent.length) {
|
|
||||||
// In Firefox cursor can be after the trailingLfNode
|
if(selectionStart === selectionEnd && selectionRange.startContainer.textContent == '\n' && selectionRange.startOffset == 1) {
|
||||||
selection.nativeSelection.modify && selection.nativeSelection.modify("move", "backward", "character");
|
// In IE if end of line is selected, offset is wrong
|
||||||
|
// Also, in Firefox cursor can be after the trailingLfNode
|
||||||
selectionStart = --selectionEnd;
|
selectionStart = --selectionEnd;
|
||||||
|
self.setSelectionStartEnd(selectionStart, selectionEnd);
|
||||||
|
self.updateSelectionRange();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user