added: section in outline

This commit is contained in:
quenousimporte 2023-01-30 10:36:43 +01:00
parent 578e548883
commit e0ec91ee29
1 changed files with 11 additions and 3 deletions

14
main.js
View File

@ -549,10 +549,10 @@ function showoutline()
{
var outline = {};
var pos = 0;
getnotecontent().split("\n").forEach(line =>
getnotecontent().split("\n").forEach((line, index, lines) =>
{
pos += line.length + 1;
if (line.startsWith("#"))
if (line.startsWith("#") || line == "---")
{
line = line
.replace("# ", "")
@ -560,7 +560,15 @@ function showoutline()
outline[line] = pos;
}
});
searchinlist(Object.keys(outline))
var keys = Object
.keys(outline)
.sort((a,b) =>
{
return outline[a] - outline[b];
});
searchinlist(keys)
.then(line =>
{
md.setSelectionRange(outline[line], outline[line]);