Reset the cursor
Once tab key is pressed, place the cursor 4 spaces away from the location where the tab key was pressed. This handles the case of when a tab key is pressed in the middle of an existing note and the cursor was placed at the end of the document. fix https://github.com/standardnotes/web/issues/50
This commit is contained in:
@@ -23,11 +23,17 @@ angular.module('app.frontend')
|
|||||||
var handleTab = function (event) {
|
var handleTab = function (event) {
|
||||||
if (event.which == 9) {
|
if (event.which == 9) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
var start = event.target.selectionStart;
|
var start = this.selectionStart;
|
||||||
var end = event.target.selectionEnd;
|
var end = this.selectionEnd;
|
||||||
var spaces = " ";
|
var spaces = " ";
|
||||||
event.target.value = event.target.value.substring(0, start)
|
|
||||||
+ spaces + event.target.value.substring(end);
|
// Insert 4 spaces
|
||||||
|
this.value = this.value.substring(0, start)
|
||||||
|
+ spaces + this.value.substring(end);
|
||||||
|
|
||||||
|
// Place cursor 4 spaces away from where
|
||||||
|
// the tab key was pressed
|
||||||
|
this.selectionStart = this.selectionEnd = start + 4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user