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
8a0a85e0
"driver/conv_driver.cpp" did not exist on "e55cfe1536e44cccfe814f29a6b1f37255d02b3b"
Commit
8a0a85e0
authored
Apr 02, 2023
by
pythongosssss
Browse files
Added filter input to combos
parent
940893f9
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
67 additions
and
1 deletion
+67
-1
web/extensions/core/contextMenuFilter.js
web/extensions/core/contextMenuFilter.js
+66
-0
web/extensions/core/invertMenuScrolling.js
web/extensions/core/invertMenuScrolling.js
+1
-1
No files found.
web/extensions/core/contextMenuFilter.js
0 → 100644
View file @
8a0a85e0
import
{
app
}
from
"
/scripts/app.js
"
;
// Adds filtering to context menus
const
id
=
"
Comfy.ContextMenuFilter
"
;
app
.
registerExtension
({
name
:
id
,
init
()
{
const
ctxMenu
=
LiteGraph
.
ContextMenu
;
LiteGraph
.
ContextMenu
=
function
(
values
,
options
)
{
const
ctx
=
ctxMenu
.
call
(
this
,
values
,
options
);
// If we are a dark menu (only used for combo boxes) then add a filter input
if
(
options
?.
className
===
"
dark
"
&&
values
?.
length
>
10
)
{
const
filter
=
document
.
createElement
(
"
input
"
);
Object
.
assign
(
filter
.
style
,
{
width
:
"
calc(100% - 10px)
"
,
border
:
"
0
"
,
boxSizing
:
"
border-box
"
,
background
:
"
#333
"
,
border
:
"
1px solid #999
"
,
margin
:
"
0 0 5px 5px
"
,
color
:
"
#fff
"
,
});
filter
.
placeholder
=
"
Filter list
"
;
this
.
root
.
prepend
(
filter
);
filter
.
addEventListener
(
"
input
"
,
()
=>
{
// Hide all items that dont match our filter
const
term
=
filter
.
value
.
toLocaleLowerCase
();
const
items
=
this
.
root
.
querySelectorAll
(
"
.litemenu-entry
"
);
for
(
const
item
of
items
)
{
item
.
style
.
display
=
!
term
||
item
.
textContent
.
toLocaleLowerCase
().
includes
(
term
)
?
"
block
"
:
"
none
"
;
}
// If we have an event then we can try and position the list under the source
if
(
options
.
event
)
{
let
top
=
options
.
event
.
clientY
-
10
;
const
bodyRect
=
document
.
body
.
getBoundingClientRect
();
const
rootRect
=
this
.
root
.
getBoundingClientRect
();
if
(
bodyRect
.
height
&&
top
>
bodyRect
.
height
-
rootRect
.
height
-
10
)
{
top
=
Math
.
max
(
0
,
bodyRect
.
height
-
rootRect
.
height
-
10
);
}
this
.
root
.
style
.
top
=
top
+
"
px
"
;
}
});
requestAnimationFrame
(()
=>
{
// Focus the filter box when opening
filter
.
focus
();
// If the top is off screen then shift the element
if
(
parseInt
(
this
.
root
.
style
.
top
)
<
0
)
{
this
.
root
.
style
.
top
=
0
;
}
});
}
return
ctx
;
};
LiteGraph
.
ContextMenu
.
prototype
=
ctxMenu
.
prototype
;
},
});
web/extensions/core/invertMenuScrolling.js
View file @
8a0a85e0
...
@@ -3,10 +3,10 @@ import { app } from "/scripts/app.js";
...
@@ -3,10 +3,10 @@ import { app } from "/scripts/app.js";
// Inverts the scrolling of context menus
// Inverts the scrolling of context menus
const
id
=
"
Comfy.InvertMenuScrolling
"
;
const
id
=
"
Comfy.InvertMenuScrolling
"
;
const
ctxMenu
=
LiteGraph
.
ContextMenu
;
app
.
registerExtension
({
app
.
registerExtension
({
name
:
id
,
name
:
id
,
init
()
{
init
()
{
const
ctxMenu
=
LiteGraph
.
ContextMenu
;
const
replace
=
()
=>
{
const
replace
=
()
=>
{
LiteGraph
.
ContextMenu
=
function
(
values
,
options
)
{
LiteGraph
.
ContextMenu
=
function
(
values
,
options
)
{
options
=
options
||
{};
options
=
options
||
{};
...
...
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