docs/.vitepress/theme/composables/useTooltips.ts

1ed3089066ccaca7b4cc338342237b8e0bdf195a
wotaku/docs/.vitepress/theme/composables/useTooltips.ts
taskylizard chore: update license0dddca8d19 1 year ago

32 lines · 854 bytes

 1/**
 2*  All Rights Reserved
 3*
 4*  Copyright (c) 2025 taskylizard
 5*
 6*  All rights reserved. This code and its associated files may not be copied, modified, distributed, sublicensed, or used in any form, in whole or in part, without prior written permission from the copyright holder.
 7*/
 8import { ref } from 'vue'
 9import { getTooltip, type TooltipData } from 'virtual:tooltips'
10
11const tooltipCache = ref<Map<string, TooltipData>>(new Map())
12
13export function useTooltips() {
14  const getTooltipData = (id: string): TooltipData | null => {
15    if (tooltipCache.value.has(id)) {
16      return tooltipCache.value.get(id)!
17    }
18
19    const tooltip = getTooltip(id)
20    if (tooltip) {
21      tooltipCache.value.set(id, tooltip)
22      return tooltip
23    }
24
25    console.warn(`Tooltip with id "${id}" not found`)
26    return null
27  }
28
29  return {
30    getTooltipData
31  }
32}
Keyboard shortcuts

Global

⌘K
Command palette & jump
/
Focus search
?
Show this help
g d
Dashboard
g e
Explore repositories
g n
Notifications

Repository & editor

t
Find file in repository
y
Copy immutable SHA permalink
g c
Code tab
g i
Issues tab
g m
Merge requests tab
g b
Builds tab
⌘↵
Submit active form