generated from nhcarrigan/template
@@ -2,6 +2,7 @@
|
|||||||
import { marked } from "marked";
|
import { marked } from "marked";
|
||||||
import hljs from "highlight.js";
|
import hljs from "highlight.js";
|
||||||
import { onMount } from "svelte";
|
import { onMount } from "svelte";
|
||||||
|
import { openUrl } from "@tauri-apps/plugin-opener";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
content: string;
|
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(() => {
|
onMount(() => {
|
||||||
if (containerElement) {
|
if (containerElement) {
|
||||||
containerElement.querySelectorAll("pre code:not(.hljs)").forEach((block) => {
|
containerElement.querySelectorAll("pre code:not(.hljs)").forEach((block) => {
|
||||||
@@ -87,7 +97,10 @@
|
|||||||
<div
|
<div
|
||||||
bind:this={containerElement}
|
bind:this={containerElement}
|
||||||
class="markdown-content"
|
class="markdown-content"
|
||||||
onclick={handleSpoilerClick}
|
onclick={(e) => {
|
||||||
|
handleSpoilerClick(e);
|
||||||
|
handleLinkClick(e);
|
||||||
|
}}
|
||||||
onkeydown={handleSpoilerKeydown}
|
onkeydown={handleSpoilerKeydown}
|
||||||
role="presentation"
|
role="presentation"
|
||||||
>
|
>
|
||||||
|
|||||||
Reference in New Issue
Block a user