generated from nhcarrigan/template
@@ -2,6 +2,7 @@
|
||||
import { marked } from "marked";
|
||||
import hljs from "highlight.js";
|
||||
import { onMount } from "svelte";
|
||||
import { openUrl } from "@tauri-apps/plugin-opener";
|
||||
|
||||
interface Props {
|
||||
content: string;
|
||||
@@ -75,6 +76,15 @@
|
||||
}
|
||||
}
|
||||
|
||||
function handleLinkClick(event: MouseEvent) {
|
||||
const target = event.target as HTMLElement;
|
||||
const anchor = target.closest("a");
|
||||
if (anchor?.href) {
|
||||
event.preventDefault();
|
||||
openUrl(anchor.href);
|
||||
}
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
if (containerElement) {
|
||||
containerElement.querySelectorAll("pre code:not(.hljs)").forEach((block) => {
|
||||
@@ -87,7 +97,10 @@
|
||||
<div
|
||||
bind:this={containerElement}
|
||||
class="markdown-content"
|
||||
onclick={handleSpoilerClick}
|
||||
onclick={(e) => {
|
||||
handleSpoilerClick(e);
|
||||
handleLinkClick(e);
|
||||
}}
|
||||
onkeydown={handleSpoilerKeydown}
|
||||
role="presentation"
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user