scope use links
This commit is contained in:
@@ -24,8 +24,8 @@ const props = defineProps<{
|
|||||||
|
|
||||||
const { scrollToFocusedNote } = useQueryStackedNotes()
|
const { scrollToFocusedNote } = useQueryStackedNotes()
|
||||||
const { content } = useFile(props.sha)
|
const { content } = useFile(props.sha)
|
||||||
const { listenToClick } = useLinks('stacked-note', props.sha)
|
|
||||||
const className = computed(() => `stacked-note-${props.index}`)
|
const className = computed(() => `stacked-note-${props.index}`)
|
||||||
|
const { listenToClick } = useLinks(className.value, props.sha)
|
||||||
const titleClassName = computed(() => `title-${className.value}`)
|
const titleClassName = computed(() => `title-${className.value}`)
|
||||||
useTitleNotes(props.repo)
|
useTitleNotes(props.repo)
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
import { noteEventBus } from '@/bus/noteEventBus'
|
import { noteEventBus } from '@/bus/noteEventBus'
|
||||||
import { useUserRepoStore } from '@/modules/repo/store/userRepo.store'
|
import { useUserRepoStore } from '@/modules/repo/store/userRepo.store'
|
||||||
import { isExternalLink } from '@/utils/link'
|
import { isExternalLink } from '@/utils/link'
|
||||||
import { onUnmounted } from 'vue'
|
import { ComputedRef, onUnmounted, toValue } from 'vue'
|
||||||
|
|
||||||
export const useLinks = (className: string, sha?: string) => {
|
export const useLinks = (
|
||||||
|
className: ComputedRef<string> | string,
|
||||||
|
sha?: string
|
||||||
|
) => {
|
||||||
const store = useUserRepoStore()
|
const store = useUserRepoStore()
|
||||||
|
|
||||||
const linkNote: EventListener = (event) => {
|
const linkNote: EventListener = (event) => {
|
||||||
@@ -34,7 +37,7 @@ export const useLinks = (className: string, sha?: string) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const selector = `.${className} a`
|
const selector = `.${toValue(className)} a`
|
||||||
|
|
||||||
const removeListeners = () => {
|
const removeListeners = () => {
|
||||||
const elements = document.querySelectorAll(selector)
|
const elements = document.querySelectorAll(selector)
|
||||||
|
|||||||
Reference in New Issue
Block a user