Only show delete in selection toolbox for reroute (#2670)

This commit is contained in:
Chenlei Hu
2025-02-21 16:03:36 -05:00
committed by GitHub
parent 6cb33d9431
commit b012f243b3
2 changed files with 12 additions and 5 deletions

View File

@@ -6,7 +6,7 @@
content: 'p-0 flex flex-row'
}"
>
<ColorPickerButton />
<ColorPickerButton v-if="nodeSelected || groupSelected" />
<Button
v-if="nodeSelected"
severity="secondary"
@@ -21,6 +21,7 @@
</template>
</Button>
<Button
v-if="nodeSelected || groupSelected"
severity="secondary"
text
icon="pi pi-thumbtack"
@@ -51,7 +52,7 @@ import ColorPickerButton from '@/components/graph/selectionToolbox/ColorPickerBu
import { useRefreshableSelection } from '@/composables/useRefreshableSelection'
import { useCommandStore } from '@/stores/commandStore'
import { useCanvasStore } from '@/stores/graphStore'
import { isLGraphNode } from '@/utils/litegraphUtil'
import { isLGraphGroup, isLGraphNode } from '@/utils/litegraphUtil'
const commandStore = useCommandStore()
const canvasStore = useCanvasStore()
@@ -59,6 +60,9 @@ const { isRefreshable, refreshSelected } = useRefreshableSelection()
const nodeSelected = computed(() =>
canvasStore.selectedItems.some(isLGraphNode)
)
const groupSelected = computed(() =>
canvasStore.selectedItems.some(isLGraphGroup)
)
</script>
<style scoped>

View File

@@ -1,5 +1,5 @@
import type { ColorOption, IWidget } from '@comfyorg/litegraph'
import { LGraphNode, isColorable } from '@comfyorg/litegraph'
import { LGraphGroup, LGraphNode, isColorable } from '@comfyorg/litegraph'
import type { IComboWidget } from '@comfyorg/litegraph/dist/types/widgets'
import _ from 'lodash'
@@ -21,8 +21,11 @@ export function addToComboValues(widget: IComboWidget, value: string) {
}
export const isLGraphNode = (item: unknown): item is LGraphNode => {
const name = item?.constructor?.name
return name === 'ComfyNode' || name === 'LGraphNode'
return item instanceof LGraphNode
}
export const isLGraphGroup = (item: unknown): item is LGraphGroup => {
return item instanceof LGraphGroup
}
/**