From 7b32b4e1679c4710be284327514998f09a404b26 Mon Sep 17 00:00:00 2001 From: quenousimporte <76260127+quenousimporte@users.noreply.github.com> Date: Mon, 6 Mar 2023 09:51:44 +0100 Subject: [PATCH] refactor: get range content in function added: cursor position in info --- main.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/main.js b/main.js index ca18ef5..3110c2e 100644 --- a/main.js +++ b/main.js @@ -403,6 +403,11 @@ function getnote(title) return localdata.find(note => note.title == title); } +function getrangecontent(range) +{ + return md.value.substring(range.start, range.end); +} + function createsubnote(suggestedtitle) { var name = []; @@ -411,7 +416,7 @@ function createsubnote(suggestedtitle) name.push(suggestedtitle); } var range = getlinesrange(); - var content = md.value.substring(range.start, range.end); + var content = getrangecontent(range); filter.placeholder = "Create subnote..."; searchinlist(name) .then(title => @@ -502,6 +507,7 @@ function showinfo() [ "saved: " + saved, "title: " + currentnote.title, + "cursor position: " + (100 * md.selectionStart / md.value.length).toFixed(2) + "%", "vault: " + currentvault, (tags ? "tags: " + tags : ""), "spell check: " + (md.spellcheck ? "en" : "dis") + "abled",