diff --git a/src/pages/Drive/markdown/plugins/components/A.svelte b/src/pages/Drive/markdown/plugins/components/A.svelte index 6cd58ff..16add6f 100644 --- a/src/pages/Drive/markdown/plugins/components/A.svelte +++ b/src/pages/Drive/markdown/plugins/components/A.svelte @@ -5,6 +5,7 @@ import type Drive from "../../../../../blossom-drive-client/Drive"; import { joinPath } from "../../../../../blossom-drive-client/FileTree/methods"; import { servers } from "../../../../../services/servers"; + import { getLocalFileURL } from "../../../../../services/downloads"; export let href: string; let resolved = href; @@ -28,10 +29,21 @@ } } - function handleClick(e: MouseEvent) { - const drive = getContext("drive"); + const drive = getContext("drive"); + const subPath = getContext("path"); + + async function handleClick(e: MouseEvent) { if (drive instanceof EncryptedDrive) { - // TODO: open encrypted file + e.preventDefault(); + + const fullPath = href.startsWith("/") + ? href.replaceAll("%20", " ") + : joinPath(subPath, href.replaceAll("%20", " ").replace(/^\.\//, "")); + + const file = drive.getFile(fullPath); + const url = await getLocalFileURL(drive, file.path, $servers); + + window.open(url, "_blank"); } }