Skip to content

Commit

Permalink
handle anchor links in encrypted drives
Browse files Browse the repository at this point in the history
  • Loading branch information
hzrd149 committed Mar 20, 2024
1 parent a05ffe9 commit 4f291f0
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/pages/Drive/markdown/plugins/components/A.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -28,10 +29,21 @@
}
}
function handleClick(e: MouseEvent) {
const drive = getContext<Drive | EncryptedDrive>("drive");
const drive = getContext<Drive | EncryptedDrive>("drive");
const subPath = getContext<string>("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");
}
}
</script>
Expand Down

0 comments on commit 4f291f0

Please sign in to comment.