mirror of
https://github.com/zadam/trilium.git
synced 2024-12-26 17:21:23 +08:00
added conversion of notes to html
This commit is contained in:
parent
0fc604e7b4
commit
52034e0cdc
2 changed files with 51 additions and 0 deletions
|
@ -232,5 +232,6 @@
|
|||
<script src="stat/js/settings.js"></script>
|
||||
|
||||
<script src="stat/js/utils.js"></script>
|
||||
<script src="stat/js/convert2html.js"></script>
|
||||
</body>
|
||||
</html>
|
50
static/js/convert2html.js
Normal file
50
static/js/convert2html.js
Normal file
|
@ -0,0 +1,50 @@
|
|||
function convertAll2Html() {
|
||||
const failedNotes = [];
|
||||
let counter = 1;
|
||||
|
||||
for (const noteId of globalAllNoteIds) {
|
||||
console.log('Converting ' + counter + "/" + globalAllNoteIds.length);
|
||||
counter++;
|
||||
|
||||
$.ajax({
|
||||
url: baseUrl + 'notes/' + noteId,
|
||||
type: 'GET',
|
||||
async: false,
|
||||
success: function (note) {
|
||||
note.detail.note_text = notecase2html(note);
|
||||
note.formatting = [];
|
||||
|
||||
for (const link of note.links) {
|
||||
delete link.type;
|
||||
}
|
||||
|
||||
console.log(note.detail.note_text);
|
||||
|
||||
$.ajax({
|
||||
url: baseUrl + 'notes/' + noteId,
|
||||
type: 'PUT',
|
||||
data: JSON.stringify(note),
|
||||
contentType: "application/json",
|
||||
async: false,
|
||||
success: function () {
|
||||
console.log("Note " + noteId + " converted.")
|
||||
},
|
||||
error: function () {
|
||||
console.log("Note " + noteId + " failed when writing");
|
||||
|
||||
failedNotes.push(noteId);
|
||||
}
|
||||
});
|
||||
},
|
||||
error: function () {
|
||||
console.log("Note " + noteId + " failed when reading");
|
||||
|
||||
failedNotes.push(noteId);
|
||||
}
|
||||
});
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
console.log("Failed notes: ", failedNotes);
|
||||
}
|
Loading…
Reference in a new issue