add: download all notes of tag

This commit is contained in:
quenousimporte 2024-03-03 12:25:36 +00:00
parent e1fad4468d
commit 928893c112
1 changed files with 25 additions and 0 deletions

25
main.js
View File

@ -183,6 +183,10 @@ var commands = [
action: downloadnotes,
shortcut: "ctrl+shift+S"
},
{
hint: "Download all notes of tag (md files in zip archive)",
action: downloadtag
},
{
hint: "Download all notes (html files in zip archive)",
action: downloadhtmlnotes
@ -1006,6 +1010,27 @@ function download(filename, content)
element = null;
}
function downloadtag()
{
tagslist()
.then(tag =>
{
var zip = new JSZip();
Object.keys(metadata).forEach(guid =>
{
if (metadata[guid].header.tags.includes(tag))
{
zip.file(getfilename(metadata[guid].title), localStorage.getItem(guid));
}
});
zip.generateAsync({type:"blob"})
.then(function(content)
{
saveAs(content, "notes-" + tag + "=" + timestamp() + ".zip");
});
});
}
function downloadnotes()
{
var zip = new JSZip();