mirror of
https://github.com/CharaChorder/DeviceManager.git
synced 2026-01-21 01:12:59 +00:00
@@ -1,12 +1,12 @@
|
||||
import type {Action} from "svelte/action"
|
||||
import type { Action } from "svelte/action"
|
||||
import tippy from "tippy.js"
|
||||
import type {SvelteComponent} from "svelte"
|
||||
import type { SvelteComponent } from "svelte"
|
||||
import Tooltip from "$lib/components/Tooltip.svelte"
|
||||
import hotkeys from "hotkeys-js"
|
||||
|
||||
export const action: Action<HTMLElement, {title?: string; shortcut?: string}> = (
|
||||
export const action: Action<HTMLElement, { title?: string; shortcut?: string }> = (
|
||||
node: HTMLElement,
|
||||
{title, shortcut},
|
||||
{ title, shortcut },
|
||||
) => {
|
||||
let component: SvelteComponent | undefined
|
||||
const tooltip = tippy(node, {
|
||||
@@ -16,7 +16,7 @@ export const action: Action<HTMLElement, {title?: string; shortcut?: string}> =
|
||||
onShow(instance) {
|
||||
component ??= new Tooltip({
|
||||
target: instance.popper.querySelector(".tippy-content") as HTMLElement,
|
||||
props: {title, shortcut},
|
||||
props: { title, shortcut },
|
||||
})
|
||||
},
|
||||
onHidden() {
|
||||
@@ -26,7 +26,7 @@ export const action: Action<HTMLElement, {title?: string; shortcut?: string}> =
|
||||
})
|
||||
|
||||
if (shortcut) {
|
||||
hotkeys(shortcut, function (keyboardEvent) {
|
||||
hotkeys(shortcut, function(keyboardEvent) {
|
||||
keyboardEvent.preventDefault()
|
||||
node.click()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user