Fixed trailing lf selection in firefox

This commit is contained in:
benweet 2014-08-21 19:47:54 +01:00
parent 7d2b254f6f
commit fc8a9c641d

View File

@ -25,6 +25,8 @@ define([
var $marginElt;
var previewElt;
var pagedownEditor;
var trailingLfNode;
var refreshPreviewLater = (function() {
var elapsedTime = 0;
var timeoutId;
@ -148,7 +150,7 @@ define([
do {
result.push({
container: walker.currentNode,
offsetInContainer: walkerOffset,
offsetInContainer: text.length,
offset: offset
});
offset = offsetList.shift();
@ -271,6 +273,11 @@ define([
selectionStart = offset;
selectionEnd = offset + (range + '').length;
}
if(selectionStart === selectionEnd && selectionStart > textContent.length) {
// In Firefox cursor can be after the trailingLfNode
selection.nativeSelection.modify("move", "backward", "character");
selectionStart = --selectionEnd;
}
}
}
self.setSelectionStartEnd(selectionStart, selectionEnd);
@ -652,8 +659,6 @@ define([
}
}, 10);
var trailingLfNode;
function checkContentChange() {
var newTextContent = inputElt.textContent;
if(contentElt.lastChild === trailingLfNode && trailingLfNode.textContent.slice(-1) == '\n') {