mirror of
https://github.com/zadam/trilium.git
synced 2025-11-17 02:30:42 +01:00
chore(prettier): fix all files
This commit is contained in:
@@ -14,32 +14,32 @@ interface Result {
|
||||
function getContent(note: SNote) {
|
||||
if (note.isProtected) {
|
||||
return {
|
||||
header: '',
|
||||
content: '<p>Protected note cannot be displayed</p>',
|
||||
header: "",
|
||||
content: "<p>Protected note cannot be displayed</p>",
|
||||
isEmpty: false
|
||||
};
|
||||
}
|
||||
|
||||
const result: Result = {
|
||||
content: note.getContent(),
|
||||
header: '',
|
||||
header: "",
|
||||
isEmpty: false
|
||||
};
|
||||
|
||||
if (note.type === 'text') {
|
||||
if (note.type === "text") {
|
||||
renderText(result, note);
|
||||
} else if (note.type === 'code') {
|
||||
} else if (note.type === "code") {
|
||||
renderCode(result);
|
||||
} else if (note.type === 'mermaid') {
|
||||
} else if (note.type === "mermaid") {
|
||||
renderMermaid(result, note);
|
||||
} else if ([ "image", "canvas", "mindMap"].includes(note.type)) {
|
||||
} else if (["image", "canvas", "mindMap"].includes(note.type)) {
|
||||
renderImage(result, note);
|
||||
} else if (note.type === 'file') {
|
||||
} else if (note.type === "file") {
|
||||
renderFile(note, result);
|
||||
} else if (note.type === 'book') {
|
||||
} else if (note.type === "book") {
|
||||
result.isEmpty = true;
|
||||
} else {
|
||||
result.content = '<p>This note type cannot be displayed.</p>';
|
||||
result.content = "<p>This note type cannot be displayed.</p>";
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -57,14 +57,13 @@ function renderIndex(result: Result) {
|
||||
result.content += `<li><a class="${childNote.type}" href="${href}" ${target}>${childNote.escapedTitle}</a></li>`;
|
||||
}
|
||||
|
||||
result.content += '</ul>';
|
||||
result.content += "</ul>";
|
||||
}
|
||||
|
||||
function renderText(result: Result, note: SNote) {
|
||||
const document = new JSDOM(result.content || "").window.document;
|
||||
|
||||
result.isEmpty = document.body.textContent?.trim().length === 0
|
||||
&& document.querySelectorAll("img").length === 0;
|
||||
result.isEmpty = document.body.textContent?.trim().length === 0 && document.querySelectorAll("img").length === 0;
|
||||
|
||||
if (!result.isEmpty) {
|
||||
for (const linkEl of document.querySelectorAll("a")) {
|
||||
@@ -103,8 +102,8 @@ document.addEventListener("DOMContentLoaded", function() {
|
||||
|
||||
function handleAttachmentLink(linkEl: HTMLAnchorElement, href: string) {
|
||||
const linkRegExp = /attachmentId=([a-zA-Z0-9_]+)/g;
|
||||
let attachmentMatch
|
||||
if (attachmentMatch = linkRegExp.exec(href)) {
|
||||
let attachmentMatch;
|
||||
if ((attachmentMatch = linkRegExp.exec(href))) {
|
||||
const attachmentId = attachmentMatch[1];
|
||||
const attachment = shaca.getAttachment(attachmentId);
|
||||
|
||||
@@ -117,7 +116,7 @@ function handleAttachmentLink(linkEl: HTMLAnchorElement, href: string) {
|
||||
linkEl.removeAttribute("href");
|
||||
}
|
||||
} else {
|
||||
const [notePath] = href.split('?');
|
||||
const [notePath] = href.split("?");
|
||||
const notePathSegments = notePath.split("/");
|
||||
const noteId = notePathSegments[notePathSegments.length - 1];
|
||||
const linkedNote = shaca.getNote(noteId);
|
||||
@@ -144,7 +143,7 @@ function renderCode(result: Result) {
|
||||
} else {
|
||||
const document = new JSDOM().window.document;
|
||||
|
||||
const preEl = document.createElement('pre');
|
||||
const preEl = document.createElement("pre");
|
||||
preEl.appendChild(document.createTextNode(result.content));
|
||||
|
||||
result.content = preEl.outerHTML;
|
||||
@@ -162,7 +161,7 @@ function renderMermaid(result: Result, note: SNote) {
|
||||
<details>
|
||||
<summary>Chart source</summary>
|
||||
<pre>${escapeHtml(result.content)}</pre>
|
||||
</details>`
|
||||
</details>`;
|
||||
}
|
||||
|
||||
function renderImage(result: Result, note: SNote) {
|
||||
@@ -170,8 +169,8 @@ function renderImage(result: Result, note: SNote) {
|
||||
}
|
||||
|
||||
function renderFile(note: SNote, result: Result) {
|
||||
if (note.mime === 'application/pdf') {
|
||||
result.content = `<iframe class="pdf-view" src="api/notes/${note.noteId}/view"></iframe>`
|
||||
if (note.mime === "application/pdf") {
|
||||
result.content = `<iframe class="pdf-view" src="api/notes/${note.noteId}/view"></iframe>`;
|
||||
} else {
|
||||
result.content = `<button type="button" onclick="location.href='api/notes/${note.noteId}/download'">Download file</button>`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user