feat: add stacked public notes

This commit is contained in:
Julien Calixte
2026-02-15 00:00:12 +01:00
parent 77c1f41b6d
commit d1b0d51ec9
8 changed files with 289 additions and 78 deletions

View File

@@ -1,36 +1,34 @@
import { ComputedRef, onUnmounted, Ref, toValue } from "vue"
import { isExternalLink } from "@/utils/link"
import { publicNoteEventBus } from "@/bus/publicNoteEventBus"
import { useRouteQueryStackedNotes } from "@/hooks/useRouteQueryStackedNotes.hook"
export const useATProtoLinks = (
className: ComputedRef<string> | string,
rkey?: Ref<string> | string,
currentAtUri?: Ref<string> | string,
) => {
const { addStackedNote } = useRouteQueryStackedNotes()
const linkNote: EventListener = (event) => {
const target = event.target as HTMLElement
const href = target.getAttribute("href")
const atUri = target.getAttribute("href")
if (!href) {
if (!atUri) {
return
}
if (href.startsWith("#")) {
if (atUri.startsWith("#")) {
return
}
event.preventDefault()
event.stopPropagation()
if (isExternalLink(href)) {
window.open(href, "_blank")
if (isExternalLink(atUri)) {
window.open(atUri, "_blank")
return
}
publicNoteEventBus.emit({
path: href,
currentNoteRkey: toValue(rkey),
})
addStackedNote(toValue(currentAtUri) ?? "", atUri)
}
const LINK_SELECTOR = `.${toValue(className)} a`