Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
ComfyUI
Commits
d2e7f1b0
Commit
d2e7f1b0
authored
Feb 06, 2024
by
pythongosssss
Browse files
Support linking converted inputs from api json
parent
236bda26
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
2 deletions
+17
-2
web/extensions/core/widgetInputs.js
web/extensions/core/widgetInputs.js
+6
-0
web/scripts/app.js
web/scripts/app.js
+11
-2
No files found.
web/extensions/core/widgetInputs.js
View file @
d2e7f1b0
...
@@ -260,6 +260,12 @@ app.registerExtension({
...
@@ -260,6 +260,12 @@ app.registerExtension({
async
beforeRegisterNodeDef
(
nodeType
,
nodeData
,
app
)
{
async
beforeRegisterNodeDef
(
nodeType
,
nodeData
,
app
)
{
// Add menu options to conver to/from widgets
// Add menu options to conver to/from widgets
const
origGetExtraMenuOptions
=
nodeType
.
prototype
.
getExtraMenuOptions
;
const
origGetExtraMenuOptions
=
nodeType
.
prototype
.
getExtraMenuOptions
;
nodeType
.
prototype
.
convertWidgetToInput
=
function
(
widget
)
{
const
config
=
getConfig
.
call
(
this
,
widget
.
name
)
??
[
widget
.
type
,
widget
.
options
||
{}];
if
(
!
isConvertableWidget
(
widget
,
config
))
return
false
;
convertToInput
(
this
,
widget
,
config
);
return
true
;
};
nodeType
.
prototype
.
getExtraMenuOptions
=
function
(
_
,
options
)
{
nodeType
.
prototype
.
getExtraMenuOptions
=
function
(
_
,
options
)
{
const
r
=
origGetExtraMenuOptions
?
origGetExtraMenuOptions
.
apply
(
this
,
arguments
)
:
undefined
;
const
r
=
origGetExtraMenuOptions
?
origGetExtraMenuOptions
.
apply
(
this
,
arguments
)
:
undefined
;
...
...
web/scripts/app.js
View file @
d2e7f1b0
...
@@ -2162,8 +2162,17 @@ export class ComfyApp {
...
@@ -2162,8 +2162,17 @@ export class ComfyApp {
if
(
value
instanceof
Array
)
{
if
(
value
instanceof
Array
)
{
const
[
fromId
,
fromSlot
]
=
value
;
const
[
fromId
,
fromSlot
]
=
value
;
const
fromNode
=
app
.
graph
.
getNodeById
(
fromId
);
const
fromNode
=
app
.
graph
.
getNodeById
(
fromId
);
const
toSlot
=
node
.
inputs
?.
findIndex
((
inp
)
=>
inp
.
name
===
input
);
let
toSlot
=
node
.
inputs
?.
findIndex
((
inp
)
=>
inp
.
name
===
input
);
if
(
toSlot
!==
-
1
)
{
if
(
toSlot
==
null
||
toSlot
===
-
1
)
{
try
{
// Target has no matching input, most likely a converted widget
const
widget
=
node
.
widgets
?.
find
((
w
)
=>
w
.
name
===
input
);
if
(
widget
&&
node
.
convertWidgetToInput
?.(
widget
))
{
toSlot
=
node
.
inputs
?.
length
-
1
;
}
}
catch
(
error
)
{}
}
if
(
toSlot
!=
null
||
toSlot
!==
-
1
)
{
fromNode
.
connect
(
fromSlot
,
node
,
toSlot
);
fromNode
.
connect
(
fromSlot
,
node
,
toSlot
);
}
}
}
else
{
}
else
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment