Update litegraph (Proper ContextMenu export) (#790)

This commit is contained in:
Chenlei Hu
2024-09-12 14:09:00 +09:00
committed by GitHub
parent fdb01c06f2
commit 110c007912
3 changed files with 11 additions and 15 deletions

8
package-lock.json generated
View File

@@ -9,7 +9,7 @@
"version": "1.2.49",
"dependencies": {
"@atlaskit/pragmatic-drag-and-drop": "^1.2.1",
"@comfyorg/litegraph": "^0.7.67",
"@comfyorg/litegraph": "^0.7.68",
"@primevue/themes": "^4.0.5",
"@vitejs/plugin-vue": "^5.0.5",
"@vueuse/core": "^11.0.0",
@@ -1909,9 +1909,9 @@
"dev": true
},
"node_modules/@comfyorg/litegraph": {
"version": "0.7.67",
"resolved": "https://registry.npmjs.org/@comfyorg/litegraph/-/litegraph-0.7.67.tgz",
"integrity": "sha512-X8eRpBmSGTahJteNFDG9P0IsHXOk4QDU3p3iWPhk0rGfTnl4RZ8YcJ8MVo7zRgF3qxxX/Tcw4RpelhnjBJe4Gg==",
"version": "0.7.68",
"resolved": "https://registry.npmjs.org/@comfyorg/litegraph/-/litegraph-0.7.68.tgz",
"integrity": "sha512-tF7+t659oDYRmiSK12kctJOiBnUgs/wGqfbmEluerIZxEsecfDovJJ0MOfpzvOQxz7R7HoruEJY7BzvcVeilqg==",
"license": "MIT"
},
"node_modules/@cspotcode/source-map-support": {

View File

@@ -62,7 +62,7 @@
},
"dependencies": {
"@atlaskit/pragmatic-drag-and-drop": "^1.2.1",
"@comfyorg/litegraph": "^0.7.67",
"@comfyorg/litegraph": "^0.7.68",
"@primevue/themes": "^4.0.5",
"@vitejs/plugin-vue": "^5.0.5",
"@vueuse/core": "^11.0.0",

View File

@@ -7,8 +7,8 @@ const ext = {
name: 'Comfy.ContextMenuFilter',
init() {
const ctxMenu = LiteGraph.ContextMenu
// @ts-expect-error
// TODO Very hacky way to modify Litegraph behaviour. Fix ctx later.
// @ts-expect-error TODO Very hacky way to modify Litegraph behaviour. Fix ctx later.
LiteGraph.ContextMenu = function (values, options) {
const ctx = new ctxMenu(values, options)
@@ -17,11 +17,10 @@ const ext = {
const filter = document.createElement('input')
filter.classList.add('comfy-context-menu-filter')
filter.placeholder = 'Filter list'
// @ts-expect-error
ctx.root.prepend(filter)
const items = Array.from(
// @ts-expect-error
ctx.root.querySelectorAll('.litemenu-entry')
) as HTMLElement[]
let displayedItems = [...items]
@@ -63,18 +62,16 @@ const ext = {
}
const positionList = () => {
// @ts-expect-error
const rect = ctx.root.getBoundingClientRect()
// If the top is off-screen then shift the element with scaling applied
if (rect.top < 0) {
const scale =
1 -
// @ts-expect-error
ctx.root.getBoundingClientRect().height / ctx.root.clientHeight
// @ts-expect-error
const shift = (ctx.root.clientHeight * scale) / 2
// @ts-expect-error
ctx.root.style.top = -shift + 'px'
}
}
@@ -145,7 +142,7 @@ const ext = {
let top = options.event.clientY - 10
const bodyRect = document.body.getBoundingClientRect()
// @ts-expect-error
const rootRect = ctx.root.getBoundingClientRect()
if (
bodyRect.height &&
@@ -154,7 +151,6 @@ const ext = {
top = Math.max(0, bodyRect.height - rootRect.height - 10)
}
// @ts-expect-error
ctx.root.style.top = top + 'px'
positionList()
}