mirror of
https://github.com/zadam/trilium.git
synced 2026-01-01 04:04:25 +01:00
feat(share): display an icon for attachment download
This commit is contained in:
parent
1ae11ce3a5
commit
082040c6e1
@ -1,7 +1,8 @@
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { getContent, renderCode, type Result } from "./content_renderer.js";
|
||||
import { trimIndentation } from "@triliumnext/commons";
|
||||
import { describe, expect,it, vi } from "vitest";
|
||||
|
||||
import { buildShareNote, buildShareNotes } from "../test/shaca_mocking.js";
|
||||
import { getContent, renderCode, type Result } from "./content_renderer.js";
|
||||
|
||||
describe("content_renderer", () => {
|
||||
beforeAll(() => {
|
||||
@ -84,7 +85,7 @@ describe("content_renderer", () => {
|
||||
<span class="hljs-tag"></<span class="hljs-name">BuilderRow</span>></span>
|
||||
<span class="hljs-tag"></<span class="hljs-name">t</span>></span></code>
|
||||
</pre>
|
||||
`)
|
||||
`);
|
||||
});
|
||||
|
||||
describe("Reference links", () => {
|
||||
@ -106,7 +107,7 @@ describe("content_renderer", () => {
|
||||
expect(result.content).toStrictEqual(trimIndentation`\
|
||||
<h1>Test</h1>
|
||||
<p>
|
||||
<a class="reference-link attachment-link role-file" href="api/attachments/q14s2Id7V6pp/download">5863845791835102555.mp4</a>
|
||||
<a class="reference-link attachment-link role-file" href="api/attachments/q14s2Id7V6pp/download"><span><span class="tn-icon bx bx-download"></span>5863845791835102555.mp4</span></a>
|
||||
|
||||
</p>
|
||||
`);
|
||||
@ -170,7 +171,7 @@ describe("content_renderer", () => {
|
||||
const result = getContent(note);
|
||||
expect(result.content).toStrictEqual(trimIndentation`\
|
||||
<p>
|
||||
<a class="reference-link type-text" href="./MSkxxCFbBsYP"><span><span class="bx bx-note"></span>The quick <strong>brown</strong> fox</span></a>
|
||||
<a class="reference-link type-text" href="./MSkxxCFbBsYP"><span><span class="tn-icon bx bx-note"></span>The quick <strong>brown</strong> fox</span></a>
|
||||
</p>
|
||||
`);
|
||||
});
|
||||
|
||||
@ -413,7 +413,13 @@ function handleAttachmentLink(linkEl: HTMLElement, href: string, getNote: GetNot
|
||||
function cleanUpReferenceLinks(linkEl: HTMLElement, getNote: GetNoteFunction) {
|
||||
// Note: this method is basically a reimplementation of getReferenceLinkTitleSync from the link service of the client.
|
||||
const href = linkEl.getAttribute("href") ?? "";
|
||||
if (linkEl.classList.contains("attachment-link")) return;
|
||||
|
||||
// Handle attachment reference links
|
||||
if (linkEl.classList.contains("attachment-link")) {
|
||||
const title = linkEl.innerText;
|
||||
linkEl.innerHTML = `<span><span class="tn-icon bx bx-download"></span>${utils.escapeHtml(title)}</span>`;
|
||||
return;
|
||||
}
|
||||
|
||||
const noteId = href.split("/").at(-1);
|
||||
const note = noteId ? getNote(noteId) : undefined;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user