Skip to content

Commit 1d6d3fd

Browse files
[backport core/1.36] fix: restore mask editor compatibility with Impact-Pack plugin (#7800)
Backport of #7762 to `core/1.36` Automatically created by backport workflow. ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-7800-backport-core-1-36-fix-restore-mask-editor-compatibility-with-Impact-Pack-plugin-2d96d73d365081429479ffcf2e2b5181) by [Unito](https://www.unito.io) Co-authored-by: Terry Jia <terryjia88@gmail.com>
1 parent 7b68b19 commit 1d6d3fd

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

src/composables/maskeditor/useMaskEditorLoader.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ export function useMaskEditorLoader() {
104104
// If we have a widget filename, we should prioritize it over the node image
105105
// because the node image might be stale (e.g. from a previous save)
106106
// while the widget value reflects the current selection.
107-
if (widgetFilename) {
107+
// Skip internal reference formats (e.g. "$35-0" used by some plugins like Impact-Pack)
108+
if (widgetFilename && !widgetFilename.startsWith('$')) {
108109
try {
109110
// Parse the widget value which might be in format "subfolder/filename [type]" or just "filename"
110111
let filename = widgetFilename

src/extensions/core/maskeditor.ts

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import _ from 'es-toolkit/compat'
22
import type { LGraphNode } from '@/lib/litegraph/src/litegraph'
33

4-
import { app } from '@/scripts/app'
4+
import { app, ComfyApp } from '@/scripts/app'
55
import { useMaskEditorStore } from '@/stores/maskEditorStore'
66
import { useDialogStore } from '@/stores/dialogStore'
77
import { useMaskEditor } from '@/composables/maskeditor/useMaskEditor'
@@ -20,6 +20,18 @@ function openMaskEditor(node: LGraphNode): void {
2020
useMaskEditor().openMaskEditor(node)
2121
}
2222

23+
// Open mask editor from clipspace (for plugin compatibility)
24+
// This is called when ComfyApp.open_maskeditor() is invoked without arguments
25+
function openMaskEditorFromClipspace(): void {
26+
const node = ComfyApp.clipspace_return_node as LGraphNode | null
27+
if (!node) {
28+
console.error('[MaskEditor] No clipspace_return_node found')
29+
return
30+
}
31+
32+
openMaskEditor(node)
33+
}
34+
2335
// Check if the dialog is already opened
2436
function isOpened(): boolean {
2537
return useDialogStore().isDialogOpen('global-mask-editor')
@@ -78,7 +90,16 @@ app.registerExtension({
7890
label: 'Decrease Brush Size in MaskEditor',
7991
function: () => changeBrushSize((old) => _.clamp(old - 4, 1, 100))
8092
}
81-
]
93+
],
94+
init() {
95+
// Set up ComfyApp static methods for plugin compatibility (deprecated)
96+
ComfyApp.open_maskeditor = openMaskEditorFromClipspace
97+
98+
console.warn(
99+
'[MaskEditor] ComfyApp.open_maskeditor is deprecated. ' +
100+
'Plugins should migrate to using the command system or direct node context menu integration.'
101+
)
102+
}
82103
})
83104

84105
const changeBrushSize = async (sizeChanger: (oldSize: number) => number) => {

0 commit comments

Comments
 (0)