unification of tooltip and note list renderers

This commit is contained in:
zadam
2020-12-03 22:54:24 +01:00
parent bc520edd19
commit a1fb84f14d
6 changed files with 76 additions and 66 deletions

View File

@@ -2,6 +2,7 @@ import linkService from "./link.js";
import noteContentRenderer from "./note_content_renderer.js";
import treeCache from "./tree_cache.js";
import attributeService from "./attributes.js";
import attributeRenderer from "./attribute_renderer.js";
const TPL = `
<div class="note-list">
@@ -56,6 +57,14 @@ const TPL = `
margin-bottom: 0;
}
.note-book-title .rendered-note-attributes {
font-size: medium;
}
.note-book-title .rendered-note-attributes:before {
content: "\\00a0\\00a0";
}
.note-book-card .note-book-card {
border: 1px solid var(--main-border-color);
}
@@ -244,16 +253,18 @@ class NoteListRenderer {
}
}
// TODO: we should also render (promoted) attributes
async renderNote(note, expand = false) {
const $expander = $('<span class="note-expander bx bx-chevron-right"></span>');
const {$renderedAttributes} = await attributeRenderer.renderNormalAttributes(note);
const $card = $('<div class="note-book-card">')
.attr('data-note-id', note.noteId)
.append(
$('<h5 class="note-book-title">')
.append($expander)
.append(await linkService.createNoteLink(note.noteId, {showTooltip: false}))
.append($renderedAttributes)
);
$expander.on('click', () => this.toggleContent($card, note, !$card.hasClass("expanded")));
@@ -288,11 +299,11 @@ class NoteListRenderer {
const $content = $('<div class="note-book-content">');
try {
const {renderedContent, type} = await noteContentRenderer.getRenderedContent(note, {
const {$renderedContent, type} = await noteContentRenderer.getRenderedContent(note, {
trim: this.viewType === 'grid' // for grid only short content is needed
});
$content.append(renderedContent);
$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}`);