diff --git a/public/res/editor.js b/public/res/editor.js index cdbe26aa..1c2da95f 100644 --- a/public/res/editor.js +++ b/public/res/editor.js @@ -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') {