chore(prettier): fix all files

This commit is contained in:
Elian Doran
2025-01-09 18:07:02 +02:00
parent 19ee861699
commit 4cbb529fd4
571 changed files with 23226 additions and 23940 deletions

View File

@@ -158,7 +158,6 @@ const TPL = `
</div>`;
class NoteListRenderer {
private $noteList: JQuery<HTMLElement>;
private parentNote: FNote;
@@ -181,7 +180,7 @@ class NoteListRenderer {
this.parentNote = parentNote;
const includedNoteIds = this.getIncludedNoteIds();
this.noteIds = noteIds.filter(noteId => !includedNoteIds.has(noteId) && noteId !== '_hidden');
this.noteIds = noteIds.filter((noteId) => !includedNoteIds.has(noteId) && noteId !== "_hidden");
if (this.noteIds.length === 0) {
return;
@@ -190,17 +189,17 @@ class NoteListRenderer {
$parent.append(this.$noteList);
this.page = 1;
this.pageSize = parseInt(parentNote.getLabelValue('pageSize') || "");
this.pageSize = parseInt(parentNote.getLabelValue("pageSize") || "");
if (!this.pageSize || this.pageSize < 1) {
this.pageSize = 20;
}
this.viewType = parentNote.getLabelValue('viewType');
this.viewType = parentNote.getLabelValue("viewType");
if (!['list', 'grid'].includes(this.viewType || "")) {
if (!["list", "grid"].includes(this.viewType || "")) {
// when not explicitly set, decide based on the note type
this.viewType = parentNote.type === 'search' ? 'list' : 'grid';
this.viewType = parentNote.type === "search" ? "list" : "grid";
}
this.$noteList.addClass(`${this.viewType}-view`);
@@ -211,11 +210,9 @@ class NoteListRenderer {
/** @returns {Set<string>} list of noteIds included (images, included notes) in the parent note and which
* don't have to be shown in the note list. */
getIncludedNoteIds() {
const includedLinks = this.parentNote
? this.parentNote.getRelations().filter(rel => rel.name === 'imageLink' || rel.name === 'includeNoteLink')
: [];
const includedLinks = this.parentNote ? this.parentNote.getRelations().filter((rel) => rel.name === "imageLink" || rel.name === "includeNoteLink") : [];
return new Set(includedLinks.map(rel => rel.value));
return new Set(includedLinks.map((rel) => rel.value));
}
async renderList() {
@@ -228,18 +225,16 @@ class NoteListRenderer {
if (highlightedTokens.length > 0) {
await libraryLoader.requireLibrary(libraryLoader.MARKJS);
const regex = highlightedTokens
.map(token => utils.escapeRegExp(token))
.join("|");
const regex = highlightedTokens.map((token) => utils.escapeRegExp(token)).join("|");
this.highlightRegex = new RegExp(regex, 'gi');
this.highlightRegex = new RegExp(regex, "gi");
} else {
this.highlightRegex = null;
}
this.$noteList.show();
const $container = this.$noteList.find('.note-list-container').empty();
const $container = this.$noteList.find(".note-list-container").empty();
const startIdx = (this.page - 1) * this.pageSize;
const endIdx = startIdx + this.pageSize;
@@ -248,7 +243,7 @@ class NoteListRenderer {
const pageNotes = await froca.getNotes(pageNoteIds);
for (const note of pageNotes) {
const $card = await this.renderNote(note, this.parentNote.isLabelTruthy('expanded'));
const $card = await this.renderNote(note, this.parentNote.isLabelTruthy("expanded"));
$container.append($card);
}
@@ -259,7 +254,7 @@ class NoteListRenderer {
}
renderPager() {
const $pager = this.$noteList.find('.note-list-pager').empty();
const $pager = this.$noteList.find(".note-list-pager").empty();
if (!this.page || !this.pageSize) {
return;
}
@@ -279,18 +274,17 @@ class NoteListRenderer {
$pager.append(
i === this.page
? $('<span>').text(i).css('text-decoration', 'underline').css('font-weight', "bold")
? $("<span>").text(i).css("text-decoration", "underline").css("font-weight", "bold")
: $('<a href="javascript:">')
.text(i)
.attr("title", `Page of ${startIndex} - ${endIndex}`)
.on('click', () => {
this.page = i;
this.renderList();
}),
.text(i)
.attr("title", `Page of ${startIndex} - ${endIndex}`)
.on("click", () => {
this.page = i;
this.renderList();
}),
" &nbsp; "
);
}
else if (lastPrinted) {
} else if (lastPrinted) {
$pager.append("... &nbsp; ");
lastPrinted = false;
@@ -304,33 +298,34 @@ class NoteListRenderer {
async renderNote(note: FNote, expand: boolean = false) {
const $expander = $('<span class="note-expander bx bx-chevron-right"></span>');
const {$renderedAttributes} = await attributeRenderer.renderNormalAttributes(note);
const notePath = this.parentNote.type === 'search'
? note.noteId // for search note parent, we want to display a non-search path
: `${this.parentNote.noteId}/${note.noteId}`;
const { $renderedAttributes } = await attributeRenderer.renderNormalAttributes(note);
const notePath =
this.parentNote.type === "search"
? note.noteId // for search note parent, we want to display a non-search path
: `${this.parentNote.noteId}/${note.noteId}`;
const $card = $('<div class="note-book-card">')
.attr('data-note-id', note.noteId)
.attr("data-note-id", note.noteId)
.append(
$('<h5 class="note-book-header">')
.append($expander)
.append($('<span class="note-icon">').addClass(note.getIcon()))
.append(this.viewType === 'grid'
? $('<span class="note-book-title">').text(await treeService.getNoteTitle(note.noteId, this.parentNote.noteId))
: (await linkService.createLink(notePath, {showTooltip: false, showNotePath: this.showNotePath}))
.addClass("note-book-title")
.append(
this.viewType === "grid"
? $('<span class="note-book-title">').text(await treeService.getNoteTitle(note.noteId, this.parentNote.noteId))
: (await linkService.createLink(notePath, { showTooltip: false, showNotePath: this.showNotePath })).addClass("note-book-title")
)
.append($renderedAttributes)
);
if (this.viewType === 'grid') {
if (this.viewType === "grid") {
$card
.addClass("block-link")
.attr("data-href", `#${notePath}`)
.on('click', e => linkService.goToLink(e));
.on("click", (e) => linkService.goToLink(e));
}
$expander.on('click', () => this.toggleContent($card, note, !$card.hasClass("expanded")));
$expander.on("click", () => this.toggleContent($card, note, !$card.hasClass("expanded")));
if (this.highlightRegex) {
$card.find(".note-book-title").markRegExp(this.highlightRegex, {
@@ -347,22 +342,21 @@ class NoteListRenderer {
}
async toggleContent($card: JQuery<HTMLElement>, note: FNote, expand: boolean) {
if (this.viewType === 'list' && ((expand && $card.hasClass("expanded")) || (!expand && !$card.hasClass("expanded")))) {
if (this.viewType === "list" && ((expand && $card.hasClass("expanded")) || (!expand && !$card.hasClass("expanded")))) {
return;
}
const $expander = $card.find('> .note-book-header .note-expander');
const $expander = $card.find("> .note-book-header .note-expander");
if (expand || this.viewType === 'grid') {
if (expand || this.viewType === "grid") {
$card.addClass("expanded");
$expander.addClass("bx-chevron-down").removeClass("bx-chevron-right");
}
else {
} else {
$card.removeClass("expanded");
$expander.addClass("bx-chevron-right").removeClass("bx-chevron-down");
}
if ((expand || this.viewType === 'grid') && $card.find('.note-book-content').length === 0) {
if ((expand || this.viewType === "grid") && $card.find(".note-book-content").length === 0) {
$card.append(await this.renderNoteContent(note));
}
}
@@ -371,8 +365,8 @@ class NoteListRenderer {
const $content = $('<div class="note-book-content">');
try {
const {$renderedContent, type} = await contentRenderer.getRenderedContent(note, {
trim: this.viewType === 'grid' // for grid only short content is needed
const { $renderedContent, type } = await contentRenderer.getRenderedContent(note, {
trim: this.viewType === "grid" // for grid only short content is needed
});
if (this.highlightRegex) {
@@ -393,11 +387,10 @@ class NoteListRenderer {
$content.append("rendering error");
}
if (this.viewType === 'list') {
const imageLinks = note.getRelations('imageLink');
if (this.viewType === "list") {
const imageLinks = note.getRelations("imageLink");
const childNotes = (await note.getChildNotes())
.filter(childNote => !imageLinks.find(rel => rel.value === childNote.noteId));
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));