drop download as json
fix tags list fix zip download fix backlinks
This commit is contained in:
parent
c176d25287
commit
8c27dfbd77
54
main.js
54
main.js
|
@ -190,11 +190,6 @@ var commands = [
|
||||||
hint: "Download all notes (json file)",
|
hint: "Download all notes (json file)",
|
||||||
action: downloadnotesjson
|
action: downloadnotesjson
|
||||||
},
|
},
|
||||||
{
|
|
||||||
hint: "Download all notes (encrypted json file)",
|
|
||||||
action: downloadencrypted,
|
|
||||||
remoteonly: true
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
hint: "Insert text in todo",
|
hint: "Insert text in todo",
|
||||||
action: promptinserttodo
|
action: promptinserttodo
|
||||||
|
@ -767,11 +762,6 @@ function clickeditor()
|
||||||
var word, link;
|
var word, link;
|
||||||
if (event.ctrlKey)
|
if (event.ctrlKey)
|
||||||
{
|
{
|
||||||
if (!saved)
|
|
||||||
{
|
|
||||||
console.log("Not saved, ctrl+click ignored.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
link = linkatpos();
|
link = linkatpos();
|
||||||
var tag = tagatpos();
|
var tag = tagatpos();
|
||||||
word = wordatpos();
|
word = wordatpos();
|
||||||
|
@ -914,10 +904,10 @@ function tagslist()
|
||||||
{
|
{
|
||||||
tags = {};
|
tags = {};
|
||||||
|
|
||||||
localdata
|
Object.values(metadata)
|
||||||
.forEach(n =>
|
.forEach(n =>
|
||||||
{
|
{
|
||||||
var ts = gettags(n);
|
var ts = n.header.tags;
|
||||||
ts.forEach(t =>
|
ts.forEach(t =>
|
||||||
{
|
{
|
||||||
tags[t] = tags[t] || [];
|
tags[t] = tags[t] || [];
|
||||||
|
@ -999,9 +989,9 @@ function download(filename, content)
|
||||||
function downloadnotes()
|
function downloadnotes()
|
||||||
{
|
{
|
||||||
var zip = new JSZip();
|
var zip = new JSZip();
|
||||||
localdata.forEach(note =>
|
Object.keys(metadata).forEach(guid =>
|
||||||
{
|
{
|
||||||
zip.file(getfilename(note.title), note.content);
|
zip.file(getfilename(metadata[guid].title), localStorage.getItem(guid));
|
||||||
});
|
});
|
||||||
zip.generateAsync({type:"blob"})
|
zip.generateAsync({type:"blob"})
|
||||||
.then(function(content)
|
.then(function(content)
|
||||||
|
@ -1013,9 +1003,9 @@ function downloadnotes()
|
||||||
function downloadhtmlnotes()
|
function downloadhtmlnotes()
|
||||||
{
|
{
|
||||||
var zip = new JSZip();
|
var zip = new JSZip();
|
||||||
localdata.forEach(note =>
|
Object.keys(metadata).forEach(guid =>
|
||||||
{
|
{
|
||||||
zip.file(getfilename(note.title).replace(".md", ".html"), md2html(note.content));
|
zip.file(getfilename(metadata[guid].title).replace(".md", ".html"), md2html(localStorage.getItem(guid)));
|
||||||
});
|
});
|
||||||
zip.generateAsync({type:"blob"})
|
zip.generateAsync({type:"blob"})
|
||||||
.then(function(content)
|
.then(function(content)
|
||||||
|
@ -1079,15 +1069,6 @@ function downloadnotesjson()
|
||||||
download("notes-" + timestamp() + ".json", window.localStorage.getItem("data"));
|
download("notes-" + timestamp() + ".json", window.localStorage.getItem("data"));
|
||||||
}
|
}
|
||||||
|
|
||||||
function downloadencrypted()
|
|
||||||
{
|
|
||||||
encryptstring(JSON.stringify(localdata))
|
|
||||||
.then(encrypted =>
|
|
||||||
{
|
|
||||||
download("notes-encrypted-" + timestamp() + ".acs", encrypted);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function downloadnotewithsubs()
|
function downloadnotewithsubs()
|
||||||
{
|
{
|
||||||
var note = withsubs();
|
var note = withsubs();
|
||||||
|
@ -1224,10 +1205,11 @@ function loadsettings()
|
||||||
|
|
||||||
function checksaved()
|
function checksaved()
|
||||||
{
|
{
|
||||||
if (!saved)
|
// todo
|
||||||
|
/*if (!saved)
|
||||||
{
|
{
|
||||||
return "not saved";
|
return "not saved";
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
function initsnippets()
|
function initsnippets()
|
||||||
|
@ -1442,9 +1424,9 @@ function getlinesrange()
|
||||||
|
|
||||||
function backlinks()
|
function backlinks()
|
||||||
{
|
{
|
||||||
searchinlist(localdata
|
searchinlist(Object.keys(metadata)
|
||||||
.filter(n => n.content.includes("[[" + title.value + "]]"))
|
.filter(guid => localStorage.getItem(guid).includes("[[" + title.value + "]]"))
|
||||||
.map(n => n.title))
|
.map(guid => metadata[guid].title))
|
||||||
.then(loadnote);
|
.then(loadnote);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2780,19 +2762,9 @@ function togglepreview()
|
||||||
|
|
||||||
function withsubs()
|
function withsubs()
|
||||||
{
|
{
|
||||||
|
// todo: handle loops
|
||||||
var currentguid = getguid(title.value);
|
var currentguid = getguid(title.value);
|
||||||
|
|
||||||
// probe for infinite loop
|
|
||||||
try
|
|
||||||
{
|
|
||||||
descendants(currentguid);
|
|
||||||
}
|
|
||||||
catch (err)
|
|
||||||
{
|
|
||||||
showtemporaryinfo(err);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
var content = md.value;
|
var content = md.value;
|
||||||
var kids = children(currentguid);
|
var kids = children(currentguid);
|
||||||
while (kids.length)
|
while (kids.length)
|
||||||
|
|
Loading…
Reference in New Issue