fixed: avoid toggle header in preview mode

This commit is contained in:
quenousimporte 2023-05-09 12:01:57 +02:00
parent 3240854915
commit 2f0d18822f
1 changed files with 21 additions and 18 deletions

39
main.js
View File

@ -1935,26 +1935,29 @@ function restore()
function toggleheader() function toggleheader()
{ {
if (md.value.startsWith("---")) if (preview.hidden)
{ {
var idx = md.value.indexOf("---", 3); if (md.value.startsWith("---"))
var header = md.value.substring(0, idx + 4); {
currentheader = header; var idx = md.value.indexOf("---", 3);
md.value = md.value.substring(idx + 4); var header = md.value.substring(0, idx + 4);
} currentheader = header;
else if (currentheader) md.value = md.value.substring(idx + 4);
{ }
md.value = currentheader + md.value; else if (currentheader)
currentheader = ""; {
} md.value = currentheader + md.value;
else currentheader = "";
{ }
var headers = "---\ndate: " + (new Date).toISOString().substring(0, 10) + "\ntags: \n---\n\n"; else
md.value = headers + md.value; {
setpos(27); var headers = "---\ndate: " + (new Date).toISOString().substring(0, 10) + "\ntags: \n---\n\n";
} md.value = headers + md.value;
setpos(27);
}
resize(); resize();
}
} }
function splitshortcut(s) function splitshortcut(s)