mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-03-01 11:10:00 +00:00
Pin reroute on link release searchbox (#469)
* Correctly handle wildcard type * Add test * nit * Pin reroute on link release search * Connect wildcard * nit
This commit is contained in:
@@ -78,6 +78,11 @@ const props = defineProps({
|
||||
searchLimit: {
|
||||
type: Number,
|
||||
default: 64
|
||||
},
|
||||
// TODO: Find a more flexible mechanism to add pinned nodes
|
||||
includeReroute: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
})
|
||||
|
||||
@@ -91,13 +96,14 @@ const placeholder = computed(() => {
|
||||
|
||||
const search = (query: string) => {
|
||||
currentQuery.value = query
|
||||
suggestions.value = useNodeDefStore().nodeSearchService.searchNode(
|
||||
query,
|
||||
props.filters,
|
||||
{
|
||||
suggestions.value = [
|
||||
...(props.includeReroute
|
||||
? [useNodeDefStore().nodeDefsByName['Reroute']]
|
||||
: []),
|
||||
...useNodeDefStore().nodeSearchService.searchNode(query, props.filters, {
|
||||
limit: props.searchLimit
|
||||
}
|
||||
)
|
||||
})
|
||||
]
|
||||
}
|
||||
|
||||
const highlightQuery = (text: string, query: string) => {
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
<template #container>
|
||||
<NodeSearchBox
|
||||
:filters="nodeFilters"
|
||||
:includeReroute="includeReroute"
|
||||
@add-filter="addFilter"
|
||||
@remove-filter="removeFilter"
|
||||
@add-node="addNode"
|
||||
@@ -61,6 +62,7 @@ const getNewNodeLocation = (): [number, number] => {
|
||||
return [originalEvent.canvasX, originalEvent.canvasY]
|
||||
}
|
||||
const nodeFilters = reactive([])
|
||||
const includeReroute = ref(false)
|
||||
const addFilter = (filter: FilterAndValue) => {
|
||||
nodeFilters.push(filter)
|
||||
}
|
||||
@@ -100,6 +102,7 @@ const linkReleaseTriggerMode = computed(() => {
|
||||
})
|
||||
|
||||
const canvasEventHandler = (e: LiteGraphCanvasEvent) => {
|
||||
includeReroute.value = false
|
||||
const shiftPressed = (e.detail.originalEvent as KeyboardEvent).shiftKey
|
||||
|
||||
if (e.detail.subType === 'empty-release') {
|
||||
@@ -123,6 +126,7 @@ const canvasEventHandler = (e: LiteGraphCanvasEvent) => {
|
||||
)
|
||||
const dataType = firstLink.type
|
||||
addFilter([filter, dataType])
|
||||
includeReroute.value = true
|
||||
}
|
||||
triggerEvent.value = e
|
||||
visible.value = true
|
||||
|
||||
@@ -57,7 +57,13 @@ export abstract class NodeFilter<FilterOptionT = string> {
|
||||
public abstract getNodeOptions(node: ComfyNodeDefImpl): FilterOptionT[]
|
||||
|
||||
public matches(node: ComfyNodeDefImpl, value: FilterOptionT): boolean {
|
||||
return this.getNodeOptions(node).includes(value)
|
||||
if (value === '*') {
|
||||
return true
|
||||
}
|
||||
const options = this.getNodeOptions(node)
|
||||
return (
|
||||
options.includes(value) || _.some(options, (option) => option === '*')
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,8 @@ export class ConnectingLinkImpl implements ConnectingLink {
|
||||
const newNodeSlots =
|
||||
this.releaseSlotType === 'output' ? newNode.outputs : newNode.inputs
|
||||
const newNodeSlot = newNodeSlots.findIndex(
|
||||
(slot: INodeSlot) => slot.type === this.type
|
||||
(slot: INodeSlot) =>
|
||||
slot.type === this.type || slot.type === '*' || this.type === '*'
|
||||
)
|
||||
|
||||
if (newNodeSlot === -1) {
|
||||
|
||||
Reference in New Issue
Block a user