fixed: subnote

This commit is contained in:
quenousimporte 2023-11-07 11:48:37 +01:00
parent f2cb4b4bfe
commit d805864972
1 changed files with 26 additions and 28 deletions

54
main.js
View File

@ -397,44 +397,42 @@ function getrangecontent(range)
return md.value.substring(range.start, range.end); return md.value.substring(range.start, range.end);
} }
function createsubnote(suggestedtitle) function createsubnote()
{ {
var name = []; var title = prompt("Subnote tite:");
if (suggestedtitle) if (!title)
{ {
name.push(suggestedtitle); showtemporaryinfo("No title provided");
setpos(md.selectionStart);
md.focus();
} }
var range = getlinesrange(); else if (getnote(title))
var content = getrangecontent(range);
filter.placeholder = "Create subnote...";
searchinlist(name)
.then(title =>
{ {
if (!title) showtemporaryinfo("'" + title + "' already exists");
setpos(md.selectionStart);
md.focus();
}
else
{
var range =
{ {
showtemporaryinfo("No title provided"); start: md.selectionStart,
setpos(md.selectionStart); end: md.selectionEnd
} }
else if (getnote(title)) var content = getrangecontent(range);
var newnote =
{ {
showtemporaryinfo("'" + title + "' already exists"); title: title,
setpos(md.selectionStart); content: content
} }
else localdata.unshift(newnote);
{ seteditorcontent(md.value.substring(0, range.start)
var newnote = + "[[" + title + "]]"
{ + md.value.substring(range.end));
title: title, }
content: content
}
localdata.unshift(newnote);
seteditorcontent(md.value.substring(0, range.start)
+ "[[" + title + "]]"
+ md.value.substring(range.end));
}
});
} }
function comment() function comment()
{ {
seteditorcontent(md.value.substring(0, md.selectionStart) seteditorcontent(md.value.substring(0, md.selectionStart)