Line data Source code
1 : import { defineStore } from 'pinia'
2 : import { shallowRef } from 'vue'
3 :
4 : import type { LLink } from '@/lib/litegraph/src/LLink'
5 : import type { Bounds } from '@comfyorg/shared-frontend-utils/geometry'
6 :
7 : interface LinkSelection {
8 : readonly links: readonly LLink[]
9 : readonly marquee: Bounds
10 : readonly anchorX: number
11 : readonly includesHidden?: boolean
12 : }
13 :
14 2356 : export const useLinkSelectionStore = defineStore('linkSelection', () => {
15 2355 : const selection = shallowRef<LinkSelection | null>(null)
16 :
17 7 : function select(next: LinkSelection): void {
18 7 : selection.value = next.links.length ? next : null
19 : }
20 :
21 1972 : function clear(): boolean {
22 1972 : if (!selection.value) return false
23 7 : selection.value = null
24 7 : return true
25 : }
26 :
27 2355 : return { selection, select, clear }
28 : })
|