From 110c007912cc1c8399c3e50685b0e404fa478dbe Mon Sep 17 00:00:00 2001 From: Chenlei Hu Date: Thu, 12 Sep 2024 14:09:00 +0900 Subject: [PATCH] Update litegraph (Proper ContextMenu export) (#790) --- package-lock.json | 8 ++++---- package.json | 2 +- src/extensions/core/contextMenuFilter.ts | 16 ++++++---------- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/package-lock.json b/package-lock.json index 88b757c32..1a0752ff8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -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": { diff --git a/package.json b/package.json index 8ff8f11db..7df739791 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/extensions/core/contextMenuFilter.ts b/src/extensions/core/contextMenuFilter.ts index 675514f6e..05ef7bec4 100644 --- a/src/extensions/core/contextMenuFilter.ts +++ b/src/extensions/core/contextMenuFilter.ts @@ -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() }