refactor: get range content in function

added: cursor position in info
This commit is contained in:
quenousimporte 2023-03-06 09:51:44 +01:00
parent fdd5a8e41b
commit 7b32b4e167
1 changed files with 7 additions and 1 deletions

View File

@ -403,6 +403,11 @@ function getnote(title)
return localdata.find(note => note.title == title); return localdata.find(note => note.title == title);
} }
function getrangecontent(range)
{
return md.value.substring(range.start, range.end);
}
function createsubnote(suggestedtitle) function createsubnote(suggestedtitle)
{ {
var name = []; var name = [];
@ -411,7 +416,7 @@ function createsubnote(suggestedtitle)
name.push(suggestedtitle); name.push(suggestedtitle);
} }
var range = getlinesrange(); var range = getlinesrange();
var content = md.value.substring(range.start, range.end); var content = getrangecontent(range);
filter.placeholder = "Create subnote..."; filter.placeholder = "Create subnote...";
searchinlist(name) searchinlist(name)
.then(title => .then(title =>
@ -502,6 +507,7 @@ function showinfo()
[ [
"saved: " + saved, "saved: " + saved,
"title: " + currentnote.title, "title: " + currentnote.title,
"cursor position: " + (100 * md.selectionStart / md.value.length).toFixed(2) + "%",
"vault: " + currentvault, "vault: " + currentvault,
(tags ? "tags: " + tags : ""), (tags ? "tags: " + tags : ""),
"spell check: " + (md.spellcheck ? "en" : "dis") + "abled", "spell check: " + (md.spellcheck ? "en" : "dis") + "abled",