changed: bookmarks preview

This commit is contained in:
quenousimporte 2024-01-08 10:53:36 +01:00
parent e9076eb2d0
commit b800debd2f
1 changed files with 11 additions and 2 deletions

13
main.js
View File

@ -2831,9 +2831,18 @@ function insertautocomplete(selectednote)
insert(selectednote + "]] ");
}
function bookmarkspreview()
{
var bookmarks = JSON.parse(md.value);
return "# Bookmarks" + bookmarks.reduce( (acc, cur) =>
{
return acc + "[" + cur.title + "](" + cur.url + ")\n";
}, "\n");
}
function togglepreview()
{
preview.innerHTML = md2html(md.value);
preview.innerHTML = md2html(currentnote.title == "bookmarks" ? bookmarkspreview() : md.value);
toggleeditor(!md.hidden);
preview.hidden = !preview.hidden;
@ -2965,7 +2974,7 @@ function loadnote(name)
stat.cur.d = 0;
stat.cur.t = timestamp();
if (!preview.hidden || (preview.hidden && gettags(note).indexOf("preview") !== -1))
if (!preview.hidden || (preview.hidden && (gettags(note).indexOf("preview") !== -1) || note.title == "bookmarks"))
{
togglepreview();
}