refactor for current range

This commit is contained in:
quenousimporte 2023-12-04 10:40:57 +01:00
parent 2572378eaf
commit 41bffbe0f3
1 changed files with 3 additions and 13 deletions

16
main.js
View File

@ -428,11 +428,7 @@ function createsubnote()
} }
else else
{ {
var range = var range = currentrange();
{
start: md.selectionStart,
end: md.selectionEnd
}
var content = getrangecontent(range); var content = getrangecontent(range);
var newnote = var newnote =
{ {
@ -2676,10 +2672,7 @@ function mainkeydownhandler()
} }
else if (event.ctrlKey && event.shiftKey && (event.keyCode == "40" || event.keyCode == "38")) else if (event.ctrlKey && event.shiftKey && (event.keyCode == "40" || event.keyCode == "38"))
{ {
var pos = { var pos = currentrange();
start: md.selectionStart,
end: md.selectionEnd
};
var direction = event.keyCode == "40" ? 1 : -1; var direction = event.keyCode == "40" ? 1 : -1;
var start = lineatpos(md.selectionStart); var start = lineatpos(md.selectionStart);
var end = lineatpos(md.selectionEnd); var end = lineatpos(md.selectionEnd);
@ -2809,10 +2802,7 @@ function editorkeydown()
else if (event.key === "Tab") else if (event.key === "Tab")
{ {
event.preventDefault(); event.preventDefault();
var init = { var init = currentrange();
start: md.selectionStart,
end: md.selectionEnd
};
var range = getlinesrange(); var range = getlinesrange();
range.start--; range.start--;
range.end--; range.end--;