Set the right cursor position at the start of editing.

I assumed that all editing start with the whold content being selected.
The project note editor shows that this assumption might not be sure.
Added code in initializeTextarea to get the cursor right at the start
of editing.
pull/89/head
Zhenlei Jia 2019-02-08 20:58:40 -05:00
rodzic aabdfeade6
commit e972ae0ccd
1 zmienionych plików z 4 dodań i 2 usunięć

Wyświetl plik

@ -5418,7 +5418,7 @@ CursorMorph.prototype.initializeTextarea = function () {
}
});
// For other keyboard events, let the textarea element handle other key
// For other keyboard events, first let the textarea element handle the
// events, then we take its state and update the target morph and cursor
// morph accordingly.
this.textarea.addEventListener('keyup', function (event) {
@ -5498,7 +5498,9 @@ CursorMorph.prototype.syncTextareaSelectionWith = function (targetMorph) {
var start = targetMorph.startMark;
var end = targetMorph.endMark;
if (start <= end) {
if (start === end) {
this.textarea.setSelectionRange(this.slot, this.slot, 'none');
} else if (start < end) {
this.textarea.setSelectionRange(start, end, 'forward');
} else {
this.textarea.setSelectionRange(end, start, 'backward');