');
try {
const {renderedContent, type} = await noteContentRenderer.getRenderedContent(note);
$content.append(renderedContent);
$content.addClass("type-" + type);
} catch (e) {
console.log(`Caught error while rendering note ${note.noteId} of type ${note.type}: ${e.message}, stack: ${e.stack}`);
$content.append("rendering error");
}
const imageLinks = note.getRelations('imageLink');
const childNotes = (await note.getChildNotes())
.filter(childNote => !imageLinks.find(rel => rel.value === childNote.noteId));
for (const childNote of childNotes) {
$content.append(await this.renderNote(childNote, false));
}
return $content;
}
// TODO: we should also render (promoted) attributes
async renderNote(note, expand) {
const notePath = /*this.notePath + '/' + */ note.noteId;
const $expander = $('
');
const $card = $('
')
.attr('data-note-id', note.noteId)
.append(
$('
')
.append($expander)
.append(await linkService.createNoteLink(notePath, {showTooltip: false}))
);
$expander.on('click', () => toggleContent($card, note, !$card.hasClass("expanded")));
await this.toggleContent($card, note, expand);
return $card;
}
async toggleContent($card, note, expand) {
if (this.viewType === 'list' && ((expand && $card.hasClass("expanded")) || (!expand && !$card.hasClass("expanded")))) {
return;
}
const $expander = $card.find('> .note-book-title .note-expander');
if (expand) {
$card.addClass("expanded");
$expander.addClass("bx-chevron-down").removeClass("bx-chevron-right");
}
else {
$card.removeClass("expanded");
$expander.addClass("bx-chevron-right").removeClass("bx-chevron-down");
}
if (expand && $card.find('.note-book-content').length === 0) {
$card.append(await this.renderNoteContent(note));
}
}
}
export default NoteListRenderer;