This commit is contained in:
ammarahm-ed
2021-08-27 08:59:22 +05:00
parent 6dfa0cbbf4
commit 0a52991b03

View File

@@ -18,6 +18,22 @@ const colors = {
brown: "orange"
};
/**
*
* @param {object} keepNote A google keep note object
* @returns parsed html list from json.
*/
function makeListHtml(keepNote) {
let content = '<ul class="tox-checklist">';
for (item of keepNote.listContent) {
content += `<li class="${
item.isChecked ? "tox-checklist--checked" : ""
}" >${item.text}</li>`;
}
content += "</ul>";
return content;
}
/**
*
* @param {Array<{data:string | Buffer,createdAt:number,modifiedAt:number,fileName:string}>} files
@@ -34,7 +50,7 @@ function convert(files) {
let imageKeys = items.filter(
(i) => i.endsWith("png") || i.endsWith("jpg") || i.endsWith("jpeg")
);
for (let key of noteKeys) {
let keepNote = JSON.parse(Buffer.from(unzip[key].buffer).toString());
let note = templates.note();
@@ -62,14 +78,7 @@ function convert(files) {
note.tags = keepNote.labels.map((label) => label.name);
}
if (keepNote.listContent) {
let content = '<ul class="tox-checklist">';
for (item of keepNote.listContent) {
content += `<li class="${
item.isChecked ? "tox-checklist--checked" : ""
}" >${item.text}</li>`;
}
content += "</ul>";
note.content.data = content;
note.content.data = makeListHtml(keepNote);
}
if (keepNote.color && keepNote.color !== "DEFAULT") {
note.color = colors[keepNote.color.toLowerCase()];