From e0ec91ee29d7d39ae42b7a4763c18a0901e2afc1 Mon Sep 17 00:00:00 2001 From: quenousimporte <76260127+quenousimporte@users.noreply.github.com> Date: Mon, 30 Jan 2023 10:36:43 +0100 Subject: [PATCH] added: section in outline --- main.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/main.js b/main.js index 93ad338..54341da 100644 --- a/main.js +++ b/main.js @@ -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]);