Files
ComfyUI_frontend/src/stores/graphStore.ts
Chenlei Hu 5d957a05b9 Replace locking/unlocking of canvas with select/pan mode (#1050)
* Add dragging canvas state

* Change icon

* Add playwright test

* tooltip change

* Enable for legacy menu

* Update litegraph

* Hide canvas menu for test
2024-09-30 20:20:49 -04:00

42 lines
1.0 KiB
TypeScript

import { LGraphNode, LGraphGroup, LGraphCanvas } from '@comfyorg/litegraph'
import { defineStore } from 'pinia'
import { ref, shallowRef } from 'vue'
export const useTitleEditorStore = defineStore('titleEditor', () => {
const titleEditorTarget = shallowRef<LGraphNode | LGraphGroup | null>(null)
return {
titleEditorTarget
}
})
export const useCanvasStore = defineStore('canvas', () => {
const canvas = shallowRef<LGraphCanvas | null>(null)
const readOnly = ref(false)
const draggingCanvas = ref(false)
document.addEventListener(
'litegraph:canvas',
(e: CustomEvent<{ subType: string; readOnly: boolean }>) => {
if (e.detail?.subType === 'read-only') {
readOnly.value = e.detail.readOnly
}
}
)
document.addEventListener(
'litegraph:canvas',
(e: CustomEvent<{ subType: string; draggingCanvas: boolean }>) => {
if (e.detail?.subType === 'dragging-canvas') {
draggingCanvas.value = e.detail.draggingCanvas
}
}
)
return {
canvas,
readOnly,
draggingCanvas
}
})