[fix] Update Search & Replace to support nodes in subgraphs (#4576)

This commit is contained in:
Christian Byrne
2025-07-29 00:10:56 -07:00
committed by GitHub
parent 00cd9fadec
commit dd14144f47
5 changed files with 24 additions and 8 deletions

View File

@@ -35,7 +35,7 @@ app.registerExtension({
// @ts-expect-error fixme ts strict error
widget.serializeValue = () => {
// @ts-expect-error fixme ts strict error
return applyTextReplacements(app.graph.nodes, widget.value)
return applyTextReplacements(app.graph, widget.value)
}
return r

View File

@@ -46,7 +46,7 @@ export class PrimitiveNode extends LGraphNode {
]
let v = this.widgets?.[0].value
if (v && this.properties[replacePropertyName]) {
v = applyTextReplacements(app.graph.nodes, v as string)
v = applyTextReplacements(app.graph, v as string)
}
// For each output link copy our value over the original widget value

View File

@@ -21,7 +21,7 @@ export function clone<T>(obj: T): T {
* There are external callers to this function, so we need to keep it for now
*/
export function applyTextReplacements(app: ComfyApp, value: string): string {
return _applyTextReplacements(app.graph.nodes, value)
return _applyTextReplacements(app.graph, value)
}
export async function addStylesheet(

View File

@@ -1,11 +1,14 @@
import type { LGraphNode } from '@comfyorg/litegraph'
import type { LGraph, Subgraph } from '@comfyorg/litegraph'
import { formatDate } from '@/utils/formatUtil'
import { collectAllNodes } from '@/utils/graphTraversalUtil'
export function applyTextReplacements(
allNodes: LGraphNode[],
graph: LGraph | Subgraph,
value: string
): string {
const allNodes = collectAllNodes(graph)
return value.replace(/%([^%]+)%/g, function (match, text) {
const split = text.split('.')
if (split.length !== 2) {